use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class BoxPlot method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart();
chart.getConfiguration().setTitle("Box Plot Example");
Legend legend = new Legend();
legend.setEnabled(false);
chart.getConfiguration().setLegend(legend);
XAxis xaxis = chart.getConfiguration().getxAxis();
xaxis.setTitle("Experiment No.");
xaxis.setCategories("1", "2", "3", "4", "5");
YAxis yAxis = chart.getConfiguration().getyAxis();
yAxis.setTitle("Observations");
PlotLine plotLine = new PlotLine();
plotLine.setValue(932);
plotLine.setZIndex(0);
Label label = new Label("Theoretical mean: 932");
label.setAlign(HorizontalAlign.CENTER);
plotLine.setLabel(label);
yAxis.setPlotLines(plotLine);
final DataSeries observations = new DataSeries();
observations.setName("Observations");
// Add PlotBoxItems contain all fields relevant for plot box chart
observations.add(new BoxPlotItem(760, 801, 848, 895, 965));
// Example with no arg constructor
BoxPlotItem plotBoxItem = new BoxPlotItem();
plotBoxItem.setLow(733);
plotBoxItem.setLowerQuartile(853);
plotBoxItem.setMedian(939);
plotBoxItem.setUpperQuartile(980);
plotBoxItem.setHigh(1080);
observations.add(plotBoxItem);
observations.add(new BoxPlotItem(714, 762, 817, 870, 918));
observations.add(new BoxPlotItem(724, 802, 806, 871, 950));
observations.add(new BoxPlotItem(834, 836, 864, 882, 910));
PlotOptionsBoxplot plotOptions = new PlotOptionsBoxplot();
SeriesTooltip observationsTooltip = new SeriesTooltip();
observationsTooltip.setHeaderFormat("<em>Experiment No {point.key}</em><br/>");
plotOptions.setTooltip(observationsTooltip);
observations.setPlotOptions(plotOptions);
chart.getConfiguration().addSeries(observations);
final DataSeries outlier = new DataSeries();
outlier.setName("Outlier");
outlier.add(new DataSeriesItem(0, 644));
outlier.add(new DataSeriesItem(4, 718));
outlier.add(new DataSeriesItem(4, 951));
outlier.add(new DataSeriesItem(4, 969));
PlotOptionsScatter outlierOptions = new PlotOptionsScatter();
SeriesTooltip outlierTooltip = new SeriesTooltip();
outlierTooltip.setPointFormat("Observation: {point.y}");
outlierOptions.setTooltip(outlierTooltip);
outlier.setPlotOptions(outlierOptions);
chart.getConfiguration().addSeries(outlier);
Checkbox useCustomStyles = new Checkbox("Use custom styling");
useCustomStyles.addValueChangeListener(e -> {
PlotOptionsBoxplot options = new PlotOptionsBoxplot();
if (e.getValue()) {
options.setClassName("custom-style");
options.setWhiskerLength("70");
}
observations.setPlotOptions(options);
chart.drawChart(true);
});
add(chart, useCustomStyles);
}
use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class DynamicChangingChart method getFunnelConfiguration.
private Configuration getFunnelConfiguration() {
DataSeries dataSeries = new DataSeries("Unique users");
dataSeries.add(new DataSeriesItem("Website visits", 15654));
dataSeries.add(new DataSeriesItem("Downloads", 4064));
dataSeries.add(new DataSeriesItem("Requested price list", 1987));
dataSeries.add(new DataSeriesItem("Invoice sent", 976));
dataSeries.add(new DataSeriesItem("Finalized", 846));
Configuration configuration = new Configuration();
configuration.setTitle("Sales funnel");
configuration.getLegend().setEnabled(false);
PlotOptionsFunnel options = new PlotOptionsFunnel();
options.setReversed(false);
options.setNeckWidth("30%");
options.setNeckHeight("30%");
options.setWidth("70%");
DataLabelsFunnel dataLabels = new DataLabelsFunnel();
dataLabels.setFormat("<b>{point.name}</b> ({point.y:,.0f})");
options.setDataLabels(dataLabels);
dataSeries.setPlotOptions(options);
configuration.addSeries(dataSeries);
return configuration;
}
use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class FunnelChart method initDemo.
@Override
public void initDemo() {
DataSeries dataSeries = new DataSeries("Unique users");
dataSeries.add(new DataSeriesItem("Website visits", 15654));
dataSeries.add(new DataSeriesItem("Downloads", 4064));
dataSeries.add(new DataSeriesItem("Requested price list", 1987));
dataSeries.add(new DataSeriesItem("Invoice sent", 976));
dataSeries.add(new DataSeriesItem("Finalized", 846));
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
conf.setTitle("Sales funnel");
conf.getLegend().setEnabled(false);
PlotOptionsFunnel options = new PlotOptionsFunnel();
options.setReversed(false);
options.setNeckWidth("30%");
options.setNeckHeight("30%");
options.setWidth("70%");
DataLabelsFunnel dataLabels = new DataLabelsFunnel();
dataLabels.setFormat("<b>{point.name}</b> ({point.y:,.0f})");
options.setDataLabels(dataLabels);
dataSeries.setPlotOptions(options);
conf.addSeries(dataSeries);
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class ColumnWithNativeLazyDrilldown method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
conf = chart.getConfiguration();
conf.setTitle("Browser market share, April, 2011");
conf.setSubTitle("Click the columns to view versions. Click again to view brands.");
conf.getLegend().setEnabled(false);
XAxis x = new XAxis();
x.setType(AxisType.CATEGORY);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setTitle("Total percent market share");
conf.addyAxis(y);
PlotOptionsColumn column = new PlotOptionsColumn();
column.setCursor(Cursor.POINTER);
column.setDataLabels(new DataLabels(true));
// column.getDataLabels().setFormatter("this.y +'%'");
conf.setPlotOptions(column);
Tooltip tooltip = new Tooltip();
tooltip.setHeaderFormat("<span style=\"font-size:11px\">{series.name}</span><br>");
tooltip.setPointFormat("<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>");
conf.setTooltip(tooltip);
DataSeries series = new DataSeries();
series.setName("Browser brands");
PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
plotOptionsColumn.setColorByPoint(true);
series.setPlotOptions(plotOptionsColumn);
DataSeriesItem item = new DataSeriesItem("MSIE", 55.11);
item.setId("MSIE");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Firefox", 21.63);
item.setId("Firefox");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Chrome", 11.94);
item.setId("Chrome");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Safari", 7.15);
item.setId("Safari");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Opera", 2.14);
item.setId("Opera");
series.addItemWithDrilldown(item);
conf.addSeries(series);
drillSeries = new HashMap<String, DataSeries>();
DataSeries drill = new DataSeries("MSIE versions");
String[] categories = new String[] { "MSIE 6.0", "MSIE 7.0", "MSIE 8.0", "MSIE 9.0" };
Number[] ys = new Number[] { 10.85, 7.35, 33.06, 2.81 };
drill.setData(categories, ys);
drillSeries.put("MSIE", drill);
drill = new DataSeries("Firefox versions");
categories = new String[] { "Firefox 2.0", "Firefox 3.0", "Firefox 3.5", "Firefox 3.6", "Firefox 4.0" };
ys = new Number[] { 0.20, 0.83, 1.58, 13.12, 5.43 };
drill.setData(categories, ys);
drillSeries.put("Firefox", drill);
drill = new DataSeries("Chrome versions");
categories = new String[] { "Chrome 5.0", "Chrome 6.0", "Chrome 7.0", "Chrome 8.0", "Chrome 9.0", "Chrome 10.0", "Chrome 11.0", "Chrome 12.0" };
ys = new Number[] { 0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22 };
drill.setData(categories, ys);
drillSeries.put("Chrome", drill);
drill = new DataSeries("Safari versions");
categories = new String[] { "Safari 5.0", "Safari 4.0", "Safari Win 5.0", "Safari 4.1", "Safari/Maxthon", "Safari 3.1", "Safari 4.1" };
ys = new Number[] { 4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14 };
drill.setData(categories, ys);
drillSeries.put("Safari", drill);
drill = new DataSeries("Opera versions");
categories = new String[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" };
ys = new Number[] { 0.12, 0.37, 1.65 };
drill.setData(categories, ys);
drillSeries.put("Opera", drill);
chart.setDrilldownCallback(event -> getPointDrilldown(event.getItem()));
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataSeriesItem in project flow-components by vaadin.
the class ColumnRange method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.COLUMNRANGE);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Temperature variation by day");
DataSeries dataSeries = new DataSeries("Temperatures");
for (StockPrices.RangeData data : StockPrices.fetchDailyTempRanges()) {
dataSeries.add(new DataSeriesItem(data.getDate(), data.getMin(), data.getMax()));
}
configuration.setSeries(dataSeries);
RangeSelector rangeSelector = new RangeSelector();
rangeSelector.setSelected(2);
configuration.setRangeSelector(rangeSelector);
chart.setTimeline(true);
add(chart);
}
Aggregations