I am using achartengine 1.0.1 (latest) and want to demonstrate a bar chart.
This is what I want:
My Desired Graph
What I achieved so far
1:1 view:
Zoom-out View:
Problems:
setLabelColor()
but not working.Do you know how to fix these problems? I need a graph approximately like my desired graph. Thanks in advance.
Edit:
This is my trying code:
public GraphicalView getView(Context context)
{
// Bar 1
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
XYSeries ac = new XYSeries("AC");
XYSeries pe = new XYSeries("PE");
XYSeries wa = new XYSeries("WA");
XYSeries tl = new XYSeries("TL");
XYSeries ml = new XYSeries("ML");
XYSeries ce = new XYSeries("CE");
XYSeries re = new XYSeries("RE");
XYSeries ot = new XYSeries("OT");
ac.add(1, 291);
pe.add(2, 11);
wa.add(3, 204);
tl.add(4, 28);
ml.add(5, 0);
ce.add(6, 21);
re.add(7, 51);
ot.add(8, 4);
dataset.addSeries(ac);
dataset.addSeries(pe);
dataset.addSeries(wa);
dataset.addSeries(tl);
dataset.addSeries(ml);
dataset.addSeries(ce);
dataset.addSeries(re);
dataset.addSeries(ot);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.setChartTitle("Submission Statistics");
mRenderer.setXTitle("Verdict Code");
mRenderer.setYTitle("No. of Submissions");
mRenderer.setAxesColor(Color.BLACK);
mRenderer.setLabelsColor(Color.BLACK);
mRenderer.setApplyBackgroundColor(true);
mRenderer.setBackgroundColor(Color.WHITE);
mRenderer.setMarginsColor(Color.WHITE);
mRenderer.setZoomEnabled(true);
mRenderer.setZoomButtonsVisible(true);
mRenderer.setBarSpacing(-0.5);
// mRenderer.setMargins(new int[] {20, 30, 15, 0});
mRenderer.setAxisTitleTextSize(16);
mRenderer.setChartTitleTextSize(20);
mRenderer.setLabelsTextSize(15);
mRenderer.setLegendTextSize(15);
mRenderer.addXTextLabel(1, "AC");
mRenderer.addXTextLabel(2, "PE");
mRenderer.addXTextLabel(3, "WA");
mRenderer.addXTextLabel(4, "TL");
mRenderer.addXTextLabel(5, "ML");
mRenderer.addXTextLabel(6, "CE");
mRenderer.addXTextLabel(7, "RE");
mRenderer.addXTextLabel(8, "OT");
mRenderer.setBarWidth(50);
// mRenderer.setXAxisMax(9);
mRenderer.setXAxisMin(0);
mRenderer.setYAxisMin(0);
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setColor(Color.parseColor("#00AA00"));
renderer.setDisplayChartValues(true);
XYSeriesRenderer renderer2 = new XYSeriesRenderer();
renderer2.setColor(Color.parseColor("#666600"));
renderer2.setDisplayChartValues(true);
XYSeriesRenderer renderer3 = new XYSeriesRenderer();
renderer3.setColor(Color.parseColor("#FF0000"));
renderer3.setDisplayChartValues(true);
XYSeriesRenderer renderer4 = new XYSeriesRenderer();
renderer4.setColor(Color.parseColor("#0000FF"));
renderer4.setDisplayChartValues(true);
XYSeriesRenderer renderer5 = new XYSeriesRenderer();
renderer5.setColor(Color.parseColor("#6767D0"));
renderer5.setDisplayChartValues(true);
XYSeriesRenderer renderer6 = new XYSeriesRenderer();
renderer6.setColor(Color.parseColor("#AAAA00"));
renderer6.setDisplayChartValues(true);
XYSeriesRenderer renderer7 = new XYSeriesRenderer();
renderer7.setColor(Color.parseColor("#00AAAA"));
renderer7.setDisplayChartValues(true);
XYSeriesRenderer renderer8 = new XYSeriesRenderer();
renderer8.setColor(Color.parseColor("#000000"));
renderer8.setDisplayChartValues(true);
mRenderer.addSeriesRenderer(renderer);
mRenderer.addSeriesRenderer(renderer2);
mRenderer.addSeriesRenderer(renderer3);
mRenderer.addSeriesRenderer(renderer4);
mRenderer.addSeriesRenderer(renderer5);
mRenderer.addSeriesRenderer(renderer6);
mRenderer.addSeriesRenderer(renderer7);
mRenderer.addSeriesRenderer(renderer8);
return ChartFactory.getBarChartView(context, dataset,mRenderer, Type.DEFAULT);
}
Edit (After applying Dan's suggestion)
My new code:
.........
mRenderer.setChartTitle("Submission Statistics");
mRenderer.setXTitle("Verdict Code");
mRenderer.setYTitle("No. of Submissions");
mRenderer.setAxesColor(Color.BLACK);
mRenderer.setApplyBackgroundColor(true);
mRenderer.setBackgroundColor(Color.WHITE);
mRenderer.setMarginsColor(Color.WHITE);
mRenderer.setZoomEnabled(true);
mRenderer.setBarSpacing(-0.5);
mRenderer.setMargins(new int[] {20, 30, 15, 0});
mRenderer.setShowLegend(false);
mRenderer.setAxisTitleTextSize(16);
mRenderer.setChartTitleTextSize(20);
mRenderer.setLabelsTextSize(15);
mRenderer.setLegendTextSize(15);
mRenderer.addXTextLabel(1, "AC");
mRenderer.addXTextLabel(2, "PE");
mRenderer.addXTextLabel(3, "WA");
mRenderer.addXTextLabel(4, "TL");
mRenderer.addXTextLabel(5, "ML");
mRenderer.addXTextLabel(6, "CE");
mRenderer.addXTextLabel(7, "RE");
mRenderer.addXTextLabel(8, "OT");
mRenderer.setBarWidth(50);
mRenderer.setXAxisMin(-2);
mRenderer.setXAxisMax(11);
mRenderer.setYAxisMin(0);
mRenderer.setYLabelsAlign(Align.RIGHT);
mRenderer.setXLabelsColor(Color.BLACK);
mRenderer.setYLabelsColor(0, Color.BLACK);
mRenderer.setXLabels(0);
mRenderer.setChartValuesTextSize(16);
.........
Now the problems are:
mRenderer.setChartValuesTextSize(size);
is not working as it is
deprecatedFollowing your numbering scheme:
mRenderer.setXAxisMin(min);
and mRenderer.setXAxisMax(max);
mRenderer.setXLabelsColor(color);
renderer.setChartValuesTextSize(size);
mRenderer.setXLabels(0);
Edit:
renderer.setChartValuesTextSize(size);
mRenderer.setYAxisMax(300);