use of com.vaadin.addon.charts.model.PlotOptionsSeries in project charts by vaadin.
the class ContainerDataSeriesBeanSerializer method serialize.
@Override
public void serialize(ContainerDataSeries bean, BeanSerializerDelegator<ContainerDataSeries> 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.getVaadinContainer(), bean.getAttributeToPropertyIdMap());
jgen.writeObjectField("data", data);
jgen.writeEndObject();
}
use of com.vaadin.addon.charts.model.PlotOptionsSeries in project charts by vaadin.
the class Timeline method chartsTimelineIntroSnippet1.
public void chartsTimelineIntroSnippet1() {
Chart chart = new Chart();
Configuration configuration = chart.getConfiguration();
Navigator navigator = configuration.getNavigator();
navigator.setEnabled(true);
navigator.setMargin(75);
PlotOptionsSeries plotOptions = new PlotOptionsSeries();
plotOptions.setColor(SolidColor.BROWN);
navigator.setSeries(plotOptions);
}
use of com.vaadin.addon.charts.model.PlotOptionsSeries in project charts by vaadin.
the class ChartDataSeriesJSONSerializationTest method serialize_ContainerWithSeriesPlotOptions_PlotTypeNotSerialized.
@Test
public void serialize_ContainerWithSeriesPlotOptions_PlotTypeNotSerialized() {
PlotOptionsSeries plotOptions = new PlotOptionsSeries();
plotOptions.setShowInLegend(true);
final Pair<ListDataProvider<TestItem>, DataProviderSeries<TestItem>> pair = createTuple();
final DataProviderSeries<TestItem> dataProviderSeries = pair.getT2();
dataProviderSeries.setY(TestItem::getY);
dataProviderSeries.setPlotOptions(plotOptions);
Configuration config = new Configuration();
config.addSeries(dataProviderSeries);
String actual = toJSON(dataProviderSeries);
String expected = "{\"showInLegend\":true,\"data\":[]}";
assertEquals(expected, actual);
}
use of com.vaadin.addon.charts.model.PlotOptionsSeries 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