Java 类org.jfree.data.xy.TableXYDataset 实例源码

项目:parabuild-ci    文件:DatasetUtilitiesTests.java   
/**
 * Tests that the stacked range extent returns the expected result.
 */
public void testFindStackedRangeExtent() {

    // first the category datasets...
    CategoryDataset d1 = createCategoryDataset1();
    Range r = DatasetUtilities.findStackedRangeExtent(d1);
    assertEquals(0.0, r.getLowerBound(), EPSILON);
    assertEquals(15.0, r.getUpperBound(), EPSILON);

    d1 = createCategoryDataset2();
    r = DatasetUtilities.findStackedRangeExtent(d1);
    assertEquals(-2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);

    // then the XYDatasets...
    TableXYDataset d2 = createTableXYDataset1();
    r = DatasetUtilities.findStackedRangeExtent(d2);
    assertEquals(-2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);        

}
项目:parabuild-ci    文件:StackedXYBarRendererTests.java   
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
public void testFindDomainBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, 
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
项目:parabuild-ci    文件:StackedXYAreaRenderer2Tests.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
public void testFindRangeBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, 
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:parabuild-ci    文件:XYLineAndShapeRendererTests.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
public void testFindRangeBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, 
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    Range bounds = rangeAxis.getRange();
    assertFalse(bounds.contains(1.0));
    assertTrue(bounds.contains(2.0));
    assertTrue(bounds.contains(5.0));
    assertFalse(bounds.contains(6.0));
}
项目:parabuild-ci    文件:DatasetUtilitiesTests.java   
/**
 * Creates a sample dataset for testing purposes.
 * 
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;  
}
项目:parabuild-ci    文件:StackedXYAreaRenderer2.java   
/**
 * Returns the range of values the renderer requires to display all the 
 * items from the specified dataset.
 * 
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range (or <code>null</code> if the dataset is 
 *         <code>null</code> or empty).
 */
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset, 
                d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}
项目:parabuild-ci    文件:StackedXYAreaRenderer2.java   
/**
 * Calculates the stacked values (one positive and one negative) of all 
 * series up to, but not including, <code>series</code> for the specified 
 * item. It returns [0.0, 0.0] if <code>series</code> is the first series.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series index.
 * @param index  the item index.
 *
 * @return An array containing the cumulative negative and positive values
 *     for all series values up to but excluding <code>series</code> 
 *     for <code>index</code>.
 */
private double[] getStackValues(TableXYDataset dataset, 
                                int series, int index) {
    double[] result = new double[2];
    for (int i = 0; i < series; i++) {
        double v = dataset.getYValue(i, index);
        if (!Double.isNaN(v)) {
            if (v >= 0.0) {
                result[1] += v;   
            }
            else {
                result[0] += v;   
            }
        }
    }
    return result;
}
项目:ccu-historian    文件:StackedXYAreaRenderer2Test.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:ccu-historian    文件:StackedXYBarRendererTest.java   
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
项目:ccu-historian    文件:XYLineAndShapeRendererTest.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    Range bounds = rangeAxis.getRange();
    assertFalse(bounds.contains(1.0));
    assertTrue(bounds.contains(2.0));
    assertTrue(bounds.contains(5.0));
    assertFalse(bounds.contains(6.0));
}
项目:ccu-historian    文件:DatasetUtilitiesTest.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
项目:ccu-historian    文件:StackedXYAreaRenderer2.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (or <code>null</code> if the dataset is
 *         <code>null</code> or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset,
                d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}
项目:ccu-historian    文件:StackedXYAreaRenderer2.java   
/**
 * Calculates the stacked values (one positive and one negative) of all
 * series up to, but not including, <code>series</code> for the specified
 * item. It returns [0.0, 0.0] if <code>series</code> is the first series.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series index.
 * @param index  the item index.
 *
 * @return An array containing the cumulative negative and positive values
 *     for all series values up to but excluding <code>series</code>
 *     for <code>index</code>.
 */
