Search in sources :

Example 1 with PointClickListener

use of com.vaadin.addon.charts.PointClickListener in project charts by vaadin.

the class AbstractPointClickCoordinatesChart method createChart.

protected Chart createChart() {
    Chart chart = new Chart(type);
    chart.setWidth("900px");
    chart.setHeight("450px");
    chart.addPointClickListener(new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            lastAction.setValue("PointClickEvent: absoluteX: " + event.getAbsoluteX() + " - absoluteY: " + event.getAbsoluteY());
        }
    });
    chart.addChartClickListener(new ChartClickListener() {

        @Override
        public void onClick(ChartClickEvent event) {
            lastAction.setValue("ChartClickEvent: absoluteX: " + event.getAbsoluteX() + " - absoluteY: " + event.getAbsoluteY());
        }
    });
    addSeries(chart.getConfiguration());
    return chart;
}
Also used : ChartClickListener(com.vaadin.addon.charts.ChartClickListener) PointClickListener(com.vaadin.addon.charts.PointClickListener) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) Chart(com.vaadin.addon.charts.Chart) ChartClickEvent(com.vaadin.addon.charts.ChartClickEvent)

Example 2 with PointClickListener

use of com.vaadin.addon.charts.PointClickListener in project charts by vaadin.

the class PieChart method createChart.

public static Chart createChart() {
    Chart chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Browser market shares at a specific website, 2010");
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setCursor(Cursor.POINTER);
    DataLabels dataLabels = new DataLabels();
    dataLabels.setEnabled(true);
    dataLabels.setFormatter("'<b>'+ this.point.name +'</b>: '+ this.percentage +' %'");
    plotOptions.setDataLabels(dataLabels);
    conf.setPlotOptions(plotOptions);
    final DataSeries series = new DataSeries();
    series.add(new DataSeriesItem("Firefox", 45.0));
    series.add(new DataSeriesItem("IE", 26.8));
    DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
    chrome.setSliced(true);
    chrome.setSelected(true);
    series.add(chrome);
    series.add(new DataSeriesItem("Safari", 8.5));
    series.add(new DataSeriesItem("Opera", 6.2));
    series.add(new DataSeriesItem("Others", 0.7));
    conf.setSeries(series);
    chart.addPointClickListener(new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            Notification.show("Click: " + series.get(event.getPointIndex()).getName());
        }
    });
    chart.drawChart(conf);
    return chart;
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PointClickListener(com.vaadin.addon.charts.PointClickListener) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 3 with PointClickListener

use of com.vaadin.addon.charts.PointClickListener in project charts by vaadin.

the class Basic3DPie method createChart.

public static Chart createChart() {
    Chart chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Browser market shares at a specific website, 2010");
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setCursor(Cursor.POINTER);
    DataLabels dataLabels = new DataLabels(true);
    dataLabels.setFormatter("'<b>'+ this.point.name +'</b>: '+ this.percentage +' %'");
    plotOptions.setDataLabels(dataLabels);
    plotOptions.setDepth(45);
    conf.setPlotOptions(plotOptions);
    final DataSeries series = new DataSeries();
    series.add(new DataSeriesItem("Firefox", 45.0));
    series.add(new DataSeriesItem("IE", 26.8));
    DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
    chrome.setSliced(true);
    chrome.setSelected(true);
    series.add(chrome);
    series.add(new DataSeriesItem("Safari", 8.5));
    series.add(new DataSeriesItem("Opera", 6.2));
    series.add(new DataSeriesItem("Others", 0.7));
    conf.setSeries(series);
    Options3d options3d = new Options3d();
    options3d.setEnabled(true);
    options3d.setAlpha(60);
    conf.getChart().setOptions3d(options3d);
    chart.addPointClickListener(new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            Notification.show("Click: " + series.get(event.getPointIndex()).getName());
        }
    });
    chart.drawChart(conf);
    return chart;
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PointClickListener(com.vaadin.addon.charts.PointClickListener) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Options3d(com.vaadin.addon.charts.model.Options3d)

Example 4 with PointClickListener

use of com.vaadin.addon.charts.PointClickListener in project charts by vaadin.

the class ServerSideEvents method addEventListeners.

