Bar color displayed for 0 values ​​in AchartEngine, android

I used AchartEngine to display Barchart. In my chart, the panel color is also displayed for 0 values. I checked the following: but he set all the values ​​to transparent. I want to set the border color to values ​​greater than 0.

CategorySeries series = new CategorySeries(""); for (int i = 0; i < y_onemonth.length; i++) { series.add("Bar" + (i + 1), y_onemonth[i]); } XYMultipleSeriesDataset dataSet = new XYMultipleSeriesDataset(); dataSet.addSeries(series.toXYSeries()); // number of series // customization of the chart XYSeriesRenderer renderer = new XYSeriesRenderer(); for (int i = 0; i < y_onemonth.length; i++) { if(y_onemonth[i]==0) { renderer.setColor(Color.TRANSPARENT); } else { renderer.setColor(Color.RED); } } 

Update: I changed my code when you mention, but get the diagram as follows. I have a value for the 19th of the month, but it is not visible.

enter image description here

+7
android achartengine
source share
1 answer

I had some success replacing 0 values ​​with MathHelper.NULL_VALUE. You can find the documentation for this class here .

EDIT: when filling out a series of data, you can try something like this:

 for (int i = 0; i < y_onemonth.length; i++) { double doubleValue = MathHelper.NULL_VALUE; if (y_onemonth[i] != 0){ doubleValue = y_onemonth[i]; } series.add("Bar" + (i + 1), doubleValue); } 

Hope this helps; -)

+6
source share

All Articles