示例#1
0
  /**
   * 绘制最外围的标签及主轴的刻度线标签
   *
   * @param canvas 画布
   */
  private void renderAxisLabels(Canvas canvas) {
    // 标签个数决定角的个数
    int labelsCount = getPlotAgentNumber();
    // 轴线tick总数
    int dataAxisTickCount = getAxisTickCount();

    for (int i = 0; i < dataAxisTickCount; i++) {
      for (int j = 0; j < labelsCount; j++) {
        // 绘制最外围的标签
        if (i == dataAxisTickCount - 1) {
          // 绘制最外围的标签
          String label = CategoryAxis.getDataSet().get(j);

          canvas.drawText(label, mArrayLabelX[i][j], mArrayLabelY[i][j], getLabelPaint());
        }

        // 绘制主轴的刻度线与标签
        if (0 == j) { // 显示在第一轴线上(即270度的那根线)									
          // 绘制主轴(DataAxis)的刻度线
          double tick = this.dataAxis.getAxisSteps() * i + dataAxis.getAxisMin();
          dataAxis.renderAxisHorizontalTick(
              this, canvas, mArrayDotX[i][j], mArrayDotY[i][j], Double.toString(tick));
        }
      } // end for labels
    } // end for data
  }
示例#2
0
  private void initChart() {
    dataAxis = new DataAxisRender();
    CategoryAxis = new CategoryAxisRender();
    dataAxis.setHorizontalTickAlign(Align.LEFT);
    dataAxis.getTickLabelPaint().setTextAlign(Align.RIGHT);
    dataAxis.setTickMarksVisible(false);

    showKeyLabels();
  }
示例#3
0
  /**
   * 绘制数据区网络
   *
   * @param canvas 画布
   */
  private void renderDataArea(Canvas canvas) {
    float cirX = plotArea.getCenterX();
    float cirY = plotArea.getCenterY();

    for (RadarData lineData : mDataSet) {
      // 画各自的网
      List<Double> dataset = lineData.getLinePoint();

      int dataSize = dataset.size();
      if (dataSize < 3) {
        Log.e(TAG, "这几个数据可不够,最少三个起步.");
        continue;
      }

      Float[] arrayDataX = new Float[dataSize];
      Float[] arrayDataY = new Float[dataSize];

      int i = 0;
      for (Double data : dataset) {
        Double per = (data - dataAxis.getAxisMin()) / dataAxis.getAxisRange();
        float curRadius = (float) (getRadius() * per);

        // 计算位置
        MathHelper.getInstance().calcArcEndPointXY(cirX, cirY, curRadius, mArrayLabelAgent[i]);

        // 依Path还是Line来决定画线风格
        arrayDataX[i] = MathHelper.getInstance().getPosX();
        arrayDataY[i] = MathHelper.getInstance().getPosY();

        i++; // 标签
      }

      // 画线或填充
      switch (lineData.getAreaStyle()) {
        case FILL:
          drawDataPath(canvas, lineData, arrayDataX, arrayDataY);
          break;
        case STROKE:
          renderDataLine(canvas, lineData, arrayDataX, arrayDataY);
          break;
        default:
          Log.e(TAG, "这类型不认识.");
      }
    }
  }
示例#4
0
 /**
  * 轴线上tick总个数
  *
  * @return 总个数
  */
 private int getAxisTickCount() {
   return (int) Math.round(dataAxis.getAixTickCount() + 1);
 }