Sort the Y-Axis using JFreeChart
-
- Posts: 10
- Joined: Wed Apr 18, 2007 8:37 pm
Sort the Y-Axis using JFreeChart
I was wondering what is the easiest method of displaying the values on the Y-Axis in a JFreeChart line or bar graph in descending order. Any help would be much appreciated.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Code: Select all
axis.setInverted(true);
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 10
- Joined: Wed Apr 18, 2007 8:37 pm
Sorting Y-Axis in descending order
I used the DefaultKeyedValues object to sort them (i.e. dataF.sortByValues(SortOrder.DESCENDING)) and then used DatasetUtilities.createCategoryDataset (for my first series). The second series and first series are set up to have the exact same keys so all is well. Thanks for the post.
AF
AF
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
OK, I guess by "y-axis" you meant the CategoryAxis?
I'd like to rework the CategoryAxis at some point so that it can control the order of the categories independently of the order that they appear in the dataset. But for now, the order is driven by the dataset, as you've found.
I'd like to rework the CategoryAxis at some point so that it can control the order of the categories independently of the order that they appear in the dataset. But for now, the order is driven by the dataset, as you've found.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

