private void generateLineData(int color, int range, float textTemple) {
      // Cancel last animation if not finished.
      // chartTop.cancelDataAnimation();

      // Modify data targets
      // 修改数据目标
      Line line = lineData.getLines().get(0); // For this example there is always only one line.
      line.setColor(color);
      line.setFilled(true);
      line.setHasLabels(true);
      line.setHasPoints(false);
      List<PointValue> lineList = line.getValues();

      for (int j = 0; j < lineList.size(); j++) {
        PointValue value = lineList.get(j);
        if (j == lineList.size() - 1) {
          value.setTarget(value.getX(), textTemple);
        } else {
          PointValue nextValue = lineList.get(j + 1);
          value.setTarget(value.getX(), nextValue.getY());
        }
      }

      // Start new data animation with 300ms duration;
      realeChartTop.startDataAnimation(0);
    }
示例#2
0
  private void generateLineData(int color, float range) {
    // Cancel last animation if not finished.
    chartTop.cancelDataAnimation();

    // Modify data targets
    Line line = lineData.getLines().get(0); // For this example there is always only one line.
    line.setColor(color);
    for (PointValue value : line.getValues()) {
      // Change target only for Y value.
      value.setTarget(value.getX(), (float) Math.random() * range);
    }
    // Start new data animation with 300ms duration;
    chartTop.startDataAnimation(300);
  }