Example usage for org.jfree.chart ChartFactory createBoxAndWhiskerChart

List of usage examples for org.jfree.chart ChartFactory createBoxAndWhiskerChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createBoxAndWhiskerChart.

Prototype

public static JFreeChart createBoxAndWhiskerChart(String title, String timeAxisLabel, String valueAxisLabel,
        BoxAndWhiskerXYDataset dataset, boolean legend) 

Source Link

Document

Creates and returns a default instance of a box and whisker chart.

Usage

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

public JFreeChart getChartForGlobalQC() {
    IntensityMatrixImpl intensityMatrix = dataManager.getIntensityMatrix();
    if (intensityMatrix == null)
        return null;
    List<Sample> globalQCList = intensityMatrix.getGlobalQCSamples();
    log.info("global QC {}", globalQCList.size());
    if (globalQCList.size() == 0)
        return null;
    List<Injection> injections = intensityMatrix.getInjectionsBySample(globalQCList.get(0));

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (Injection one : injections) {
        dataset.add(Arrays.asList(intensityMatrix.getColumn(one)).stream().map((o) -> ((Double) o))
                .collect(Collectors.toList()), "Intensity", one.toString());
    }// w  ww.  j a  va 2 s.  com

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Global QC " + globalQCList.get(0).toString(),
            "Injection", "Intensity", dataset, true);
    chart.getCategoryPlot().getDomainAxis()
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2));
    return chart;
}

From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java

/**
 * DOC Zqin Comment method "createBoxAndWhiskerChart".
 * //from  ww w. j  ava2s .  co m
 * @param title
 * @param dataset
 * @return
 */
public static JFreeChart createBoxAndWhiskerChart(String title, BoxAndWhiskerCategoryDataset dataset) {
    // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    // TDQ-5112~
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, title,
            Messages.getString("TopChartFactory.Value"), dataset, false); //$NON-NLS-1$
    CategoryPlot plot = chart.getCategoryPlot();

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(false);

    double min = dataset.getMinRegularValue("0", "").doubleValue(); //$NON-NLS-1$ //$NON-NLS-2$
    double max = dataset.getMaxRegularValue("0", "").doubleValue(); //$NON-NLS-1$ //$NON-NLS-2$

    double unit = (max - min) / 10;
    rangeAxis.setRange(min - unit, max + unit);
    rangeAxis.setTickUnit(new NumberTickUnit(unit));

    BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) plot.getRenderer();
    renderer.setArtifactPaint(ChartDecorator.COLOR_LIST.get(1));

    return chart;
}

From source file:playground.christoph.evacuation.analysis.EvacuationTimePictureWriter.java

private JFreeChart createBoxplotChart(List<Double> travelTimes) {

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    dataset.add(travelTimes, "Series", "");

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, "evacuation travel time", dataset,
            false);/*from  w  w  w.  java  2 s . c  o m*/
    chart.getCategoryPlot().setForegroundAlpha(0.75f);
    return chart;
}

From source file:msi.gama.outputs.layers.ChartLayerStatement.java

private void createChart(final IScope scope) {
    switch (type) {
    case SERIES_CHART: {
        chart = ChartFactory.createXYLineChart(getName(), "time", "", null, PlotOrientation.VERTICAL, true,
                false, false);//from   w w  w .  ja v  a  2 s .c om
        break;
    }
    case PIE_CHART: {
        if (style.equals(IKeyword.THREE_D)) {
            chart = ChartFactory.createPieChart3D(getName(), null, false, true, false);
        } else if (style.equals(IKeyword.RING)) {
            chart = ChartFactory.createRingChart(getName(), null, false, true, false);
        } else if (style.equals(IKeyword.EXPLODED)) {
            chart = ChartFactory.createPieChart(getName(), null, false, true, false);
            exploded = true;
        } else {
            chart = ChartFactory.createPieChart(getName(), null, false, true, false);
        }
        break;
    }
    case HISTOGRAM_CHART: {
        if (style.equals(IKeyword.THREE_D)) {
            chart = ChartFactory.createBarChart3D(getName(), null, null, null, PlotOrientation.VERTICAL, true,
                    true, false);
        } else if (style.equals(IKeyword.STACK)) {
            chart = ChartFactory.createStackedBarChart(getName(), null, null, null, PlotOrientation.VERTICAL,
                    true, true, false);
        } else {
            chart = ChartFactory.createBarChart(getName(), null, null, null, PlotOrientation.VERTICAL, true,
                    true, false);
        }
        break;
    }
    case XY_CHART:
        chart = ChartFactory.createXYLineChart(getName(), "", "", null, PlotOrientation.VERTICAL, true, false,
                false);
        break;
    case SCATTER_CHART:
        chart = ChartFactory.createXYLineChart(getName(), "", "", null, PlotOrientation.VERTICAL, true, false,
                false);
        break;
    case BOX_WHISKER_CHART: {
        chart = ChartFactory.createBoxAndWhiskerChart(getName(), "Time", "Value",
                (BoxAndWhiskerCategoryDataset) dataset, true);
        chart.setBackgroundPaint(new Color(249, 231, 236));

        break;
    }
    }
    Plot plot = chart.getPlot();
    chart.getTitle().setFont(getTitleFont());
    if (backgroundColor == null) {
        plot.setBackgroundPaint(null);
        chart.setBackgroundPaint(null);
        chart.setBorderPaint(null);
        if (chart.getLegend() != null) {
            chart.getLegend().setBackgroundPaint(null);
        }
    } else {
        Color bg = backgroundColor;
        chart.setBackgroundPaint(bg);
        plot.setBackgroundPaint(bg);
        chart.setBorderPaint(bg);
        if (chart.getLegend() != null) {
            chart.getLegend().setBackgroundPaint(bg);
        }
    }
    // chart.getLegend().setItemPaint(axesColor);
    // chart.getLegend().setBackgroundPaint(null);

    if (plot instanceof CategoryPlot) {
        final CategoryPlot pp = (CategoryPlot) chart.getPlot();
        pp.setDomainGridlinePaint(axesColor);
        pp.setRangeGridlinePaint(axesColor);
        // plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
        // plot.setDomainCrosshairVisible(true);
        pp.setRangeCrosshairVisible(true);
    } else if (plot instanceof XYPlot) {
        final XYPlot pp = (XYPlot) chart.getPlot();
        pp.setDomainGridlinePaint(axesColor);
        pp.setRangeGridlinePaint(axesColor);
        pp.setDomainCrosshairPaint(axesColor);
        pp.setRangeCrosshairPaint(axesColor);
        pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
        pp.setDomainCrosshairVisible(true);
        pp.setRangeCrosshairVisible(true);
    }
}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

private byte[] generateBoxAndWhiskerChart(BoxAndWhiskerCategoryDataset dataset, int width, int height) {
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, null, dataset, false);

    // set background
    chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);//w ww. j  a va 2s.com
    chart.setBorderPaint(parseColor("#cccccc"));

    // set anti alias
    chart.setAntiAlias(true);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis();
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        log.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}