use of com.vaadin.addon.charts.model.ZoomType in project charts by vaadin.
the class ServerSideEvents method createControls.
private Layout createControls() {
visibilityToggling = new CheckBox("Disable series visibility toggling");
visibilityToggling.addValueChangeListener(e -> {
chart.setSeriesVisibilityTogglingDisabled(visibilityToggling.getValue());
});
final Button firstSeriesVisible = new Button("Hide first series");
firstSeriesVisible.setId("hideFirstSeries");
firstSeriesVisible.addClickListener(new Button.ClickListener() {
boolean hideSeries = true;
@Override
public void buttonClick(Button.ClickEvent event) {
Series firstSeries = chart.getConfiguration().getSeries().get(0);
((AbstractSeries) firstSeries).setVisible(!hideSeries);
hideSeries = !hideSeries;
String caption = hideSeries ? "Hide first series" : "Show first series";
firstSeriesVisible.setCaption(caption);
}
});
Button setExtremes = new Button("Toggle extremes");
setExtremes.setId("setExtremes");
setExtremes.addClickListener(new Button.ClickListener() {
public boolean extremesSet;
@Override
public void buttonClick(Button.ClickEvent event) {
if (extremesSet) {
chart.getConfiguration().getxAxis().setExtremes(10, 90);
} else {
chart.getConfiguration().getxAxis().setExtremes(20, 80);
}
extremesSet = !extremesSet;
}
});
final OptionGroup zoomLevels = new OptionGroup("Zoom Type");
zoomLevels.addItem(ZoomType.XY);
zoomLevels.addItem(ZoomType.X);
zoomLevels.addItem(ZoomType.Y);
zoomLevels.setValue(ZoomType.XY);
zoomLevels.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {
ZoomType zoom = (ZoomType) zoomLevels.getValue();
chart.getConfiguration().getChart().setZoomType(zoom);
chart.drawChart();
}
});
Button resetHistory = new Button("Reset history");
resetHistory.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
lastEvent.setValue(null);
eventDetails.setValue(null);
historyLayout.removeAllComponents();
}
});
HorizontalLayout controls = new HorizontalLayout();
controls.setId("controls");
controls.setSpacing(true);
controls.addComponent(visibilityToggling);
controls.addComponent(firstSeriesVisible);
controls.addComponent(setExtremes);
controls.addComponent(zoomLevels);
controls.addComponent(resetHistory);
return controls;
}
Aggregations