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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations