用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - android代码库

数据图表

2015-01-15 作者: 云代码会员举报

[android]代码库

package com.example.graphdemo;

import org.achartengine.ChartFactory;
import org.achartengine.chart.BarChart.Type;
import org.achartengine.model.CategorySeries;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;

public class BarGraph {
	  public Intent getIntent(Context context){
	        int y[] = {25,10,15,20};
	        CategorySeries series = new CategorySeries("Bar1");
	        for(int i=0; i < y.length; i++){
	            series.add("Bar"+(i+1),y[i]);
	        }
	        XYMultipleSeriesDataset dataSet = new XYMultipleSeriesDataset();  // collection of series under one object.,there could any
	        dataSet.addSeries(series.toXYSeries());                            // number of series
	        //customization of the chart
	        XYSeriesRenderer renderer = new XYSeriesRenderer();     // one renderer for one series
	        renderer.setColor(Color.RED);
	        renderer.setDisplayChartValues(true);
	        renderer.setChartValuesSpacing((float) 5.5d);
	        renderer.setLineWidth((float) 10.5d);
	         XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();   // collection multiple values for one renderer or series
	        mRenderer.addSeriesRenderer(renderer);
	        mRenderer.setChartTitle("Demo Graph");
//	      mRenderer.setXTitle("xValues");
	        mRenderer.setYTitle("Rupee");
	        mRenderer.setZoomButtonsVisible(true);    mRenderer.setShowLegend(true);
	        mRenderer.setShowGridX(true);      // this will show the grid in  graph
	        mRenderer.setShowGridY(true);              
//	      mRenderer.setAntialiasing(true);
	        mRenderer.setBarSpacing(.5);   // adding spacing between the line or stacks
	        mRenderer.setApplyBackgroundColor(true);
	        mRenderer.setBackgroundColor(Color.BLACK);
	        mRenderer.setXAxisMin(0);
//	      mRenderer.setYAxisMin(.5);
	        mRenderer.setXAxisMax(5);
	        mRenderer.setYAxisMax(50);
	//    
	        mRenderer.setXLabels(0);
	        mRenderer.addXTextLabel(1,"Income");
	        mRenderer.addXTextLabel(2,"Saving");
	        mRenderer.addXTextLabel(3,"Expenditure");
	        mRenderer.addXTextLabel(4,"NetIncome");
	        mRenderer.setPanEnabled(true, true);    // will fix the chart position
	        Intent intent = ChartFactory.getBarChartIntent(context, dataSet, mRenderer,Type.DEFAULT);
	        return intent;
	    }
}


网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...