use of org.xclcharts.common.IFormatterTextCallBack 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.IFormatterTextCallBack 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.IFormatterTextCallBack in project XCL-Charts by xcltapestry.
the class BubbleChart01View method chartRender.
private void chartRender() {
try {
// 设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int[] ltrb = getBarLnDefaultSpadding();
chart.setPadding(15, ltrb[1], 15, ltrb[3]);
// 显示边框
chart.showRoundBorder();
// 数据源
chart.setCategories(labels);
chart.setDataSource(chartData);
// 坐标系
// 数据轴最大值
chart.getDataAxis().setAxisMax(100);
// chart.getDataAxis().setAxisMin(0);
// 数据轴刻度间隔
chart.getDataAxis().setAxisSteps(10);
// 标签轴最大值
chart.setCategoryAxisMax(100);
// 标签轴最小值
chart.setCategoryAxisMin(0);
// 指定气泡半径的最大大小
chart.setBubbleMaxSize(200);
// 指定气泡半径的最小大小
chart.setBubbleMinSize(10);
// 指定最大气泡大小的实际数据值
chart.setBubbleScaleMax(100);
// 指定最小气泡大小的实际数据值
chart.setBubbleScaleMin(0);
// 设置图的背景色
// chart.setBackgroupColor(true,Color.BLACK);
// 设置绘图区的背景色
// chart.getPlotArea().setBackgroupColor(true, Color.WHITE);
// chart.getCategoryAxis().setVerticalTickPosition(XEnum.VerticalAlign.TOP);
chart.getCategoryAxis().hideTickMarks();
chart.getDataAxis().setHorizontalTickAlign(Align.RIGHT);
chart.getDataAxis().getTickLabelPaint().setTextAlign(Align.LEFT);
chart.getDataAxis().getAxisPaint().setStrokeWidth(3);
chart.getCategoryAxis().getAxisPaint().setStrokeWidth(3);
chart.getDataAxis().getAxisPaint().setColor(Color.rgb(127, 204, 204));
chart.getCategoryAxis().getAxisPaint().setColor(Color.rgb(127, 204, 204));
chart.getDataAxis().getTickMarksPaint().setColor(Color.rgb(127, 204, 204));
chart.getCategoryAxis().getTickMarksPaint().setColor(Color.rgb(127, 204, 204));
// 定义交叉点标签显示格式,特别备注,因曲线图的特殊性,所以返回格式为: x值,y值
// 请自行分析定制
chart.setDotLabelFormatter(new IFormatterTextCallBack() {
@Override
public String textFormatter(String value) {
// TODO Auto-generated method stub
String label = "(" + value + ")";
return (label);
}
});
// 标题
chart.setTitle("气泡图");
chart.addSubtitle("(XCL-Charts Demo)");
// 激活点击监听
chart.ActiveListenItemClick();
// 为了让触发更灵敏,可以扩大5px的点击监听范围
chart.extPointClickRange(5);
chart.showClikedFocus();
// 绘制交叉线
// chart.showDyLine();
// chart.getPlotArea().extWidth(500.f);
// 背景渐变
chart.getPlotArea().setBackgroundColor(true, Color.rgb(163, 69, 213));
chart.getPlotArea().setApplayGradient(true);
chart.getPlotArea().setEndColor(Color.WHITE);
// 图例
chart.getPlotLegend().setVerticalAlign(XEnum.VerticalAlign.BOTTOM);
chart.getPlotLegend().setHorizontalAlign(XEnum.HorizontalAlign.RIGHT);
// 不使用精确计算,忽略Java计算误差
chart.disableHighPrecision();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e(TAG, e.toString());
}
}
use of org.xclcharts.common.IFormatterTextCallBack 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.IFormatterTextCallBack 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