Search in sources :

Example 11 with SplineData

use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.

the class SplineChart01View method chartDataSet.

private void chartDataSet() {
    /*
		//线1的数据集
		List<PointD> linePoint1 = new ArrayList<PointD>();
		linePoint1.add(new PointD(5d, 8d));
		
		linePoint1.add(new PointD(12d, 12d));
		linePoint1.add(new PointD(25d, 15d));
		linePoint1.add(new PointD(30d, 30d));
		linePoint1.add(new PointD(45d, 25d));
		
		linePoint1.add(new PointD(55d, 33d));
		linePoint1.add(new PointD(62d, 45d));
		SplineData dataSeries1 = new SplineData("青菜萝卜够吃",linePoint1,
				Color.rgb(54, 141, 238) );	
		//把线弄细点
		dataSeries1.getLinePaint().setStrokeWidth(2);
		
		//线2的数据集
		List<PointD> linePoint2 = new ArrayList<PointD>();
		linePoint2.add(new PointD(40d, 50d));
		linePoint2.add(new PointD(55d, 55d));
		linePoint2.add(new PointD(60d, 65d));
		linePoint2.add(new PointD(65d, 85d));		
		
		linePoint2.add(new PointD(72d, 70d));	
		linePoint2.add(new PointD(85d, 68d));	
		SplineData dataSeries2 = new SplineData("饭管够",linePoint2,
				Color.rgb(255, 165, 132) );
		
				
		dataSeries2.setLabelVisible(true);		
		dataSeries2.setDotStyle(XEnum.DotStyle.RECT);				
		dataSeries2.getDotLabelPaint().setColor(Color.RED);	
			
		//设定数据源		
		chartData.add(dataSeries1);				
		chartData.add(dataSeries2);	
		*/
    // 线1的数据集
    List<PointD> linePoint1 = new ArrayList<PointD>();
    linePoint1.add(new PointD(2d, 8d));
    linePoint1.add(new PointD(5d, 8d));
    linePoint1.add(new PointD(10d, 12d));
    // linePoint1.add(new PointD(25d, 15d));
    // linePoint1.add(new PointD(30d, 30d));
    // linePoint1.add(new PointD(45d, 25d));
    // linePoint1.add(new PointD(55d, 33d));
    // linePoint1.add(new PointD(62d, 45d));
    SplineData dataSeries1 = new SplineData("青菜萝卜够吃", linePoint1, Color.rgb(54, 141, 238));
    // 把线弄细点
    dataSeries1.getLinePaint().setStrokeWidth(2);
    // 线2的数据集
    List<PointD> linePoint2 = new ArrayList<PointD>();
    linePoint2.add(new PointD(1d, 50d));
    linePoint2.add(new PointD(2d, 52d));
    linePoint2.add(new PointD(3d, 53d));
    linePoint2.add(new PointD(8d, 55d));
    SplineData dataSeries2 = new SplineData("饭管够", linePoint2, Color.rgb(255, 165, 132));
    dataSeries2.setLabelVisible(true);
    dataSeries2.setDotStyle(XEnum.DotStyle.RECT);
    dataSeries2.getDotLabelPaint().setColor(Color.RED);
    // 设置round风格的标签
    // dataSeries2.getLabelOptions().showBackground();
    dataSeries2.getLabelOptions().getBox().getBackgroundPaint().setColor(Color.GREEN);
    dataSeries2.getLabelOptions().getBox().setRoundRadius(8);
    dataSeries2.getLabelOptions().setLabelBoxStyle(XEnum.LabelBoxStyle.CAPROUNDRECT);
    chartData.add(dataSeries1);
    chartData.add(dataSeries2);
}
Also used : PointD(org.xclcharts.chart.PointD) ArrayList(java.util.ArrayList) SplineData(org.xclcharts.chart.SplineData)

Aggregations

PointD (org.xclcharts.chart.PointD)11 SplineData (org.xclcharts.chart.SplineData)11 ArrayList (java.util.ArrayList)7 Iterator (java.util.Iterator)4 PointPosition (org.xclcharts.event.click.PointPosition)4 Paint (android.graphics.Paint)3 AnchorDataPoint (org.xclcharts.renderer.info.AnchorDataPoint)2