use of com.vaadin.flow.component.charts.model.PlotOptionsSeries in project flow-components by vaadin.
the class Polar method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
conf.getChart().setPolar(true);
conf.setTitle("Polar Chart");
Pane pane = new Pane(0, 360);
conf.addPane(pane);
XAxis xAxis = new XAxis();
xAxis.setTickInterval(45);
xAxis.setMin(0);
xAxis.setMax(360);
Labels labels = new Labels();
labels.setFormatter("function() {return this.value + '°';}");
xAxis.setLabels(labels);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
conf.addxAxis(xAxis);
conf.addyAxis(yAxis);
PlotOptionsSeries series = new PlotOptionsSeries();
PlotOptionsColumn column = new PlotOptionsColumn();
series.setPointStart(0);
series.setPointInterval(45);
column.setPointPadding(0);
column.setGroupPadding(0);
conf.setPlotOptions(series, column);
ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
col.setPlotOptions(new PlotOptionsColumn());
col.setName(ChartType.COLUMN.toString());
line.setPlotOptions(new PlotOptionsLine());
line.setName(ChartType.LINE.toString());
area.setPlotOptions(new PlotOptionsArea());
area.setName(ChartType.AREA.toString());
conf.setSeries(col, line, area);
add(chart);
}
use of com.vaadin.flow.component.charts.model.PlotOptionsSeries in project flow-components by vaadin.
the class DynamicChangingChart method getPolarConfiguration.
public Configuration getPolarConfiguration() {
Configuration configuration = new Configuration();
configuration.getChart().setPolar(true);
configuration.setTitle("Polar Chart");
Pane pane = new Pane(0, 360);
configuration.addPane(pane);
XAxis xAxis = new XAxis();
xAxis.setTickInterval(45);
xAxis.setMin(0);
xAxis.setMax(360);
Labels labels = new Labels();
labels.setFormatter("function() {return this.value + '°';}");
xAxis.setLabels(labels);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
configuration.addxAxis(xAxis);
configuration.addyAxis(yAxis);
PlotOptionsSeries series = new PlotOptionsSeries();
PlotOptionsColumn column = new PlotOptionsColumn();
series.setPointStart(0);
series.setPointInterval(45);
column.setPointPadding(0);
column.setGroupPadding(0);
configuration.setPlotOptions(series, column);
ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
col.setPlotOptions(new PlotOptionsColumn());
col.setName(ChartType.COLUMN.toString());
line.setPlotOptions(new PlotOptionsLine());
line.setName(ChartType.LINE.toString());
area.setPlotOptions(new PlotOptionsArea());
area.setName(ChartType.AREA.toString());
configuration.setSeries(col, line, area);
return configuration;
}
use of com.vaadin.flow.component.charts.model.PlotOptionsSeries in project flow-components by vaadin.
the class GlobalOptions method initDemo.
@Override
public void initDemo() {
List<Chart> charts = new ArrayList();
NativeButton changeTitleButton = new NativeButton();
changeTitleButton.setId("add_chart");
changeTitleButton.setText("Add chart");
changeTitleButton.addClickListener(e -> {
final Chart chart = new Chart();
Configuration configuration = chart.getConfiguration();
configuration.setTitle("First Chart for Flow");
chart.getConfiguration().getChart().setType(ChartType.AREA);
Tooltip tooltip = configuration.getTooltip();
tooltip.setEnabled(true);
tooltip.setShared(true);
PlotOptionsSeries options = new PlotOptionsSeries();
options.setPointStart(0);
options.setPointIntervalUnit(IntervalUnit.DAY);
configuration.setPlotOptions(options);
configuration.addSeries(new ListSeries("Tokyo", 20, 12, 34, 23, 65, 8, 4, 7, 76, 19, 20, 8));
configuration.addSeries(new ListSeries("Miami", 34, 29, 23, 65, 8, 4, 7, 7, 59, 8, 9, 19));
XAxis x = new XAxis();
x.setType(AxisType.DATETIME);
x.getLabels().setFormat("{value:%a}");
configuration.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
y.setTitle("Rainfall (mm)");
configuration.addyAxis(y);
charts.add(chart);
add(chart);
});
add(changeTitleButton);
NativeButton changeLangButton = new NativeButton();
changeLangButton.setId("change_lang");
changeLangButton.setText("Change lang");
changeLangButton.addClickListener(e -> {
Lang lang = new Lang();
lang.setShortMonths(new String[] { "Tammi", "Helmi", "Maalis", "Huhti", "Touko", "Kesä", "Heinä", "Elo", "Syys", "Loka", "Marras", "Joulu" });
lang.setMonths(new String[] { "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu" });
lang.setWeekdays(new String[] { "Sunnuntai", "Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai" });
lang.setShortWeekdays(new String[] { "su", "ma", "ti", "ke", "to", "pe", "la" });
ChartOptions.get().setLang(lang);
});
add(changeLangButton);
NativeButton changeThemeLightButton = new NativeButton();
changeThemeLightButton.setId("change_theme_light");
changeThemeLightButton.setText("Change theme light");
changeThemeLightButton.addClickListener(e -> {
ChartOptions.get().setTheme(new LumoLightTheme());
for (Chart chart : charts) {
chart.drawChart(true);
}
});
add(changeThemeLightButton);
NativeButton changeThemeDarkButton = new NativeButton();
changeThemeDarkButton.setId("change_theme_dark");
changeThemeDarkButton.setText("Change theme Dark");
changeThemeDarkButton.addClickListener(e -> {
ChartOptions.get().setTheme(new LumoDarkTheme());
for (Chart chart : charts) {
chart.drawChart(true);
}
});
add(changeThemeDarkButton);
}
use of com.vaadin.flow.component.charts.model.PlotOptionsSeries in project flow-components by vaadin.
the class AbstractSeriesBeanSerializer method serialize.
@Override
public void serialize(AbstractSeries bean, BeanSerializerDelegator<AbstractSeries> serializer, JsonGenerator jgen, SerializerProvider provider) throws IOException {
AbstractSeries series = bean;
jgen.writeStartObject();
// write other fields as per normal serialization rules
serializer.serializeFields(bean, jgen, provider);
if (series.getPlotOptions() != null && !(bean.getPlotOptions() instanceof PlotOptionsSeries)) {
jgen.writeObjectField("type", series.getPlotOptions().getChartType());
}
jgen.writeEndObject();
}
use of com.vaadin.flow.component.charts.model.PlotOptionsSeries in project flow-components by vaadin.
the class DataProviderSeriesBeanSerializer method serialize.
@Override
public void serialize(DataProviderSeries bean, BeanSerializerDelegator<DataProviderSeries> serializer, JsonGenerator jgen, SerializerProvider provider) throws IOException {
jgen.writeStartObject();
if (bean.getPlotOptions() != null && !(bean.getPlotOptions() instanceof PlotOptionsSeries)) {
jgen.writeObjectField("type", bean.getPlotOptions().getChartType());
}
// write other fields as per normal serialization rules
serializer.serializeFields(bean, jgen, provider);
ArrayNode data = createDataArray(bean);
jgen.writeObjectField("data", data);
jgen.writeEndObject();
}
Aggregations