private double[] getStackValues(TableXYDataset dataset,
                                int series, int index) {
    double[] result = new double[2];
    for (int i = 0; i < series; i++) {
        double v = dataset.getYValue(i, index);
        if (!Double.isNaN(v)) {
            if (v >= 0.0) {
                result[1] += v;
            }
            else {
                result[0] += v;
            }
        }
    }
    return result;
}
项目:ccu-historian    文件:StackedXYBarRenderer.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset != null) {
        if (this.renderAsPercentages) {
            return new Range(0.0, 1.0);
        }
        else {
            return DatasetUtilities.findStackedRangeBounds(
                    (TableXYDataset) dataset);
        }
    }
    else {
        return null;
    }
}
项目:jfreechart    文件:StackedXYAreaRenderer2.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset ({@code null} permitted).
 *
 * @return The range (or {@code null} if the dataset is {@code null} or 
 *     empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset,
                d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}
项目:jfreechart    文件:StackedXYAreaRenderer2.java   
/**
 * Calculates the stacked values (one positive and one negative) of all
 * series up to, but not including, {@code series} for the specified
 * item. It returns [0.0, 0.0] if {@code series} is the first series.
 *
 * @param dataset  the dataset ({@code null} not permitted).
 * @param series  the series index.
 * @param index  the item index.
 *
 * @return An array containing the cumulative negative and positive values
 *     for all series values up to but excluding {@code series}
 *     for {@code index}.
 */
private double[] getStackValues(TableXYDataset dataset,
                                int series, int index) {
    double[] result = new double[2];
    for (int i = 0; i < series; i++) {
        double v = dataset.getYValue(i, index);
        if (!Double.isNaN(v)) {
            if (v >= 0.0) {
                result[1] += v;
            }
            else {
                result[0] += v;
            }
        }
    }
    return result;
}
项目:jfreechart    文件:StackedXYBarRenderer.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset ({@code null} permitted).
 *
 * @return The range ({@code null} if the dataset is {@code null}
 *         or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset != null) {
        if (this.renderAsPercentages) {
            return new Range(0.0, 1.0);
        }
        else {
            return DatasetUtils.findStackedRangeBounds(
                    (TableXYDataset) dataset);
        }
    }
    else {
        return null;
    }
}
项目:jfreechart    文件:StackedXYAreaRenderer2Test.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:jfreechart    文件:StackedXYBarRendererTest.java   
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
项目:jfreechart    文件:XYLineAndShapeRendererTest.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    Range bounds = rangeAxis.getRange();
    assertFalse(bounds.contains(1.0));
    assertTrue(bounds.contains(2.0));
    assertTrue(bounds.contains(5.0));
    assertFalse(bounds.contains(6.0));
}
项目:jfreechart    文件:DatasetUtilsTest.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
项目:aya-lang    文件:StackedXYAreaRenderer2Test.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:aya-lang    文件:StackedXYBarRendererTest.java   
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
项目:aya-lang    文件:XYLineAndShapeRendererTest.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    Range bounds = rangeAxis.getRange();
    assertFalse(bounds.contains(1.0));
    assertTrue(bounds.contains(2.0));
    assertTrue(bounds.contains(5.0));
    assertFalse(bounds.contains(6.0));
}
项目:aya-lang    文件:DatasetUtilitiesTest.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
项目:aya-lang    文件:StackedXYAreaRenderer2.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (or <code>null</code> if the dataset is
 *         <code>null</code> or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset,
                d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}
项目:aya-lang    文件:StackedXYAreaRenderer2.java   
/**
 * Calculates the stacked values (one positive and one negative) of all
 * series up to, but not including, <code>series</code> for the specified
 * item. It returns [0.0, 0.0] if <code>series</code> is the first series.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series index.
 * @param index  the item index.
 *
 * @return An array containing the cumulative negative and positive values
 *     for all series values up to but excluding <code>series</code>
 *     for <code>index</code>.
 */
