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