Search in sources :

Example 1 with BoxAndWhiskerItem

use of org.jfree.data.statistics.BoxAndWhiskerItem in project tdq-studio-se by Talend.

the class TOPChartService method createDefaultBoxAndWhiskerCategoryDataset.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.service.ITOPChartService#createDefaultBoxAndWhiskerCategoryDataset(java.lang.Double,
     * java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double)
     */
@Override
public Object createDefaultBoxAndWhiskerCategoryDataset(Double mean, Double median, Double q1, Double q3, Double minRegularValue, Double maxRegularValue) {
    DefaultBoxAndWhiskerCategoryDataset dataset = ChartDatasetUtils.createBoxAndWhiskerDataset();
    BoxAndWhiskerItem item = ChartDatasetUtils.createBoxAndWhiskerItem(mean, median, q1, q3, minRegularValue, maxRegularValue, null);
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(item, "0", "");
    @SuppressWarnings("rawtypes") List zerolist = new ArrayList();
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "1", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "2", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "3", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "4", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "5", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "6", "");
    return dataset;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem)

Example 2 with BoxAndWhiskerItem

use of org.jfree.data.statistics.BoxAndWhiskerItem in project tdq-studio-se by Talend.

the class ChartDatasetUtils method createBoxAndWhiskerItem.

public static BoxAndWhiskerItem createBoxAndWhiskerItem(Double mean, Double median, Double q1, Double q3, Double minRegularValue, Double maxRegularValue, List outliers) {
    // MOD scorreia 2008-06-05 automatic computation of outliers limits
    // see http://en.wikipedia.org/wiki/Box_plot
    Double xIQR = (q1 != null && q3 != null) ? OUTLIER_FACTOR * (q3 - q1) : null;
    Double minOutlier = xIQR != null ? q1 - xIQR : null;
    Double maxOutlier = xIQR != null ? q3 + xIQR : null;
    // enhance bounds of graphics when needed
    if (minOutlier != null && minRegularValue != null) {
        minOutlier = Math.min(minOutlier, minRegularValue);
    }
    if (maxOutlier != null && maxRegularValue != null) {
        maxOutlier = Math.max(maxOutlier, maxRegularValue);
    }
    BoxAndWhiskerItem item = new BoxAndWhiskerItem(mean, median, q1, q3, minRegularValue, maxRegularValue, minOutlier, maxOutlier, outliers);
    return item;
}
Also used : BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem)

Example 3 with BoxAndWhiskerItem

use of org.jfree.data.statistics.BoxAndWhiskerItem in project SIMVA-SoS by SESoS.

the class BoxAndWhiskerRendererTest method testDrawWithNullQ1.

/**
 * Draws a chart where the dataset contains a null Q1 value.
 */
@Test
public void testDrawWithNullQ1() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), null, new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, info);
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 4 with BoxAndWhiskerItem

use of org.jfree.data.statistics.BoxAndWhiskerItem in project SIMVA-SoS by SESoS.

the class BoxAndWhiskerRendererTest method testDrawWithNullMedian.

/**
 * Draws a chart where the dataset contains a null median value.
 */
@Test
public void testDrawWithNullMedian() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), null, new Double(0.0), new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, info);
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 5 with BoxAndWhiskerItem

use of org.jfree.data.statistics.BoxAndWhiskerItem in project SIMVA-SoS by SESoS.

the class BoxAndWhiskerRendererTest method testDrawWithNullQ3.

/**
 * Draws a chart where the dataset contains a null Q3 value.
 */
@Test
public void testDrawWithNullQ3() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), null, new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, info);
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Aggregations

BoxAndWhiskerItem (org.jfree.data.statistics.BoxAndWhiskerItem)13 Test (org.junit.Test)11 JFreeChart (org.jfree.chart.JFreeChart)10 DefaultBoxAndWhiskerCategoryDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset)10 CategoryAxis (org.jfree.chart.axis.CategoryAxis)9 NumberAxis (org.jfree.chart.axis.NumberAxis)9 CategoryPlot (org.jfree.chart.plot.CategoryPlot)9 ChartRenderingInfo (org.jfree.chart.ChartRenderingInfo)8 ArrayList (java.util.ArrayList)3 Date (java.util.Date)2 List (java.util.List)2 DefaultBoxAndWhiskerXYDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset)2 Graphics2D (java.awt.Graphics2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 Range (org.jfree.data.Range)1