Hi, I want to make a bar chart where all the data from each series is grouped into its own separate category. So, all series 1 red bars together, then all series 2 blue bars, then series 3 all together and so on.
Here's an example of what I"m trying to do:
http://home.comcast.net/~cwpllc/example.png
I've tried a lot of different things by tweaking the examples but haven't figured it out yet. Any clues on how/if I can do this in JFreeChart?
Thanks!
-John
Barcharts - differnet series grouping?
Create your dataset with a 2d array in this fassion:
The first dimension will be your "Category".
The second dimension will be the data.
So the first bar of the first category would be:
Or the 3rd bar in the 2nd category:
Code: Select all
double data = new double[3][i]; // where i is the # of elements displayed.
The second dimension will be the data.
So the first bar of the first category would be:
Code: Select all
data[0][0] = 309.23;
Code: Select all
data[1][2] = 89.3;
OK thanks!
So using your info:
I get this:
http://home.comcast.net/~cwpllc/example2.png
which is pretty close to what I want.
Is there any way to now turn all the bars for dataKey1 to red, all the bars for dataKey2 to blue, and so on? (same color for each dataKey grouping)
thanks a ton!
-John
So using your info:
Code: Select all
double data[][] =
{{1,2,3,4}, {3,2,1,4}, {4,2,1,3}};
CategoryDataset ds = DatasetUtilities.createCategoryDataset("rowKey", "dataKey", data);
JFreeChart chart = ChartFactory.createBarChart(
"Bar Chart Demo 8", // chart title
"Category", // domain axis label
"Value", // range axis label
ds, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
true, // tooltips?
false // URLs?
);
http://home.comcast.net/~cwpllc/example2.png
which is pretty close to what I want.
Is there any way to now turn all the bars for dataKey1 to red, all the bars for dataKey2 to blue, and so on? (same color for each dataKey grouping)
thanks a ton!
-John