Displaying Series Name

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Georgia

Displaying Series Name

Post by Georgia » Mon Feb 03, 2003 9:26 pm

I have created serveral jchart: line, bar, area, pie and stackedbar by using a DefaultCategoryDataset contructed like these:

DefaultCategoryDataset chartData =
new DefaultCategoryDataset(series, categories, dataSet);

and the code to create a chart is like these:

chart = ChartFactory.createLineChart
(title, domainAxis, rangeAxis, chartData, legend);

Here serires is a String[], categories a Object[], dataSet Number[][].

The charts can display category name and the target real chart. But I don't see any series names is displayed.

I put this after I created DefaultCategoryDataset:
for (int i=0;i<chartData.getSeriesCount() ;i++ )
{
System.out.println(chartData.getSeriesName(i));
}
and see the series names are displayed in my console.


Is there anybody who has a clue what should I do in order to display these series names in my charts?

Thank you.

Georgia

David Gilbert

Re: Displaying Series Name

Post by David Gilbert » Tue Feb 04, 2003 5:43 pm

It sounds like it should be working, as long as 'legend' is set to true.

Regards,

Dave Gilbert

Arnaud

Re: Displaying Series Name

Post by Arnaud » Tue Feb 04, 2003 5:45 pm

Hello Georgia,

I'm sure I understand Your problem...
In case You want to display the series names in the legend, You have to indicate the chartFactory method You want to show the legend.

This is done by assigning a true value to the boolean parameter legend.

Does that answer Your question ?

Best regards,
Arnaud

Georgia

Re: Displaying Series Name

Post by Georgia » Tue Feb 04, 2003 9:24 pm

Dave $ Arnaud,

Thank you very much.

That's really solved the problem. I set my testing html page with legend being set to "ture". But it has never been parsed to the ChartFactory object.

Now, everything is working.

Bin

Locked