Search in sources :

Example 6 with Configuration

use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.

the class TimeAxisTimeline method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.TIMELINE);
    Configuration conf = chart.getConfiguration();
    conf.getxAxis().setVisible(false);
    conf.getxAxis().setType(AxisType.DATETIME);
    conf.getyAxis().setVisible(false);
    conf.setTitle("Timeline of Space Exploration");
    conf.setSubTitle("Info source: <a href=\"https://en.wikipedia.org/wiki/Timeline_of_space_exploration\">www.wikipedia.org</a>");
    conf.getTooltip().setEnabled(true);
    DataSeries series = new DataSeries();
    series.add(new DataSeriesItemTimeline(getInstant(1951, 6, 22), "First dogs in space", "First dogs in space", "Dezik and Tsygan were the first dogs to make a sub-orbital flight on 22 July 1951. Both dogs were recovered unharmed after travelling to a maximum altitude of 110 km."));
    series.add(new DataSeriesItemTimeline(getInstant(1957, 10, 4), "First artificial satellite", "First artificial satellite", "Sputnik 1 was the first artificial Earth satellite. The Soviet Union launched it into an elliptical low Earth orbit on 4 October 1957, orbiting for three weeks before its batteries died, then silently for two more months before falling back into the atmosphere."));
    series.add(new DataSeriesItemTimeline(getInstant(1959, 1, 4), "First artificial satellite to reach the Moon", "First artificial satellite to reach the Moon", "Luna 1 was the first artificial satellite to reach the Moon vicinity and first artificial satellite in heliocentric orbit."));
    series.add(new DataSeriesItemTimeline(getInstant(1961, 4, 12), "First human spaceflight", "First human spaceflight", "Yuri Gagarin was a Soviet pilot and cosmonaut. He became the first human to journey into outer space when his Vostok spacecraft completed one orbit of the Earth on 12 April 1961."));
    series.add(new DataSeriesItemTimeline(getInstant(1966, 2, 3), "First soft landing on the Moon", "First soft landing on the Moon", "Yuri Gagarin was a Soviet pilot and cosmonaut. He became the first human to journey into outer space when his Vostok spacecraft completed one orbit of the Earth on 12 April 1961."));
    series.add(new DataSeriesItemTimeline(getInstant(1969, 7, 20), "First human on the Moon", "First human on the Moon", "Apollo 11 was the spaceflight that landed the first two people on the Moon. Commander Neil Armstrong and lunar module pilot Buzz Aldrin, both American, landed the Apollo Lunar Module Eagle on July 20, 1969, at 20:17 UTC."));
    series.add(new DataSeriesItemTimeline(getInstant(1971, 4, 19), "First space station", "First space station", "Salyute 1 was the first space station of any kind, launched into low Earth orbit by the Soviet Union on April 19, 1971. The Salyut program followed this with five more successful launches out of seven more stations."));
    series.add(new DataSeriesItemTimeline(getInstant(1971, 12, 2), "First soft Mars landing", "First soft Mars landing", "Mars 3 was an unmanned space probe of the Soviet Mars program which spanned the years between 1960 and 1973. Mars 3 was launched May 28, 1971, nine days after its twin spacecraft Mars 2. The probes were identical robotic spacecraft launched by Proton-K rockets with a Blok D upper stage, each consisting of an orbiter and an attached lander."));
    series.add(new DataSeriesItemTimeline(getInstant(1976, 4, 17), "Closest flyby of the Sun", "Closest flyby of the Sun", "Helios-A and Helios-B (also known as Helios 1 and Helios 2) are a pair of probes launched into heliocentric orbit for the purpose of studying solar processes. A joint venture of West Germany's space agency DFVLR (70 percent share) and NASA (30 percent), the probes were launched from Cape Canaveral Air Force Station, Florida."));
    series.add(new DataSeriesItemTimeline(getInstant(1978, 12, 4), "First orbital exploration of Venus", "First orbital exploration of Venus", "The Pioneer Venus Orbiter entered orbit around Venus on December 4, 1978, and performed observations to characterize the atmosphere and surface of Venus. It continued to transmit data until October 1992."));
    series.add(new DataSeriesItemTimeline(getInstant(1986, 2, 19), "First inhabited space station", "First inhabited space station", "was a space station that operated in low Earth orbit from 1986 to 2001, operated by the Soviet Union and later by Russia. Mir was the first modular space station and was assembled in orbit from 1986 to 1996. It had a greater mass than any previous spacecraft."));
    series.add(new DataSeriesItemTimeline(getInstant(1989, 8, 8), "First astrometric satellite", "First astrometric satellite", "Hipparcos was a scientific satellite of the European Space Agency (ESA), launched in 1989 and operated until 1993. It was the first space experiment devoted to precision astrometry, the accurate measurement of the positions of celestial objects on the sky."));
    series.add(new DataSeriesItemTimeline(getInstant(1998, 11, 20), "First multinational space station", "First multinational space station", "The International Space Station (ISS) is a space station, or a habitable artificial satellite, in low Earth orbit. Its first component was launched into orbit in 1998, with the first long-term residents arriving in November 2000.[7] It has been inhabited continuously since that date."));
    PlotOptionsTimeline options = new PlotOptionsTimeline();
    options.getMarker().setSymbol(MarkerSymbolEnum.CIRCLE);
    DataLabels labels = options.getDataLabels();
    labels.setAllowOverlap(false);
    labels.setFormat("<span style=\"color:{point.color}\">● </span><span style=\"font-weight: bold;\" > {point.x:%d %b %Y}</span><br/>{point.label}");
    series.setPlotOptions(options);
    conf.addSeries(series);
    add(chart);
}
Also used : PlotOptionsTimeline(com.vaadin.flow.component.charts.model.PlotOptionsTimeline) DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) DataSeriesItemTimeline(com.vaadin.flow.component.charts.model.DataSeriesItemTimeline) Chart(com.vaadin.flow.component.charts.Chart)

