Hi
Could someone please let me know how I can set the x axis labels on a bar chart? In other words, so that I can replace "category 1", "category 2" etc with my own labels.
This is what my plot looks like:
Plot plot = new VerticalBarPlot(new HorizontalCategoryAxis("months"), new VerticalNumberAxis("sales"));
and the dataset is build up as follows:
Number[][] data = new Number[1][5];
data[0][0] = new Integer(20);
data[0][1] = new Integer(25);
data[0][2] = new Integer(27);
data[0][3] = new Integer(22);
data[0][4] = new Integer(24);
DefaultCategoryDataset ds = new DefaultCategoryDataset(data);
This is just a test I am using to see how bar chars work in JFreeChart. I am not sure if I have done the above in the correct way.
Thanks in advance,
Belinda
x axis labels on a bar chart
Re: x axis labels on a bar chart
There's two ways to handle it:
1) Use this constructor:
public DefaultCategoryDataset(String[] seriesNames, Object[] categories, Number[][] data);
...instead of the one you are using; or
2) Call the following method on the dataset you already have:
public void setCategories(Object[] categories);
...making sure you supply the correct number of categories.
Regards,
DG.
1) Use this constructor:
public DefaultCategoryDataset(String[] seriesNames, Object[] categories, Number[][] data);
...instead of the one you are using; or
2) Call the following method on the dataset you already have:
public void setCategories(Object[] categories);
...making sure you supply the correct number of categories.
Regards,
DG.