Search in sources :

Example 6 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testDrawWithNullMinRegular.

/**
 * Draws a chart where the dataset contains a null min regular value.
 */
@Test
public void testDrawWithNullMinRegular() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), null, 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 7 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testDrawWithNullMaxOutlier.

/**
 * Draws a chart where the dataset contains a null max outlier value.
 */
@Test
public void testDrawWithNullMaxOutlier() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), null, new java.util.ArrayList()), "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) ArrayList(java.util.ArrayList) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) Test(org.junit.Test)

Example 8 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testGetLegendItem.

/**
 * Some checks for the getLegendItem() method.
 */
@Test
public void testGetLegendItem() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    List values = new ArrayList();
    values.add(new Double(1.10));
    values.add(new Double(1.45));
    values.add(new Double(1.33));
    values.add(new Double(1.23));
    dataset.add(values, "R1", "C1");
    BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), r);
    /*JFreeChart chart =*/
    new JFreeChart(plot);
    LegendItem li = r.getLegendItem(0, 0);
    assertNotNull(li);
    r.setSeriesVisibleInLegend(0, Boolean.FALSE);
    li = r.getLegendItem(0, 0);
    assertNull(li);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) LegendItem(org.jfree.chart.LegendItem) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 9 with DefaultBoxAndWhiskerCategoryDataset

use of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset 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 10 with DefaultBoxAndWhiskerCategoryDataset

use of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset in project gephi by gephi.

the class ChartsUtils method buildBoxPlot.

/**
 * Build a new box-plot from an array of numbers using a default title and yLabel.
 * String dataName will be used for xLabel.
 * @param numbers Numbers for building box-plot
 * @param dataName Name of the numbers data
 * @return Prepared box-plot
 */
public static JFreeChart buildBoxPlot(final Number[] numbers, final String dataName) {
    if (numbers == null || numbers.length == 0) {
        return null;
    }
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    final ArrayList<Number> list = new ArrayList<>();
    list.addAll(Arrays.asList(numbers));
    final String valuesString = getMessage("ChartsUtils.report.box-plot.values");
    dataset.add(list, valuesString, "");
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setMeanVisible(false);
    renderer.setFillBox(false);
    renderer.setMaximumBarWidth(0.5);
    final CategoryAxis xAxis = new CategoryAxis(dataName);
    final NumberAxis yAxis = new NumberAxis(getMessage("ChartsUtils.report.box-plot.values-range"));
    yAxis.setAutoRangeIncludesZero(false);
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    plot.setRenderer(renderer);
    JFreeChart boxPlot = new JFreeChart(getMessage("ChartsUtils.report.box-plot.title"), plot);
    return boxPlot;
}
Also used : BoxAndWhiskerRenderer(org.jfree.chart.renderer.category.BoxAndWhiskerRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) BoxAndWhiskerToolTipGenerator(org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ArrayList(java.util.ArrayList) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

DefaultBoxAndWhiskerCategoryDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset)15 JFreeChart (org.jfree.chart.JFreeChart)13 CategoryAxis (org.jfree.chart.axis.CategoryAxis)13 NumberAxis (org.jfree.chart.axis.NumberAxis)13 CategoryPlot (org.jfree.chart.plot.CategoryPlot)13 Test (org.junit.Test)12 ChartRenderingInfo (org.jfree.chart.ChartRenderingInfo)10 BoxAndWhiskerItem (org.jfree.data.statistics.BoxAndWhiskerItem)10 ArrayList (java.util.ArrayList)6 List (java.util.List)4 Graphics2D (java.awt.Graphics2D)2 Rectangle2D (java.awt.geom.Rectangle2D)2 BufferedImage (java.awt.image.BufferedImage)2 LegendItem (org.jfree.chart.LegendItem)1 BoxAndWhiskerToolTipGenerator (org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator)1 BoxAndWhiskerRenderer (org.jfree.chart.renderer.category.BoxAndWhiskerRenderer)1