Search in sources :

Example 51 with Chart

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

the class ColumnWithNativeLazyDrilldownMultipleSeries method initDemo.

@Override
public void initDemo() {
    final Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    conf = chart.getConfiguration();
    conf.setTitle("Browser market share, April, 2011");
    conf.setSubTitle("Click the columns to view versions. Click again to view brands.");
    conf.getLegend().setEnabled(false);
    XAxis x = new XAxis();
    x.setType(AxisType.CATEGORY);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setTitle("Total percent market share");
    conf.addyAxis(y);
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setCursor(Cursor.POINTER);
    column.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(column);
    Tooltip tooltip = new Tooltip();
    tooltip.setHeaderFormat("<span style=\"font-size:11px\">{series.name}</span><br>");
    tooltip.setPointFormat("<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>");
    conf.setTooltip(tooltip);
    createSeries(1);
    createSeries(2);
    drillSeries = new HashMap<>();
    addDrillSeries(1);
    addDrillSeries(2);
    chart.setDrilldownCallback(event -> getPointDrilldown(event.getItem()));
    add(chart);
}
Also used : DataLabels(com.vaadin.flow.component.charts.model.DataLabels) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 52 with Chart

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

the class Timeline method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.TIMELINE);
    Configuration conf = chart.getConfiguration();
    conf.getxAxis().setVisible(false);
    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("First dogs", "1951: First dogs in space", "22 July 1951 First dogs in space (Dezik and Tsygan)"));
    series.add(new DataSeriesItemTimeline("Sputnik 1", "1957: First artificial satellite", "4 October 1957 First artificial satellite. First signals from space."));
    series.add(new DataSeriesItemTimeline("First human spaceflight", "1961: First human spaceflight (Yuri Gagarin)", "First human spaceflight (Yuri Gagarin), and the first human-crewed orbital flight"));
    series.add(new DataSeriesItemTimeline("First human on the Moon", "1969: First human on the Moon", "First human on the Moon, and first space launch from a celestial body other than the Earth. First sample return from the Moon"));
    conf.addSeries(series);
    add(chart);
}
Also used : 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 53 with Chart

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

the class Treemap method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.TREEMAP);
    Configuration conf = chart.getConfiguration();
    conf.getTooltip().setEnabled(true);
    PlotOptionsTreemap plotOptions = new PlotOptionsTreemap();
    plotOptions.setLayoutAlgorithm(TreeMapLayoutAlgorithm.STRIPES);
    plotOptions.setAlternateStartingDirection(true);
    Level level1 = new Level();
    level1.setLevel(1);
    level1.setLayoutAlgorithm(TreeMapLayoutAlgorithm.SLICEANDDICE);
    DataLabels dataLabels = new DataLabels();
    dataLabels.setEnabled(true);
    dataLabels.setAlign(HorizontalAlign.LEFT);
    dataLabels.setVerticalAlign(VerticalAlign.TOP);
    level1.setDataLabels(dataLabels);
    plotOptions.setLevels(level1);
    TreeSeries series = createSeries();
    series.setPlotOptions(plotOptions);
    chart.getConfiguration().addSeries(series);
    chart.getConfiguration().setTitle("Fruit consumption");
    add(chart);
}
Also used : TreeSeries(com.vaadin.flow.component.charts.model.TreeSeries) DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsTreemap(com.vaadin.flow.component.charts.model.PlotOptionsTreemap) Level(com.vaadin.flow.component.charts.model.Level) Chart(com.vaadin.flow.component.charts.Chart)

Example 54 with Chart

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

