Hi..
In my application of showing quote averages, the plot data comes in, will have random timestamps, and is not ordered.
i.e. plotdata[0] is a quote for 2-JAN-2008 09:35:00
whereas plotdata[1] corresponds to a quote at 2-JAN-2008 09:20:00
If I use the plot data to draw a graph, the graph comes in zig zag fashion. Is there a property I can set for the graph, to show the plot data in an ordered fashion?
The graph shows properly if plotdata is in increasing order of timestamps. But is there a property in the chart renderer to plot the points properly even when the plot data is not in increasing order?
-Rambabu
Plot data ordering
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
All the renderers just process the data in the order that it comes from the dataset.
Some of the dataset classes in JFreeChart have an option to "auto-sort" data (e.g. XYSeries/XYSeriesCollection), so maybe that can help you.
Some of the dataset classes in JFreeChart have an option to "auto-sort" data (e.g. XYSeries/XYSeriesCollection), so maybe that can help you.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 6
- Joined: Mon Apr 14, 2008 3:06 pm
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Not true. The CategoryPlot or, more specifically, the CategoryAxis will display the categories in the order that they were added to the dataset.1337rooster wrote:If your using CategoryPlot, it sorts the labels alphabetically
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 6
- Joined: Mon Apr 14, 2008 3:06 pm
Oh, it didn't seem to work that way for me. I was trying to figure out how to get the labels to display in the order I provided. I noticed that they were going in alphabetical order so I looked at the api for CategoryPlot and found:
setColumnRenderingOrder(org.jfree.util.SortOrder order)
Sets the column order in which the items in each dataset should be rendered and sends a PlotChangeEvent to all registered listeners.
which only had SortOrder.Ascending and SortOrder.Descending as options. Any idea as to why it would have been in Ascending order for me? Does it depend on the dataset? I used the charfactory to get a bar chart and these were the only changes I made:
CategoryPlot plot = (CategoryPlot)chart.getPlot();
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());//displays ony integers for now
yAxis.setLabelFont(HISTOGRAM_AXIS_FONT);
//set the x axis, set its font, set vertical Labels
CategoryAxis xAxis = (CategoryAxis)plot.getDomainAxis();
xAxis.setLabelFont(HISTOGRAM_AXIS_FONT);
xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
xAxis.setLowerMargin(0.00);
xAxis.setCategoryMargin(0.05);
xAxis.setUpperMargin(0.00);
Dataset was a CategoryDataset
Jfreechart version: 1.0.1
setColumnRenderingOrder(org.jfree.util.SortOrder order)
Sets the column order in which the items in each dataset should be rendered and sends a PlotChangeEvent to all registered listeners.
which only had SortOrder.Ascending and SortOrder.Descending as options. Any idea as to why it would have been in Ascending order for me? Does it depend on the dataset? I used the charfactory to get a bar chart and these were the only changes I made:
CategoryPlot plot = (CategoryPlot)chart.getPlot();
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());//displays ony integers for now
yAxis.setLabelFont(HISTOGRAM_AXIS_FONT);
//set the x axis, set its font, set vertical Labels
CategoryAxis xAxis = (CategoryAxis)plot.getDomainAxis();
xAxis.setLabelFont(HISTOGRAM_AXIS_FONT);
xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
xAxis.setLowerMargin(0.00);
xAxis.setCategoryMargin(0.05);
xAxis.setUpperMargin(0.00);
Dataset was a CategoryDataset
Jfreechart version: 1.0.1
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
The columnRenderingOrder doesn't change the position of the categories (columns), just the order in which they are drawn. It is a hack to make the 3D effect work for bar charts, where sometimes the 3D effect overlaps so you need to draw the bars from right-to-left instead of left-to-right.
It is still the dataset that controls the position of the categories along the axis.
It is still the dataset that controls the position of the categories along the axis.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

