#661 XYBarRenderer does not draw bars if setUseYInterval(true)

closed-invalid
General (896)
5
2006-09-04
2006-08-30
Anonymous
No

I have created a bar chart that I am using to draw
error bars. The error bars do not have a fixed base
value, so I am using an XYSeriesCollection to add a
bunch of series (each with a min/max y-value), with an
XYBarRenderer. This effectively draws horizontal lines
to mark the upper and lower error bound. However, it
does not fill in the error bars, or even draw vertical
lines for the outline. All I see are two horizontal
lines. If I then call
XYBarRenderer.setUseYInterval(false), it correctly
draws bars, but they all extend down to 0 (which is not
what I want). Can you fix this so that even if you
call setUseYInterval(true), it will draw actual bars
based on the min/max of each series?

Email: marcusworkmail@yahoo.com

Here is an example snippet:

    XYSeriesCollection errDataset = new XYSeriesCollection\(\);

    // create bar renderer that draws y-intervals
    XYBarRenderer barRenderer = new XYBarRenderer\(\);

    //\*\*\* this draws bars instead of horizontal lines if

you set to false
barRenderer.setUseYInterval(true);

    barRenderer.setOutlinePaint\(Color.BLACK\); 
    barRenderer.setBaseOutlinePaint\(Color.BLACK\); 
    barRenderer.setFillPaint\(Color.gray\); 
    barRenderer.setBaseFillPaint\(Color.gray\); 
    barRenderer.setBasePaint\(Color.gray\); 
    barRenderer.setPaint\(Color.gray\); 
    barRenderer.setDrawBarOutline\(true\);

    // add each distance/value as a separate series in

the IntervalXYDataset
for(int i = 0; i < numObs; i++) {
XYSeries series = new XYSeries("");

        // add lower then upper bound for bars
        // \(interpeted as y-interval\)
        series.add\(dists\[i\], vals\[i\] - errs\[i\]\);
        series.add\(dists\[i\], vals\[i\] + errs\[i\]\);
        errDataset.addSeries\(series\);
    \}

    // customize interval widths for error bars
    errDataset.setIntervalWidth\(0.1\);

    // set new dataset for error bars
    plot.setDataset\(seriesIndex, errDataset\);

    // set bar renderer for error bars
    plot.setRenderer\(seriesIndex, barR

Discussion

  • David Gilbert

    David Gilbert - 2006-09-04

    Logged In: YES
    user_id=112975

    The problem here is not the renderer, but the way you are
    defining the dataset. XYSeriesCollection does implement the
    IntervalXYDataset interface, but only partially (it doesn't
    record any start and end y-values). In your case, you are
    adding one item in the dataset for the lower y-value and
    another item in the dataset for the upper y-value - storing
    these as two separate observations in the series isn't going
    to work.

    You need to write a class that stores your data values and
    implements all the methods in IntervalXYDataset to provide
    access to those values. JFreeChart doesn't have a general
    purpose class that does this yet.

     
  • David Gilbert

    David Gilbert - 2006-09-04
    • labels: --> General
    • assigned_to: nobody --> mungady
    • status: open --> closed-invalid
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks