use of com.vaadin.addon.charts.model.DataProviderSeries in project charts by vaadin.
the class ChartWithExternalDataProvider method createChartDataSeries2.
private DataProviderSeries<Order> createChartDataSeries2(DataProvider<Order, ?> dataProvider) {
DataProviderSeries<Order> chartDS = new DataProviderSeries<>(dataProvider);
chartDS.setName("Order item prices");
chartDS.setPlotOptions(new PlotOptionsColumn());
chartDS.setY(order -> order.getItemPrice().intValue());
chartDS.setPointName(Order::getDescription);
return chartDS;
}
use of com.vaadin.addon.charts.model.DataProviderSeries in project charts by vaadin.
the class ChartWithExternalDataProvider method createChartDataSeries1.
private DataProviderSeries<Order> createChartDataSeries1(DataProvider<Order, ?> dataProvider) {
DataProviderSeries<Order> chartDS = new DataProviderSeries<>(dataProvider);
chartDS.setName("Order item quantities");
chartDS.setPlotOptions(new PlotOptionsPie());
chartDS.setY(Order::getQuantity);
chartDS.setPointName(Order::getDescription);
return chartDS;
}
use of com.vaadin.addon.charts.model.DataProviderSeries in project charts by vaadin.
the class DataProviderSeriesWithSpline method getChart.
@Override
protected Component getChart() {
// Create container with two points
Collection<TestItem> col = new ArrayList<>();
DataProvider<TestItem, ?> ds = new ListDataProvider<>(col);
LocalDateTime dateTime = LocalDateTime.of(2013, 3, 22, 12, 00);
col.add(new TestItem(dateTime.toInstant(ZoneOffset.UTC), 5));
dateTime = dateTime.plusDays(1);
col.add(new TestItem(dateTime.toInstant(ZoneOffset.UTC), 10));
dateTime = dateTime.plusDays(1);
col.add(new TestItem(dateTime.toInstant(ZoneOffset.UTC), 5));
DataProviderSeries<TestItem> chartDataSeries = new DataProviderSeries<>(ds);
chartDataSeries.setX(TestItem::getDate);
chartDataSeries.setY(TestItem::getValue);
// Create chart and render
Chart chart = new Chart();
// Create chart config
Configuration config = chart.getConfiguration();
config.getxAxis().setType(AxisType.DATETIME);
// Wrap container in a container data series
chartDataSeries.setPlotOptions(new PlotOptionsSpline());
// Add points to series
config.addSeries(chartDataSeries);
chart.setSizeFull();
chart.drawChart(config);
return chart;
}
use of com.vaadin.addon.charts.model.DataProviderSeries in project charts by vaadin.
the class ColoredContainerSeries method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.AREA);
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Colored ContainerDataSeries"));
conf.addxAxis(new XAxis());
YAxis yAxis = new YAxis();
yAxis.setTitle("Numbers");
conf.addyAxis(yAxis);
Collection<Test> col = new ArrayList<>();
col.add(new Test(10, "TEN"));
col.add(new Test(11, "ELEVEN"));
col.add(new Test(12, "TWELVE"));
DataProvider<Test, ?> ds = new ListDataProvider<>(col);
DataProviderSeries<Test> chartDS = new DataProviderSeries<>(ds);
chartDS.setName("Test Series");
chartDS.setY(Test::getNumber);
chartDS.setPointName(Test::getName);
PlotOptionsArea plotOptions = new PlotOptionsArea();
plotOptions.setFillColor(SolidColor.CORNFLOWERBLUE);
plotOptions.setColor(SolidColor.GOLDENROD);
chartDS.setPlotOptions(plotOptions);
// conf.setPlotOptions(plotOptions);
conf.setSeries(chartDS);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.DataProviderSeries in project charts by vaadin.
the class ConfigurationTest method setSeries_containerDataSeriesWithName_NameAppearsInLegend.
@Test
public void setSeries_containerDataSeriesWithName_NameAppearsInLegend() {
Configuration conf = new Configuration();
conf.getChart().setType(ChartType.AREA);
XAxis xAxis = new XAxis();
xAxis.setCategories("A", "B", "C", "D", "E");
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
AxisTitle title = new AxisTitle();
title.setText("Numbers");
yAxis.setTitle(title);
conf.addyAxis(yAxis);
DataProviderSeries<Pair> ds = new DataProviderSeries<>(createDataProvider());
ds.setName("Test Series1");
ds.setY(Pair::getValue);
ds.setPointName(Pair::getName);
// if a 'plotOptionsArea' is not set, the name of this series will not
// be shown in legend
// containerDataSeries1.setPlotOptions(new PlotOptionsArea());
conf.setSeries(ds);
Assert.assertTrue(toJSON(conf).contains("Test Series1"));
}
Aggregations