the class WindRose method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.getChart().setPolar(true);
    conf.setTitle("Wind rose for South Shore Met Station, Oregon");
    conf.setSubTitle("Source: or.water.usgs.gov");
    XAxis xAxis = conf.getxAxis();
    xAxis.setCategories("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");
    YAxis yAxis = conf.getyAxis();
    yAxis.setReversedStacks(false);
    yAxis.setTitle("Frequency (%)");
    yAxis.setMin(0);
    yAxis.setEndOnTick(false);
    yAxis.setShowLastLabel(true);
    yAxis.getLabels().setFormatter("function() { return this.value + '%';}");
    conf.getTooltip().setValueSuffix("%");
    conf.getPane().setSize("85%");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setStacking(Stacking.NORMAL);
    plotOptionsColumn.setGroupPadding(0);
    plotOptionsColumn.setPointPlacement(PointPlacement.ON);
    conf.setPlotOptions(plotOptionsColumn);
    Legend legend = conf.getLegend();
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setY(100);
    legend.setLayout(LayoutDirection.VERTICAL);
    DataSeries series = new DataSeries();
    series.setName("&lt; 0.5 m/s");
    series.setData(1.81, 0.62, 0.82, 0.59, 0.62, 1.22, 1.61, 2.04, 2.66, 2.96, 2.53, 1.97, 1.64, 1.32, 1.58, 1.51);
    conf.addSeries(series);
    series = new DataSeries();
    series.setName("0.5-2 m/s");
    series.setData(1.78, 1.09, 0.82, 1.22, 2.2, 2.01, 3.06, 3.42, 4.74, 4.14, 4.01, 2.66, 1.71, 2.4, 4.28, 5);
    conf.addSeries(series);
    series = new DataSeries();
    series.setName("2-4 m/s");
    series.setData(0.16, 0, 0.07, 0.07, 0.49, 1.55, 2.37, 1.97, 0.43, 0.26, 1.22, 1.97, 0.92, 0.99, 1.28, 1.32);
    conf.addSeries(series);
    series = new DataSeries();
    series.setName("4-6 m/s");
    series.setData(0, 0, 0, 0, 0, 0.3, 2.14, 0.86, 0, 0, 0.49, 0.79, 1.45, 1.61, 0.76, 0.13);
    conf.addSeries(series);
    series = new DataSeries();
    series.setName("6-8 m/s");
    series.setData(0, 0, 0, 0, 0, 0.13, 1.74, 0.53, 0, 0, 0.13, 0.3, 0.26, 0.33, 0.66, 0.23);
    conf.addSeries(series);
    series = new DataSeries();
    series.setName("8-10 m/s");
    series.setData(0, 0, 0, 0, 0, 0, 0.39, 0.49, 0, 0, 0, 0, 0.1, 0, 0.69, 0.13);
    conf.addSeries(series);
    series = new DataSeries();
    series.setName("&gt; 10 m/s");
    series.setData(0, 0, 0, 0, 0, 0, 0.13, 0, 0, 0, 0, 0, 0, 0, 0.03, 0.07);
    conf.addSeries(series);
    add(chart);
}
Also used : Legend(com.vaadin.flow.component.charts.model.Legend) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) 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)

Example 55 with Chart

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

the class ColumnRange method initDemo.

@Override
public void initDemo() {
    final Chart chart = new Chart(ChartType.COLUMNRANGE);
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Temperature variation by day");
    DataSeries dataSeries = new DataSeries("Temperatures");
    for (StockPrices.RangeData data : StockPrices.fetchDailyTempRanges()) {
        dataSeries.add(new DataSeriesItem(data.getDate(), data.getMin(), data.getMax()));
    }
    configuration.setSeries(dataSeries);
    RangeSelector rangeSelector = new RangeSelector();
    rangeSelector.setSelected(2);
    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) RangeSelector(com.vaadin.flow.component.charts.model.RangeSelector) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem)

Aggregations

Chart (com.vaadin.flow.component.charts.Chart)57 Configuration (com.vaadin.flow.component.charts.model.Configuration)48 DataSeries (com.vaadin.flow.component.charts.model.DataSeries)32 YAxis (com.vaadin.flow.component.charts.model.YAxis)31 XAxis (com.vaadin.flow.component.charts.model.XAxis)26 DataSeriesItem (com.vaadin.flow.component.charts.model.DataSeriesItem)20 Tooltip (com.vaadin.flow.component.charts.model.Tooltip)20 ListSeries (com.vaadin.flow.component.charts.model.ListSeries)17 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)15 PlotOptionsColumn (com.vaadin.flow.component.charts.model.PlotOptionsColumn)13 AxisTitle (com.vaadin.flow.component.charts.model.AxisTitle)8 Legend (com.vaadin.flow.component.charts.model.Legend)8 StockPrices (com.vaadin.flow.component.charts.examples.timeline.util.StockPrices)6 Labels (com.vaadin.flow.component.charts.model.Labels)6 PlotOptionsSeries (com.vaadin.flow.component.charts.model.PlotOptionsSeries)6 SeriesTooltip (com.vaadin.flow.component.charts.model.SeriesTooltip)6 RangeSelector (com.vaadin.flow.component.charts.model.RangeSelector)5 ChartType (com.vaadin.flow.component.charts.model.ChartType)4 SolidColor (com.vaadin.flow.component.charts.model.style.SolidColor)4 AbstractChartExample (com.vaadin.flow.component.charts.examples.AbstractChartExample)3