Beispiel #1
0
  @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);
    PlotBandLabel label = new PlotBandLabel("Theoretical mean: 932");
    label.setAlign(HorizontalAlign.CENTER);
    Style style = new Style();
    style.setColor(new SolidColor("gray"));
    label.setStyle(style);
    plotLine.setLabel(label);
    yAxis.setPlotLines(plotLine);

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