Bar renderer with time series chart...

Discussion about JFreeChart related to stockmarket charts.
Locked
fanrien
Posts: 1
Joined: Fri Jun 20, 2008 10:20 am

Bar renderer with time series chart...

Post by fanrien » Fri Jun 20, 2008 11:41 am

Hi all,

I encountered a problem, and here is the pic:

www . mybeast . info / ~fanrien / Volume.png


I have added the SegmentedTimeline to DateAxis in DomainAxis in XYPlot.
The bar data have gap on the days without real data.
JFreechart reserved space for non-trading days, and combined ex-data within.

I don't want that gap, could anybody help me??

Fanrien

RoyW
Posts: 93
Joined: Wed Apr 23, 2008 7:42 pm
Contact:

Post by RoyW » Thu Jun 26, 2008 10:24 pm

Here's a link to your pic
http://www.mybeast.info/~fanrien/Volume.png
Also, please read this
http://www.jfree.org/phpBB2/viewtopic.php?t=24715

I am assuming
1) You are using JFreeChart 1.0.9
2) You are using XYBarRenderer()
3) You are using TimeSeriesDataset

Try

Code: Select all

        domainAxis = new DateAxis()
        domainAxis.setTickMarkPosition( DateTickMarkPosition.START );
If that doesn't work then it appears to be a bug in XYBarRenderer.
Here is the relevant code from XYBarRenderer

Code: Select all

        double startX = intervalDataset.getStartXValue(series, item);
        if (Double.isNaN(startX)) {
            return;
        }
        double endX = intervalDataset.getEndXValue(series, item);
        if (Double.isNaN(endX)) {
            return;
        }
        if (startX <= endX) {
            if (!domainAxis.getRange().intersects(startX, endX)) {
                return;
            }
        }
        else {
            if (!domainAxis.getRange().intersects(endX, startX)) {
                return;
            }
        }

        RectangleEdge location = plot.getDomainAxisEdge();
        double translatedStartX = domainAxis.valueToJava2D(startX, dataArea, 
                location);
        double translatedEndX = domainAxis.valueToJava2D(endX, dataArea, 
                location);

Unfortunately StartX will be a time that is less than the time segment so when it gets translated it gets truncated.
E.g.
Suppose your segment is 8am to 4pm
Your data is at 8.00
StartX = 8:00 - 1 min - 7:59
EndX = 8:00 + 1 min = 8:01

StartX lies outside the segment so it seems to be returning 8:00 for startX so the bar at the beginning of the segment is always thinner than the rest.

I would need to create a demo program to test the theory.
The answer does not come from thinking outside the box, rather the answer comes from realizing the truth; There is no Box. my js site

Locked