use of com.vaadin.flow.component.charts.model.PlotOptionsPie in project flow-components by vaadin.
the class PieWithLegend method initDemo.
@Override
public void initDemo() {
chart = new Chart(ChartType.PIE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Browser market shares in January, 2018");
Tooltip tooltip = new Tooltip();
tooltip.setValueDecimals(1);
conf.setTooltip(tooltip);
PlotOptionsPie plotOptions = new PlotOptionsPie();
plotOptions.setAllowPointSelect(true);
plotOptions.setCursor(Cursor.POINTER);
plotOptions.setShowInLegend(true);
conf.setPlotOptions(plotOptions);
DataSeries series = new DataSeries();
DataSeriesItem chrome = new DataSeriesItem("Chrome", 61.41);
chrome.setSliced(true);
chrome.setSelected(true);
series.add(chrome);
series.add(new DataSeriesItem("Internet Explorer", 11.84));
series.add(new DataSeriesItem("Firefox", 10.85));
series.add(new DataSeriesItem("Edge", 4.67));
series.add(new DataSeriesItem("Safari", 4.18));
series.add(new DataSeriesItem("Sogou Explorer", 1.64));
series.add(new DataSeriesItem("Opera", 6.2));
series.add(new DataSeriesItem("QQ", 1.2));
series.add(new DataSeriesItem("Others", 2.61));
conf.setSeries(series);
chart.setVisibilityTogglingDisabled(true);
listenerRegistration = chart.addPointLegendItemClickListener(event -> {
showNotification("Legend item click" + " : " + event.getItemIndex() + " : " + event.getItem().getName());
});
add(chart);
}
use of com.vaadin.flow.component.charts.model.PlotOptionsPie in project flow-components by vaadin.
the class ConfigurationJSONSerializationTest method configurationJSONSerialization_setOptionsWithInactiveState_inactiveStatesSerialized.
@Test
public void configurationJSONSerialization_setOptionsWithInactiveState_inactiveStatesSerialized() {
Configuration conf = new Configuration();
PlotOptionsPie options = new PlotOptionsPie();
States states = options.getStates();
Inactive inactive = states.getInactive();
inactive.setOpacity(1.0);
inactive.setBorderColor(new SolidColor("#000000"));
inactive.setColor(new SolidColor("#808080"));
inactive.setAnimation(false);
conf.setPlotOptions(options);
assertEquals("{\"chart\":{\"styledMode\":false},\"plotOptions\":{\"pie\":{\"states\":{\"inactive\":{\"animation\":false,\"borderColor\":\"#000000\",\"color\":\"#808080\",\"opacity\":1.0}}}},\"series\":[],\"exporting\":{\"enabled\":false}}", toJSON(conf));
}
use of com.vaadin.flow.component.charts.model.PlotOptionsPie 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.PlotOptionsPie in project flow-components by vaadin.
the class SVGGeneratorTest method createPieChartConfiguration.
private Configuration createPieChartConfiguration() {
Configuration conf = new Configuration();
conf.setTitle("Browser market shares in January, 2018");
conf.getChart().setType(ChartType.PIE);
Tooltip tooltip = new Tooltip();
tooltip.setValueDecimals(1);
conf.setTooltip(tooltip);
PlotOptionsPie plotOptions = new PlotOptionsPie();
plotOptions.setAllowPointSelect(true);
plotOptions.setCursor(Cursor.POINTER);
plotOptions.setShowInLegend(true);
conf.setPlotOptions(plotOptions);
DataSeries series = new DataSeries();
DataSeriesItem chrome = new DataSeriesItem("Chrome", 61.41);
chrome.setSliced(true);
chrome.setSelected(true);
series.add(chrome);
series.add(new DataSeriesItem("Internet Explorer", 11.84));
series.add(new DataSeriesItem("Firefox", 10.85));
series.add(new DataSeriesItem("Edge", 4.67));
series.add(new DataSeriesItem("Safari", 4.18));
series.add(new DataSeriesItem("Sogou Explorer", 1.64));
series.add(new DataSeriesItem("Opera", 6.2));
series.add(new DataSeriesItem("QQ", 1.2));
series.add(new DataSeriesItem("Others", 2.61));
conf.setSeries(series);
return conf;
}
Aggregations