private double[] getStackValues(TableXYDataset dataset,
                                int series, int index) {
    double[] result = new double[2];
    for (int i = 0; i < series; i++) {
        double v = dataset.getYValue(i, index);
        if (!Double.isNaN(v)) {
            if (v >= 0.0) {
                result[1] += v;
            }
            else {
                result[0] += v;
            }
        }
    }
    return result;
}
项目:aya-lang    文件:StackedXYBarRenderer.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset != null) {
        if (this.renderAsPercentages) {
            return new Range(0.0, 1.0);
        }
        else {
            return DatasetUtilities.findStackedRangeBounds(
                    (TableXYDataset) dataset);
        }
    }
    else {
        return null;
    }
}
项目:HTML5_WebSite    文件:StackedXYAreaChartDemo2.java   
/**
   * Creates a sample chart.
   * 
   * @param dataset  the dataset for the chart.
   * 
   * @return a sample chart.
   */
  protected JFreeChart createChart(TableXYDataset dataset) {

      JFreeChart chart = ChartFactory.createStackedXYAreaChart(
          chartTitle,  // chart title
          domainLabel,                       // domain axis label
          rangeLabel,                       // range axis label
          dataset,                         // data
          PlotOrientation.VERTICAL,        // the plot orientation
          !legendPanelOn,                            // legend
          true,                            // tooltips
          false                            // urls
      );
      XYPlot plot = (XYPlot) chart.getPlot();
      StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); 
      renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
      plot.setRenderer(0, renderer);    

renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); 
setXSummary(dataset);   
      return chart;

  }
项目:HTML5_WebSite    文件:StackedXYAreaChartDemo1.java   
/**
   * Creates a sample dataset.
   * 
   * @return a sample dataset.
   */
  protected  TableXYDataset createDataset(boolean isDemo) {
      if (isDemo){
      DefaultTableXYDataset dataset = new DefaultTableXYDataset();

      XYSeries s1 = new XYSeries("Series 1", true, false);
      s1.add(5.0, 5.0);
      s1.add(10.0, 15.5);
      s1.add(15.0, 9.5);
      s1.add(20.0, 7.5);
      dataset.addSeries(s1);

      XYSeries s2 = new XYSeries("Series 2", true, false);
      s2.add(5.0, 5.0);
      s2.add(10.0, 15.5);
      s2.add(15.0, 9.5);
      s2.add(20.0, 3.5);
      dataset.addSeries(s2);

      return dataset;}
else return super.createDataset(false);

  }
项目:HTML5_WebSite    文件:StackedXYAreaChartDemo1.java   
/**
   * Creates a sample chart.
   * 
   * @param dataset  the dataset for the chart.
   * 
   * @return a sample chart.
   */
  protected JFreeChart createChart(TableXYDataset dataset) {

      JFreeChart chart = ChartFactory.createStackedXYAreaChart(
          chartTitle,  // chart title
          domainLabel,                       // domain axis label
          rangeLabel,                       // range axis label
          dataset,                         // data
          PlotOrientation.VERTICAL,        // the plot orientation
          !legendPanelOn,                            // legend
          true,                            // tooltips
          false                            // urls
      );
      XYPlot plot = (XYPlot) chart.getPlot();
      StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); 
      renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
      plot.setRenderer(0, renderer);  

renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

setXSummary(dataset);
      return chart;

  }
项目:HTML5_WebSite    文件:SuperAreaChart_XY.java   
/**
    * Creates a chart.
    * 
    * @param dataset  the dataset.
    * 
    * @return a chart.
    */
   protected JFreeChart createChart(TableXYDataset dataset) {
        // create the chart...
       JFreeChart chart = ChartFactory.createStackedXYAreaChart(
           chartTitle,      // chart title
           domainLabel,                      // x axis label
           rangeLabel,                      // y axis label
           dataset,                  // data
           PlotOrientation.VERTICAL,
           !legendPanelOn,                     // include legend
           true,                     // tooltips
           false                     // urls
       );

    XYPlot plot = (XYPlot) chart.getPlot();
       StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); 
       renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
       plot.setRenderer(0, renderer);        
       return chart;

}
项目:HTML5_WebSite    文件:SuperAreaChart_XY.java   
protected JFreeChart createLegend(TableXYDataset dataset) {

//  JFreeChart chart = ChartFactory.createAreaChart(
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
           chartTitle,      // chart title
           domainLabel,                      // x axis label
           rangeLabel,                      // y axis label
           dataset,                  // data
           PlotOrientation.VERTICAL,
           true,                     // include legend
           true,                     // tooltips
           false                     // urls
       );

       // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
