I just got hit by the following exception:
java.lang.ClassCastException: org.jfree.data.time.TimeSeriesCollection cannot be cast to org.jfree.data.xy.TableXYDataset
Is there a reason org.jfree.data.time.TimeSeriesCollection is not derived from org.jfree.data.xy.TableXYDataset? I would have expected the time series collection to be derived from the basic XY dataset classes since it is just a special case of an XY dataset.
If I change my timer series collection into a TableXYDataset, can I still use org.jfree.chart.axis.SegmentedTimeline for the domain?
This exception occurs for the second plot I want for the combined chart, and that uses the org.jfree.chart.renderer.xy.StackedXYAreaRenderer2 as the renderer. I NEED the combination of a time series with a stacked area renderer for three of my charts. Is that possible? The range axis is not remarkable in this case (it is just a Value axis).
Will there be a problem with org.jfree.chart.renderer.xy.XYStepAreaRenderer too? (I have one chart that combines a step renderer with time series.)
Thanks
Ted
inheritance hierarchy for dataset classes
OK, I found the problem, and there is a logical capability missing from TimeTableXYDataset.
Consider the following from the manual (53.21 TableXYDataset); "This interface is an extension of the XYDataset interface. By implementing this interface, a dataset is declaring that all series share a common set of x-values—this is required by renderers that “stack” values (for example, the StackedXYAreaRenderer)."
There needs to be a shallow class derived from TableXYDataset or TimeTableXYDataset that can be created from TimeSeriesCollection (perhaps a copy constructor, or a static member function that returns an instance of a class that CAN be cast to a TableXYDataset and which takes a TimeSeriesCollection as an argument).
The point is, I have several TimeSeriesCollection instances for which I can GUARANTEE that the basic assumption of a TableXYDataset is satisfied. ALL of the series in these collections have the same x-values! And the code to verify this would be a trivially simple loop! If a mistake is made in organizing the data for the collection, it would be simple enough to throw an exception to indicate to the user that the assumption on which the TableXYDataset is based has been violated. Alternatively, since this is something assumed by certain renderers, logically the renderers ought to have a logical fall back position should the data provided not be suitable for the requested chart type.
Doing this right should not be too painful. After all, TableXYDataset is an extension of the XYDataset, and TimeSeriesCollection is a concrete implementation of XYDataset. TimeSeriesCollection and TableXYDataset are, in a sense, siblings, but alas I can't cast the one to the other. Worse, TimeTableXYDataset is NOT a simple replacement for TimeSeriesCollection because, unlike TimeSeriesCollection, it will not allow one to just add one org.jfree.data.time.TimeSeries after another. And it seems to insist on working only with periods for the domain, rather than simple dates. This, too, doesn't make sense to me since it assumes that the range value ought to be constant over the provided period, and in most cases that will not be true. Normally, the data I see, if I define a period, the data is changing through that period, regardless of the time scale.
Can you create a class, derived from TableXYDataset or TimeTableXYDataset, that delegates calls to a TimeSeriesCollection data member. Is there a simpler way?
What would you recommend that would involve the least amount of coding?
Thanks
Ted
Consider the following from the manual (53.21 TableXYDataset); "This interface is an extension of the XYDataset interface. By implementing this interface, a dataset is declaring that all series share a common set of x-values—this is required by renderers that “stack” values (for example, the StackedXYAreaRenderer)."
There needs to be a shallow class derived from TableXYDataset or TimeTableXYDataset that can be created from TimeSeriesCollection (perhaps a copy constructor, or a static member function that returns an instance of a class that CAN be cast to a TableXYDataset and which takes a TimeSeriesCollection as an argument).
The point is, I have several TimeSeriesCollection instances for which I can GUARANTEE that the basic assumption of a TableXYDataset is satisfied. ALL of the series in these collections have the same x-values! And the code to verify this would be a trivially simple loop! If a mistake is made in organizing the data for the collection, it would be simple enough to throw an exception to indicate to the user that the assumption on which the TableXYDataset is based has been violated. Alternatively, since this is something assumed by certain renderers, logically the renderers ought to have a logical fall back position should the data provided not be suitable for the requested chart type.
Doing this right should not be too painful. After all, TableXYDataset is an extension of the XYDataset, and TimeSeriesCollection is a concrete implementation of XYDataset. TimeSeriesCollection and TableXYDataset are, in a sense, siblings, but alas I can't cast the one to the other. Worse, TimeTableXYDataset is NOT a simple replacement for TimeSeriesCollection because, unlike TimeSeriesCollection, it will not allow one to just add one org.jfree.data.time.TimeSeries after another. And it seems to insist on working only with periods for the domain, rather than simple dates. This, too, doesn't make sense to me since it assumes that the range value ought to be constant over the provided period, and in most cases that will not be true. Normally, the data I see, if I define a period, the data is changing through that period, regardless of the time scale.
Can you create a class, derived from TableXYDataset or TimeTableXYDataset, that delegates calls to a TimeSeriesCollection data member. Is there a simpler way?
What would you recommend that would involve the least amount of coding?
Thanks
Ted
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Yes, that sounds like a reasonable approach. The only reason it hasn't been done so far, it laziness on my part (or just a lack of time).tedbyers wrote:Can you create a class, derived from TableXYDataset or TimeTableXYDataset, that delegates calls to a TimeSeriesCollection data member.
TableXYDataset only exists because the StackedXYAreaRenderer classes are not sophisticated enough to handle a collection of series with *different* x-values. Richard West has been doing some work to fix this in the renderer (so you'll eventually be able to use *any* XYDataset for stacked area charts). Once that's included in JFreeChart, the TableXYDataset interface will be redundant (and deprecated accordingly).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 1
- Joined: Wed Dec 09, 2009 12:00 am
- antibot: No, of course not.
Re: inheritance hierarchy for dataset classes
I apologize for the necro, but I don't want to reinvent the wheel.
Has any progress been made on this topic? I am attempting to combine a time series graph with a stacked area graph as well, and I have run into this exception.
Has any progress been made on this topic? I am attempting to combine a time series graph with a stacked area graph as well, and I have run into this exception.
Re: inheritance hierarchy for dataset classes
@tblackwell necro? what about that: I have this problem now ( ͡° ͜ʖ ͡°)
and this topic is the only result in Google when pasting this exception... so... up?
EDIT: just for the reference, I think that may help the ones who will get here from Google: viewtopic.php?t=9840
and this topic is the only result in Google when pasting this exception... so... up?

EDIT: just for the reference, I think that may help the ones who will get here from Google: viewtopic.php?t=9840