use of com.vaadin.addon.charts.model.DataProviderSeries in project charts by vaadin.
the class ChartDataSeriesJSONSerializationTest method serialize_ContainerWithNonUTCDate_DateSerializedAsUTC.
@Test
public void serialize_ContainerWithNonUTCDate_DateSerializedAsUTC() {
final ZonedDateTime nowUTC = ZonedDateTime.of(2010, 10, 10, 10, 39, 00, 00, ZoneId.of("UTC"));
final ZonedDateTime nowEuropeParis = ZonedDateTime.of(2010, 10, 10, 10, 39, 00, 00, ZoneId.of("Europe/Paris"));
final Collection<TestDateItem> colEurope = singletonList(new TestDateItem(nowEuropeParis, 80));
final DataProvider<TestDateItem, ?> dataProviderEurope = new ListDataProvider<>(colEurope);
final DataProviderSeries<TestDateItem> chartDataSeriesEurope = new DataProviderSeries<>(dataProviderEurope);
chartDataSeriesEurope.setX(TestDateItem::getDate);
chartDataSeriesEurope.setY(TestDateItem::getValue);
final Collection<TestDateItem> colUTC = singletonList(new TestDateItem(nowUTC, 80));
final DataProvider<TestDateItem, ?> dataProviderUTC = new ListDataProvider<>(colUTC);
final DataProviderSeries<TestDateItem> chartDataSeriesUTC = new DataProviderSeries<>(dataProviderUTC);
chartDataSeriesUTC.setX(TestDateItem::getDate);
chartDataSeriesUTC.setY(TestDateItem::getValue);
final String actualEurope = toJSON(chartDataSeriesEurope);
final String actualUTC = toJSON(chartDataSeriesUTC);
// not loosing TimeZone
assertNotEquals(actualUTC, actualEurope);
}
use of com.vaadin.addon.charts.model.DataProviderSeries 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);
}
Aggregations