コード例 #1
0
  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);
    }
  }
  private void setUpChartColumns() {
    List<Column> chartColumns = getChartColumns();
    List<AxisValue> chartAxisPoints = getChartAxisPoints();
    List<AxisValue> chartAxisValues = getChartAxisValues();

    ColumnChartData chartData = new ColumnChartData().setColumns(chartColumns);
    chartData.setAxisXBottom(new Axis().setValues(chartAxisPoints));
    chartData.setAxisYLeft(new Axis().setValues(chartAxisValues));

    chart.setColumnChartData(chartData);
  }
コード例 #3
0
    private void generateColumnData() {

      int numSubcolumns = 1;
      int numColumns = months.length;

      List<AxisValue> axisValues = new ArrayList<AxisValue>();
      List<Column> columns = new ArrayList<Column>();
      List<SubcolumnValue> values;
      for (int i = 0; i < numColumns; ++i) {

        values = new ArrayList<SubcolumnValue>();
        for (int j = 0; j < numSubcolumns; ++j) {
          values.add(new SubcolumnValue((float) Math.random() * 50f + 5, ChartUtils.pickColor()));
        }

        axisValues.add(new AxisValue(i).setLabel(months[i]));

        columns.add(new Column(values).setHasLabelsOnlyForSelected(true));
      }

      columnData = new ColumnChartData(columns);

      columnData.setAxisXBottom(new Axis(axisValues).setHasLines(true));
      columnData.setAxisYLeft(new Axis().setHasLines(true).setMaxLabelChars(2));

      chartBottom.setColumnChartData(columnData);

      // Set value touch listener that will trigger changes for chartTop.
      chartBottom.setOnValueTouchListener(new ValueTouchListener());

      // Set selection mode to keep selected month column highlighted.
      chartBottom.setValueSelectionEnabled(true);

      chartBottom.setZoomType(ZoomType.HORIZONTAL);

      // chartBottom.setOnClickListener(new View.OnClickListener() {
      //
      // @Override
      // public void onClick(View v) {
      // SelectedValue sv = chartBottom.getSelectedValue();
      // if (!sv.isSet()) {
      // generateInitialLineData();
      // }
      //
      // }
      // });

    }
コード例 #4
0
  public void loadNumStacks() {
    List<Column> cols = new ArrayList<>();
    for (MatchData m : team.getMatchData()) {
      List<SubcolumnValue> subCols = new ArrayList<>();
      SubcolumnValue auton = new SubcolumnValue(m.autonYellowTotes).setLabel("m" + m.matchNo);
      auton.setColor(getResources().getColor(R.color.accent));
      subCols.add(auton);
      cols.add(new Column(subCols).setHasLabels(true));
    }

    ColumnChartData data = new ColumnChartData(cols).setBaseValue(0).setStacked(true);
    data.setAxisYLeft(new Axis().setHasLines(true).setName("Yellow totes stacked"));
    data.setAxisXBottom(new Axis().setName("Match"));

    autonTotes.setColumnChartData(data);
  }
コード例 #5
0
  /** 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);
  }
コード例 #6
0
    private ColumnChartData generateColumnChartData() {
      int numSubcolumns = 1;
      int numColumns = 12;
      // Column can have many subcolumns, here by default I use 1 subcolumn in each of 8 columns.
      List<Column> columns = new ArrayList<Column>();
      List<SubcolumnValue> values;
      for (int i = 0; i < numColumns; ++i) {

        values = new ArrayList<SubcolumnValue>();
        for (int j = 0; j < numSubcolumns; ++j) {
          values.add(new SubcolumnValue((float) Math.random() * 50f + 5, ChartUtils.pickColor()));
        }

        columns.add(new Column(values));
      }

      ColumnChartData data = new ColumnChartData(columns);

      data.setAxisXBottom(new Axis().setName("Axis X"));
      data.setAxisYLeft(new Axis().setName("Axis Y").setHasLines(true));
      return data;
    }