Hi,
I tried to create linechart.But,I am not getting any line visible in the linechart.I used the below code:
DefaultCategoryDataset categoryDataset=new DefaultCategoryDataset();
Iterator iterator = dataSetMap.keySet().iterator();
while(iterator.hasNext()) {
String key = (String)iterator.next();
Double value = (Double)dataSetMap.get(key);
categoryDataset.addValue(value,key,value);
}
JFreeChart linechart= ChartFactory.createLineChart3D(title, "", "", categoryDataset, PlotOrientation.VERTICAL, true, true, true);
I also wan know what are the parameters to be passed to
categoryDataset.addValue(value,key,value);I passed a value but what are the rowKey and columKey ??
Is this a correct way?
line not visible in linechart
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
The data in a CategoryDataset are organized in a kind of chessboard with towers. Each data point or tower can be accessed by an address that consists of the row and column key, e. g. "A1" or "F6".
Visualizing that "chessboard" in a plot would mean to generate a 3D object that is difficult to visualize on a 2D screen. If you take a saw, cut your chessboard in rows of 8 fields length and one field width and then string together these rows you basically have transformed your 3D plot into a CategoryPlot with a BarRenderer. If you leave the chessboard intact, paint the uppermost part of your towers and cut off the rest (the uppermost, painted part stays on its level by some magic force) you have a CategoryPlot with a LineRenderer. If you leave your board and the towers intact but give the tower in the background the largest diameter and the one in the foreground the smallest so that the one in the background is still visible, you have a CategoryPlot with a LayeredBarRenderer. In any case you are only requiring two dimensions for visualization.
To your actual problem: If you are not seeing anything I would first suspect that there is no data in your dataSetMap! Second: with your approach you are using a numerical index as columnKey that can have a lot of different values and can thus generate lots of different columns that might blow up your chart. Maybe an XYDataset is a better alternative?
Regards, paradoxoff
Visualizing that "chessboard" in a plot would mean to generate a 3D object that is difficult to visualize on a 2D screen. If you take a saw, cut your chessboard in rows of 8 fields length and one field width and then string together these rows you basically have transformed your 3D plot into a CategoryPlot with a BarRenderer. If you leave the chessboard intact, paint the uppermost part of your towers and cut off the rest (the uppermost, painted part stays on its level by some magic force) you have a CategoryPlot with a LineRenderer. If you leave your board and the towers intact but give the tower in the background the largest diameter and the one in the foreground the smallest so that the one in the background is still visible, you have a CategoryPlot with a LayeredBarRenderer. In any case you are only requiring two dimensions for visualization.
To your actual problem: If you are not seeing anything I would first suspect that there is no data in your dataSetMap! Second: with your approach you are using a numerical index as columnKey that can have a lot of different values and can thus generate lots of different columns that might blow up your chart. Maybe an XYDataset is a better alternative?
Regards, paradoxoff