Search in sources :

Example 31 with PlotOptionsLine

use of com.vaadin.addon.charts.model.PlotOptionsLine in project charts by vaadin.

the class ChartBeforeClienResponseTest method beforeClientResponse_chartWithTimelineAndNoSupportForItButLineAsFirstSeries_chartIsSerialized.

@Test
public void beforeClientResponse_chartWithTimelineAndNoSupportForItButLineAsFirstSeries_chartIsSerialized() throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
    TestChart chart = new TestChart(timelineNotSupported);
    chart.setTimeline(true);
    ListSeries series = new ListSeries();
    series.setPlotOptions(new PlotOptionsLine());
    chart.getConfiguration().addSeries(series);
    chart.beforeClientResponse(true);
    assertNotNull(chart.getSerializedConfiguration());
    assertNotEquals("", chart.getSerializedConfiguration());
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Test(org.junit.Test)

Example 32 with PlotOptionsLine

use of com.vaadin.addon.charts.model.PlotOptionsLine in project charts by vaadin.

the class ChartDataSeriesJSONSerializationTest method serialize_ContainerWithLinePlotOptions_PlotOptionsAndTypeSerialized.

@Test
public void serialize_ContainerWithLinePlotOptions_PlotOptionsAndTypeSerialized() {
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    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 = "{\"type\":\"line\",\"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) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Test(org.junit.Test)

Example 33 with PlotOptionsLine

use of com.vaadin.addon.charts.model.PlotOptionsLine in project charts by vaadin.

the class ChartDesignReaderTest method readConfiguration_enableDataLabelsInPlotoptions_dataLabelsAreEnabledInConfiguration.

@Test
public void readConfiguration_enableDataLabelsInPlotoptions_dataLabelsAreEnabledInConfiguration() {
    Elements elements = createElements("<plot-options><line><data-labels enabled=\"true\"></data-labels></line></plot-options>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    PlotOptionsLine lineOptions = (PlotOptionsLine) configuration.getPlotOptions(ChartType.LINE);
    assertEquals(true, lineOptions.getDataLabels().getEnabled());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Aggregations

PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)33 Configuration (com.vaadin.addon.charts.model.Configuration)25 Chart (com.vaadin.addon.charts.Chart)21 ListSeries (com.vaadin.addon.charts.model.ListSeries)19 YAxis (com.vaadin.addon.charts.model.YAxis)13 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)10 DataLabels (com.vaadin.addon.charts.model.DataLabels)9 Test (org.junit.Test)9 DataSeries (com.vaadin.addon.charts.model.DataSeries)7 Legend (com.vaadin.addon.charts.model.Legend)6 Marker (com.vaadin.addon.charts.model.Marker)5 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)4 XAxis (com.vaadin.addon.charts.model.XAxis)4 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)3 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)3 Elements (org.jsoup.select.Elements)3 Hover (com.vaadin.addon.charts.model.Hover)2 Labels (com.vaadin.addon.charts.model.Labels)2 Pane (com.vaadin.addon.charts.model.Pane)2 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)2