Example 7 with Configuration

use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.

the class WaterfallChart method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.WATERFALL);
    DataSeries dataSeries = new DataSeries();
    dataSeries.add(new DataSeriesItem("Start", 120000));
    dataSeries.add(new DataSeriesItem("Product Revenue", 569000));
    dataSeries.add(new DataSeriesItem("Service Revenue", 231000));
    WaterFallSum positiveBalance = new WaterFallSum("Positive Balance");
    positiveBalance.setIntermediate(true);
    dataSeries.add(positiveBalance);
    dataSeries.add(new DataSeriesItem("Fixed Costs", -342000));
    dataSeries.add(new DataSeriesItem("Variable Costs", -233000));
    WaterFallSum balance = new WaterFallSum("Balance");
    dataSeries.add(balance);
    PlotOptionsWaterfall opts = new PlotOptionsWaterfall();
    DataLabels dataLabels = new DataLabels(true);
    dataLabels.setVerticalAlign(VerticalAlign.TOP);
    dataLabels.setY(-30);
    dataLabels.setFormatter("function() { return this.y / 1000 + 'k'; }");
    opts.setDataLabels(dataLabels);
    dataSeries.setPlotOptions(opts);
    Configuration configuration = chart.getConfiguration();
    configuration.addSeries(dataSeries);
    configuration.getxAxis().setType(AxisType.CATEGORY);
    add(chart);
}
Also used : DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsWaterfall(com.vaadin.flow.component.charts.model.PlotOptionsWaterfall) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) WaterFallSum(com.vaadin.flow.component.charts.model.WaterFallSum) Chart(com.vaadin.flow.component.charts.Chart) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem)

Example 8 with Configuration

use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.

the class DynamicChangingChart method getPolarConfiguration.

public Configuration getPolarConfiguration() {
    Configuration configuration = new Configuration();
    configuration.getChart().setPolar(true);
    configuration.setTitle("Polar Chart");
    Pane pane = new Pane(0, 360);
    configuration.addPane(pane);
    XAxis xAxis = new XAxis();
    xAxis.setTickInterval(45);
    xAxis.setMin(0);
    xAxis.setMax(360);
    Labels labels = new Labels();
    labels.setFormatter("function() {return this.value + '°';}");
    xAxis.setLabels(labels);
    YAxis yAxis = new YAxis();
    yAxis.setMin(0);
    configuration.addxAxis(xAxis);
    configuration.addyAxis(yAxis);
    PlotOptionsSeries series = new PlotOptionsSeries();
    PlotOptionsColumn column = new PlotOptionsColumn();
    series.setPointStart(0);
    series.setPointInterval(45);
    column.setPointPadding(0);
    column.setGroupPadding(0);
    configuration.setPlotOptions(series, column);
    ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
    ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
    ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
    col.setPlotOptions(new PlotOptionsColumn());
    col.setName(ChartType.COLUMN.toString());
    line.setPlotOptions(new PlotOptionsLine());
    line.setName(ChartType.LINE.toString());
    area.setPlotOptions(new PlotOptionsArea());
    area.setName(ChartType.AREA.toString());
    configuration.setSeries(col, line, area);
    return configuration;
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) PlotOptionsLine(com.vaadin.flow.component.charts.model.PlotOptionsLine) PlotOptionsArea(com.vaadin.flow.component.charts.model.PlotOptionsArea) Labels(com.vaadin.flow.component.charts.model.Labels) Pane(com.vaadin.flow.component.charts.model.Pane) XAxis(com.vaadin.flow.component.charts.model.XAxis) PlotOptionsSeries(com.vaadin.flow.component.charts.model.PlotOptionsSeries) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 9 with Configuration

