开发者

JFreeChart domain axis with multiple (but sequential) data series

I am trying to display a plot that will have different colors at specific time-periods.

The only way I managed to do that was by chopping the initial data series into parts and adding them in the appropriate order in the dataset to be plotted. For example if the default color of the plot is blue and I wanted to highlight two time-periods (e.g. color red), I would have a dataset comprised by 5 data series:

dataset.add(blue) initial plot

dataset.add(red) highlight 1

dataset.add(blue) initial plot continued

dataset.add(red) highlight 2

dataset.add(blue) initial plot continued

The points in the domain axis that connect each of the 5 parts of the dataset are ordered. However I have a problem with the domain axis. Each point in the data series is instantiated appropriately (i guess, since the aligning of the domain axis works fine for dataseries that have the same start and end points)

milliseconds = ts.getTime() + (ts.getNanos() / 1000000);
date = new Da开发者_JAVA技巧te(milliseconds);
intYear = date.getYear() + 1900;
year = new Year(intYear);
intMonth = date.getMonth();
month = new Month(intMonth, year);
intDay = date.getDate();
day = new Day(intDay, month.getMonth(), year.getYear());
hour = new Hour(date.getHours(), day);
minute = new Minute(date.getMinutes(), hour);

tpVal = new TimePeriodValue(minute, watts);
s1.add(tpVal);

This image has the domain axis zoomed in multiple times. The domain axis ranges from 00:00:00 to 23:59:59 http://i.imgur.com/c7TDY.jpg

Is there a way to fix the alignment of the domain axis so I can have the plot displayed properly without the need to zoom in?


I found a "way" to overcome the problem.

After adding each data-series into the data-set as described above, I just added the original un-chopped data-series in the end of the data-set and the domain axis included all the date-points and was aligned properly.

The original un-chopped data series is being overlapped by the "chopped" parts so it is not visible at all. This is how it looks now. http://i.imgur.com/Wc893.jpg

I guess the problem was due to the fact that there was no data-series that would cover every point in the domain axis from start (first timePeriodValue of 1st data-series) to end (last timePeriodValue of the last data-series) which messed up the autorange() or whatever methods are called that take care of axis alignment.

I though I should let you know; maybe it will help someone else with a similar problem.

Thanks toto for suggesting to leave the original data series untouched.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