use of org.xclcharts.common.IFormatterDoubleCallBack in project XCL-Charts by xcltapestry.
the class LineChart02View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(DensityUtil.dip2px(getContext(), 45), ltrb[1], ltrb[2], ltrb[3]);
// 设定数据源
chart.setCategories(labels);
// chart.setDataSource(chartData);
// chart.setCustomLines(mCustomLineDataset);
// 数据轴最大值
chart.getDataAxis().setAxisMax(3500);
// 数据轴刻度间隔
chart.getDataAxis().setAxisSteps(100);
// 指隔多少个轴刻度(即细刻度)后为主刻度
chart.getDataAxis().setDetailModeSteps(5);
// 背景网格
chart.getPlotGrid().showHorizontalLines();
// 标题
chart.setTitle("个人历年租房情况一览");
chart.addSubtitle("(XCL-Charts Demo)");
// 隐藏顶轴和右边轴
// chart.hideTopAxis();
// chart.hideRightAxis();
// 设置轴风格
// chart.getDataAxis().setTickMarksVisible(false);
chart.getDataAxis().getAxisPaint().setStrokeWidth(2);
chart.getDataAxis().getTickMarksPaint().setStrokeWidth(2);
chart.getDataAxis().showAxisLabels();
chart.getCategoryAxis().getAxisPaint().setStrokeWidth(2);
chart.getCategoryAxis().hideTickMarks();
// 定义数据轴标签显示格式
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.setItemLabelFormatter(callBack)
// 允许线与轴交叉时,线会断开
chart.setLineAxisIntersectVisible(false);
// chart.setDataSource(chartData);
// 动态线
chart.showDyLine();
// 不封闭
chart.setAxesClosed(false);
// 扩展绘图区右边分割的范围,让定制线的说明文字能显示出来
chart.getClipExt().setExtRight(150.f);
// 设置标签交错换行显示
chart.getCategoryAxis().setLabelLineFeed(XEnum.LabelLineFeed.ODD_EVEN);
// 仅能横向移动
chart.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
// chart.getDataAxis().hide();
} 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 MultiAxisChart02View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
chart.setChartDirection(XEnum.Direction.VERTICAL);
// 标题
chart.setTitle("Virtual vs Native Oracle RAC Performance");
chart.addSubtitle("(XCL-Charts Demo)");
// 因为太长缩小标题字体
// chart.getPlotTitle().getChartTitlePaint().setTextSize(20);
// 图例
chart.getAxisTitle().setLeftTitle("Orders Per Minute (OPM)");
chart.getAxisTitle().setRightTitle("Average Response Time (RT)");
// 标签轴
chart.setCategories(chartLabels);
// 数据轴
chart.setDataSource(chartData);
chart.getDataAxis().setAxisMax(90000);
chart.getDataAxis().setAxisSteps(10000);
// 定制数据轴上的标签格式
chart.getDataAxis().setLabelFormatter(new IFormatterTextCallBack() {
@Override
public String textFormatter(String value) {
// TODO Auto-generated method stub
double label = Double.parseDouble(value);
DecimalFormat df = new DecimalFormat("#0");
return df.format(label).toString();
}
});
// 定制标签轴标签的标签格式
CategoryAxis categoryAxis = chart.getCategoryAxis();
categoryAxis.setTickLabelRotateAngle(-15f);
categoryAxis.getTickLabelPaint().setTextSize(15);
categoryAxis.getTickLabelPaint().setTextAlign(Align.CENTER);
categoryAxis.setLabelFormatter(new IFormatterTextCallBack() {
@Override
public String textFormatter(String value) {
// String tmp = "c-["+value+"]";
return value;
}
});
// 定制柱形顶上的标签格式
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");
DecimalFormat df = new DecimalFormat("#0");
return df.format(value).toString();
}
});
// 网格背景
chart.getPlotGrid().showHorizontalLines();
chart.getPlotGrid().showEvenRowBgColor();
chart.getPlotGrid().showOddRowBgColor();
// 隐藏Key值
chart.getPlotLegend().hide();
chart.setBarCenterStyle(XEnum.BarCenterStyle.SPACE);
} 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 BarChart12View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3] + DensityUtil.dip2px(this.getContext(), 30));
// 标题
chart.setTitle("身份认证方案");
chart.addSubtitle("(XCL-Charts Demo)");
// 数据源
chart.setCategories(chartLabels);
chart.setDataSource(chartData);
// 数据轴
chart.getDataAxis().setAxisMax(105);
chart.getDataAxis().setAxisMin(0);
chart.getDataAxis().setAxisSteps(5);
// 指隔多少个轴刻度(即细刻度)后为主刻度
chart.getDataAxis().setDetailModeSteps(5);
// 背景网格
chart.getPlotGrid().hideHorizontalLines();
chart.getPlotGrid().hideVerticalLines();
chart.getPlotGrid().hideEvenRowBgColor();
chart.getPlotGrid().hideOddRowBgColor();
// 定义数据轴标签显示格式
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().setItemLabelStyle(XEnum.ItemLabelStyle.INNER);
chart.getBar().getItemLabelPaint().setColor(Color.rgb(162, 53, 46));
chart.getBar().getItemLabelPaint().setTextSize(20);
chart.getBar().setBarRoundRadius(15);
chart.getBar().setBarStyle(XEnum.BarStyle.ROUNDBAR);
chart.getCategoryAxis().hideAxisLine();
chart.getCategoryAxis().hideTickMarks();
chart.getCategoryAxis().hideAxisLabels();
chart.getBar().setBarTickSpacePercent(0.9f);
chart.getDataAxis().hide();
chart.disablePanMode();
chart.disableHighPrecision();
// 设定格式
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 RadarChart01View 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.ActiveListenItemClick();
chart.extPointClickRange(50);
chart.showClikedFocus();
// 数据轴最大值
chart.getDataAxis().setAxisMax(50);
// 数据轴刻度间隔
chart.getDataAxis().setAxisSteps(10);
// 主轴标签偏移50,以便留出空间用于显示点和标签
chart.getDataAxis().setTickLabelMargin(50);
// 定义数据轴标签显示格式
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;
}
});
} 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 SpinnerBarChart01View method chartRender.
public void chartRender() {
try {
initChart(mChartStyle);
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
mChart.setPadding(DensityUtil.dip2px(getContext(), 50), ltrb[1], ltrb[2], ltrb[3]);
// 数据源
mChart.setDataSource(chartData);
mChart.setCategories(chartLabels);
// 数据轴
mChart.getDataAxis().setAxisMax(100);
mChart.getDataAxis().setAxisMin(0);
mChart.getDataAxis().setAxisSteps(20);
// 定义数据轴标签显示格式
mChart.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 + "%";
}
});
// 定义柱形上标签显示格式
mChart.getBar().setItemLabelVisible(true);
mChart.getBar().getItemLabelPaint().setColor(Color.rgb(72, 61, 139));
mChart.getBar().getItemLabelPaint().setFakeBoldText(true);
mChart.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 + "%";
}
});
mChart.DeactiveListenItemClick();
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
Aggregations