Search in sources :

Example 26 with PlotOptionsLine

use of com.vaadin.addon.charts.model.PlotOptionsLine in project charts by vaadin.

the class LineWithMissingPoint method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getChart().setMarginRight(130);
    configuration.getChart().setMarginBottom(25);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(-5d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.HIGH);
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    configuration.setPlotOptions(plotOptions);
    Legend legend = configuration.getLegend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-10d);
    legend.setY(100d);
    legend.setBorderWidth(0);
    DataSeries ds = new DataSeries();
    DataSeriesItem item = new DataSeriesItem(1, 2);
    item.setName("a");
    ds.add(item);
    item = new DataSeriesItem(2, 2);
    item.setName("b");
    ds.add(item);
    item = new DataSeriesItem(3, 2);
    item.setName("c");
    ds.add(item);
    item = new DataSeriesItem(4, null);
    item.setName("d");
    ds.add(item);
    item = new DataSeriesItem(5, 2);
    item.setName("e");
    ds.add(item);
    item = new DataSeriesItem(6, 2);
    item.setName("f");
    ds.add(item);
    configuration.addSeries(ds);
    chart.drawChart(configuration);
    System.out.println(configuration);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 27 with PlotOptionsLine

use of com.vaadin.addon.charts.model.PlotOptionsLine in project charts by vaadin.

the class StepLines method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration configuration = chart.getConfiguration();
    configuration.setTitle("Step lines");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    ListSeries ls = new ListSeries();
    ls.setName("Right");
    ls.setData(1, 2, 3, 4, null, 6, 7, null, 9);
    PlotOptionsLine options = new PlotOptionsLine();
    options.setStep(StepType.RIGHT);
    ls.setPlotOptions(options);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("Center");
    ls.setData(5, 6, 7, 8, null, 10, 11, null, 13);
    options = new PlotOptionsLine();
    options.setStep(StepType.CENTER);
    ls.setPlotOptions(options);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("Left");
    ls.setData(9, 10, 11, 12, null, 14, 15, null, 17);
    options = new PlotOptionsLine();
    options.setStep(StepType.LEFT);
    ls.setPlotOptions(options);
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Chart(com.vaadin.addon.charts.Chart)

Example 28 with PlotOptionsLine

use of com.vaadin.addon.charts.model.PlotOptionsLine in project charts by vaadin.

the class ContainerSeriesJSONSerializationTest method serialize_ContainerWithLinePlotOptions_PlotOptionsAndTypeSerialized.

@Test
public void serialize_ContainerWithLinePlotOptions_PlotOptionsAndTypeSerialized() {
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setShowInLegend(true);
    containerSeries.setPlotOptions(plotOptions);
    Configuration config = new Configuration();
    config.addSeries(containerSeries);
    assertEquals("{\"type\":\"line\",\"showInLegend\":true,\"data\":[]}", toJSON(containerSeries));
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Test(org.junit.Test)

Example 29 with PlotOptionsLine

use of com.vaadin.addon.charts.model.PlotOptionsLine in project charts by vaadin.

the class ChartConfiguration method plotOptionsSnippet3.

public void plotOptionsSnippet3(Configuration configuration) {
    PlotOptionsSpline lineOptions = new PlotOptionsSpline();
    PlotOptionsLine splineOptions = new PlotOptionsLine();
    setCommonProperties(lineOptions);
    setCommonProperties(splineOptions);
    configuration.setPlotOptions(lineOptions, splineOptions);
}
Also used : PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline)

Example 30 with PlotOptionsLine

use of com.vaadin.addon.charts.model.PlotOptionsLine in project charts by vaadin.

the class ChartData method listSeriesSnippet1.

public void listSeriesSnippet1(Configuration conf) {
    ListSeries series = new ListSeries("Total Reindeer Population", 181091, 201485, 188105);
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setPointStart(1959);
    series.setPlotOptions(plotOptions);
    conf.addSeries(series);
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine)

Aggregations

PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)33 Configuration (com.vaadin.addon.charts.model.Configuration)25 Chart (com.vaadin.addon.charts.Chart)21 ListSeries (com.vaadin.addon.charts.model.ListSeries)19 YAxis (com.vaadin.addon.charts.model.YAxis)13 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)10 DataLabels (com.vaadin.addon.charts.model.DataLabels)9 Test (org.junit.Test)9 DataSeries (com.vaadin.addon.charts.model.DataSeries)7 Legend (com.vaadin.addon.charts.model.Legend)6 Marker (com.vaadin.addon.charts.model.Marker)5 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)4 XAxis (com.vaadin.addon.charts.model.XAxis)4 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)3 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)3 Elements (org.jsoup.select.Elements)3 Hover (com.vaadin.addon.charts.model.Hover)2 Labels (com.vaadin.addon.charts.model.Labels)2 Pane (com.vaadin.addon.charts.model.Pane)2 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)2