use of org.xclcharts.common.IFormatterDoubleCallBack in project XCL-Charts by xcltapestry.
the class BarChart03View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
// 标题
chart.setTitle("小小熊 - 期末考试成绩");
chart.addSubtitle("(XCL-Charts Demo)");
// 数据源
// chart.setDataSource(chartData);
chart.setCategories(chartLabels);
chart.setCustomLines(mCustomLineDataset);
// 图例
chart.getAxisTitle().setTitleStyle(XEnum.AxisTitleStyle.ENDPOINT);
chart.getAxisTitle().setLeftTitle("分数");
chart.getAxisTitle().setLowerTitle("科目");
chart.getAxisTitle().setCrossPointTitle("(一班)");
// 数据轴
chart.getDataAxis().setAxisMax(105);
chart.getDataAxis().setAxisMin(0);
chart.getDataAxis().setAxisSteps(5);
// 指隔多少个轴刻度(即细刻度)后为主刻度
chart.getDataAxis().setDetailModeSteps(5);
// 背景网格
chart.getPlotGrid().showHorizontalLines();
// 定义数据轴标签显示格式
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.getBar().setItemLabelVisible(true);
chart.getBar().setBarStyle(XEnum.BarStyle.OUTLINE);
chart.getBar().setBorderWidth(5);
chart.getBar().setOutlineAlpha(150);
// chart.getBar().setBarRoundRadius(5);
// chart.getBar().setBarStyle(XEnum.BarStyle.ROUNDBAR);
// chart.setPlotPanMode(XEnum.PanMode.FREE);
chart.disablePanMode();
// 设定格式
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;
}
});
// 隐藏Key
chart.getPlotLegend().hide();
chart.getClipExt().setExtTop(150.f);
// 柱形和标签居中方式
chart.setBarCenterStyle(XEnum.BarCenterStyle.TICKMARKS);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.xclcharts.common.IFormatterDoubleCallBack in project XCL-Charts by xcltapestry.
the class MultiBarChart01View method chartRender2.
private void chartRender2() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart2.setPadding(mOffset, ltrb[1], ltrb[2], ltrb[3]);
// 显示边框
// chart2.showRoundBorder();
// chart.setApplyBackgroundColor(true);
chart2.setBackgroundColor(Color.rgb(19, 163, 224));
chart2.showRoundBorder();
chart2.getBar().setBarStyle(XEnum.BarStyle.FILL);
// 标题
chart2.setTitle("负债率标准: 40%~60%");
chart2.addSubtitle("(XCL-Charts Demo)");
chart2.getPlotTitle().getTitlePaint().setColor(axisColor);
chart2.getPlotTitle().getSubtitlePaint().setColor(axisColor);
// 数据源
chart2.setDataSource(chartData2);
chart2.setCategories(chartLabels);
// 轴标题
chart2.getAxisTitle().setLeftTitle("金额");
chart2.getAxisTitle().setLowerTitle("资产负债率");
// 数据轴
chart2.getDataAxis().setAxisMax(2500);
chart2.getDataAxis().setAxisMin(0);
chart2.getDataAxis().setAxisSteps(500);
// 定义数据轴标签显示格式
chart2.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);
}
});
// 在柱形顶部显示值
chart2.getBar().setItemLabelVisible(true);
// 设定格式
chart2.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;
}
});
// 让柱子间没空白
chart2.getBar().setBarInnerMargin(0.f);
// 轴颜色
chart2.getDataAxis().getAxisPaint().setColor(axisColor);
chart2.getCategoryAxis().getAxisPaint().setColor(axisColor);
chart2.getDataAxis().getTickMarksPaint().setColor(axisColor);
chart2.getCategoryAxis().getTickMarksPaint().setColor(axisColor);
chart2.getDataAxis().getTickLabelPaint().setColor(axisColor);
chart2.getCategoryAxis().getTickLabelPaint().setColor(axisColor);
chart2.getAxisTitle().getLeftTitlePaint().setColor(axisColor);
chart2.getAxisTitle().getLowerTitlePaint().setColor(axisColor);
// 隐藏图例
chart2.getPlotLegend().hide();
// chart2.showRoundBorder();
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.common.IFormatterDoubleCallBack in project XCL-Charts by xcltapestry.
the class RadarChart02View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值
int[] ltrb = getPieDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
chart.setTitle("圆形雷达图");
chart.addSubtitle("(XCL-Charts Demo)");
// 设定数据源
chart.setCategories(labels);
chart.setDataSource(chartData);
// 圆形雷达图
chart.setChartType(XEnum.RadarChartType.ROUND);
// 点击事件处理
chart.ActiveListenItemClick();
chart.extPointClickRange(30);
// 数据轴最大值
chart.getDataAxis().setAxisMax(100);
// 数据轴刻度间隔
chart.getDataAxis().setAxisSteps(10);
// 主轴标签偏移50,以便留出空间用于显示点和标签
chart.getDataAxis().setTickLabelMargin(20);
// Color.parseColor("#BFE154"));
chart.getLinePaint().setColor(Color.rgb(133, 194, 2));
chart.getLabelPaint().setColor(Color.parseColor("#E94D43"));
chart.getLabelPaint().setFakeBoldText(true);
// 定义数据轴标签显示格式
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.setDotLabelFormatter(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.enablePanMode();
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.common.IFormatterDoubleCallBack in project XCL-Charts by xcltapestry.
the class StackBarChart01View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], DensityUtil.dip2px(getContext(), 55));
// 显示边框
chart.showRoundBorder();
chart.setChartDirection(XEnum.Direction.VERTICAL);
// 数据源
chart.setCategories(chartLabels);
chart.setDataSource(BarDataSet);
// 坐标系
chart.getDataAxis().setAxisMax(1024);
chart.getDataAxis().setAxisMin(0);
chart.getDataAxis().setAxisSteps(64);
// 指定数据轴标签旋转-45度显示
chart.getCategoryAxis().setTickLabelRotateAngle(-45f);
Paint labelPaint = chart.getCategoryAxis().getTickLabelPaint();
labelPaint.setTextAlign(Align.RIGHT);
labelPaint.setColor(Color.rgb(0, 75, 106));
// 标题
chart.setTitle("文件服务器空间使用情况");
chart.addSubtitle("(XCL-Charts Demo)");
chart.setTitleAlign(XEnum.HorizontalAlign.CENTER);
chart.setTitleVerticalAlign(XEnum.VerticalAlign.MIDDLE);
// 轴标题
chart.getAxisTitle().setLeftTitle("单位(TB)");
// 背景网格
chart.getPlotGrid().showEvenRowBgColor();
chart.getPlotGrid().showOddRowBgColor();
// 定义数据轴标签显示格式
chart.getDataAxis().setLabelFormatter(new IFormatterTextCallBack() {
@Override
public String textFormatter(String value) {
// TODO Auto-generated method stub
DecimalFormat df = new DecimalFormat("#0");
Double tmp = Double.parseDouble(value);
String label = df.format(tmp).toString();
return label;
}
});
// 定义标签轴标签显示格式
chart.getCategoryAxis().setLabelFormatter(new IFormatterTextCallBack() {
@Override
public String textFormatter(String value) {
// TODO Auto-generated method stub
String label = "IP-[" + value + "]";
return label;
}
});
// 定义柱形上标签显示格式
chart.getBar().setItemLabelVisible(true);
chart.setItemLabelFormatter(new IFormatterDoubleCallBack() {
@Override
public String doubleFormatter(Double value) {
// TODO Auto-generated method stub
DecimalFormat df = new DecimalFormat("#0.00");
String label = df.format(value).toString();
return label;
}
});
// 定义柱形上标签显示颜色
chart.getBar().getItemLabelPaint().setColor(Color.rgb(77, 184, 73));
chart.getBar().getItemLabelPaint().setTypeface(Typeface.DEFAULT_BOLD);
// 激活点击监听
chart.ActiveListenItemClick();
chart.showClikedFocus();
chart.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
chart.setBarCenterStyle(XEnum.BarCenterStyle.TICKMARKS);
// chart.disablePanMode();
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.common.IFormatterDoubleCallBack in project XCL-Charts by xcltapestry.
the class RangeBarChart01View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], DensityUtil.dip2px(getContext(), 55));
// 显示边框
// chart.showRoundBorder();
// 数据源
chart.setCategories(chartLabels);
chart.setDataSource(BarDataSet);
// 坐标系
chart.getDataAxis().setAxisMax(1024);
chart.getDataAxis().setAxisMin(0);
chart.getDataAxis().setAxisSteps(64);
chart.getDataAxis().setDetailModeSteps(4);
chart.setCategoryAxisMax(100);
chart.setCategoryAxisMin(0);
// 指定数据轴标签旋转-45度显示
chart.getCategoryAxis().setTickLabelRotateAngle(-45f);
chart.getDataAxis().getAxisPaint().setColor(Color.rgb(79, 200, 100));
chart.getCategoryAxis().getAxisPaint().setColor(Color.rgb(79, 200, 100));
chart.getDataAxis().getTickMarksPaint().setColor(Color.rgb(79, 200, 100));
chart.getCategoryAxis().getTickMarksPaint().setColor(Color.rgb(79, 200, 100));
chart.getPlotTitle().getTitlePaint().setColor(Color.rgb(79, 200, 100));
chart.getPlotTitle().getSubtitlePaint().setColor(Color.rgb(79, 200, 100));
chart.getDataAxis().getTickLabelPaint().setColor(Color.rgb(79, 200, 100));
chart.getCategoryAxis().getTickLabelPaint().setColor(Color.rgb(79, 200, 100));
// 标题
chart.setTitle("范围条形图");
chart.addSubtitle("(XCL-Charts Demo)");
chart.setTitleAlign(XEnum.HorizontalAlign.CENTER);
chart.setTitleVerticalAlign(XEnum.VerticalAlign.MIDDLE);
// 背景网格
chart.getPlotGrid().showEvenRowBgColor();
chart.getPlotGrid().showOddRowBgColor();
// 定义数据轴标签显示格式
chart.getDataAxis().setLabelFormatter(new IFormatterTextCallBack() {
@Override
public String textFormatter(String value) {
// TODO Auto-generated method stub
DecimalFormat df = new DecimalFormat("#0");
Double tmp = Double.parseDouble(value);
String label = df.format(tmp).toString();
return label;
}
});
// 定义标签轴标签显示格式
chart.getCategoryAxis().setLabelFormatter(new IFormatterTextCallBack() {
@Override
public String textFormatter(String value) {
// TODO Auto-generated method stub
String label = "***" + value + "***";
return label;
}
});
// 定义柱形上标签显示格式
chart.getBar().setItemLabelVisible(true);
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.getBar().getItemLabelPaint().setColor(Color.rgb(77, 184, 73));
chart.getBar().getItemLabelPaint().setTypeface(Typeface.DEFAULT_BOLD);
// 设置柱形颜色
chart.getBar().getBarPaint().setColor(Color.rgb(79, 200, 100));
// 设置图例
chart.setKey("图例");
// 激活点击监听
chart.ActiveListenItemClick();
chart.showClikedFocus();
// chart.enablePanMode();
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
Aggregations