Search in sources :

Example 11 with Chart

use of com.vaadin.addon.charts.Chart 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 12 with Chart

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

the class PointClickCoordinatesBarChart method createChart.

@Override
protected Chart createChart() {
    Chart chart = super.createChart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Historic World Population by Region");
    conf.setSubTitle("Source: Wikipedia.org");
    Legend legend = new Legend();
    legend.setLabelFormatter("function() { return this.name + ' (click to hide)'; }");
    conf.setLegend(legend);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Chart(com.vaadin.addon.charts.Chart)

Example 13 with Chart

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

the class PointClickCoordinatesPieChart method createChart.

@Override
protected Chart createChart() {
    Chart chart = super.createChart();
    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);
    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) Chart(com.vaadin.addon.charts.Chart)

Example 14 with Chart

use of com.vaadin.addon.charts.Chart 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 15 with Chart

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

the class PieChartCursors method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(PIE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Browser market shares at a specific website, 2010");
    final DataSeries series = new DataSeries();
    DataSeriesItem item = new DataSeriesItem("Firefox", 45.0);
    item.setCursor("no-drop");
    series.add(item);
    item = new DataSeriesItem("IE", 26.8);
    item.setCursor("none");
    series.add(item);
    DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
    chrome.setCursor("progress");
    series.add(chrome);
    item = new DataSeriesItem("Safari", 8.5);
    item.setCursor("pointer");
    series.add(item);
    item = new DataSeriesItem("Opera", 6.2);
    item.setCursor("move");
    series.add(item);
    item = new DataSeriesItem("Others", 0.7);
    item.setCursor("copy");
    series.add(item);
    conf.setSeries(series);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Aggregations

Chart (com.vaadin.addon.charts.Chart)243 Configuration (com.vaadin.addon.charts.model.Configuration)196 YAxis (com.vaadin.addon.charts.model.YAxis)105 DataSeries (com.vaadin.addon.charts.model.DataSeries)81 ListSeries (com.vaadin.addon.charts.model.ListSeries)76 XAxis (com.vaadin.addon.charts.model.XAxis)71 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)57 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)55 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)50 DataLabels (com.vaadin.addon.charts.model.DataLabels)45 Tooltip (com.vaadin.addon.charts.model.Tooltip)44 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)34 Legend (com.vaadin.addon.charts.model.Legend)29 Marker (com.vaadin.addon.charts.model.Marker)23 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)21 Style (com.vaadin.addon.charts.model.style.Style)20 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)19 Labels (com.vaadin.addon.charts.model.Labels)18 VerticalLayout (com.vaadin.ui.VerticalLayout)18 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)16