首页 > 代码库 > XCL-Charts画曲线图(CurveChart)

XCL-Charts画曲线图(CurveChart)

  曲线图与通常的折线图不同的地方是它的线条位置计算有点特别,所以我独立弄了一个类.同样,只需传入数据源给基类,

再加上,你想加的控制,可自动依设置绘出你想要的效果。

     

     代码:

//图基类
				chart = new CurveChart();
				//图所占范围大小
				chart.setChartRange(0, 0, this.mScrWidth  , this.mScrHeight );
				
				//标签轴标签集合
				LinkedList<String> lables = new LinkedList<String>();
				lables.add("2010");
				lables.add("2011");
				lables.add("2012");
				lables.add("2013");
				lables.add("2014");
				chart.setLineLables(lables);
				
				//线1的数据集
				LinkedHashMap<Double,Double> linePoint1 = new LinkedHashMap<Double,Double>();
				linePoint1.put(10d, 30d);
				linePoint1.put(25d, 80d);
				linePoint1.put(60d, 60d);
				linePoint1.put(75d, 45d);
				CurveData curveData1 = new CurveData("青菜萝卜够吃",
						(int)Color.rgb(54, 141, 238) ,linePoint1);
				//线2的数据集
				LinkedHashMap<Double,Double> linePoint2 = new LinkedHashMap<Double,Double>();
				linePoint2.put(40d, 40d);
				linePoint2.put(55d, 85d);
				linePoint2.put(70d, 65d);
				linePoint2.put(85d, 55d);				
				CurveData curveData2 = new CurveData("饭管够",
						(int)Color.rgb(255, 165, 132) ,linePoint2);
								
				//设定数据源
				LinkedList<CurveData> chartData = http://www.mamicode.com/new LinkedList();>

MAIL: xcl_168@aliyun.com

BLOG:http://blog.csdn.net/xcl168