Hi,
I tried to use the Horizontal Stacked Bar Chart and it works fine. But I didn't find how to change 2 things.
First of all, the legend, there's a flag to set it on or off. But, I don't know how to change the lables of the legend (series 1, series 2, and so on).
My second question is about the values. Is it possible to limit the values between a certain range ?
For example, I would like to limit it between 0 and 100.
Thanx in advance,
Dasch
Horizontal Stacked Bar Chart
Re: Horizontal Stacked Bar Chart
Dasch wrote:
> I tried to use the Horizontal Stacked Bar Chart and it works
> fine. But I didn't find how to change 2 things.
> First of all, the legend, there's a flag to set it on or off.
> But, I don't know how to change the lables of the legend
> (series 1, series 2, and so on).
The legend gets the labels from the series names in the dataset. If you are using DefaultCategoryDataset then you can use the setSeriesNames(...) method to change them.
> My second question is about the values. Is it possible to
> limit the values between a certain range ?
> For example, I would like to limit it between 0 and 100.
Do you mean just on the axis for display purposes? By default JFreeChart will calculate an axis range that displays all the data, but you can set a range manually if you want to. With a stacked horizontal bar chart you would need to do something like this:
CategoryPlot plot = chart.getCategoryPlot();
NumberAxis axis = (NumberAxis)plot.getRangeAxis();
axis.setAxisRange(0.0, 100.0);
Regards,
DG.
> I tried to use the Horizontal Stacked Bar Chart and it works
> fine. But I didn't find how to change 2 things.
> First of all, the legend, there's a flag to set it on or off.
> But, I don't know how to change the lables of the legend
> (series 1, series 2, and so on).
The legend gets the labels from the series names in the dataset. If you are using DefaultCategoryDataset then you can use the setSeriesNames(...) method to change them.
> My second question is about the values. Is it possible to
> limit the values between a certain range ?
> For example, I would like to limit it between 0 and 100.
Do you mean just on the axis for display purposes? By default JFreeChart will calculate an axis range that displays all the data, but you can set a range manually if you want to. With a stacked horizontal bar chart you would need to do something like this:
CategoryPlot plot = chart.getCategoryPlot();
NumberAxis axis = (NumberAxis)plot.getRangeAxis();
axis.setAxisRange(0.0, 100.0);
Regards,
DG.