Search in sources :

Example 1 with DefaultXYZDataset

use of org.jfree.data.xy.DefaultXYZDataset in project tdq-studio-se by Talend.

the class TopChartFactory method createBubbleChart.

/**
 * Method "createBubbleChart".
 *
 * @param indic the indicator
 * @param numericColumn the analyzed numeric column
 * @return the bubble chart
 */
public static JFreeChart createBubbleChart(String chartName, Object dataset, Map<String, ValueAggregator> xyzDatasets) {
    final Map<String, ValueAggregator> xyzDatasetsFinal = xyzDatasets;
    JFreeChart chart = TopChartFactory.createBubbleChart(chartName, // $NON-NLS-1$ //$NON-NLS-2$
    Messages.getString("TopChartFactory.average"), // $NON-NLS-1$ //$NON-NLS-2$
    Messages.getString("TopChartFactory.count"), // $NON-NLS-1$ //$NON-NLS-2$
    (DefaultXYZDataset) dataset, // $NON-NLS-1$ //$NON-NLS-2$
    PlotOrientation.HORIZONTAL, true, true, true);
    final XYPlot plot = (XYPlot) chart.getPlot();
    final XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator() {

        private static final long serialVersionUID = 1L;

        /*
             * (non-Javadoc)
             * 
             * @see org.jfree.chart.labels.StandardXYZToolTipGenerator#createItemArray(org.jfree.data.xy.XYZDataset,
             * int, int)
             */
        @Override
        protected Object[] createItemArray(XYZDataset dset, int series, int item) {
            final Comparable<?> seriesKey = dset.getSeriesKey(series);
            final String seriesK = String.valueOf(seriesKey);
            String label = seriesK;
            if (xyzDatasetsFinal != null) {
                ValueAggregator valueAggregator = xyzDatasetsFinal.get(seriesKey);
                label = valueAggregator.getLabels(seriesK).get(item);
            }
            final Object[] itemArray = super.createItemArray(dset, series, item);
            // label;
            itemArray[0] = label;
            // $NON-NLS-1$
            itemArray[1] = "avg=" + itemArray[1];
            // $NON-NLS-1$
            itemArray[2] = "record count=" + itemArray[2];
            // $NON-NLS-1$
            itemArray[3] = "null count=" + itemArray[3];
            return itemArray;
        }
    });
    return chart;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) ValueAggregator(org.talend.dataprofiler.service.utils.ValueAggregator) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) JFreeChart(org.jfree.chart.JFreeChart) DefaultXYZDataset(org.jfree.data.xy.DefaultXYZDataset) XYZDataset(org.jfree.data.xy.XYZDataset) Paint(java.awt.Paint) StandardXYZToolTipGenerator(org.jfree.chart.labels.StandardXYZToolTipGenerator)

Example 2 with DefaultXYZDataset

use of org.jfree.data.xy.DefaultXYZDataset in project cytoscape-impl by cytoscape.

the class HeatMapLayer method createDataset.

// ==[ PRIVATE METHODS ]============================================================================================
@Override
protected XYZDataset createDataset() {
    final DefaultXYZDataset dataset = new DefaultXYZDataset();
    int x = 0;
    for (final Entry<String, List<Double>> series : data.entrySet()) {
        final String k = series.getKey();
        final List<Double> zValues = series.getValue();
        // Must be an array with length 3, containing three arrays of equal length,
        // - the first containing the x-values,
        // - the second containing the y-values
        // - and the third containing the z-values
        // { { x1, x2 }, { y1, y2 }, { z1, z2 } }
        final double[][] seriesData = new double[3][maxYSize];
        Arrays.fill(seriesData[0], x);
        for (int y = 0; y < maxYSize; y++) {
            double z = Double.NaN;
            if (zValues.size() > y && zValues.get(y) != null)
                z = zValues.get(y);
            seriesData[1][y] = y;
            seriesData[2][y] = z;
        }
        dataset.addSeries(k, seriesData);
        x++;
    }
    return dataset;
}
Also used : DefaultXYZDataset(org.jfree.data.xy.DefaultXYZDataset) List(java.util.List)

Example 3 with DefaultXYZDataset

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

the class XYBlockRendererTest method testBug1766646B.

/**
 * A simple test for bug 1766646.
 */
@Test
public void testBug1766646B() {
    XYBlockRenderer r = new XYBlockRenderer();
    Range range = r.findRangeBounds(null);
    assertTrue(range == null);
    DefaultXYZDataset emptyDataset = new DefaultXYZDataset();
    range = r.findRangeBounds(emptyDataset);
    assertTrue(range == null);
}
Also used : DefaultXYZDataset(org.jfree.data.xy.DefaultXYZDataset) Range(org.jfree.data.Range) Test(org.junit.Test)

Example 4 with DefaultXYZDataset

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

the class XYBlockRendererTest method testBug1766646A.

/**
 * A simple test for bug 1766646.
 */
@Test
public void testBug1766646A() {
    XYBlockRenderer r = new XYBlockRenderer();
    Range range = r.findDomainBounds(null);
    assertTrue(range == null);
    DefaultXYZDataset emptyDataset = new DefaultXYZDataset();
    range = r.findDomainBounds(emptyDataset);
    assertTrue(range == null);
}
Also used : DefaultXYZDataset(org.jfree.data.xy.DefaultXYZDataset) Range(org.jfree.data.Range) Test(org.junit.Test)

Example 5 with DefaultXYZDataset

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

the class XYBubbleRendererTest method testGetLegendItemSeriesIndex.

/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    DefaultXYZDataset d1 = new DefaultXYZDataset();
    double[] x = { 2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8 };
    double[] y = { 14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25 };
    double[] z = { 2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4 };
    double[][] s1 = new double[][] { x, y, z };
    d1.addSeries("S1", s1);
    x = new double[] { 2.1 };
    y = new double[] { 14.1 };
    z = new double[] { 2.4 };
    double[][] s2 = new double[][] { x, y, z };
    d1.addSeries("S2", s2);
    DefaultXYZDataset d2 = new DefaultXYZDataset();
    x = new double[] { 2.1 };
    y = new double[] { 14.1 };
    z = new double[] { 2.4 };
    double[][] s3 = new double[][] { x, y, z };
    d2.addSeries("S3", s3);
    x = new double[] { 2.1 };
    y = new double[] { 14.1 };
    z = new double[] { 2.4 };
    double[][] s4 = new double[][] { x, y, z };
    d2.addSeries("S4", s4);
    x = new double[] { 2.1 };
    y = new double[] { 14.1 };
    z = new double[] { 2.4 };
    double[][] s5 = new double[][] { x, y, z };
    d2.addSeries("S5", s5);
    XYBubbleRenderer r = new XYBubbleRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*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 : NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) LegendItem(org.jfree.chart.LegendItem) DefaultXYZDataset(org.jfree.data.xy.DefaultXYZDataset) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Aggregations

DefaultXYZDataset (org.jfree.data.xy.DefaultXYZDataset)6 Range (org.jfree.data.Range)3 Test (org.junit.Test)3 JFreeChart (org.jfree.chart.JFreeChart)2 XYPlot (org.jfree.chart.plot.XYPlot)2 Paint (java.awt.Paint)1 List (java.util.List)1 LegendItem (org.jfree.chart.LegendItem)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 StandardXYZToolTipGenerator (org.jfree.chart.labels.StandardXYZToolTipGenerator)1 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)1 XYZDataset (org.jfree.data.xy.XYZDataset)1 ValueAggregator (org.talend.dataprofiler.service.utils.ValueAggregator)1