use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.

the class ErrorBar method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart();
    Configuration configuration = chart.getConfiguration();
    configuration.setTitle("Monthly Rainfall");
    XAxis x = new XAxis();
    x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    configuration.addxAxis(x);
    YAxis y = new YAxis();
    Labels yLabels = new Labels();
    yLabels.setFormat("{value} mm");
    y.setLabels(yLabels);
    y.setTitle("Rainfall");
    configuration.addyAxis(y);
    Tooltip tooltip = new Tooltip();
    tooltip.setShared(true);
    configuration.setTooltip(tooltip);
    Series rainfall = new ListSeries("Rainfall", 49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
    PlotOptionsColumn rainfallOptions = new PlotOptionsColumn();
    SeriesTooltip rainfallTooltip = new SeriesTooltip();
    rainfallTooltip.setPointFormat("<span style=\"font-weight: bold; color: {series.color}\">" + "{series.name}</span>: <b>{point.y:.1f} mm</b> ");
    rainfallOptions.setTooltip(rainfallTooltip);
    rainfall.setPlotOptions(rainfallOptions);
    configuration.addSeries(rainfall);
    Series error = new RangeSeries("Rainfall error", new Number[] { 48, 51 }, new Number[] { 68, 73 }, new Number[] { 92, 110 }, new Number[] { 128, 136 }, new Number[] { 140, 150 }, new Number[] { 171, 179 }, new Number[] { 135, 143 }, new Number[] { 142, 149 }, new Number[] { 204, 220 }, new Number[] { 189, 199 }, new Number[] { 95, 110 }, new Number[] { 52, 56 });
    PlotOptionsErrorbar errorOptions = new PlotOptionsErrorbar();
    SeriesTooltip errorTooltip = new SeriesTooltip();
    errorTooltip.setPointFormat("(error range: {point.low}-{point.high} mm)<br/>");
    errorOptions.setTooltip(errorTooltip);
    error.setPlotOptions(errorOptions);
    configuration.addSeries(error);
    add(chart);
}
Also used : RangeSeries(com.vaadin.flow.component.charts.model.RangeSeries) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) Series(com.vaadin.flow.component.charts.model.Series) PlotOptionsErrorbar(com.vaadin.flow.component.charts.model.PlotOptionsErrorbar) Configuration(com.vaadin.flow.component.charts.model.Configuration) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) RangeSeries(com.vaadin.flow.component.charts.model.RangeSeries) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) SeriesTooltip(com.vaadin.flow.component.charts.model.SeriesTooltip) Labels(com.vaadin.flow.component.charts.model.Labels) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) YAxis(com.vaadin.flow.component.charts.model.YAxis) SeriesTooltip(com.vaadin.flow.component.charts.model.SeriesTooltip)

Example 10 with Configuration

use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.

the class Flags method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.AREASPLINE);
    Configuration configuration = chart.getConfiguration();
    configuration.setTitle("Average fruit consumption during one week");
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
    configuration.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setTitle("Fruit units");
    configuration.addyAxis(yAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setShared(true);
    tooltip.setValueSuffix(" units");
    configuration.setTooltip(tooltip);
    configuration.addSeries(new ListSeries("John", 3, 4, 3, 5, 4, 10, 12));
    ListSeries janeSeries = new ListSeries("Jane", 1, 3, 4, 3, 3, 5, 4);
    janeSeries.setId("jane");
    configuration.addSeries(janeSeries);
    DataSeries onSeriesFlags = new DataSeries("On series");
    PlotOptionsFlags onSeriesFlagsOptions = new PlotOptionsFlags();
    onSeriesFlagsOptions.setOnSeries("jane");
    onSeriesFlagsOptions.setShape(FlagShape.SQUAREPIN);
    onSeriesFlags.setPlotOptions(onSeriesFlagsOptions);
    onSeriesFlags.add(new FlagItem(2, "On series"));
    onSeriesFlags.add(new FlagItem(5, "On series"));
    configuration.addSeries(onSeriesFlags);
    DataSeries onAxisFlags = new DataSeries("On axis");
    onAxisFlags.setPlotOptions(new PlotOptionsFlags());
    onAxisFlags.add(new FlagItem(3, "On axis"));
    configuration.addSeries(onAxisFlags);
    add(chart);
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) PlotOptionsFlags(com.vaadin.flow.component.charts.model.PlotOptionsFlags) FlagItem(com.vaadin.flow.component.charts.model.FlagItem) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) YAxis(com.vaadin.flow.component.charts.model.YAxis)

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