예제 #1
0
  private Chart createChart(int points) {
    Chart chart = new Chart(ChartType.SCATTER);
    Configuration conf = chart.getConfiguration();

    conf.getChart().setZoomType(ZoomType.XY);
    conf.disableCredits();
    conf.setTitle("Height vs Weight");
    conf.setSubTitle("Polygon series in Vaadin Charts.");

    Tooltip tooltip = conf.getTooltip();
    tooltip.setHeaderFormat("{series.name}");
    tooltip.setPointFormat("{point.x} cm, {point.y} kg");

    XAxis xAxis = conf.getxAxis();
    xAxis.setStartOnTick(true);
    xAxis.setEndOnTick(true);
    xAxis.setShowLastLabel(true);
    xAxis.setTitle("Height (cm)");

    YAxis yAxis = conf.getyAxis();
    yAxis.setTitle("Weight (kg)");

    AbstractLinePlotOptions plotOptions = new PlotOptionsScatter();
    plotOptions.setThreshold(0);
    DataSeries scatter = new DataSeries();
    scatter.setPlotOptions(plotOptions);
    scatter.setName("Observations");
    fillScatter(scatter, points);
    conf.addSeries(scatter);
    return chart;
  }
예제 #2
0
  @Override
  protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");

    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Logarithmic axis demo");

    configuration.getxAxis().setTickInterval(1);

    YAxis yAxis = configuration.getyAxis();
    yAxis.setType(AxisType.LOGARITHMIC);
    yAxis.setMinorTickInterval("0.1");

    configuration.getTooltip().setHeaderFormat("<b>{series.name}</b><br />");
    configuration.getTooltip().setPointFormat("x = {point.x}, y = {point.y}");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setPointStart(1);
    configuration.setPlotOptions(plotOptions);

    ListSeries ls = new ListSeries(1, 2, 4, 8, 16, 32, 64, 128, 256, 512);
    configuration.setSeries(ls);

    chart.drawChart(configuration);
    return chart;
  }
예제 #3
0
  @Override
  protected Component getChart() {

    Chart chart = new Chart();

    Configuration config = chart.getConfiguration();
    config.getChart().setType(ChartType.HEATMAP);
    config.getChart().setMarginTop(40);
    config.getChart().setMarginBottom(40);

    config.getTitle().setText("Sales per employee per weekday");

    config
        .getxAxis()
        .setCategories(
            "Marta",
            "Mysia",
            "Misiek",
            "Maniek",
            "Miki",
            "Guillermo",
            "Jonatan",
            "Zdzisław",
            "Antoni",
            "Zygmunt");
    config.getyAxis().setCategories("Monday", "Tuesday", "Wednesday", "Thursday", "Friday");

    config.getColorAxis().setMin(0);
    config.getColorAxis().setMinColor(SolidColor.WHITE);
    config.getColorAxis().setMaxColor(getThemeColors()[0]);

    config.getLegend().setLayout(LayoutDirection.VERTICAL);
    config.getLegend().setAlign(HorizontalAlign.RIGHT);
    config.getLegend().setMargin(0);
    config.getLegend().setVerticalAlign(VerticalAlign.TOP);
    config.getLegend().setY(25);
    config.getLegend().setSymbolHeight(320);

    HeatSeries rs = new HeatSeries("Sales per employee", getRawData());

    PlotOptionsHeatmap plotOptionsHeatmap = new PlotOptionsHeatmap();
    plotOptionsHeatmap.setDataLabels(new DataLabels());
    plotOptionsHeatmap.getDataLabels().setEnabled(true);

    SeriesTooltip tooltip = new SeriesTooltip();
    tooltip.setHeaderFormat("{series.name}<br/>");
    tooltip.setPointFormat("Amount: <b>{point.value}</b> ");
    plotOptionsHeatmap.setTooltip(tooltip);
    config.setPlotOptions(plotOptionsHeatmap);

    config.setSeries(rs);

    chart.drawChart(config);

    return chart;
  }
  @Override
  protected Component getChart() {
    Chart mychart = new Chart();

    Configuration configuration = mychart.getConfiguration();
    configuration.getChart().setType(ChartType.COLUMN);
    configuration.getxAxis().setType(AxisType.CATEGORY);

    // series have points for different categories, no series is complete
    // (#13050)
    configuration.setSeries(
        new DataSeries(new DataSeriesItem("X", 6)),
        new DataSeries(new DataSeriesItem("X", 5)),
        new DataSeries(new DataSeriesItem("Y", 4)),
        new DataSeries(new DataSeriesItem("X", 3)),
        new DataSeries(new DataSeriesItem("X", 2)),
        new DataSeries(new DataSeriesItem("X", 1)));

    return mychart;
  }