Search in sources :

Example 6 with PieData

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

the class PieChart01View method triggerClick.

// 触发监听
private void triggerClick(float x, float y) {
    if (!chart.getListenItemClickStatus())
        return;
    ArcPosition record = chart.getPositionRecord(x, y);
    if (null == record)
        return;
    /*
		PieData pData = chartData.get(record.getDataID());		
		Toast.makeText(this.getContext(),								
				" key:" +  pData.getKey() +
				" Label:" + pData.getLabel() ,
				Toast.LENGTH_SHORT).show(); 
		*/
    // 用于处理点击时弹开,再点时弹回的效果
    PieData pData = chartData.get(record.getDataID());
    if (record.getDataID() == mSelectedID) {
        boolean bStatus = chartData.get(mSelectedID).getSelected();
        chartData.get(mSelectedID).setSelected(!bStatus);
    } else {
        if (mSelectedID >= 0)
            chartData.get(mSelectedID).setSelected(false);
        pData.setSelected(true);
    }
    mSelectedID = record.getDataID();
    this.refreshChart();
/*
		boolean isInvaldate = true;		
		for(int i=0;i < chartData.size();i++)
		{	
			PieData cData = chartData.get(i);
			if(i == record.getDataID())
			{
				if(cData.getSelected()) 
				{
					isInvaldate = false;
					break;
				}else{
					cData.setSelected(true);	
				}
			}else
				cData.setSelected(false);			
		}
		if(isInvaldate)this.invalidate();
		*/
}
Also used : ArcPosition(org.xclcharts.event.click.ArcPosition) PieData(org.xclcharts.chart.PieData)

Example 7 with PieData

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

the class PieChart3D01View method chartDataSet.

private void chartDataSet() {
    // 设置图表数据源
    // PieData(标签,百分比,在饼图中对应的颜色)
    chartData.add(new PieData("test", "PHP(15%)", 15, Color.rgb(1, 170, 255)));
    chartData.add(new PieData("Other", 10, Color.rgb(148, 42, 133), false));
    chartData.add(new PieData("Oracle", 40, Color.rgb(241, 62, 1)));
    chartData.add(new PieData("Java", 15, Color.rgb(242, 167, 69)));
    // 将此比例块突出显示
    chartData.add(new PieData("C++(20%)", 20, Color.rgb(164, 233, 0), true));
}
Also used : PieData(org.xclcharts.chart.PieData)

Example 8 with PieData

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

the class RoseChart01View method chartDataSet.

private void chartDataSet() {
    // 设置图表数据源
    // PieData(标签,百分比,在饼图中对应的颜色)
    roseData.add(new PieData("PostgreSQL", 40, Color.rgb(77, 83, 97)));
    roseData.add(new PieData("Sybase", 50, Color.rgb(148, 159, 181)));
    roseData.add(new PieData("DB2", 60, Color.rgb(253, 180, 90)));
    roseData.add(new PieData("国产及其它", 35, Color.rgb(52, 194, 188)));
    roseData.add(new PieData("SQL Server", 70, Color.rgb(39, 51, 72)));
    roseData.add(new PieData("DB2", 80, Color.rgb(255, 135, 195)));
    roseData.add(new PieData("Oracle", 90, Color.rgb(215, 124, 124)));
}
Also used : PieData(org.xclcharts.chart.PieData)

Example 9 with PieData

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

the class BarChart01View method chartPieDataSet.

private void chartPieDataSet() {
    // 演示用,不精准计算,生产环境应使用MathHelper相关类来时行计算
    // 随便弄的
    chartDataPie.clear();
    chartDataPie.add(new PieData("ORACLE", "27%", 27, colorORACLE));
    chartDataPie.add(new PieData("SQL Server", "8%", 8, colorMSSQL));
    chartDataPie.add(new PieData("MySQL", "42%", 42, colorMYSQL));
    chartDataPie.add(new PieData("其它", "23%", 23, colorOTHER));
}
Also used : PieData(org.xclcharts.chart.PieData)

Example 10 with PieData

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

the class PieChart02View method chartDataSet.

private void chartDataSet() {
    // 因为Java中Float和double的计算误差问题,所以建议
    // 用图库中的MathHelper.getInstance()来做运算,以保证总值为100%
    // 设置图表数据源
    PieData pieData = new PieData("芝麻", "芝麻:15%", 15, Color.rgb(77, 83, 97));
    pieData.setCustLabelStyle(XEnum.SliceLabelStyle.INSIDE, Color.WHITE);
    // pieData.setItemLabelRotateAngle(rotateAngle)
    chartData.add(pieData);
    chartData.add(new PieData("白糖", "白糖(5%)", 5, Color.rgb(75, 132, 1)));
    // 将此比例块突出显示
    PieData pd = new PieData("花生", "花生:35%", 35, Color.rgb(180, 205, 230));
    pd.setItemLabelRotateAngle(45.f);
    chartData.add(pd);
    PieData pdOther = new PieData("其它", "其它(炒米,炒花生之类)", 15, Color.rgb(148, 159, 181));
    pdOther.setCustLabelStyle(XEnum.SliceLabelStyle.INSIDE, Color.BLACK);
    chartData.add(pdOther);
    PieData pdTea = new PieData("茶叶", "茶叶(30%)", 30, Color.rgb(253, 180, 90), true);
    pdTea.setCustLabelStyle(XEnum.SliceLabelStyle.OUTSIDE, Color.rgb(253, 180, 90));
    chartData.add(pdTea);
}
Also used : PieData(org.xclcharts.chart.PieData)

Aggregations

PieData (org.xclcharts.chart.PieData)23 ArcPosition (org.xclcharts.event.click.ArcPosition)5 Paint (android.graphics.Paint)3 PointF (android.graphics.PointF)1 ArrayList (java.util.ArrayList)1 PlotDot (org.xclcharts.renderer.line.PlotDot)1 PlotLegend (org.xclcharts.renderer.plot.PlotLegend)1