Search in sources :

Example 1 with LegendNavigation

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

the class PieWithLegendNavigator method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    Legend legend = conf.getLegend();
    legend.setLayout(VERTICAL);
    legend.setAlign(RIGHT);
    legend.setVerticalAlign(TOP);
    LegendNavigation nav = legend.getNavigation();
    nav.setActiveColor(GREEN);
    nav.setArrowSize(24);
    conf.setTitle("Lot of slices to force navigation in legend");
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.getDataLabels().setEnabled(false);
    plotOptions.setShowInLegend(true);
    conf.setPlotOptions(plotOptions);
    DataSeries series = new DataSeries();
    for (int i = 0; i < 50; i++) {
        series.add(new DataSeriesItem("Item " + i, 1));
    }
    conf.addSeries(series);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) LegendNavigation(com.vaadin.addon.charts.model.LegendNavigation) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Aggregations

Chart (com.vaadin.addon.charts.Chart)1 Configuration (com.vaadin.addon.charts.model.Configuration)1 DataSeries (com.vaadin.addon.charts.model.DataSeries)1 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)1 Legend (com.vaadin.addon.charts.model.Legend)1 LegendNavigation (com.vaadin.addon.charts.model.LegendNavigation)1 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)1