Search in sources :

Example 11 with PlotOptionsColumn

use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.

the class ColumnWithNativeLazyDrilldownByIndex method getChart.

@Override
protected Component getChart() {
    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.setEnabled(false);
    conf.setTooltip(tooltip);
    topCategories = new String[] { "MSIE", "Firefox", "Chrome", "Safari", "Opera" };
    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);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Firefox", 21.63);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Chrome", 11.94);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Safari", 7.15);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Opera", 2.14);
    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(new DrilldownCallback() {

        @Override
        public Series handleDrilldown(DrilldownEvent event) {
            return getPointDrilldown(event.getItemIndex());
        }
    });
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Tooltip(com.vaadin.addon.charts.model.Tooltip) XAxis(com.vaadin.addon.charts.model.XAxis) DrilldownEvent(com.vaadin.addon.charts.DrilldownEvent) Series(com.vaadin.addon.charts.model.Series) DataSeries(com.vaadin.addon.charts.model.DataSeries) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) DrilldownCallback(com.vaadin.addon.charts.DrilldownCallback) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 12 with PlotOptionsColumn

use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.

the class ColumnWithNativeLazyDrilldownMultipleSeries method getChart.

@Override
protected Component getChart() {
    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);
    createSeries(1);
    createSeries(2);
    drillSeries = new HashMap<String, DataSeries>();
    addDrillSeries(1);
    addDrillSeries(2);
    chart.setDrilldownCallback(new DrilldownCallback() {

        @Override
        public Series handleDrilldown(DrilldownEvent event) {
            return getPointDrilldown(event.getItem());
        }
    });
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Tooltip(com.vaadin.addon.charts.model.Tooltip) XAxis(com.vaadin.addon.charts.model.XAxis) DrilldownEvent(com.vaadin.addon.charts.DrilldownEvent) Series(com.vaadin.addon.charts.model.Series) DataSeries(com.vaadin.addon.charts.model.DataSeries) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) DrilldownCallback(com.vaadin.addon.charts.DrilldownCallback) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 13 with PlotOptionsColumn

use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.

the class ColumnWithNegativeValues method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Column chart with negative values"));
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setMinPointLength(3);
    conf.setPlotOptions(column);
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Apples", "Oranges", "Pears", "Grapes", "Bananas");
    conf.addxAxis(xAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("function() { return ''+ this.series.name +': '+ this.y +'';}");
    conf.setTooltip(tooltip);
    conf.setCredits(new Credits(false));
    conf.addSeries(new ListSeries("John", 5, 0.1, 4, 7, 2));
    conf.addSeries(new ListSeries("Jane", 2, -2, -0.1, 2, 1));
    conf.addSeries(new ListSeries("Joe", 3, 4, 4, -2, 5));
    chart.drawChart(conf);
    return chart;
}
Also used : Credits(com.vaadin.addon.charts.model.Credits) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) Title(com.vaadin.addon.charts.model.Title) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis)

Example 14 with PlotOptionsColumn

use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.

the class BasicColumn method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Monthly Average Rainfall");
    conf.setSubTitle("Source: WorldClimate.com");
    XAxis x = new XAxis();
    x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    y.setTitle("Rainfall (mm)");
    conf.addyAxis(y);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(100);
    legend.setY(70);
    legend.setFloating(true);
    legend.setShadow(true);
    conf.setLegend(legend);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.x +': '+ this.y +' mm'");
    conf.setTooltip(tooltip);
    PlotOptionsColumn plot = new PlotOptionsColumn();
    plot.setPointPadding(0.2);
    plot.setBorderWidth(0);
    conf.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));
    conf.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));
    conf.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));
    conf.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));
    chart.drawChart(conf);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 15 with PlotOptionsColumn

use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.

the class ColumnWithLazyMultiLevelDrilldown method getChart.

