use of com.vaadin.addon.charts.model.BoxPlotItem in project charts by vaadin.
the class BoxPlotExample method getChart.
@Override
protected Component getChart() {
chart = new Chart();
chart.getConfiguration().setTitle("Box Plot Example");
Legend legend = new Legend();
legend.setEnabled(false);
chart.getConfiguration().setLegend(legend);
XAxis xaxis = chart.getConfiguration().getxAxis();
xaxis.setTitle("Experiment No.");
xaxis.setCategories("1", "2", "3", "4", "5");
YAxis yAxis = chart.getConfiguration().getyAxis();
yAxis.setTitle("Observations");
PlotLine plotLine = new PlotLine();
plotLine.setColor(new SolidColor("red"));
plotLine.setValue(932);
plotLine.setWidth(1);
plotLine.setZIndex(0);
plotLine.setDashStyle(DashStyle.DASHDOT);
Label label = new Label("Theoretical mean: 932");
label.setAlign(HorizontalAlign.CENTER);
Style style = new Style();
style.setColor(new SolidColor("gray"));
label.setStyle(style);
plotLine.setLabel(label);
PlotLine plotLine2 = new PlotLine();
plotLine2.setColor(new SolidColor("blue"));
plotLine2.setValue(800);
plotLine2.setWidth(1);
plotLine2.setZIndex(500);
plotLine2.setDashStyle(DashStyle.SHORTDASHDOTDOT);
Label label2 = new Label("Second plotline: 800");
label2.setAlign(HorizontalAlign.CENTER);
Style style2 = new Style();
style2.setColor(new SolidColor("gray"));
label2.setStyle(style2);
plotLine2.setLabel(label2);
yAxis.setPlotLines(plotLine, plotLine2);
observations = new DataSeries();
observations.setName("Observations");
// Add PlotBoxItems contain all fields relevant for plot box chart
observations.add(new BoxPlotItem(760, 801, 848, 895, 965));
// Example with no arg constructor
BoxPlotItem plotBoxItem = new BoxPlotItem();
plotBoxItem.setLow(733);
plotBoxItem.setLowerQuartile(853);
plotBoxItem.setMedian(939);
plotBoxItem.setUpperQuartile(980);
plotBoxItem.setHigh(1080);
observations.add(plotBoxItem);
observations.add(new BoxPlotItem(714, 762, 817, 870, 918));
observations.add(new BoxPlotItem(724, 802, 806, 871, 950));
observations.add(new BoxPlotItem(834, 836, 864, 882, 910));
observations.setPlotOptions(getPlotBoxOptions());
chart.getConfiguration().addSeries(observations);
return chart;
}
use of com.vaadin.addon.charts.model.BoxPlotItem in project charts by vaadin.
the class ChartTypes method chartTypesBoxplotPlotoptionsSnippet2.
public void chartTypesBoxplotPlotoptionsSnippet2() {
Chart chart = new Chart(ChartType.BOXPLOT);
Configuration conf = chart.getConfiguration();
// Orienteering control point times for runners
double[][] data = new double[5][5];
DataSeries series = new DataSeries();
for (double[] cpointtimes : data) {
StatAnalysis analysis = new StatAnalysis(cpointtimes);
series.add(new BoxPlotItem(analysis.low(), analysis.firstQuartile(), analysis.median(), analysis.thirdQuartile(), analysis.high()));
}
conf.setSeries(series);
}
Aggregations