Search in sources :

Example 1 with BoxPlotItem

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;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Label(com.vaadin.addon.charts.model.Label) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DashStyle(com.vaadin.addon.charts.model.DashStyle) Style(com.vaadin.addon.charts.model.style.Style) PlotLine(com.vaadin.addon.charts.model.PlotLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis) BoxPlotItem(com.vaadin.addon.charts.model.BoxPlotItem)

Example 2 with BoxPlotItem

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);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) BoxPlotItem(com.vaadin.addon.charts.model.BoxPlotItem)

Aggregations

Chart (com.vaadin.addon.charts.Chart)2 BoxPlotItem (com.vaadin.addon.charts.model.BoxPlotItem)2 DataSeries (com.vaadin.addon.charts.model.DataSeries)2 Configuration (com.vaadin.addon.charts.model.Configuration)1 DashStyle (com.vaadin.addon.charts.model.DashStyle)1 Label (com.vaadin.addon.charts.model.Label)1 Legend (com.vaadin.addon.charts.model.Legend)1 PlotLine (com.vaadin.addon.charts.model.PlotLine)1 XAxis (com.vaadin.addon.charts.model.XAxis)1 YAxis (com.vaadin.addon.charts.model.YAxis)1 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)1 Style (com.vaadin.addon.charts.model.style.Style)1