Search in sources :

Example 1 with XYBarDataset

use of org.jfree.data.xy.XYBarDataset in project SIMVA-SoS by SESoS.

the class XYBarRendererTest method testGetLegendItemSeriesIndex.

/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    XYSeriesCollection d1 = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(1.0, 1.1);
    XYSeries s2 = new XYSeries("S2");
    s2.add(1.0, 1.1);
    d1.addSeries(s1);
    d1.addSeries(s2);
    XYSeriesCollection d2 = new XYSeriesCollection();
    XYSeries s3 = new XYSeries("S3");
    s3.add(1.0, 1.1);
    XYSeries s4 = new XYSeries("S4");
    s4.add(1.0, 1.1);
    XYSeries s5 = new XYSeries("S5");
    s5.add(1.0, 1.1);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);
    XYBarRenderer r = new XYBarRenderer();
    XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r);
    plot.setDataset(1, new XYBarDataset(d2, 2.0));
    /*JFreeChart chart =*/
    new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) XYBarDataset(org.jfree.data.xy.XYBarDataset) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) LegendItem(org.jfree.chart.LegendItem) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 2 with XYBarDataset

use of org.jfree.data.xy.XYBarDataset in project SIMVA-SoS by SESoS.

the class XYBarChartTest method createChart.

/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection(series1), 1.0);
    return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset);
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) XYBarDataset(org.jfree.data.xy.XYBarDataset) IntervalXYDataset(org.jfree.data.xy.IntervalXYDataset) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection)

Aggregations

XYBarDataset (org.jfree.data.xy.XYBarDataset)2 XYSeries (org.jfree.data.xy.XYSeries)2 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)2 JFreeChart (org.jfree.chart.JFreeChart)1 LegendItem (org.jfree.chart.LegendItem)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 XYPlot (org.jfree.chart.plot.XYPlot)1 IntervalXYDataset (org.jfree.data.xy.IntervalXYDataset)1 Test (org.junit.Test)1