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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations