private void updateChart(int total) {
    int numSubcolumns = 60;
    int numColumns = 1000;
    List<float[]> flist = new ArrayList<>();
    //        if (!Constants.Queue_DrawRealtimewaterfall.isEmpty()) {
    //            flist = Constants.Queue_DrawRealtimewaterfall.poll();
    if (!Constants.Queue_DrawRealtimeSpectrum.isEmpty()) {
      flist = Constants.Queue_DrawRealtimeSpectrum.poll();
      int realsize = Constants.Queue_DrawRealtimeSpectrum.size();
      if (realsize >= 5) Constants.Queue_DrawRealtimeSpectrum.clear();
      List<Column> columns = new ArrayList<Column>();
      List<SubcolumnValue> values;
      if (flist.size() != total) {
        // 没收到整段就返回
        return;
      }
      float[] ff1 = selectData(flist);
      if (Xvalues.size() > 0) {
        int size = Xvalues.size();
        for (int i = 0; i < size; i++) {
          values = new ArrayList<SubcolumnValue>();
          values = Xvalues.get(i);
          for (int j = numSubcolumns - 1; j > 0; j--) {
            values.set(j, values.get(j - 1));
          }
          // int color=ChartUtils.pickColor();
          int index = (int) ((ff1[i] + 150) / 8);
          int color = 0;
          if (index >= 20) {
            color = colors[19];
          } else if (index < 0) {
            color = colors[0];
          } else {
            color = colors[(int) ((ff1[i] + 150) / 8)];
          }
          values.set(0, new SubcolumnValue(1, color));

          Column column = new Column(values);
          columns.add(column);
        }
      }
      data = new ColumnChartData(columns);
      data.setStacked(true);
      data.setFillRatio(1);
      Axis axisX = new Axis(Lvalues);
      Axis axisY = Axis.generateAxisFromRange(0, 60, 2);
      axisY.setLineColor(Color.GREEN);
      axisX.setHasLines(false);
      axisX.setHasSeparationLine(false);
      axisY.setHasSeparationLine(false);
      axisY.setHasLines(false);

      axisX.setName("Axis X");
      axisY.setName("Axis Y");
      data.setAxisXBottom(axisX);
      data.setAxisYLeft(axisY);
      chart.setColumnChartData(data);
    }
  }
  /** Generates columns with stacked subcolumns. */
  private void generateStackedData(int start, int end) {
    int numSubcolumns = 60;
    int numColumns = 1000;
    List<Column> columns = new ArrayList<Column>();
    List<SubcolumnValue> values;
    Lvalues = new ArrayList<>();
    Xvalues = new ArrayList<List<SubcolumnValue>>();
    for (int i = 0; i < numColumns; ++i) {
      values = new ArrayList<SubcolumnValue>();
      if (i == 0) {
        Lvalues.add(new AxisValue(i).setLabel(String.valueOf(start)));
      } else if (i == numColumns - 30) {
        Lvalues.add(new AxisValue(i).setLabel(String.valueOf(end)));
      }
      for (int j = 1; j <= numSubcolumns; ++j) {
        values.add(new SubcolumnValue(1, Color.WHITE));
      }

      Column column = new Column(values);
      column.setHasLabelsOnlyForSelected(hasLabelForSelected);
      columns.add(column);

      Xvalues.add(values);
    }
    data = new ColumnChartData(columns);

    data.setStacked(true);
    data.setFillRatio(1);

    Axis axisX = new Axis(Lvalues);
    axisX.setHasSeparationLine(false);
    axisX.setHasLines(false);
    Axis axisY = Axis.generateAxisFromRange(0, 60, 1);
    axisY.setHasSeparationLine(false);
    axisY.setHasLines(false);
    axisY.setLineColor(Color.GREEN);

    axisX.setName("Axis X");
    axisY.setName("Axis Y");
    data.setAxisXBottom(axisX);
    data.setAxisYLeft(axisY);
    chart.setColumnChartData(data);
  }
    // 产生数据 实时
    /////////////////////////////////////////////////////////////////////////////////////////
    private void generateInitialLineData() {
      int numValues = 19;

      List<AxisValue> axisValues = new ArrayList<AxisValue>();
      List<PointValue> values = new ArrayList<PointValue>();
      for (int i = 0; i < numValues; ++i) {
        values.add(new PointValue(i, 0));
        axisValues.add(new AxisValue(i).setLabel(days[i]));
      }

      Line line = new Line(values);
      line.setColor(ChartUtils.COLOR_BLUE);
      line.setHasPoints(false);
      line.getShape();
      line.setCubic(false); // 平滑

      List<Line> lines = new ArrayList<Line>();
      lines.add(line);
      //            lines.add(line1);
      //            lines.add(line2);

      Axis axisX = new Axis(axisValues);
      Axis axisY = new Axis().setHasLines(true);
      if (hasAxesNames) {
        axisX.setName("时间间隔");
        // axisY.setName("温度");
        axisX.setTextColor(ChartUtils.HOLO_BLUE_DARK);
        axisY.setTextColor(ChartUtils.HOLO_BLUE_DARK);
      }

      lineData = new LineChartData(lines);
      lineData.setAxisXBottom(axisX.setHasLines(true));
      lineData.setAxisYLeft(axisY.setMaxLabelChars(4));

      realeChartTop.setLineChartData(lineData);

      // For build-up animation you have to disable viewport recalculation.
      // 建立动画你必须禁用视图重新计算。
      realeChartTop.setViewportCalculationEnabled(false);

      // And set initial max viewport and current viewport- remember to set viewports after data.
      // 设置初始值和当前视口视口记得要在数据集视图。
      Viewport v = new Viewport(0, 50, 20, -10);
      realeChartTop.setMaximumViewport(v);
      realeChartTop.setCurrentViewport(v);
      realeChartTop.setZoomType(ZoomType.HORIZONTAL);

      // toggleFilled();
      // toggleLabels();
      toggleAxesNames();
    }