Search in sources :

Example 1 with Credits

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

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

the class ColumnWithNegativeValues method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Column chart with negative values"));
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setMinPointLength(3);
    conf.setPlotOptions(column);
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Apples", "Oranges", "Pears", "Grapes", "Bananas");
    conf.addxAxis(xAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("function() { return ''+ this.series.name +': '+ this.y +'';}");
    conf.setTooltip(tooltip);
    conf.setCredits(new Credits(false));
    conf.addSeries(new ListSeries("John", 5, 0.1, 4, 7, 2));
    conf.addSeries(new ListSeries("Jane", 2, -2, -0.1, 2, 1));
    conf.addSeries(new ListSeries("Joe", 3, 4, 4, -2, 5));
    chart.drawChart(conf);
    return chart;
}
Also used : Credits(com.vaadin.addon.charts.model.Credits) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) Title(com.vaadin.addon.charts.model.Title) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis)

Example 3 with Credits

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

the class AreaWithNegativeValues method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.AREA);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Area chart with negative values"));
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Apples", "Oranges", "Pears", "Grapes", "Bananas");
    conf.addxAxis(xAxis);
    conf.setCredits(new Credits(false));
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.series.name +': '+ this.y");
    conf.setTooltip(tooltip);
    conf.addSeries(new ListSeries("John", 5, 3, 4, 7, 2));
    conf.addSeries(new ListSeries("Jane", 2, -2, -3, 2, 1));
    conf.addSeries(new ListSeries("Joe", 3, 4, 4, -2, 5));
    chart.drawChart(conf);
    return chart;
}
Also used : Credits(com.vaadin.addon.charts.model.Credits) Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) Title(com.vaadin.addon.charts.model.Title) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis)

Aggregations

Chart (com.vaadin.addon.charts.Chart)3 Configuration (com.vaadin.addon.charts.model.Configuration)3 Credits (com.vaadin.addon.charts.model.Credits)3 ListSeries (com.vaadin.addon.charts.model.ListSeries)2 Title (com.vaadin.addon.charts.model.Title)2 Tooltip (com.vaadin.addon.charts.model.Tooltip)2 XAxis (com.vaadin.addon.charts.model.XAxis)2 DataLabels (com.vaadin.addon.charts.model.DataLabels)1 DataSeries (com.vaadin.addon.charts.model.DataSeries)1 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)1 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)1 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)1 Position (com.vaadin.addon.charts.model.Position)1