Print

Print


I'd like to share my progress so far and compare notes. I found this example which demonstrates how this can be done using a TimeTableXYDataset and ChartFactory.createStackedXYAreaChart(...). I don't like that TimeTableXYDataset uses a TimePeriod to represent the time, but I was able to modify it to use a SimpleTimePeriod based on a long (e.g. the current step). I don't see a way to base a TimePeriod on a double since the interface returns Date objects. One option would be to write a sibling class of TimeTableXYDataset that uses doubles instead of TimePeriods but I's prefer to use only the standard JFreeChart classes if possible.

Option A) Version based on TimeTableXYDataset.
Pros:
- Works

Cons:
- Uses TimePeriods, which are heavier than necessary and based on Dates rather than doubles
- Stores data internally with DefaultKeyedValues2D rather than individual XYSeries

I also tried:
Option B) Version that uses a DefaultTableXYDataset to store the data.
Pros:
- Uses individual XYSeries
- Can use doubles for the time values
Cons:
- Doesn't work!
- DefaultTableXYDataset is a lot heavier than necessary because it doesn't assume you're adding data in order

Here's what happens: DefaultTableXYDataset listens to the change event for all the XYSeries you add to it. Whenever you add a value to any series with a previously unseen x-value (e.g. x=1), it adds a dummy entry to all the other series. Then, when you try to add a value (at x=1) to another series, it sees the dummy value already there (at x=1) and throws a SeriesException: X-value already exists.

I'm not sure if this is the intended behavior or a bug. Seems like a bug to me.

I also tried turning off the notifications, but then it never draws anything. I tried forcing an update through the dataset and the chart but neither approach worked.

Thoughts?

Joey


On Fri, Jun 10, 2016 at 2:35 PM, Sean Luke <[log in to unmask]> wrote:
I'm not aware of it.

I thought there might be two ways go about this: (1) treat each stacked row as a separate series and (2) assume that the series has data for all the rows together -- like an array or a list of numbers.  It turns out #1 isn't possible in JFreeChart.

Sean

On Jun 10, 2016, at 7:56 PM, Joseph F Harrison <[log in to unmask]> wrote:

> I'm looking to make a stacked area time series chart a bit like this, and I'd like to do it within the MASON *ChartGenerator framework. Has anyone done this already?
>
> Joey