use of org.xclcharts.common.IFormatterTextCallBack in project XCL-Charts by xcltapestry.
the class BarChart01View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
// 数据源
chart.setDataSource(chartData);
chart.setCategories(chartLabels);
// 轴标题
chart.getAxisTitle().setLeftTitle("数据库");
chart.getAxisTitle().setLowerTitle("分布位置");
// 数据轴
chart.getDataAxis().setAxisMax(100);
chart.getDataAxis().setAxisMin(0);
chart.getDataAxis().setAxisSteps(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.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().setBarInnerMargin(0d);
// 轴颜色
chart.getDataAxis().getAxisPaint().setColor(colorTitalAxes);
chart.getCategoryAxis().getAxisPaint().setColor(colorTitalAxes);
chart.getDataAxis().getTickMarksPaint().setColor(colorTitalAxes);
chart.getCategoryAxis().getTickMarksPaint().setColor(colorTitalAxes);
chart.getDataAxis().getTickLabelPaint().setColor(colorTitalAxes);
chart.getCategoryAxis().getTickLabelPaint().setColor(colorTitalAxes);
chart.getAxisTitle().getLeftTitlePaint().setColor(colorTitalAxes);
chart.getAxisTitle().getLowerTitlePaint().setColor(colorTitalAxes);
chart.getBar().getItemLabelPaint().setColor(Color.rgb(246, 133, 39));
chart.getBar().getItemLabelPaint().setTextSize(15);
// 指隔多少个轴刻度(即细刻度)后为主刻度
chart.getDataAxis().setDetailModeSteps(5);
// 显示十字交叉线
chart.showDyLine();
DyLine dyl = chart.getDyLine();
if (null != dyl) {
dyl.setDyLineStyle(XEnum.DyLineStyle.Horizontal);
dyl.setLineDrawStyle(XEnum.LineStyle.DASH);
}
// 数据轴居中显示
// chart.setDataAxisLocation(XEnum.AxisLocation.VERTICAL_CENTER);
// 忽略Java的float计算误差,提高性能
// chart.disableHighPrecision();
// 柱形和标签居中方式
// chart.setBarCenterStyle(XEnum.BarCenterStyle.TICKMARKS);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, "chartRender():" + e.toString());
}
}
use of org.xclcharts.common.IFormatterTextCallBack in project XCL-Charts by xcltapestry.
the class BarChart05View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(DensityUtil.dip2px(getContext(), 35), ltrb[1], ltrb[2], ltrb[3]);
// 标题
chart.setTitle("小小熊 - 期末考试成绩");
chart.addSubtitle("(XCL-Charts Demo)");
// 数据源
// chart.setDataSource(chartData);
chart.setCategories(chartLabels);
chart.setCustomLines(mCustomLineDataset);
// 图例
chart.getAxisTitle().setLeftTitle("科目");
chart.getAxisTitle().setLowerTitle("分数");
// 数据轴
chart.getDataAxis().setAxisMax(110);
chart.getDataAxis().setAxisMin(0);
chart.getDataAxis().setAxisSteps(5);
// 指隔多少个轴刻度(即细刻度)后为主刻度
chart.getDataAxis().setDetailModeSteps(5);
// 背景网格
// chart.getPlotGrid().showHorizontalLines();
// 横向显示柱形,横向显示效果
chart.setChartDirection(XEnum.Direction.HORIZONTAL);
// chart.getPlotGrid().setVerticalLinesVisible(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.getBar().setItemLabelVisible(true);
chart.getBar().getItemLabelPaint().setTextSize(18);
// 设定格式
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.disablePanMode();
// 竖向移动
// chart.setPlotPanMode(XEnum.PanMode.VERTICAL);
// 柱形设为outline风格
chart.getBar().setBarStyle(XEnum.BarStyle.TRIANGLE);
// 轴
chart.getCategoryAxis().setHorizontalTickAlign(Align.RIGHT);
chart.getCategoryAxis().getTickLabelPaint().setTextAlign(Align.LEFT);
chart.getCategoryAxis().getTickLabelPaint().setColor(Color.rgb(199, 88, 122));
// chart.getDataAxis().setHorizontalTickAlign(Align.CENTER);
// chart.getDataAxis().getTickLabelPaint().setTextAlign(Align.CENTER);
// chart.getDataAxis().setVerticalTickPosition(XEnum.VerticalAlign.BOTTOM);
// 留出显示箭头的空间
chart.getClipExt().setExtTop(10.f);
chart.getClipExt().setExtRight(100.f);
chart.getDataAxis().setAxisLineStyle(XEnum.AxisLineStyle.CAP);
chart.getCategoryAxis().setAxisLineStyle(XEnum.AxisLineStyle.CAP);
// 修改轴标签字体大小
chart.getDataAxis().getTickLabelPaint().setTextSize(26);
chart.getCategoryAxis().getTickLabelPaint().setTextSize(36);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.xclcharts.common.IFormatterTextCallBack in project XCL-Charts by xcltapestry.
the class BarChart3D02View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(DensityUtil.dip2px(getContext(), 40), ltrb[1], ltrb[2], ltrb[3]);
// 指定显示为横向3D柱形
chart.setChartDirection(XEnum.Direction.HORIZONTAL);
// 数据源
chart.setDataSource(chartData);
chart.setCategories(chartLabels);
// 坐标系
chart.getDataAxis().setAxisMax(50);
chart.getDataAxis().setAxisMin(10);
chart.getDataAxis().setAxisSteps(10);
chart.getCategoryAxis().setTickLabelRotateAngle(-45f);
// 标题
chart.setTitle("本月原料进货情况");
chart.addSubtitle("(XCL-Charts Demo)");
// 轴标题
chart.getAxisTitle().setLeftTitle("原料");
chart.getAxisTitle().setLowerTitle("进货量");
// 背景网格
chart.getPlotGrid().showHorizontalLines();
chart.getPlotGrid().showVerticalLines();
chart.getPlotGrid().showEvenRowBgColor();
// 定义数据轴标签显示格式
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.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().setTextSize(22);
// 定义基座颜色
chart.setAxis3DBaseColor(Color.rgb(132, 162, 197));
// 激活点击监听
chart.ActiveListenItemClick();
// 仅能纵向移动
chart.setPlotPanMode(XEnum.PanMode.VERTICAL);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.common.IFormatterTextCallBack in project XCL-Charts by xcltapestry.
the class AreaChart01View 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.setCrurveLineStyle(XEnum.CrurveLineStyle.BEELINE);
// 数据轴最大值
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("区域图(Area Chart)");
chart.addSubtitle("(XCL-Charts Demo)");
//轴标题
chart.getAxisTitle().setLowerAxisTitle("(年份)");
*/
// 透明度
chart.setAreaAlpha(200);
/*
//显示图例
chart.getPlotLegend().showLegend();
//激活点击监听
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.disablePanMode();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e(TAG, e.toString());
}
}
Aggregations