Hint with values ​​when using SpiderWebPlot

I am using SpiderWebPlot from JFreeChart to create a chart. But what I want to have is clues with meanings. I found that I should set the StandardCategoryTooltipGenerator to the plot, but this does not seem to make sense. Here is my sample code:

private JFreeChart prepareChart() { Random rnd = new java.util.Random(); DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String rowKey = "Osobnik"; dataSet.addValue(rnd.nextInt(20), rowKey, "BLUFF"); dataSet.addValue(rnd.nextInt(20), rowKey, "CALL"); dataSet.addValue(rnd.nextInt(20), rowKey, "CHECK"); dataSet.addValue(rnd.nextInt(20), rowKey, "FOLD"); dataSet.addValue(rnd.nextInt(20), rowKey, "RAISE"); SpiderWebPlot plot = new SpiderWebPlot(dataSet); // CategoryToolTipGenerator generator = new // StandardCategoryToolTipGenerator(); // generator.generateToolTip(dataSet, 0, 1); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setStartAngle(54D); plot.setInteriorGap(0.40000000000000002D); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); JFreeChart chart = new JFreeChart(plot); return chart; } 

Here is an example of what I'm trying to accomplish. enter image description hereenter image description here

+4
source share
1 answer

ChartPanel "logs in with a chart to receive notification of changes in any component of the chart." I suspect you neglected the design of the ChartPanel ; given the static version of prepareChart() , main() works for me. See Also Starting Topics .

 public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame f = new JFrame("Spider Web Plot"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new ChartPanel(prepareChart())); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); } }); } 

Addition. Based on the posted screenshots, you will need a custom CategoryItemLabelGenerator , which can be set using setLabelGenerator() . It will be called from drawLabel() , shown here . For instance,

 plot.setLabelGenerator(new StandardCategoryItemLabelGenerator() { @Override public String generateColumnLabel(CategoryDataset dataset, int col) { return dataset.getColumnKey(col) + " " + dataset.getValue(0, col); } }); 
+3
source

All Articles