use of com.vaadin.addon.charts.model.AbstractSeries in project charts by vaadin.
the class SeriesTest method seriesVisibility_defaultVisibility_trueByDefault.
@Test
public void seriesVisibility_defaultVisibility_trueByDefault() {
@SuppressWarnings("serial") AbstractSeries dataSeries = new AbstractSeries() {
};
Assert.assertTrue(dataSeries.isVisible());
}
use of com.vaadin.addon.charts.model.AbstractSeries 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;
}
use of com.vaadin.addon.charts.model.AbstractSeries in project charts 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();
}
Aggregations