Page 1 of 1

Hide weekend data in a 4 hour ohlc timeseries

Posted: Wed Apr 18, 2012 5:48 pm
by reenotherhino
I have a ohlc financial chart which updates every 4 hours with a new ohlc bar and removes the oldest bar from the series. My question is this, how do I hide the blank spaces left over the weekend time periods. :roll:

OHLCSeries series0 = new OHLCSeries("EURUSD "+legendTitle);
NumberAxis rangeAxis0 = new NumberAxis("EURUSD "+legendTitle);
rangeAxis0.setAutoRangeIncludesZero(false);
XYPlot subplot0 = new XYPlot(this.datasets[0], null, rangeAxis0, new CandlestickRenderer());
CandlestickRenderer r0 = new CandlestickRenderer();
subplot0.setRenderer(0,r0);
XYLineAndShapeRenderer cRender0 = new XYLineAndShapeRenderer(true,true);
subplot0.setRenderer(1, cRender0);
subplot0.setBackgroundPaint(Color.lightGray);
subplot0.setDomainGridlinePaint(Color.white);
subplot0.setRangeGridlinePaint(Color.white);

Re: Hide weekend data in a 4 hour ohlc timeseries

Posted: Mon Jun 18, 2012 3:50 pm
by russdb
I'm having the same issue. Big Problem. Have you found a solution.

I'm using Forex Data. It's a pain because the Forex Market isn't open during the weekends and JFreeChart is showing time periods for the weekends when there's no trading.

The issue is to do with the RegularTimePeriod. I think that JFreeChart automatically increments the date by a specified time period. But the flaw with this method is that it doesn't exclude periods of which there is no data for.

Sending the word out, if anyone else is reading this I'm anxious for a response for a workaround.

Re: Hide weekend data in a 4 hour ohlc timeseries

Posted: Mon Jun 25, 2012 9:23 am
by robthewolf
you need to use a segmented time line ( I would search google for examples )
here is something simple

Code: Select all

SegmentedTimeline timeline = SegmentedTimeline.newMondayThroughFridayTimeline();
((DateAxis) chart.getXYPlot().getDomainAxis()).setTimeline(timeline);