[英]How to set the Width And Height of X & Y Axis of Bar Charts in Android AChartEngine?
I am new to Android AChartEngine. 我是Android AChartEngine的新手。
I want to set the width and height of X & Y Axes . 我想设置X和Y轴的宽度和高度 。
I have tried, but I could not find the right solution for this. 我已经尝试过,但是找不到适合的解决方案。
I am using the code below: 我正在使用以下代码:
public Intent execute(Context context) {
String[] titles = new String[] { "2008", "2007" };
List<double[]> values = new ArrayList<double[]>();
values.add(new double[] { 14230, 12300, 14240, 15244, 15900, 19200,
22030, 21200, 19500, 15500, 12600, 14000 });
values.add(new double[] { 5230, 7300, 9240, 10540, 7900, 9200, 12030,
11200, 9500, 10500, 11600, 13500 });
int[] colors = new int[] { Color.BLUE, Color.CYAN };
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
setChartSettings(renderer, "Monthly sales in the last 2 years",
"Month", "Units sold", 0.5, 12.5, 0, 24000, Color.GRAY,
Color.LTGRAY);
renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
renderer.getSeriesRendererAt(1).setDisplayChartValues(true);
renderer.setXLabels(12);
renderer.setYLabels(10);
renderer.setXLabelsAlign(Align.LEFT);
renderer.setYLabelsAlign(Align.LEFT);
renderer.setPanEnabled(true, false);
renderer.setZoomRate(1.1f);
renderer.setBarSpacing(0.5f);
return ChartFactory.getBarChartIntent(context,
buildBarDataset(titles, values), renderer, Type.STACKED);
}
You can give your own limit. 您可以自己设定限制。 For example if you want set limit to 0 to 100 for Y axis and 0 to 10 for X axis, you can change the code
例如,如果要将Y轴的极限值设置为0到100,X轴的极限值设置为0到10,则可以更改代码
setChartSettings(renderer, "Monthly sales in the last 2 years", "Month", "Units sold", 1, setChartSettings(renderer,“最近2个月的月销售额”,“月”,“售出的单位”,1,
10, 0, 100, Color.GRAY, Color.LTGRAY); 10、0、100,Color.GRAY,Color.LTGRAY);
For X axis progress count 1,(0, 1, 2, 3, 4, 5) 对于X轴进度计数1,(0,1,2,3,4,5)
renderer.setXLabels(1); renderer.setXLabels(1);
For Y axis progress count 10,(0, 10, 20, 30, .....100) 对于Y轴进度计数10,(0,10,20,30,..... 100)
renderer.setYLabels(10); renderer.setYLabels(10);
And leave others as it is. 并保持其他状态。
Hope this could be help you. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.