1

The spider web plot of JFreeChart does not display values close to the marked points, as default:

SpiderWebPlot example

what must be done to display the numbers?

That's what I have now, in a method returning StreamedContent (for PrimeFaces' p:graphicImage:

CategoryDataset categorydataset = createCategoryDataset(displayBy, configuration, null);
SpiderWebPlot plot = new SpiderWebPlot(categorydataset);
plot.setInteriorGap(0.40);
plot.setNoDataMessage("No data available");
plot.setStartAngle(0);
plot.setLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", NumberFormat.getInstance()));
plot.setWebFilled(true);

JFreeChart chart = new JFreeChart(title, TextTitle.DEFAULT_FONT, plot, true);

File chartFile = new File(String.valueOf(new Random().nextLong()));
ChartUtilities.saveChartAsPNG(chartFile, chart, 375, 300);
return new DefaultStreamedContent(new FileInputStream(chartFile), "image/png");

EDIT: After @trashgod's suggestion, some values appeared but no in the expected place. I want the columnKey values, not the `rowKey' values (addValue method in DefaultCategoryDataset class):

dataset.getColumnKey(col) + " TESTE " + dataset.getValue(0, col)

Rasshu
  • 1,764
  • 6
  • 22
  • 53
  • 1
    Use a `CategoryItemLabelGenerator `, as shown in this [duplicate](http://stackoverflow.com/q/14122929/230513). – trashgod Jan 09 '15 at 14:07
  • Did that. Now I created the dataset in that method, it has values because I debugged it right now. Nothing appears. `plot.setLabelGenerator(new StandardCategoryItemLabelGenerator() { @Override public String generateColumnLabel(CategoryDataset dataset, int col) { return dataset.getColumnKey(col) + " TESTE " + dataset.getValue(0, col); } });` – Rasshu Jan 09 '15 at 15:41
  • Edited, see the changes made. Some values appeared but no in the expected place. I need them next to the "points". – Rasshu Jan 09 '15 at 16:33
  • I don't understand; how are the labels not next to the points? – trashgod Jan 09 '15 at 19:10
  • See the edition I made. Last pic. – Rasshu Jan 09 '15 at 19:10
  • How could they be closer to the points? – trashgod Jan 09 '15 at 19:12
  • They're linked to the 8 outer categories, but what matters are the 3 others (there are 3 colors we can see if we watch closely) – Rasshu Jan 09 '15 at 19:13

1 Answers1

2

What must be done to display the numbers?

You can label points on the plot using a CategoryItemLabelGenerator, as shown here.

What matters are the three other [points].

It looks like you might be able to add a second series, one with a second rowKey, in order to get labels associated with those points.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045