1

I have this code so far. Right now I want to override where the point is drawn. If the point is below 1 I want to draw the point at 1 and place an orange marker. I have the color set up but now I want to change the Y position. The only method I see I can override is drawItem. But I'm not 100% sure.

public class XYCustomRenderer extends XYShapeRenderer {

    @Override
    public Paint getItemPaint( int series, int item ) {

        TimeSeriesCollection seriesCollection = ( TimeSeriesCollection ) getPlot().getDataset();
        //Logger.info( "" + data.getY( 0, 2 ) );

        if ( seriesCollection.getYValue( series, item ) < 1 ) {
            return Color.ORANGE;
        }

        return Color.RED;
    }
}
dacwe
  • 43,066
  • 12
  • 116
  • 140
Drew H
  • 4,699
  • 9
  • 57
  • 90
  • 1
    It seems you should be looking at how you add your data instead. How is the rest of the chart configured? – Jes Aug 29 '11 at 15:39
  • Yea I could just change how the data is added but I would prefer this method. – Drew H Aug 29 '11 at 17:40

1 Answers1

1

You might look at how BoxAndWhiskerRenderer, seen here, uses Outlier. Alternatively, pin negative ordinates to some arbitrary value, e.g. 0, in your data model, and use your custom getItemPaint() to change the corresponding item's color.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045