use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class ColumnWithNativeLazyDrilldownMultipleSeries method createSeries.
private void createSeries(int index) {
DataSeries series = new DataSeries();
DataSeriesItem item = new DataSeriesItem("MSIE", 55.11 - index - index - index);
item.setId("MSIE" + index);
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Firefox", 21.63 - index);
item.setId("Firefox" + index);
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Chrome", 11.94 + index);
item.setId("Chrome" + index);
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Safari", 7.15 + index + index);
item.setId("Safari" + index);
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Opera", 2.14 + index);
item.setId("Opera" + index);
series.addItemWithDrilldown(item);
conf.addSeries(series);
}
use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class ColumnLineAndPie method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
conf.setTitle("Combined Chart");
conf.setExporting(true);
XAxis x = new XAxis();
x.setCategories(new String[] { "Apples", "Oranges", "Pears", "Bananas", "Plums" });
conf.addxAxis(x);
Style labelStyle = new Style();
labelStyle.setTop("8px");
labelStyle.setLeft("40px");
conf.setLabels(new HTMLLabels(labelStyle, new HTMLLabelItem("Total fruit consumption")));
DataSeries series = new DataSeries();
PlotOptionsColumn plotOptions = new PlotOptionsColumn();
series.setPlotOptions(plotOptions);
series.setName("Jane");
series.setData(3, 2, 1, 3, 4);
conf.addSeries(series);
series = new DataSeries();
plotOptions = new PlotOptionsColumn();
series.setPlotOptions(plotOptions);
series.setName("John");
series.setData(2, 3, 5, 7, 6);
conf.addSeries(series);
series = new DataSeries();
plotOptions = new PlotOptionsColumn();
series.setPlotOptions(plotOptions);
series.setName("Joe");
series.setData(4, 3, 3, 9, 0);
conf.addSeries(series);
series = new DataSeries();
PlotOptionsSpline splinePlotOptions = new PlotOptionsSpline();
series.setPlotOptions(splinePlotOptions);
series.setName("Average");
series.setData(3, 2.67, 3, 6.33, 3.33);
conf.addSeries(series);
series = new DataSeries();
series.setPlotOptions(new PlotOptionsPie());
series.setName("Total consumption");
DataSeriesItem item = new DataSeriesItem("Jane", 13);
series.add(item);
item = new DataSeriesItem("John", 23);
series.add(item);
item = new DataSeriesItem("Joe", 19);
series.add(item);
PlotOptionsPie plotOptionsPie = new PlotOptionsPie();
plotOptionsPie.setSize("100px");
plotOptionsPie.setCenter("100px", "80px");
plotOptionsPie.setShowInLegend(false);
series.setPlotOptions(plotOptionsPie);
conf.addSeries(series);
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class ScatterAndPolygon method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.SCATTER);
Configuration conf = chart.getConfiguration();
chart.setId("chart");
conf.getChart().setZoomType(Dimension.XY);
conf.disableCredits();
conf.setTitle("Height vs Weight");
conf.setSubTitle("Polygon series in Vaadin Charts.");
Tooltip tooltip = conf.getTooltip();
tooltip.setHeaderFormat("<b>{series.name}</b><br>");
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)");
PlotOptionsScatter plotOptionsScatter = new PlotOptionsScatter();
DataSeries scatter = new DataSeries();
scatter.setPlotOptions(plotOptionsScatter);
scatter.setName("Observations");
fillScatter(scatter);
DataSeries polygon = new DataSeries();
PlotOptionsPolygon plotOptionsPolygon = new PlotOptionsPolygon();
plotOptionsPolygon.setEnableMouseTracking(false);
polygon.setPlotOptions(plotOptionsPolygon);
polygon.setName("Target");
polygon.add(new DataSeriesItem(153, 42));
polygon.add(new DataSeriesItem(149, 46));
polygon.add(new DataSeriesItem(149, 55));
polygon.add(new DataSeriesItem(152, 60));
polygon.add(new DataSeriesItem(159, 70));
polygon.add(new DataSeriesItem(170, 77));
polygon.add(new DataSeriesItem(180, 70));
polygon.add(new DataSeriesItem(180, 60));
polygon.add(new DataSeriesItem(173, 52));
polygon.add(new DataSeriesItem(166, 45));
conf.addSeries(polygon);
conf.addSeries(scatter);
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class ScatterAndPolygon method fillScatter.
private void fillScatter(DataSeries series) {
// NOSONAR
Random random = new Random(13);
for (int i = 0; i < 100; i++) {
double x = random.nextDouble() * 30 + 150;
double y = 60;
if (random.nextBoolean()) {
y += random.nextDouble() * 15;
if (random.nextBoolean() && x > 170) {
y += random.nextDouble() * 30;
}
} else {
y -= random.nextDouble() * 20;
}
series.add(new DataSeriesItem(x, y));
}
}
use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class DynamicChanges method getInitialData.
private List<DataSeriesItem> getInitialData() {
List<DataSeriesItem> data = new ArrayList<>();
data.add(new DataSeriesItem("Firefox", 45.0));
data.add(new DataSeriesItem("IE", 26.8));
DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
chrome.setSliced(true);
chrome.setSelected(true);
data.add(chrome);
data.add(new DataSeriesItem("Safari", 8.5));
data.add(new DataSeriesItem("Opera", 6.2));
data.add(new DataSeriesItem("Others", 0.7));
return data;
}
Aggregations