Search in sources :

Example 11 with PlotOptionsColumn

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

the class ColumnWithLazyMultiLevelDrilldownCallbackTests method initDemo.

@Override
public void initDemo() {
    log = new OrderedList();
    log.setId("log");
    Div layout = new Div();
    final Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    final Configuration conf = chart.getConfiguration();
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setCursor(Cursor.POINTER);
    column.setAnimation(false);
    conf.getDrilldown().setAnimation(false);
    column.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(column);
    DataSeries series = new DataSeries();
    series.setName("Top");
    createItems("Item").forEach(series::addItemWithDrilldown);
    conf.addSeries(series);
    chart.addChartDrillupListener(event -> log("ChartDrillupEvent"));
    final NativeButton setNew = new NativeButton("set new callback", e -> chart.setDrilldownCallback(getDrilldownCallback()));
    setNew.setId("setNew");
    final NativeButton setSame = new NativeButton("set same callback", e -> chart.setDrilldownCallback(chart.getDrilldownCallback()));
    setSame.setId("setSame");
    final NativeButton setNull = new NativeButton("set null callback", e -> chart.setDrilldownCallback(null));
    setNull.setId("setNull");
    layout.add(chart, setNew, setSame, setNull, log);
    add(layout);
}
Also used : Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) OrderedList(com.vaadin.flow.component.html.OrderedList) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart)

Example 12 with PlotOptionsColumn

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

the class ColumnWithNativeLazyDrilldown 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));
    // column.getDataLabels().setFormatter("this.y +'%'");
    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);
    DataSeries series = new DataSeries();
    series.setName("Browser brands");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setColorByPoint(true);
    series.setPlotOptions(plotOptionsColumn);
    DataSeriesItem item = new DataSeriesItem("MSIE", 55.11);
    item.setId("MSIE");
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Firefox", 21.63);
    item.setId("Firefox");
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Chrome", 11.94);
    item.setId("Chrome");
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Safari", 7.15);
    item.setId("Safari");
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Opera", 2.14);
    item.setId("Opera");
    series.addItemWithDrilldown(item);
    conf.addSeries(series);
    drillSeries = new HashMap<String, DataSeries>();
    DataSeries drill = new DataSeries("MSIE versions");
    String[] categories = new String[] { "MSIE 6.0", "MSIE 7.0", "MSIE 8.0", "MSIE 9.0" };
    Number[] ys = new Number[] { 10.85, 7.35, 33.06, 2.81 };
    drill.setData(categories, ys);
    drillSeries.put("MSIE", drill);
    drill = new DataSeries("Firefox versions");
    categories = new String[] { "Firefox 2.0", "Firefox 3.0", "Firefox 3.5", "Firefox 3.6", "Firefox 4.0" };
    ys = new Number[] { 0.20, 0.83, 1.58, 13.12, 5.43 };
    drill.setData(categories, ys);
    drillSeries.put("Firefox", drill);
    drill = new DataSeries("Chrome versions");
    categories = new String[] { "Chrome 5.0", "Chrome 6.0", "Chrome 7.0", "Chrome 8.0", "Chrome 9.0", "Chrome 10.0", "Chrome 11.0", "Chrome 12.0" };
    ys = new Number[] { 0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22 };
    drill.setData(categories, ys);
    drillSeries.put("Chrome", drill);
    drill = new DataSeries("Safari versions");
    categories = new String[] { "Safari 5.0", "Safari 4.0", "Safari Win 5.0", "Safari 4.1", "Safari/Maxthon", "Safari 3.1", "Safari 4.1" };
    ys = new Number[] { 4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14 };
    drill.setData(categories, ys);
    drillSeries.put("Safari", drill);
    drill = new DataSeries("Opera versions");
    categories = new String[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" };
    ys = new Number[] { 0.12, 0.37, 1.65 };
    drill.setData(categories, ys);
    drillSeries.put("Opera", drill);
    chart.setDrilldownCallback(event -> getPointDrilldown(event.getItem()));
    add(chart);
}
Also used : DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) XAxis(com.vaadin.flow.component.charts.model.XAxis) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 13 with PlotOptionsColumn

use of com.vaadin.flow.component.charts.model.PlotOptionsColumn 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 14 with PlotOptionsColumn

use of com.vaadin.flow.component.charts.model.PlotOptionsColumn 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)

Aggregations

PlotOptionsColumn (com.vaadin.flow.component.charts.model.PlotOptionsColumn)14 Chart (com.vaadin.flow.component.charts.Chart)13 XAxis (com.vaadin.flow.component.charts.model.XAxis)13 YAxis (com.vaadin.flow.component.charts.model.YAxis)11 Configuration (com.vaadin.flow.component.charts.model.Configuration)10 DataSeries (com.vaadin.flow.component.charts.model.DataSeries)8 Tooltip (com.vaadin.flow.component.charts.model.Tooltip)7 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)6 DataSeriesItem (com.vaadin.flow.component.charts.model.DataSeriesItem)5 ListSeries (com.vaadin.flow.component.charts.model.ListSeries)5 Labels (com.vaadin.flow.component.charts.model.Labels)4 Div (com.vaadin.flow.component.html.Div)3 ChartType (com.vaadin.flow.component.charts.model.ChartType)2 Legend (com.vaadin.flow.component.charts.model.Legend)2 Pane (com.vaadin.flow.component.charts.model.Pane)2 PlotOptionsArea (com.vaadin.flow.component.charts.model.PlotOptionsArea)2 PlotOptionsLine (com.vaadin.flow.component.charts.model.PlotOptionsLine)2 PlotOptionsSeries (com.vaadin.flow.component.charts.model.PlotOptionsSeries)2 PlotOptionsSpline (com.vaadin.flow.component.charts.model.PlotOptionsSpline)2 Series (com.vaadin.flow.component.charts.model.Series)2