CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2011

    JFreeChart with multiple 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 Date(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);

    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
    The initial chart without zooming is like this http://i.imgur.com/esEc5.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? For example, if I don't "chop" the initial data series into parts and using the same chart configuration the chart looks like this http://i.imgur.com/oYJAA.jpg

  2. #2
    Join Date
    Aug 2011

    Re: JFreeChart with multiple data series

    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 though I should let you know; maybe it will help someone else with a similar problem.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.