use of com.vaadin.flow.component.charts.model.AbstractSeries 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.AbstractSeries in project flow-components by vaadin.
the class ServerSideEvents method createControls.
private Component createControls() {
visibilityToggling = new Checkbox("Disable series visibility toggling");
visibilityToggling.setId("visibilityToggler");
visibilityToggling.addValueChangeListener(e -> chart.setVisibilityTogglingDisabled(visibilityToggling.getValue()));
visibilityToggling.setValue(false);
final Button firstSeriesVisible = new Button("Hide first series", e -> {
Series firstSeries = chart.getConfiguration().getSeries().get(0);
((AbstractSeries) firstSeries).setVisible(!hideSeries);
hideSeries = !hideSeries;
});
firstSeriesVisible.setId("hideFirstSeries");
final RadioButtonGroup<Dimension> zoomLevels = new RadioButtonGroup<>();
zoomLevels.setItems(Dimension.XY, Dimension.X, Dimension.Y);
zoomLevels.setValue(Dimension.XY);
zoomLevels.addValueChangeListener(event -> {
chart.getConfiguration().getChart().setZoomType(zoomLevels.getValue());
chart.drawChart();
});
Button resetHistory = new Button("Reset history");
resetHistory.setId("resetHistory");
resetHistory.addClickListener(event -> {
historyLayout.removeAll();
});
Button toggleExtremes = new Button("Toggle Extremes");
toggleExtremes.setId("toggleExtremes");
toggleExtremes.addClickListener(e -> {
if (setExtremes) {
chart.getConfiguration().getyAxes().getAxis(0).setExtremes(9, 15);
} else {
chart.getConfiguration().resetZoom();
}
setExtremes = !setExtremes;
});
HorizontalLayout controls = new HorizontalLayout();
controls.setId("controls");
controls.add(visibilityToggling);
controls.add(firstSeriesVisible);
controls.add(zoomLevels);
controls.add(resetHistory);
controls.add(toggleExtremes);
return controls;
}
Aggregations