@Override
protected Component getChart() {
    VerticalLayout layout = new VerticalLayout();
    final Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    conf = chart.getConfiguration();
    conf.setTitle("Global happiness index");
    conf.setSubTitle("Source: www.happyplanetindex.org");
    conf.getLegend().setEnabled(false);
    XAxis x = new XAxis();
    x.setType(AxisType.CATEGORY);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setTitle("Total");
    conf.addyAxis(y);
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setCursor(Cursor.POINTER);
    column.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(column);
    DataSeries series = new DataSeries();
    series.setName("Regions");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setColorByPoint(true);
    series.setPlotOptions(plotOptionsColumn);
    DataSeriesItem item = new DataSeriesItem("Latin America and Carribean", 60);
    item.setId("Latin America and Carribean");
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Western Nations", 50);
    item.setId("Western Nations");
    series.addItemWithDrilldown(item);
    conf.addSeries(series);
    drillSeries = new HashMap<String, DataSeries>();
    DataSeries drill = new DataSeries("Latin America and Carribean Countries");
    item = new DataSeriesItem("Costa Rica", 64);
    item.setId("Costa Rica");
    drill.addItemWithDrilldown(item);
    item = new DataSeriesItem("Colombia", 59.8);
    item.setId("Colombia");
    drill.addItemWithDrilldown(item);
    item = new DataSeriesItem("Belize", 59.3);
    item.setId("Belize");
    drill.addItemWithDrilldown(item);
    drillSeries.put("Latin America and Carribean", drill);
    drill = new DataSeries("Western Nations Countries");
    item = new DataSeriesItem("New Zealand", 51.6);
    item.setId("New Zealand");
    drill.addItemWithDrilldown(item);
    item = new DataSeriesItem("Norway", 51.4);
    item.setId("Norway");
    drill.addItemWithDrilldown(item);
    item = new DataSeriesItem("Switzerland", 50.3);
    item.setId("Switzerland");
    drill.addItemWithDrilldown(item);
    drillSeries.put("Western Nations", drill);
    drill = new DataSeries("Details Costa Rica");
    drill.setId("Details Costa Rica");
    String[] categories = new String[] { "Life Expectancy", "Well-being (0-10)", "Footprint (gha/capita)" };
    Number[] ys = new Number[] { 79.3, 7.3, 2.5 };
    drill.setData(categories, ys);
    drillSeries.put("Costa Rica", drill);
    drill = new DataSeries("Details Colombia");
    drill.setId("Details Colombia");
    ys = new Number[] { 73.7, 6.4, 1.8 };
    drill.setData(categories, ys);
    drillSeries.put("Colombia", drill);
    drill = new DataSeries("Details Belize");
    drill.setId("Details Belize");
    ys = new Number[] { 76.1, 6.5, 2.1 };
    drill.setData(categories, ys);
    drillSeries.put("Belize", drill);
    drill = new DataSeries("Details New Zealand");
    drill.setId("Details New Zealand");
    ys = new Number[] { 80.7, 7.2, 4.3 };
    drill.setData(categories, ys);
    drillSeries.put("New Zealand", drill);
    drill = new DataSeries("Details Norway");
    drill.setId("Details Norway");
    ys = new Number[] { 81.1, 7.6, 4.8 };
    drill.setData(categories, ys);
    drillSeries.put("Norway", drill);
    drill = new DataSeries("Details Switzerland");
    drill.setId("Details Switzerland");
    ys = new Number[] { 82.3, 7.5, 5.0 };
    drill.setData(categories, ys);
    drillSeries.put("Switzerland", drill);
    chart.setDrilldownCallback(new DrilldownCallback() {

        @Override
        public Series handleDrilldown(DrilldownEvent event) {
            log("DrilldownEvent: " + event.getItem().getId());
            return getPointDrilldown(event.getItem());
        }
    });
    chart.addPointClickListener(new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            log("PointClickEvent: " + event.getSeries().getName() + " index :" + event.getPointIndex());
        }
    });
    chart.addChartDrillupListener(new ChartDrillupListener() {

        @Override
        public void onDrillup(ChartDrillupEvent event) {
            log("ChartDrillupEvent");
        }
    });
    layout.addComponent(chart);
    layout.addComponent(log);
    return layout;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) ChartDrillupListener(com.vaadin.addon.charts.ChartDrillupListener) XAxis(com.vaadin.addon.charts.model.XAxis) DrilldownEvent(com.vaadin.addon.charts.DrilldownEvent) Series(com.vaadin.addon.charts.model.Series) DataSeries(com.vaadin.addon.charts.model.DataSeries) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) PointClickListener(com.vaadin.addon.charts.PointClickListener) DrilldownCallback(com.vaadin.addon.charts.DrilldownCallback) VerticalLayout(com.vaadin.ui.VerticalLayout) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis) ChartDrillupEvent(com.vaadin.addon.charts.ChartDrillupEvent)

Aggregations

PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)37 Chart (com.vaadin.addon.charts.Chart)34 Configuration (com.vaadin.addon.charts.model.Configuration)30 YAxis (com.vaadin.addon.charts.model.YAxis)28 XAxis (com.vaadin.addon.charts.model.XAxis)26 Tooltip (com.vaadin.addon.charts.model.Tooltip)20 ListSeries (com.vaadin.addon.charts.model.ListSeries)16 DataSeries (com.vaadin.addon.charts.model.DataSeries)13 DataLabels (com.vaadin.addon.charts.model.DataLabels)11 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)11 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)10 Style (com.vaadin.addon.charts.model.style.Style)9 Legend (com.vaadin.addon.charts.model.Legend)8 Title (com.vaadin.addon.charts.model.Title)8 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)7 Labels (com.vaadin.addon.charts.model.Labels)5 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)5 DrilldownCallback (com.vaadin.addon.charts.DrilldownCallback)4 DrilldownEvent (com.vaadin.addon.charts.DrilldownEvent)4 DataProviderSeries (com.vaadin.addon.charts.model.DataProviderSeries)4