Пример #1
0
  private void chartRender() {
    try {
      // 设置绘图区默认缩进px值
      int[] ltrb = getPieDefaultSpadding();
      chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);

      chart.setTitle("雷达图-Radar Chart");
      chart.addSubtitle("(XCL-Charts Demo)");

      // 设定数据源
      chart.setCategories(labels);
      chart.setDataSource(chartData);

      // 数据轴最大值
      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());
    }
  }
Пример #2
0
 @Override
 public void render(Canvas canvas) {
   try {
     chart.render(canvas);
   } catch (Exception e) {
     Log.e(TAG, e.toString());
   }
 }
Пример #3
0
 @Override
 protected void onSizeChanged(int w, int h, int oldw, int oldh) {
   super.onSizeChanged(w, h, oldw, oldh);
   // 图所占范围大小
   chart.setChartRange(w, h);
 }