XCL-Charts画曲线图(CurveChart)

来源:互联网 发布:怎样更改域名dns 编辑:程序博客网 时间:2024/06/04 19:51

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

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

     

     代码:

//图基类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 = new LinkedList<CurveData>();chartData.add(curveData1);chartData.add(curveData2);chart.setDataSource(chartData);//柱形图标题chart.setTitle("曲线图(Curve Chart)");//柱形图图例chart.setLegend("XCL-Charts");//数据轴最大值chart.setDataAxisMax(100);//数据轴刻度间隔chart.setDataAxisSteps(10);//标签轴最大值chart.setLablesAxisMax(100);//设置标签轴颜色chart.getLablesAxisPaint().setColor((int)Color.rgb(68, 136, 187));//设置数据轴颜色chart.getDataAxisPaint().setColor((int)Color.rgb(68, 136, 187));//显示分隔色chart.isShowInnerLineInterval(false);//设置分隔色chart.setInnerLineIntervalColor((int)Color.rgb(239, 239, 239));//显示横向分隔网线chart.isShowInnerHorizontalLine(true);//显示竖向分隔网线chart.isShowInnerVerticalLine(true);//显示横向分隔网线粗细及颜色chart.setInnerHorizontalLineStyle(1,(int)Color.rgb(218, 218, 218));//显示竖向分隔网线粗细及颜色chart.setInnerVerticalLineStyle(1,(int)Color.rgb(218, 218, 218));//线条粗细chart.setLineStyle(5);//chart.setPointStyle(XTypes.PointType.Circle);//点上显示圆心chart.setLineDotRadius(8);//点上显示标签chart.isShowDotLabel(true);//设置标签轴标签 偏移量,旋转角度chart.setPaintStyle(XTypes.LineTextPaintType.LABLESAXIS_LABLES,10,-45f);

MAIL: xcl_168@aliyun.com

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


0 0
原创粉丝点击