Search in sources :

Example 6 with DataSeries

use of com.vaadin.addon.charts.model.DataSeries 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)

Example 7 with DataSeries

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

the class PieWithStartAndEndAngle method getBrowserMarketShareSeries.

private DataSeries getBrowserMarketShareSeries() {
    DataSeriesItem firefox = new DataSeriesItem("Firefox", 45.0);
    DataSeriesItem ie = new DataSeriesItem("IE", 26.8);
    DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
    chrome.setSliced(true);
    chrome.setSelected(true);
    DataSeriesItem safari = new DataSeriesItem("Safari", 8.5);
    DataSeriesItem opera = new DataSeriesItem("Opera", 6.2);
    DataSeriesItem others = new DataSeriesItem("Others", 0.7);
    return new DataSeries(firefox, ie, chrome, safari, opera, others);
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 8 with DataSeries

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

use of com.vaadin.addon.charts.model.DataSeries 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)

Example 10 with DataSeries

use of com.vaadin.addon.charts.model.DataSeries 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)

Aggregations

DataSeries (com.vaadin.addon.charts.model.DataSeries)118 Chart (com.vaadin.addon.charts.Chart)81 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)81 Configuration (com.vaadin.addon.charts.model.Configuration)71 YAxis (com.vaadin.addon.charts.model.YAxis)38 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)26 XAxis (com.vaadin.addon.charts.model.XAxis)25 DataLabels (com.vaadin.addon.charts.model.DataLabels)21 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)17 Tooltip (com.vaadin.addon.charts.model.Tooltip)15 Test (org.junit.Test)15 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)14 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)14 Marker (com.vaadin.addon.charts.model.Marker)13 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)13 Style (com.vaadin.addon.charts.model.style.Style)10 Random (java.util.Random)10 Legend (com.vaadin.addon.charts.model.Legend)9 PlotLine (com.vaadin.addon.charts.model.PlotLine)9 StockPrices (com.vaadin.addon.charts.examples.timeline.util.StockPrices)8