In AChartEngine Bar Chart, is it possible that the bars are drawn over grid lines? How to do that? Currently grid lines are drawn over bars which make it a bit awkward.
Sample Image is attached below.
Grid lines come in two types: major and minor. Major grid lines separate the axis into major units. On category axes, major grid lines are the only grid lines available (you cannot show minor grid lines on a category axis.) On value axes, major grid lines are drawn for every major axis division.
Gridlines extend from any horizontal and vertical axes across the plot area of the chart. You can also display depth gridlines in 3-D charts. Displayed for major and minor units, gridlines align with major and minor tick marks on the axes when tick marks are displayed.
Click the chart with the lines, and then click the Chart Design tab. Click Add Chart Element, click Gridlines, and then click More Gridline Options. Select No line. You can also click the line and press DELETE .
Grid lines are rarely needed in graphs to help readers assign accurate numeric values to the data; the approximate values that can be perceived without the aid of grid lines are almost always adequate.
You cannot change which one is drawn first and which one next.
However, you can change the color of the grid lines. For instance, you can set a color that is a bit transparent, such as it doesn't really look like it is drawn above the bars.
Even tough this is not a perfect answer, it is possible to achieve that behaviour, by making some changes to the method 'draw' of the class XYChart.
I am not sure this will not cause any other issues, but for me it has been working. Basically the idea consists in drawing the labels and grid before drawing the chart line.
I moved all the code starting and ending in:
boolean showLabels = mRenderer.isShowLabels() && hasValues;
...
drawText(canvas, mRenderer.getChartTitle(), x + size, top + height / 2, paint, 0);
}
}
to before this line:
boolean hasValues = false;
Also, I commented the && hasValues
part.
Note that this is definitely not reliable code, just a slight hack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With