1

I think my question is a little silly, but I couldn't find the answer in the examples!

I create a area chart and I need to change the name of the series, in the legend of the graph

here:

final CategoryDataset dataset = DatasetUtilities.createCategoryDataset(
    "Series ", "Type ", data
);

When a put "Series", it appears in the legend, something like this: Series 1, Series 2, Series 3.....

Is it possible to change their names, and each one has a different name?

Rikkin
  • 509
  • 1
  • 5
  • 20
  • 1
    You don't _have_ to use that utility class to create the dataset. See this [example](http://www.java2s.com/Code/Java/Chart/JFreeChartBarChartDemo.htm) which manually builds up a `DefaultCategoryDataset` – DannyMo Aug 06 '13 at 18:22
  • Cross-posted [here](http://www.jfree.org/forum/viewtopic.php?f=3&t=116600&p=176694). – trashgod Aug 07 '13 at 00:38

1 Answers1

2

The DatasetUtilities API is here. Looking at createCategoryDataset(),

public static CategoryDataset createCategoryDataset(
    java.lang.Comparable[] rowKeys,
    java.lang.Comparable[] columnKeys,
    double[][] data)

note in particular,

Row and column keys are taken from the supplied arrays.

It looks like you can just pass in an array of the values that you want.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
Grammin
  • 11,808
  • 22
  • 80
  • 138