use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class SVGGeneratorTest method createColumnWithoutTitle.
private Configuration createColumnWithoutTitle() {
Configuration configuration = new Configuration();
configuration.getChart().setType(ChartType.COLUMN);
configuration.addSeries(new ListSeries("Tokyo", 49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4));
configuration.addSeries(new ListSeries("New York", 83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3));
configuration.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2));
configuration.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1));
XAxis x = new XAxis();
x.setCategories("January is a long month", "February is rather boring", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
configuration.addxAxis(x);
YAxis y = new YAxis();
y.setTitle("Rainfall (mm)");
configuration.addyAxis(y);
return configuration;
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class OHLC method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.OHLC);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("AAPL Stock Price");
DataSeries dataSeries = new DataSeries();
PlotOptionsOhlc plotOptionsOhlc = new PlotOptionsOhlc();
DataGrouping grouping = new DataGrouping();
grouping.addUnit(new TimeUnitMultiples(TimeUnit.WEEK, 1));
grouping.addUnit(new TimeUnitMultiples(TimeUnit.MONTH, 1, 2, 3, 4, 6));
plotOptionsOhlc.setDataGrouping(grouping);
dataSeries.setPlotOptions(plotOptionsOhlc);
for (StockPrices.OhlcData data : StockPrices.fetchAaplOhlcPrice()) {
OhlcItem item = new OhlcItem();
item.setX(data.getDate());
item.setLow(data.getLow());
item.setHigh(data.getHigh());
item.setClose(data.getClose());
item.setOpen(data.getOpen());
dataSeries.add(item);
}
configuration.setSeries(dataSeries);
RangeSelector rangeSelector = new RangeSelector();
rangeSelector.setSelected(1);
configuration.setRangeSelector(rangeSelector);
chart.setTimeline(true);
add(chart);
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class ConfigurationJSONSerializationTest method configurationJSONSerialization_configurationSerializedWithChangeListener_changeListenerNotSerialized.
@Test
public void configurationJSONSerialization_configurationSerializedWithChangeListener_changeListenerNotSerialized() {
Configuration conf = new Configuration();
conf.addChangeListener(new ConfigurationChangeListener() {
@Override
public void dataAdded(DataAddedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void dataRemoved(DataRemovedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void dataUpdated(DataUpdatedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void itemSliced(ItemSlicedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void seriesStateChanged(SeriesStateEvent event) {
// TODO Auto-generated method stub
}
@Override
public void seriesAdded(SeriesAddedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void seriesChanged(SeriesChangedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void axisRescaled(AxisRescaledEvent event) {
// TODO Auto-generated method stub
}
@Override
public void resetZoom(boolean redraw, boolean animate) {
// TODO Auto-generated method stub
}
});
assertEquals("{\"chart\":{\"styledMode\":false},\"plotOptions\":{},\"series\":[],\"exporting\":{\"enabled\":false}}", toJSON(conf));
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class ConfigurationJSONSerializationTest method configurationJSONSerialization_configurationSerializedWithYAxis_yAxisConfigurationNotSerialized.
@Test
public void configurationJSONSerialization_configurationSerializedWithYAxis_yAxisConfigurationNotSerialized() {
Configuration conf = new Configuration();
YAxis axis = new YAxis();
conf.addyAxis(axis);
assertEquals("{\"chart\":{\"styledMode\":false},\"yAxis\":{\"axisIndex\":0},\"plotOptions\":{},\"series\":[],\"exporting\":{\"enabled\":false}}", toJSON(conf));
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class ConfigurationJSONSerializationTest method configurationJSONSerialization_setOptionsWithInactiveState_inactiveStatesSerialized.
@Test
public void configurationJSONSerialization_setOptionsWithInactiveState_inactiveStatesSerialized() {
Configuration conf = new Configuration();
PlotOptionsPie options = new PlotOptionsPie();
States states = options.getStates();
Inactive inactive = states.getInactive();
inactive.setOpacity(1.0);
inactive.setBorderColor(new SolidColor("#000000"));
inactive.setColor(new SolidColor("#808080"));
inactive.setAnimation(false);
conf.setPlotOptions(options);
assertEquals("{\"chart\":{\"styledMode\":false},\"plotOptions\":{\"pie\":{\"states\":{\"inactive\":{\"animation\":false,\"borderColor\":\"#000000\",\"color\":\"#808080\",\"opacity\":1.0}}}},\"series\":[],\"exporting\":{\"enabled\":false}}", toJSON(conf));
}
Aggregations