Multiply RangeAxis with one dataset

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
FPawlak
Posts: 3
Joined: Tue Dec 03, 2013 8:33 pm
antibot: No, of course not.

Multiply RangeAxis with one dataset

Post by FPawlak » Tue Dec 03, 2013 8:43 pm

Hi,
is it possible to assign multiply range axis to one dataset? I know that it is possible with to assign different range axis to different datasets. But i don't want to double data (domain axis).
Let's say, I have to plot weather conditions - wind and temperature - each datapoints probed simultaneously, so there are no need to use more than one dataset.

Do you have some suggestions?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Multiply RangeAxis with one dataset

Post by david.gilbert » Fri Dec 06, 2013 10:01 am

No, the each dataset is matched to a single axis, so if you want to use multiple axes you'll have to have multiple datasets.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

FPawlak
Posts: 3
Joined: Tue Dec 03, 2013 8:33 pm
antibot: No, of course not.

Re: Multiply RangeAxis with one dataset

Post by FPawlak » Fri Dec 06, 2013 10:18 am

Thanks for replay.
I've already looked through the source code and I have some idea how to solve my problem implementing this feature. So I will later post here my solution. I think it may be useful to someone else.

I'm going to extends XYPlot class and override draw() method changing two for loops which are responsible for rendering data - I plan to query dataset for each series to obtain correct axis. So I need also add getRangeAxis(int series) or getRangeAxisId(int series) to my dataset.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Multiply RangeAxis with one dataset

Post by david.gilbert » Fri Dec 06, 2013 1:15 pm

That will most likely work, but I would try to avoid mixing presentation-related attributes (the axis index to use etc) with your data model (the dataset).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Multiply RangeAxis with one dataset

Post by paradoxoff » Sat Dec 07, 2013 10:12 pm

FPawlak wrote:But i don't want to double data (domain axis).
Let's say, I have to plot weather conditions - wind and temperature - each datapoints probed simultaneously, so there are no need to use more than one dataset.
But you will need two series anyways, one for the wind, the second for the temperature.
You can implement your requirement by using two datasets, each with a single series, and two renderers. I do not believe that this is more complicated to set up than using only one dataset with two series, a single renderer, and implementing your XYPlot extension.
If you have to plot a large amount of data, and if you want so save the memory for the second set of x-coordinates (which is identical to the first set), your approach has the potential to save some memory (dxepending on the type of dataset you are using), but even in that case, I would rather implement an XYDataset where multiple datasets can share the same set of x values.

FPawlak
Posts: 3
Joined: Tue Dec 03, 2013 8:33 pm
antibot: No, of course not.

Re: Multiply RangeAxis with one dataset

Post by FPawlak » Sun Dec 08, 2013 11:23 am

david.gilbert wrote:That will most likely work, but I would try to avoid mixing presentation-related attributes (the axis index to use etc) with your data model (the dataset).
This was my first solution in order to see if it will work. And yes, it works. So to make to solution better and more clear i will add to dataset only getSeriesCategory(int series) and create class AxesManager which will map series and axes. So if XYPlot has reference to AxesManager it will during plotting for each series 1) obtain series category from dataset 2) obtain correspondent Axis from AxesManager 3) plot series using that axis.
paradoxoff wrote: But you will need two series anyways, one for the wind, the second for the temperature.
You can implement your requirement by using two datasets, each with a single series, and two renderers. I do not believe that this is more complicated to set up than using only one dataset with two series, a single renderer, and implementing your XYPlot extension.
If you have to plot a large amount of data, and if you want so save the memory for the second set of x-coordinates (which is identical to the first set), your approach has the potential to save some memory (dxepending on the type of dataset you are using), but even in that case, I would rather implement an XYDataset where multiple datasets can share the same set of x values.
Yes, I need more than one series, so my dataset has one "x series" common for every "y series". I think it will be easier to manage only one dataset - I need to load new while panning, add/remove series while reviewing chart. And of course I will have more then two series - five or six axes/series category and ca. 40 series

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Multiply RangeAxis with one dataset

Post by david.gilbert » Mon Dec 09, 2013 11:27 am

OK, sounds like you've thought it through and you are on a good track.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

olbrich
Posts: 19
Joined: Fri Dec 27, 2013 9:39 am
antibot: No, of course not.

Re: Multiply RangeAxis with one dataset

Post by olbrich » Wed Jan 22, 2014 12:36 pm

Hi David,

this thread describes a very common feature.
Why not adress this in the next version?

Markus

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Multiply RangeAxis with one dataset

Post by david.gilbert » Wed Jan 22, 2014 12:53 pm

Because it would take a lot of time (which I don't have), it would break the API, and the existing mechanism (multiple datasets and renderers, with datasets being mapped to arbitrary axes) provides a perfectly workable solution.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked