Search in sources :

Example 11 with PlotOptionsSeries

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();
}
Also used : ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries)

Example 12 with PlotOptionsSeries

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);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Navigator(com.vaadin.addon.charts.model.Navigator) Chart(com.vaadin.addon.charts.Chart) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries)

Example 13 with PlotOptionsSeries

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);
}
Also used : ListDataProvider(com.vaadin.data.provider.ListDataProvider) DataProviderSeries(com.vaadin.addon.charts.model.DataProviderSeries) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries) Test(org.junit.Test)

Example 14 with PlotOptionsSeries

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();
}
Also used : AbstractSeries(com.vaadin.addon.charts.model.AbstractSeries) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries)

Aggregations

PlotOptionsSeries (com.vaadin.addon.charts.model.PlotOptionsSeries)14 Configuration (com.vaadin.addon.charts.model.Configuration)10 Chart (com.vaadin.addon.charts.Chart)8 YAxis (com.vaadin.addon.charts.model.YAxis)6 XAxis (com.vaadin.addon.charts.model.XAxis)5 DataSeries (com.vaadin.addon.charts.model.DataSeries)4 ListSeries (com.vaadin.addon.charts.model.ListSeries)4 Tooltip (com.vaadin.addon.charts.model.Tooltip)4 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)3 PlotLine (com.vaadin.addon.charts.model.PlotLine)3 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)3 VerticalLayout (com.vaadin.ui.VerticalLayout)3 Test (org.junit.Test)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)2 Labels (com.vaadin.addon.charts.model.Labels)2 Legend (com.vaadin.addon.charts.model.Legend)2 ChartClickEvent (com.vaadin.addon.charts.ChartClickEvent)1 ChartClickListener (com.vaadin.addon.charts.ChartClickListener)1 PointClickEvent (com.vaadin.addon.charts.PointClickEvent)1