private Layout addEventListeners() {
    eventListeners = new VerticalLayout();
    eventListeners.setCaption("Event listeners:");
    final ChartClickListener listener = new ChartClickListener() {

        @Override
        public void onClick(ChartClickEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Chart click", "ChartClick", new ListenerToggle() {

        @Override
        public void add() {
            chart.addChartClickListener(listener);
        }

        @Override
        public void remove() {
            chart.removeChartClickListener(listener);
        }
    });
    final PointClickListener pcListener = new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Point click", "PointClick", new ListenerToggle() {

        @Override
        public void add() {
            chart.addPointClickListener(pcListener);
        }

        @Override
        public void remove() {
            chart.removePointClickListener(pcListener);
        }
    });
    final CheckboxClickListener cbListener = new CheckboxClickListener() {

        @Override
        public void onClick(CheckboxClickEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Checkbox click", "CheckboxClick", new ListenerToggle() {

        @Override
        public void add() {
            chart.addCheckBoxClickListener(cbListener);
        }

        @Override
        public void remove() {
            chart.removeCheckBoxClickListener(cbListener);
        }
    });
    final LegendItemClickListener legendItemListener = new LegendItemClickListener() {

        @Override
        public void onClick(LegendItemClickEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Legend item click", "LegendItemClick", new ListenerToggle() {

        @Override
        public void add() {
            chart.addLegendItemClickListener(legendItemListener);
            visibilityToggling.setValue(true);
        }

        @Override
        public void remove() {
            chart.removeLegendItemClickListener(legendItemListener);
        }
    });
    final SeriesHideListener hideListener = new SeriesHideListener() {

        @Override
        public void onHide(SeriesHideEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Series hide", "SeriesHide", new ListenerToggle() {

        @Override
        public void add() {
            chart.addSeriesHideListener(hideListener);
        }

        @Override
        public void remove() {
            chart.removeSeriesHideListener(hideListener);
        }
    });
    final SeriesShowListener show = new SeriesShowListener() {

        @Override
        public void onShow(SeriesShowEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Series show", "SeriesShow", new ListenerToggle() {

        @Override
        public void add() {
            chart.addSeriesShowListener(show);
        }

        @Override
        public void remove() {
            chart.removeSeriesShowListener(show);
        }
    });
    final XAxesExtremesChangeListener xaxesListener = new XAxesExtremesChangeListener() {

        @Override
        public void onXAxesExtremesChange(XAxesExtremesChangeEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("XAxes extremes change", "XAxesExtremes", new ListenerToggle() {

        @Override
        public void add() {
            chart.addXAxesExtremesChangeListener(xaxesListener);
        }

        @Override
        public void remove() {
            chart.removeXAxesExtremesChangeListener(xaxesListener);
        }
    });
    final YAxesExtremesChangeListener yaxesListener = new YAxesExtremesChangeListener() {

        @Override
        public void onYAxesExtremesChange(YAxesExtremesChangeEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Y axes extremes change", "YAxesExtremes", new ListenerToggle() {

        @Override
        public void add() {
            chart.addYAxesExtremesChangeListener(yaxesListener);
        }

        @Override
        public void remove() {
            chart.removeYAxesExtremesChangeListener(yaxesListener);
        }
    });
    final PointSelectListener selectListener = new PointSelectListener() {

        @Override
        public void onSelect(PointSelectEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Point select", "PointSelect", new ListenerToggle() {

        @Override
        public void add() {
            chart.addPointSelectListener(selectListener);
        }

        @Override
        public void remove() {
            chart.removePointSelectListener(selectListener);
        }
    });
    final PointUnselectListener unselectListener = new PointUnselectListener() {

        @Override
        public void onUnselect(PointUnselectEvent event) {
            logEvent(event);
        }
    };
    addToggleForListener("Point unselect", "PointUnselect", new ListenerToggle() {

        @Override
        public void add() {
            chart.addPointUnselectListener(unselectListener);
        }

        @Override
        public void remove() {
            chart.removePointUnselectListener(unselectListener);
        }
    });
    return eventListeners;
}
Also used : LegendItemClickListener(com.vaadin.addon.charts.LegendItemClickListener) PointSelectEvent(com.vaadin.addon.charts.PointSelectEvent) PointUnselectListener(com.vaadin.addon.charts.PointUnselectListener) SeriesShowEvent(com.vaadin.addon.charts.SeriesShowEvent) CheckboxClickListener(com.vaadin.addon.charts.CheckboxClickListener) SeriesHideListener(com.vaadin.addon.charts.SeriesHideListener) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) SeriesShowListener(com.vaadin.addon.charts.SeriesShowListener) PointSelectListener(com.vaadin.addon.charts.PointSelectListener) PointUnselectEvent(com.vaadin.addon.charts.PointUnselectEvent) XAxesExtremesChangeListener(com.vaadin.addon.charts.XAxesExtremesChangeListener) ChartClickEvent(com.vaadin.addon.charts.ChartClickEvent) ChartClickListener(com.vaadin.addon.charts.ChartClickListener) YAxesExtremesChangeEvent(com.vaadin.addon.charts.YAxesExtremesChangeEvent) XAxesExtremesChangeEvent(com.vaadin.addon.charts.XAxesExtremesChangeEvent) LegendItemClickEvent(com.vaadin.addon.charts.LegendItemClickEvent) CheckboxClickEvent(com.vaadin.addon.charts.CheckboxClickEvent) PointClickListener(com.vaadin.addon.charts.PointClickListener) VerticalLayout(com.vaadin.ui.VerticalLayout) SeriesHideEvent(com.vaadin.addon.charts.SeriesHideEvent) YAxesExtremesChangeListener(com.vaadin.addon.charts.YAxesExtremesChangeListener)

Example 5 with PointClickListener

use of com.vaadin.addon.charts.PointClickListener 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

PointClickEvent (com.vaadin.addon.charts.PointClickEvent)9 PointClickListener (com.vaadin.addon.charts.PointClickListener)9 Chart (com.vaadin.addon.charts.Chart)8 DataSeries (com.vaadin.addon.charts.model.DataSeries)6 ChartClickEvent (com.vaadin.addon.charts.ChartClickEvent)5 ChartClickListener (com.vaadin.addon.charts.ChartClickListener)5 Configuration (com.vaadin.addon.charts.model.Configuration)5 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)5 VerticalLayout (com.vaadin.ui.VerticalLayout)4 DataLabels (com.vaadin.addon.charts.model.DataLabels)3 XAxis (com.vaadin.addon.charts.model.XAxis)3 YAxis (com.vaadin.addon.charts.model.YAxis)3 Legend (com.vaadin.addon.charts.model.Legend)2 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)2 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)2 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)2 ChartDrillupEvent (com.vaadin.addon.charts.ChartDrillupEvent)1 ChartDrillupListener (com.vaadin.addon.charts.ChartDrillupListener)1 CheckboxClickEvent (com.vaadin.addon.charts.CheckboxClickEvent)1 CheckboxClickListener (com.vaadin.addon.charts.CheckboxClickListener)1