Search in sources :

Example 6 with PlotOptionsPie

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

the class PieChartWithCredits 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");
    Credits credits = new Credits("Custom Credit");
    credits.setPosition(new Position());
    credits.getPosition().setHorizontalAlign(HorizontalAlign.LEFT);
    credits.getPosition().setX(200);
    conf.setCredits(credits);
    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);
    conf.setPlotOptions(plotOptions);
    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.drawChart(conf);
    return chart;
}
Also used : Credits(com.vaadin.addon.charts.model.Credits) PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) Position(com.vaadin.addon.charts.model.Position) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 7 with PlotOptionsPie

use of com.vaadin.addon.charts.model.PlotOptionsPie 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 8 with PlotOptionsPie

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

the class PieSite method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Revenue by industry");
    conf.setSubTitle("2015");
    Tooltip tooltip = conf.getTooltip();
    tooltip.setPointFormat("<b>{point.percentage:.1f}%</b>");
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setAllowPointSelect(true);
    plotOptions.setCursor(Cursor.POINTER);
    plotOptions.setShowInLegend(true);
    DataLabels dataLabels = plotOptions.getDataLabels();
    dataLabels.setEnabled(true);
    dataLabels.setFormat("{point.name}: {point.y:.1f} M€");
    conf.setPlotOptions(plotOptions);
    DataSeries series = new DataSeries("Revenue");
    series.add(new DataSeriesItem("Aerospace", 90.0));
    series.add(new DataSeriesItem("Medical", 53.6));
    series.add(new DataSeriesItem("Agriculture", 25.6));
    series.add(new DataSeriesItem("Automotive", 17.0));
    series.add(new DataSeriesItem("Consumers", 12.4));
    series.add(new DataSeriesItem("Subsidies", 1.4));
    conf.setSeries(series);
    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) Tooltip(com.vaadin.addon.charts.model.Tooltip) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 9 with PlotOptionsPie

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

the class ChartExportDemo method createChartConf.

private static Configuration createChartConf() {
    Configuration conf = new Configuration();
    conf.getChart().setType(ChartType.PIE);
    conf.setTitle("Browser market shares at a specific website, 2010");
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setCursor(Cursor.POINTER);
    Labels dataLabels = new Labels();
    dataLabels.setEnabled(true);
    dataLabels.setColor(new SolidColor(0, 0, 0));
    dataLabels.setConnectorColor(new SolidColor(0, 0, 0));
    dataLabels.setFormatter("'<b>'+ this.point.name +'</b>: '+ this.percentage +' %'");
    plotOptions.setDataLabels(dataLabels);
    conf.setPlotOptions(plotOptions);
    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);
    return conf;
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Labels(com.vaadin.addon.charts.model.Labels) DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 10 with PlotOptionsPie

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

the class ChartTypes method chartTypesPieSnippet1.

public void chartTypesPieSnippet1() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    PlotOptionsPie options = new PlotOptionsPie();
    // Non-0 results in a donut
    options.setInnerSize("0");
    // Default
    options.setSize("75%");
    // Default
    options.setCenter("50%", "50%");
    conf.setPlotOptions(options);
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) Configuration(com.vaadin.addon.charts.model.Configuration) Chart(com.vaadin.addon.charts.Chart)

Aggregations

PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)25 Configuration (com.vaadin.addon.charts.model.Configuration)20 Chart (com.vaadin.addon.charts.Chart)19 DataSeries (com.vaadin.addon.charts.model.DataSeries)14 DataLabels (com.vaadin.addon.charts.model.DataLabels)12 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)11 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)5 Tooltip (com.vaadin.addon.charts.model.Tooltip)3 PointClickEvent (com.vaadin.addon.charts.PointClickEvent)2 PointClickListener (com.vaadin.addon.charts.PointClickListener)2 YAxis (com.vaadin.addon.charts.model.YAxis)2 Color (com.vaadin.addon.charts.model.style.Color)2 Style (com.vaadin.addon.charts.model.style.Style)2 LegendItemClickEvent (com.vaadin.addon.charts.LegendItemClickEvent)1 LegendItemClickListener (com.vaadin.addon.charts.LegendItemClickListener)1 Credits (com.vaadin.addon.charts.model.Credits)1 DataProviderSeries (com.vaadin.addon.charts.model.DataProviderSeries)1 DrillUpButton (com.vaadin.addon.charts.model.DrillUpButton)1 DrillUpButtonTheme (com.vaadin.addon.charts.model.DrillUpButtonTheme)1 Drilldown (com.vaadin.addon.charts.model.Drilldown)1