use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.
the class ChartOptionsJSONSerializationTest method toJSON_itemWithRadialGradientColor_RadialGradientSerialized.
@Test
public void toJSON_itemWithRadialGradientColor_RadialGradientSerialized() {
GradientColor color = GradientColor.createRadial(0.5, 0.3, 0.7);
color.addColorStop(0, new SolidColor(255, 128, 0));
color.addColorStop(1, new SolidColor(128, 64, 0));
DataSeriesItem item = new DataSeriesItem("Foobar", 45.0);
item.setColor(color);
DataSeries series = new DataSeries();
series.add(item);
String expected = "{\"data\":[{\"name\":\"Foobar\",\"y\":45.0,\"color\":{\"stops\":[[0.0,\"#FF8000\"],[1.0,\"#804000\"]],\"radialGradient\":{\"cx\":0.5,\"cy\":0.3,\"r\":0.7}}}]}";
assertEquals(expected, toJSON(series));
}
use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.
the class SerializationTest method serializeChart_configurationWithDrilldown_drilldownSeriesListSerializedCorrectly.
@Test
public void serializeChart_configurationWithDrilldown_drilldownSeriesListSerializedCorrectly() throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
Chart input = new Chart();
DataSeries dataSeries = new DataSeries();
ListSeries drilldownSeries = new ListSeries();
drilldownSeries.setId("id");
dataSeries.addItemWithDrilldown(new DataSeriesItem("foobar", 42), drilldownSeries);
input.getConfiguration().addSeries(dataSeries);
Chart output = serializeObject(input);
DataSeries outputSeries = (DataSeries) output.getConfiguration().getSeries().get(0);
List<Series> outputDrilldownSeries = getPrivateField("drilldownSeries", outputSeries, DataSeries.class);
assertNotNull("Drilldown series list was null after serialization", outputDrilldownSeries);
assertThat("Drilldown series list was empty after serialization", outputDrilldownSeries, is(not(empty())));
}
use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.
the class SerializationTest method serializeDataSeries_seriesWithOneItem_dataSeriesItemsSerializedCorrectly.
@Test
public void serializeDataSeries_seriesWithOneItem_dataSeriesItemsSerializedCorrectly() throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
// this should make the item customized
final DataSeriesItem dataSeriesItem = new DataSeriesItem("foobar", 42);
DataSeries input = new DataSeries(dataSeriesItem);
DataSeries output = serializeObject(input);
final DataSeriesItem outputDataSeriesItem = output.get(0);
assertTrue("DataSeriesItem.isCustomized() was false after serialization", outputDataSeriesItem.isCustomized());
}
Aggregations