UmAnusorn
UmAnusorn

Reputation: 11124

Android aChartengine - How to fill color above the reference line in Green and below reference line in Magenta

I have used aChartEngine This is my code for my lineChart

XYSeriesRenderer xyRenderer = (XYSeriesRenderer) renderer.getSeriesRendererAt(0);
XYSeriesRenderer.FillOutsideLine fill; XYSeriesRenderer.FillOutsideLine(XYSeriesRenderer.FillOutsideLine.Type.BOUNDS_BELOW);
fill.setColor(Color.MAGENTA);
xyRenderer.addFillOutsideLine(fill);

The lineChart should colored in magenta for every area that is below the green line. However, as you can see that aChartengine render only the first area. So what have I missed? I also found that when I move the chart (shown in the figure 2) the chart will render only the first area. The figure 3 the chart render 2 areas. the figure 4 show the result of the code below.

    fill = new XYSeriesRenderer.FillOutsideLine(XYSeriesRenderer.FillOutsideLine.Type.BOUNDS_ALL);
fill.setColor(Color.MAGENTA);
xyRenderer.addFillOutsideLine(fill);

fill = new XYSeriesRenderer.FillOutsideLine(XYSeriesRenderer.FillOutsideLine.Type.BOUNDS_ABOVE);
fill.setColor(Color.GREEN);
xyRenderer.addFillOutsideLine(fill);

aChartEngine problems with color bounded below the line chart

enter image description here enter image description here enter image description here

Upvotes: 0

Views: 1251

Answers (1)

Dan D.
Dan D.

Reputation: 32391

You should probably use FillOutsideLine.Type.BOUNDS_ALL instead of FillOutsideLine.Type.BOUNDS_BELOW.

Upvotes: 0

Related Questions