XYPlot plot = (XYPlot) chart.getPlot();
   StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); 
   renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
   plot.setRenderer(0, renderer);   
   renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
       return chart;

   }
项目:HTML5_WebSite    文件:ChartGenerator_JTable.java   
private JFreeChart createTableXYAreaChart(String title, String xLabel, String yLabel, TableXYDataset dataset) {
 JFreeChart chart = ChartFactory.createStackedXYAreaChart(
           title,      // chart title
           xLabel,                      // x axis label
           yLabel,                      // y axis label
           dataset,                  // data
          orientation,
           true,                     // include legend
           true,                     // tooltips
           false                     // urls
       );

    XYPlot plot = (XYPlot) chart.getPlot();
       StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
      // renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
       plot.setRenderer(0, renderer);

       return chart;
}
项目:HTML5_WebSite    文件:StackedXYAreaRenderer2.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (or <code>null</code> if the dataset is
 *         <code>null</code> or empty).
 */
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset,
                d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}
项目:HTML5_WebSite    文件:StackedXYAreaRenderer2.java   
/**
 * Calculates the stacked values (one positive and one negative) of all
 * series up to, but not including, <code>series</code> for the specified
 * item. It returns [0.0, 0.0] if <code>series</code> is the first series.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series index.
 * @param index  the item index.
 *
 * @return An array containing the cumulative negative and positive values
 *     for all series values up to but excluding <code>series</code>
 *     for <code>index</code>.
 */
private double[] getStackValues(TableXYDataset dataset,
                                int series, int index) {
    double[] result = new double[2];
    for (int i = 0; i < series; i++) {
        double v = dataset.getYValue(i, index);
        if (!Double.isNaN(v)) {
            if (v >= 0.0) {
                result[1] += v;
            }
            else {
                result[0] += v;
            }
        }
    }
    return result;
}
项目:populus    文件:StackedXYAreaRenderer2.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (or <code>null</code> if the dataset is
 *         <code>null</code> or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset,
                d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}
项目:populus    文件:StackedXYAreaRenderer2.java   
/**
 * Calculates the stacked values (one positive and one negative) of all
 * series up to, but not including, <code>series</code> for the specified
 * item. It returns [0.0, 0.0] if <code>series</code> is the first series.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series index.
 * @param index  the item index.
 *
 * @return An array containing the cumulative negative and positive values
 *     for all series values up to but excluding <code>series</code>
 *     for <code>index</code>.
 */
private double[] getStackValues(TableXYDataset dataset,
                                int series, int index) {
    double[] result = new double[2];
    for (int i = 0; i < series; i++) {
        double v = dataset.getYValue(i, index);
        if (!Double.isNaN(v)) {
            if (v >= 0.0) {
                result[1] += v;
            }
            else {
                result[0] += v;
            }
        }
    }
    return result;
}
项目:populus    文件:StackedXYBarRenderer.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset != null) {
        if (this.renderAsPercentages) {
            return new Range(0.0, 1.0);
        }
        else {
            return DatasetUtilities.findStackedRangeBounds(
                    (TableXYDataset) dataset);
        }
    }
    else {
        return null;
    }
}
项目:PI    文件:StackedXYAreaRenderer2.java   
/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (or <code>null</code> if the dataset is
 *         <code>null</code> or empty).
 */
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset,
                d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}