Legend

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

Legend

Post by atom » Mon Jul 22, 2002 10:46 pm

Hi

I am trying to set the series/legend manually. I am using JdbcXYDataset which extracts from a database and plots the timeseries graph. But it also takes the name of the y-axis column in the database and plots it as the legend I don't want this how can I change this to my own legend name.

This is my code so far

// Create the chart

JFreeChart chart = ChartFactory.createTimeSeriesChart("Fire Alarm Report", "Time", "Temperature", dataset, true);

XYPlot plot = chart.getXYPlot();

VerticalNumberAxis axis = (VerticalNumberAxis)plot.getRangeAxis();
axis.setAutoRange(false);
axis.setMinimumAxisValue(0.0);
axis.setMaximumAxisValue(100.0);

HorizontalDateAxis axis = (HorizontalDateAxis)plot.getDomainAxis();
axis.setVerticalTickLabels(true);
chart.setLegend(null);

Kind Regards
A>M

atom

Re: Legend

Post by atom » Wed Jul 24, 2002 7:29 pm

No reply

David Gilbert

Re: Legend

Post by David Gilbert » Wed Jul 24, 2002 10:19 pm

I'm not very familiar with the JDBC dataset classes, but it looks like the getSeriesName(int) method returns the column name (and it is the series name that end up in the legend). You could subclass the JdbcXYDataset class and override the getSeriesName(int) method to return anything you want...

Regards,

DG.

Locked