Hey everyone,
I noticed there was feature hiding in DefaultCategoryDataset's constructor.
DefaultKeyedValues2D allows us to set whether we want to sort the dataset according to key's values or not.
I think that ability should propogate to DefaultCategoryDataset's constructor as well (Optionally, of course), since there is no real workaround other than to recompile the project (there are other places which depend on DefaultCategoryDataset and are not hook-able).
Morwen.
KeyedValues2D and DefaultCategoryDataset
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I plan to support this in the future, but it is a little tricky to implement, because it means that a series can change position in the dataset (for instance, when you add/insert an item with a new series key). That means the links to the series paint, stroke, shapes etc get lost (because those attributes are stored by index). The solution is either to store the attributes by series key (along the lines of the recent changes to the PiePlot class), or have the attributes reorder themselves in response to changes in the dataset. Both changes are significant pieces of work, and so far I haven't started on it.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Hi all!
Sorry to bring up this old topic again, but I have exactly the same problem: I want a DefaultCategoryDataset with sorted row keys but cannot use the DefaultCategoryDataset implementation as it hides the feature of sorted row keys, already supported by DefaultKeyedValues2D.
My row keys are sorted anyway, and the reason I want to set "sortRowKeys" to true is, to use the optimized algorithms in DefaultKeyedValues2D due to (significant) performance improvements. As my dataset won't change I don't think that I will face any of the problems mentioned by David.
Any comments?
- martin
Sorry to bring up this old topic again, but I have exactly the same problem: I want a DefaultCategoryDataset with sorted row keys but cannot use the DefaultCategoryDataset implementation as it hides the feature of sorted row keys, already supported by DefaultKeyedValues2D.
My row keys are sorted anyway, and the reason I want to set "sortRowKeys" to true is, to use the optimized algorithms in DefaultKeyedValues2D due to (significant) performance improvements. As my dataset won't change I don't think that I will face any of the problems mentioned by David.
Any comments?
- martin
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Would it be a problem to simply copy and paste the DefaultCategoryDataset source code into your own package, rename the class MyCategoryDataset, and change whatever you need to?
My comment from 12-Dec-2006 is still valid for this one, I think. I'd like to support this sorting (as has already been done for the DefaultPieDataset class)...but it means reworking the way the renderers reference paint and stroke attributes. And that is a big piece of work.
My comment from 12-Dec-2006 is still valid for this one, I think. I'd like to support this sorting (as has already been done for the DefaultPieDataset class)...but it means reworking the way the renderers reference paint and stroke attributes. And that is a big piece of work.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Hi David!
Your suggestion is exactly what I currently do, and it works. However, it would be nice if this would be possible without overriding JFreeChart classes (maybe for others as well).
Maybe I just didn't get what problems you are facing. Changing the data from a DefaultCategoryDataset would eventually change the order of the data. But where's the problem here? If this happens rerendering a chart would be necessary anyway, wouldn't it? Thus, links to series paints and the like would have to be dropped and recalculated whenever a DatasetChanged event happened. Is this a problem?
Thanks for your answer anyway,
- martin
Your suggestion is exactly what I currently do, and it works. However, it would be nice if this would be possible without overriding JFreeChart classes (maybe for others as well).
Maybe I just didn't get what problems you are facing. Changing the data from a DefaultCategoryDataset would eventually change the order of the data. But where's the problem here? If this happens rerendering a chart would be necessary anyway, wouldn't it? Thus, links to series paints and the like would have to be dropped and recalculated whenever a DatasetChanged event happened. Is this a problem?
Thanks for your answer anyway,
- martin