use of org.xclcharts.renderer.plot.PlotLegend in project XCL-Charts by xcltapestry.
the class DountChart01View method chartRender.
private void chartRender() {
try {
//设置绘图区默认缩进px值
int[] ltrb = getPieDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1] + 100, ltrb[2], ltrb[3]);
//数据源
chart.setDataSource(lPieData);
chart.setCenterText("新品太多!!!");
chart.getCenterTextPaint().setColor(Color.rgb(242, 167, 69));
//标签显示(隐藏,显示在中间,显示在扇区外面)
chart.setLabelStyle(XEnum.SliceLabelStyle.INSIDE);
chart.getLabelPaint().setColor(Color.WHITE);
//标题
chart.setTitle("环形图");
chart.addSubtitle("(XCL-Charts Demo)");
//显示key
//chart.getPlotLegend().show();
//显示图例
PlotLegend legend = chart.getPlotLegend();
legend.show();
legend.setType(XEnum.LegendType.ROW);
legend.setHorizontalAlign(XEnum.HorizontalAlign.CENTER);
legend.setVerticalAlign(XEnum.VerticalAlign.BOTTOM);
legend.showBox();
legend.getBox().setBorderRectType(XEnum.RectType.RECT);
//图背景色
chart.setApplyBackgroundColor(true);
chart.setBackgroundColor(Color.rgb(19, 163, 224));
//内环背景色
chart.getInnerPaint().setColor(Color.rgb(19, 163, 224));
//显示边框线,并设置其颜色
chart.getArcBorderPaint().setColor(Color.YELLOW);
//可用这个修改环所占比例
//chart.setInnerRadius(0.6f);
//chart.setInitialAngle(90.f);
//设置附加信息
addAttrInfo();
//保存标签位置
chart.saveLabelsPosition(XEnum.LabelSaveType.ALL);
//激活点击监听
chart.ActiveListenItemClick();
chart.showClikedFocus();
chart.setInnerRadius(0.6f);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.renderer.plot.PlotLegend in project XCL-Charts by xcltapestry.
the class PieChart01View method chartRender.
private void chartRender() {
try {
//设置绘图区默认缩进px值
int[] ltrb = getPieDefaultSpadding();
float right = DensityUtil.dip2px(getContext(), 100);
chart.setPadding(ltrb[0], ltrb[1], right, ltrb[3]);
//设置起始偏移角度(即第一个扇区从哪个角度开始绘制)
//chart.setInitialAngle(90);
//标签显示(隐藏,显示在中间,显示在扇区外面)
chart.setLabelStyle(XEnum.SliceLabelStyle.INSIDE);
chart.getLabelPaint().setColor(Color.WHITE);
//标题
chart.setTitle("饼图-Pie Chart");
chart.addSubtitle("(XCL-Charts Demo)");
chart.setTitleVerticalAlign(XEnum.VerticalAlign.BOTTOM);
//chart.setDataSource(chartData);
//激活点击监听
chart.ActiveListenItemClick();
chart.showClikedFocus();
//设置允许的平移模式
//chart.enablePanMode();
//chart.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
//显示图例
PlotLegend legend = chart.getPlotLegend();
legend.show();
legend.setType(XEnum.LegendType.COLUMN);
legend.setHorizontalAlign(XEnum.HorizontalAlign.RIGHT);
legend.setVerticalAlign(XEnum.VerticalAlign.MIDDLE);
legend.showBox();
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.renderer.plot.PlotLegend in project XCL-Charts by xcltapestry.
the class PieChart02View method chartAnimation.
private void chartAnimation() {
try {
float sum = 0.0f;
int count = chartData.size();
for (int i = 0; i < count; i++) {
Thread.sleep(150);
ArrayList<PieData> animationData = new ArrayList<PieData>();
sum = 0.0f;
for (int j = 0; j <= i; j++) {
animationData.add(chartData.get(j));
sum = (float) MathHelper.getInstance().add(sum, chartData.get(j).getPercentage());
}
animationData.add(new PieData("", "", MathHelper.getInstance().sub(100.0f, sum), Color.argb(1, 0, 0, 0)));
chart.setDataSource(animationData);
//激活点击监听
if (count - 1 == i) {
//chart.ActiveListenItemClick();
//显示边框线,并设置其颜色
//chart.getArcBorderPaint().setColor(Color.YELLOW);
//chart.getArcBorderPaint().setStrokeWidth(3);
//激活点击监听
chart.ActiveListenItemClick();
chart.showClikedFocus();
chart.disablePanMode();
//显示图例
PlotLegend legend = chart.getPlotLegend();
legend.show();
legend.setHorizontalAlign(XEnum.HorizontalAlign.CENTER);
legend.setVerticalAlign(XEnum.VerticalAlign.BOTTOM);
legend.showBox();
}
postInvalidate();
}
} catch (Exception e) {
Thread.currentThread().interrupt();
}
}
Aggregations