use of org.xclcharts.chart.CustomLineData in project XCL-Charts by xcltapestry.
the class AreaChart02View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
// 轴数据源
// 标签轴
chart.setCategories(mLabels);
// 数据轴
chart.setDataSource(mDataset);
// 仅横向平移
chart.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
// 数据轴最大值
chart.getDataAxis().setAxisMax(100);
// 数据轴刻度间隔
chart.getDataAxis().setAxisSteps(10);
// 网格
chart.getPlotGrid().showHorizontalLines();
chart.getPlotGrid().showVerticalLines();
// 把顶轴和右轴隐藏
// chart.hideTopAxis();
// chart.hideRightAxis();
// 把轴线和刻度线给隐藏起来
chart.getDataAxis().hideAxisLine();
chart.getDataAxis().hideTickMarks();
chart.getCategoryAxis().hideAxisLine();
chart.getCategoryAxis().hideTickMarks();
// 标题
chart.setTitle("平滑区域图");
chart.addSubtitle("(XCL-Charts Demo)");
// 轴标题
chart.getAxisTitle().setLowerTitle("(年份)");
// 透明度
chart.setAreaAlpha(180);
// 显示图例
chart.getPlotLegend().show();
// 激活点击监听
chart.ActiveListenItemClick();
// 为了让触发更灵敏,可以扩大5px的点击监听范围
chart.extPointClickRange(5);
// 定义数据轴标签显示格式
chart.getDataAxis().setLabelFormatter(new IFormatterTextCallBack() {
@Override
public String textFormatter(String value) {
// TODO Auto-generated method stub
Double tmp = Double.parseDouble(value);
DecimalFormat df = new DecimalFormat("#0");
String label = df.format(tmp).toString();
return (label);
}
});
// 设定交叉点标签显示格式
chart.setItemLabelFormatter(new IFormatterDoubleCallBack() {
@Override
public String doubleFormatter(Double value) {
// TODO Auto-generated method stub
DecimalFormat df = new DecimalFormat("#0");
String label = df.format(value).toString();
return label;
}
});
// 扩大显示宽度
// chart.getPlotArea().extWidth(100f);
// chart.disablePanMode(); //test
CustomLineData line1 = new CustomLineData("标识线", 60d, Color.RED, 7);
line1.setCustomLineCap(XEnum.DotStyle.CROSS);
line1.setLabelHorizontalPostion(Align.CENTER);
line1.setLabelOffset(15);
line1.getLineLabelPaint().setColor(Color.RED);
mCustomLineDataset.add(line1);
chart.setCustomLines(mCustomLineDataset);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.chart.CustomLineData in project XCL-Charts by xcltapestry.
the class LineChart02View method chartDesireLines.
/**
* 期望线/分界线
*/
private void chartDesireLines() {
mCustomLineDataset.add(new CustomLineData("稍好", 1500d, Color.rgb(35, 172, 57), 5));
mCustomLineDataset.add(new CustomLineData("舒适", 3000d, Color.rgb(69, 181, 248), 5));
mCustomLineDataset.add(new CustomLineData("[个人均线]", calcAvg(), Color.rgb(251, 79, 128), 6));
}
use of org.xclcharts.chart.CustomLineData in project XCL-Charts by xcltapestry.
the class SplineChart04View method chartDesireLines.
private void chartDesireLines() {
CustomLineData s = new CustomLineData("GO", 15d, Color.rgb(54, 141, 238), 3);
s.hideLine();
s.getLineLabelPaint().setColor(Color.rgb(54, 141, 238));
s.getLineLabelPaint().setTextSize(27);
s.setLineStyle(XEnum.LineStyle.DASH);
s.setLabelOffset(5);
mCustomLineDataset.add(s);
CustomLineData s2 = new CustomLineData("C/C++", 18d, Color.rgb(255, 165, 132), 3);
s2.hideLine();
s2.getLineLabelPaint().setColor(Color.rgb(255, 165, 132));
s2.getLineLabelPaint().setTextSize(25);
s2.setLabelOffset(5);
mCustomLineDataset.add(s2);
CustomLineData s3 = new CustomLineData("Java", 16d, Color.rgb(77, 184, 73), 3);
s3.getLineLabelPaint().setColor(Color.rgb(77, 184, 73));
s3.getLineLabelPaint().setTextSize(25);
s3.hideLine();
s3.setLabelOffset(10);
mCustomLineDataset.add(s3);
}
use of org.xclcharts.chart.CustomLineData in project XCL-Charts by xcltapestry.
the class AreaChart03View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
chart.disableHighPrecision();
chart.disablePanMode();
// 轴数据源
// 标签轴
chart.setCategories(mLabels);
// 数据轴
chart.setDataSource(mDataset);
chart.setCrurveLineStyle(XEnum.CrurveLineStyle.BEELINE);
// 数据轴最大值
chart.getDataAxis().setAxisMax(100);
// 数据轴刻度间隔
chart.getDataAxis().setAxisSteps(10);
// 网格
chart.getPlotGrid().hideHorizontalLines();
chart.getPlotGrid().hideVerticalLines();
// 把顶轴和右轴隐藏
// chart.hideTopAxis();
// chart.hideRightAxis();
// 把轴线和刻度线给隐藏起来
chart.getDataAxis().hideAxisLine();
chart.getDataAxis().hideTickMarks();
chart.getCategoryAxis().hideAxisLine();
chart.getCategoryAxis().hideTickMarks();
// 标题
chart.setTitle("区域图(Area Chart)");
chart.addSubtitle("(XCL-Charts Demo)");
// 设定交叉点标签显示格式
chart.setItemLabelFormatter(new IFormatterDoubleCallBack() {
@Override
public String doubleFormatter(Double value) {
// TODO Auto-generated method stub
DecimalFormat df = new DecimalFormat("#0");
String label = df.format(value).toString();
return label;
}
});
// chart.getBackgroundPaint().setAlpha(254);
// 背景渐变
// chart.getPlotArea().setBackgroundColor(true, Color.rgb(163, 69, 213));
// chart.getPlotArea().setApplayGradient(true);
// chart.getPlotArea().setEndColor(Color.WHITE);
chart.getAreaFillPaint().setAlpha(254);
chart.setAreaAlpha(254);
chart.getDataAxis().hide();
chart.getCategoryAxis().hide();
CustomLineData line1 = new CustomLineData("30", mStdValue, Color.RED, 7);
line1.getLineLabelPaint().setColor(Color.RED);
line1.setLabelHorizontalPostion(Align.LEFT);
line1.setLineStyle(XEnum.LineStyle.DASH);
line1.setLabelOffset(chart.getDataAxis().getTickLabelMargin());
mCustomLineDataset.add(line1);
CustomLineData line2 = new CustomLineData("20", 20d, Color.RED, 7);
line2.setLabelHorizontalPostion(Align.LEFT);
line2.hideLine();
line2.setLabelOffset(chart.getDataAxis().getTickLabelMargin());
line2.getLineLabelPaint().setColor(Color.RED);
mCustomLineDataset.add(line2);
CustomLineData line3 = new CustomLineData("10", 10d, Color.RED, 7);
line3.setLabelHorizontalPostion(Align.LEFT);
line3.hideLine();
line3.getLineLabelPaint().setColor(Color.RED);
line3.setLabelOffset(chart.getDataAxis().getTickLabelMargin());
mCustomLineDataset.add(line3);
chart.setCustomLines(mCustomLineDataset);
chart.getPlotLegend().hide();
// chart.disablePanMode();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.chart.CustomLineData in project XCL-Charts by xcltapestry.
the class BarChart04View method chartDesireLines.
/**
* 期望线/分界线
*/
private void chartDesireLines() {
mCustomLineDataset.add(new CustomLineData("适中", 18.5d, Color.rgb(77, 184, 73), 3));
mCustomLineDataset.add(new CustomLineData("超重", 24d, Color.rgb(252, 210, 9), 4));
mCustomLineDataset.add(new CustomLineData("偏胖", 27.9d, Color.rgb(171, 42, 96), 5));
mCustomLineDataset.add(new CustomLineData("肥胖", 30d, Color.RED, 6));
}
Aggregations