Example #1
0
  protected XYMultipleSeriesDataset buildDataset(String[] titles, List<double[]> xyValues) {
    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

    XYSeries series = getXYSeries(titles[0], xyValues.get(0), xyValues.get(1));
    dataset.addSeries(series);

    // we may have trend line data as well
    if (titles.length == 2 && xyValues.size() == 3) {
      series = getXYSeries(titles[1], xyValues.get(0), xyValues.get(2));
      dataset.addSeries(series);
    }

    return dataset;
  }
 /**
  * Gets the buffer/cache for values. Values set in the buffer will be applied to the target
  * dataset when the transition takes place.
  *
  * @return
  */
 public XYMultipleSeriesDataset getBuffer() {
   if (datasetCache == null) {
     datasetCache = new XYMultipleSeriesDataset();
     for (int i = 0; i < dataset.getSeriesCount(); i++) {
       datasetCache.addSeries(new XYSeries(dataset.getSeriesAt(i).getTitle()));
     }
     seriesTransitions = new XYSeriesTransition[dataset.getSeries().length];
     for (int i = 0; i < seriesTransitions.length; i++) {
       seriesTransitions[i] = new XYSeriesTransition(getChart(), dataset.getSeriesAt(i));
       seriesTransitions[i].setBuffer(datasetCache.getSeriesAt(i));
     }
   }
   return datasetCache;
 }
Example #3
0
 /**
  * Builds a bar multiple series dataset using the provided values.
  *
  * @param titles the series titles
  * @param values the values
  * @return the XY multiple bar dataset
  */
 protected XYMultipleSeriesDataset buildBarDataset(String[] titles, List<double[]> values) {
   XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
   int length = titles.length;
   for (int i = 0; i < length; i++) {
     CategorySeries series = new CategorySeries(titles[i]);
     double[] v = values.get(i);
     int seriesLength = v.length;
     for (int k = 0; k < seriesLength; k++) {
       series.add(v[k]);
     }
     dataset.addSeries(series.toXYSeries());
   }
   return dataset;
 }