标签:google 图形 开源 achartengine
//设置坐标轴名称和最大、最小刻度值和标题名称 private void setChart(XYMultipleSeriesRenderer renderer) { renderer.setChartTitle( "Algorithm" ); renderer.setXTitle( "X Axis" ); renderer.setYTitle( "Y Axis" ); renderer.setXAxisMin(0); renderer.setXAxisMax(30); renderer.setYAxisMin(0); renderer.setYAxisMax(200); } //设置图形渲染属性 private XYMultipleSeriesRenderer getBarRenderer() { XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); SimpleSeriesRenderer simpleSeriesRenderer = new SimpleSeriesRenderer(); simpleSeriesRenderer.setColor(Color.RED); renderer.addSeriesRenderer(simpleSeriesRenderer); simpleSeriesRenderer = new SimpleSeriesRenderer(); simpleSeriesRenderer.setColor(Color.GRAY ); renderer.addSeriesRenderer(simpleSeriesRenderer); setChart(renderer); return renderer; } //获取数据集 private XYMultipleSeriesDataset getBarDataset() { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); Random random = new Random(); for ( int i = 0; i < 2 ; i++) { CategorySeries series = new CategorySeries( "Algorithm" + (i + 1)); for ( int k = 0; k < 10; k++) { series.add(50 + random.nextInt() % 150); } dataset.addSeries(series.toXYSeries()); } return dataset; }调用部分:
XYMultipleSeriesRenderer renderer = getBarRenderer(); Intent intents = ChartFactory.getBarChartIntent(this, getBarDataset(), renderer, BarChart.Type.DEFAULT); startActivity(intents);运行效果如下图:
achartengine(Google给android提供的绘图工具包)的介绍和使用
标签:google 图形 开源 achartengine
原文地址:http://blog.csdn.net/u013647453/article/details/44408403