For TimeSeries Chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Ansh Desi

For TimeSeries Chart

Post by Ansh Desi » Fri Jun 14, 2002 8:13 pm

This might be a very simple question,

I am plotting a simple Time Series chart, using StandardXYItemRenderer, and BasicTimeSeries and TimePeriod being Day.

I have data for Monday, Tuesday, Thursday and Friday...but None for Wednesday.

SO when the line is drawn I do not want it to continue on from monday, to friday continuously...i want it to connect for only the values that are able and so it should be broken for wednesday.

So, which class method I need to be looking at to make that happen?

Thanks

David Gilbert

Re: For TimeSeries Chart

Post by David Gilbert » Mon Jun 17, 2002 11:01 am

You need to add data for Wednesday, but use the value null...if you leave out Wednesday, the renderer will join a line between Tuesday and Thursday.

Regards,

DG.

Ansh Desi

Re: For TimeSeries Chart

Post by Ansh Desi » Sat Jul 13, 2002 3:37 am

David,

Is there any way I could not have the line at all but just data points?

Thanks

Norbert Kiesel

Re: For TimeSeries Chart

Post by Norbert Kiesel » Fri Jul 26, 2002 2:16 am

Hi,

I had a similar problem: I have time data which is isochromatic (e.g. a data point every 15 minutes), but sometimes there is a huge gap (e.g. 10 hours). The StandardXYRendere draws a line "crossing" this gap. I hacked it and added a new line varant called "BROKEN_LINES" which does not draw a line between two points if the gap is bigger than a specified threshold, i.e.

if ((x1-x0)/(maxx-minx)*itemCount < gap) { draw line };

The patch is rather small. I"ll clean it up a bit and post it if anyone is interested.

--nk

David Gilbert

Re: For TimeSeries Chart

Post by David Gilbert » Fri Jul 26, 2002 9:07 am

Yes, you can create a new StandardXYItemRenderer:

XYItemRenderer myRenderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, new StandardXYToolTipGenerator());

Then you can set this for the plot:

XYPlot myPlot = myChart.getXYPlot();
myPlot.setXYItemRenderer(myRenderer);

Regards,

DG.

David Gilbert

Re: For TimeSeries Chart

Post by David Gilbert » Fri Jul 26, 2002 9:08 am

BROKEN_LINES : that's an excellent idea! Once you have code tidied up, please post it here or e-mail it to me and I'll incorporate it for the next version.

Regards,

DG

Norbert Kiesel

Re: For TimeSeries Chart

Post by Norbert Kiesel » Fri Jul 26, 2002 8:08 pm

Ok, I mailed it to David, because pasting it here adds stupid line brakes which kill the patch.

The one thing I'm not totally happy about is that I compute the threshold for every datapoint over and over again (i.e. the line in my patch "(maxX-minX)/numX*this.gapThreshold"). I could add a double member var which caches the value (set it to -1 initially and in SetGapThreshold(), test and set within drawItem()). Is this worth the effort?

--nk

Locked