Ejemplo n.º 1
0
  /*
   * (non-Javadoc)
   *
   * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildYSeries()
   */
  protected void buildYSeries() {
    try {

      int starting = 0;
      if (data.length > xSeriesTicks) starting = data.length - xSeriesTicks;
      int yseriescount = adapter.getSeriesCount();
      NumberDataSet orthoValuesDataSet[] = new NumberDataSet[yseriescount];
      ScatterSeries ss1[] = new ScatterSeries[yseriescount];
      SeriesDefinition sdY[] = new SeriesDefinition[yseriescount];

      for (int i = 1; i <= yseriescount; i++) {
        y = new Double[data.length - starting];
        for (int j = starting, k = 0; j < data.length; j++, k++) {
          y[k] = NumberType.obj2num(data[j][i]).doubleValue();
          if (max < y[k]) max = y[k];
          if (min > y[k]) min = y[k];
        }
        orthoValuesDataSet[i - 1] = NumberDataSetImpl.create(y);
        ss1[i - 1] = (ScatterSeries) ScatterSeriesImpl.create();
        ss1[i - 1].setDataSet(orthoValuesDataSet[i - 1]);
        // bs1[i-1].getDisplayName().
        // bs1[i-1].getLabel().setVisible(true);
        // bs1[i-1].setLabelPosition(Position.INSIDE_LITERAL);

        ss1[i - 1].setSeriesIdentifier(labels[i]);
        ss1[i - 1].getMarker().setSize(2);
        // ss1[i-1].getMarkers().
        for (int m = 0; m < ss1[i - 1].getMarkers().size(); m++) {
          ((Marker) ss1[i - 1].getMarkers().get(m)).setType(MarkerType.get(i));
          ((Marker) ss1[i - 1].getMarkers().get(m)).setSize(2);
        }
        // ss1[i-1].getLineAttributes().setVisible(true);
        sdY[i - 1] = SeriesDefinitionImpl.create();
        sdY[i - 1].getSeriesPalette().update(0 - i - 2);

        yAxis.getSeriesDefinitions().add(sdY[i - 1]);
        sdY[i - 1].getSeries().add(ss1[i - 1]);
      }
      System.out.println("not bin updatedataset:" + max);
      yAxis.getScale().setStep(max / 2);
      yAxis.getScale().setMax(NumberDataElementImpl.create(max));

    } catch (Exception e) {
      //   e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  public void updateDataSet() {
    // Associate with Data Set
    try {
      data = adapter.getData();
      int starting = 0;
      if (data.length > xSeriesTicks) starting = data.length - xSeriesTicks;

      x = new String[data.length - starting];
      for (int j = starting, k = 0; j < data.length; j++, k++) x[k] = data[j][0].toString();
      // X-Axis
      TextDataSet categoryValues = TextDataSetImpl.create(x);

      Axis xAxisPrimary = chart.getPrimaryBaseAxes()[0];
      SeriesDefinition sdX = (SeriesDefinition) xAxisPrimary.getSeriesDefinitions().get(0);
      ((Series) sdX.getSeries().get(0)).setDataSet(categoryValues);

      // Y-Axis
      Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary);
      //   chart.getOrthogonalAxes(xAxisPrimary, arg1)

      NumberDataSet orthoValuesDataSet1[] = new NumberDataSet[adapter.getSeriesCount()];
      for (int i = 1; i <= adapter.getSeriesCount(); i++) {
        y = new Double[data.length - starting];
        for (int j = starting, k = 0; j < data.length; j++, k++) {
          y[k] = NumberType.obj2num(data[j][i]).doubleValue();
          if (max < y[k]) max = y[k];
        }

        orthoValuesDataSet1[i - 1] = NumberDataSetImpl.create(y);
        SeriesDefinition sdY = (SeriesDefinition) yAxisPrimary.getSeriesDefinitions().get(i - 1);
        ((Series) sdY.getSeries().get(0)).setDataSet(orthoValuesDataSet1[i - 1]);
      }
      yAxis.getScale().setStep(max / 5);
      yAxis.getScale().setMax(NumberDataElementImpl.create(max));
    } catch (Exception e) {
      //		e.printStackTrace();
    }
  }