Search in sources :

Example 26 with Configuration

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;
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) XAxis(com.vaadin.flow.component.charts.model.XAxis) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 27 with 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);
}
Also used : StockPrices(com.vaadin.flow.component.charts.examples.timeline.util.StockPrices) Configuration(com.vaadin.flow.component.charts.model.Configuration) TimeUnitMultiples(com.vaadin.flow.component.charts.model.TimeUnitMultiples) OhlcItem(com.vaadin.flow.component.charts.model.OhlcItem) RangeSelector(com.vaadin.flow.component.charts.model.RangeSelector) DataGrouping(com.vaadin.flow.component.charts.model.DataGrouping) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) PlotOptionsOhlc(com.vaadin.flow.component.charts.model.PlotOptionsOhlc) Chart(com.vaadin.flow.component.charts.Chart)

Example 28 with Configuration

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));
}
Also used : AxisRescaledEvent(com.vaadin.flow.component.charts.events.internal.AxisRescaledEvent) SeriesAddedEvent(com.vaadin.flow.component.charts.events.internal.SeriesAddedEvent) SeriesStateEvent(com.vaadin.flow.component.charts.events.internal.SeriesStateEvent) Configuration(com.vaadin.flow.component.charts.model.Configuration) SeriesChangedEvent(com.vaadin.flow.component.charts.events.internal.SeriesChangedEvent) DataRemovedEvent(com.vaadin.flow.component.charts.events.internal.DataRemovedEvent) ConfigurationChangeListener(com.vaadin.flow.component.charts.events.internal.ConfigurationChangeListener) DataUpdatedEvent(com.vaadin.flow.component.charts.events.internal.DataUpdatedEvent) DataAddedEvent(com.vaadin.flow.component.charts.events.internal.DataAddedEvent) ItemSlicedEvent(com.vaadin.flow.component.charts.events.internal.ItemSlicedEvent) Test(org.junit.Test)

Example 29 with Configuration

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));
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) YAxis(com.vaadin.flow.component.charts.model.YAxis) Test(org.junit.Test)

Example 30 with Configuration

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));
}
Also used : States(com.vaadin.flow.component.charts.model.States) PlotOptionsPie(com.vaadin.flow.component.charts.model.PlotOptionsPie) Configuration(com.vaadin.flow.component.charts.model.Configuration) Inactive(com.vaadin.flow.component.charts.model.Inactive) SolidColor(com.vaadin.flow.component.charts.model.style.SolidColor) Test(org.junit.Test)

Aggregations

Configuration (com.vaadin.flow.component.charts.model.Configuration)72 Chart (com.vaadin.flow.component.charts.Chart)48 DataSeries (com.vaadin.flow.component.charts.model.DataSeries)32 YAxis (com.vaadin.flow.component.charts.model.YAxis)32 XAxis (com.vaadin.flow.component.charts.model.XAxis)25 ListSeries (com.vaadin.flow.component.charts.model.ListSeries)24 DataSeriesItem (com.vaadin.flow.component.charts.model.DataSeriesItem)20 Tooltip (com.vaadin.flow.component.charts.model.Tooltip)19 Test (org.junit.Test)16 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)12 PlotOptionsColumn (com.vaadin.flow.component.charts.model.PlotOptionsColumn)10 Path (java.nio.file.Path)10 PlotOptionsSeries (com.vaadin.flow.component.charts.model.PlotOptionsSeries)9 AxisTitle (com.vaadin.flow.component.charts.model.AxisTitle)8 Legend (com.vaadin.flow.component.charts.model.Legend)8 Labels (com.vaadin.flow.component.charts.model.Labels)7 StockPrices (com.vaadin.flow.component.charts.examples.timeline.util.StockPrices)6 RangeSelector (com.vaadin.flow.component.charts.model.RangeSelector)5 SeriesTooltip (com.vaadin.flow.component.charts.model.SeriesTooltip)5 Pane (com.vaadin.flow.component.charts.model.Pane)4