use of org.xclcharts.renderer.axis.CategoryAxis in project XCL-Charts by xcltapestry.
the class MultiAxisChart01View method renderBarAxis.
/**
* 柱形图轴相关
*/
private void renderBarAxis() {
//标签轴
chart.setCategories(chartLabels);
//数据轴
chart.setDataSource(chartDataset);
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.getPlotGrid().hideEvenRowBgColor();
chart.getPlotGrid().hideHorizontalLines();
chart.getPlotGrid().hideOddRowBgColor();
chart.getPlotGrid().hideVerticalLines();
chart.setBarCenterStyle(XEnum.BarCenterStyle.TICKMARKS);
//chart.getCategoryAxis().hideAxisLabels();
}
use of org.xclcharts.renderer.axis.CategoryAxis 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());
}
}
Aggregations