问题
I am trying to create Bar Chart
using AchartEngine
but various things doesn't work for me..
1) Unable to show Grid.
2) Unable to remove category series title i.e "Bar Graph".
3) It's not showing bars as it should show.
4) By Default white color background is visible.
is it possible to provide space between each bars??
Bar Chart Code
CategorySeries series = new CategorySeries("Bar Graph");
for (int i = 0; i < availCatList.size(); i++)
series.add(availCatList.get(i), mTotal.get(i));
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series.toXYSeries());
XYSeriesRenderer seriesRenderer = new XYSeriesRenderer();
seriesRenderer.setChartValuesSpacing(0.5f);
seriesRenderer.setDisplayChartValues(true);
seriesRenderer.setColor(Color.GREEN);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.setChartTitle("Bar Chart");
mRenderer.setShowGrid(true);
mRenderer.setAxisTitleTextSize(15);
mRenderer.setXLabelsAlign(Align.CENTER);
mRenderer.setXTitle("Categories");
mRenderer.setYTitle("Amount");
mRenderer.setScale(1.0f);
for (int i = 0; i < availCatList.size(); i++) {
mRenderer.addXTextLabel(i + 1, availCatList.get(i));
}
mRenderer.setXLabels(0);
mRenderer.addSeriesRenderer(seriesRenderer);
view = ChartFactory.getBarChartView(this, dataset, mRenderer,
Type.DEFAULT);
// layout.removeAllViews();
layout.addView(view);
Any Help would be highly appreciated..
Thanks
回答1:
mRenderer.setShowGrid(true)
works fine in all the examples in the demo code. Try to set another color usingmRenderer.setGridColor(color);
- You mean the legend:
mRenderer.setShowLegend(false);
series.add(mTotal.get(i));
is the correct usage for bar charts.- That's probably from the profile. Just set your own background color.
Space between bars: read the APIs for mRenderer.setBarSpacing();
来源:https://stackoverflow.com/questions/14851820/bar-chart-not-working-in-achartengine