Search in sources :

Example 51 with ListSeries

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

the class ColumnWithShapedTooltip method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Stacked column chart"));
    XAxis xAxis = new XAxis();
    xAxis.setCategories(new String[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" });
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setMin(0);
    yAxis.setTitle(new AxisTitle("Total fruit consumption"));
    conf.addyAxis(yAxis);
    PlotOptionsColumn plotOptions = new PlotOptionsColumn();
    plotOptions.setStacking(Stacking.NORMAL);
    conf.setPlotOptions(plotOptions);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("function() { return '<b>'+ this.x +'</b><br/>" + "'+this.series.name +': '+ this.y +'<br/>'+'Total: '+ this.point.stackTotal;}");
    tooltip.setShape(Shape.CIRCLE);
    conf.setTooltip(tooltip);
    conf.addSeries(new ListSeries("John", new Number[] { 5, 3, 4, 7, 2 }));
    conf.addSeries(new ListSeries("Jane", new Number[] { 2, 2, 3, 2, 1 }));
    conf.addSeries(new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 }));
    chart.drawChart(conf);
    return chart;
}
Also used : 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) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Title(com.vaadin.addon.charts.model.Title) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 52 with ListSeries

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

the class OverrideStackingForSpecificSeries method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Stacked column chart"));
    XAxis xAxis = new XAxis();
    xAxis.setCategories(new String[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" });
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setMin(0);
    yAxis.setTitle(new AxisTitle("Total fruit consumption"));
    StackLabels sLabels = new StackLabels(true);
    Style slStyle = new Style();
    slStyle.setFontWeight(FontWeight.BOLD);
    slStyle.setColor(new SolidColor("gray"));
    sLabels.setStyle(slStyle);
    yAxis.setStackLabels(sLabels);
    conf.addyAxis(yAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("'<b>'+ this.x +'</b><br/>'+this.series.name +': '" + "+ this.y +'<br/>'+'Total: '+ this.point.stackTotal");
    conf.setTooltip(tooltip);
    PlotOptionsColumn plotOptions = new PlotOptionsColumn();
    plotOptions.setStacking(Stacking.NORMAL);
    DataLabels labels = new DataLabels();
    labels.setEnabled(true);
    labels.setColor(new SolidColor("white"));
    plotOptions.setDataLabels(labels);
    conf.setPlotOptions(plotOptions);
    conf.addSeries(new ListSeries("John", new Number[] { 5, 3, 4, 7, 2 }));
    conf.addSeries(new ListSeries("Jane", new Number[] { 2, 2, 3, 2, 1 }));
    ListSeries series = new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 });
    PlotOptionsColumn joePlotOptions = new PlotOptionsColumn();
    joePlotOptions.setStacking(Stacking.NONE);
    series.setPlotOptions(joePlotOptions);
    conf.addSeries(series);
    chart.drawChart(conf);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Title(com.vaadin.addon.charts.model.Title) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) StackLabels(com.vaadin.addon.charts.model.StackLabels) Style(com.vaadin.addon.charts.model.style.Style) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 53 with ListSeries

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

the class StackedColumn method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Stacked column chart"));
    XAxis xAxis = new XAxis();
    xAxis.setCategories(new String[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" });
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setMin(0);
    yAxis.setTitle(new AxisTitle("Total fruit consumption"));
    StackLabels sLabels = new StackLabels(true);
    yAxis.setStackLabels(sLabels);
    conf.addyAxis(yAxis);
    Legend legend = new Legend();
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setFloating(true);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-100);
    legend.setY(20);
    conf.setLegend(legend);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("function() { return '<b>'+ this.x +'</b><br/>" + "'+this.series.name +': '+ this.y +'<br/>'+'Total: '+ this.point.stackTotal;}");
    conf.setTooltip(tooltip);
    PlotOptionsColumn plotOptions = new PlotOptionsColumn();
    plotOptions.setStacking(Stacking.NORMAL);
    DataLabels labels = new DataLabels(true);
    Style style = new Style();
    style.setTextShadow("0 0 3px black");
    labels.setStyle(style);
    labels.setColor(new SolidColor("white"));
    plotOptions.setDataLabels(labels);
    conf.setPlotOptions(plotOptions);
    conf.addSeries(new ListSeries("John", new Number[] { 5, 3, 4, 7, 2 }));
    conf.addSeries(new ListSeries("Jane", new Number[] { 2, 2, 3, 2, 1 }));
    conf.addSeries(new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 }));
    chart.drawChart(conf);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Title(com.vaadin.addon.charts.model.Title) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) StackLabels(com.vaadin.addon.charts.model.StackLabels) Style(com.vaadin.addon.charts.model.style.Style) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 54 with ListSeries

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

the class BarWithNegativeStack method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.BAR);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Population pyramid for Germany, midyear 2010");
    conf.setSubTitle("Source: www.census.gov");
    final String[] categories = new String[] { "0-4", "5-9", "10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40-44", "45-49", "50-54", "55-59", "60-64", "65-69", "70-74", "75-79", "80-84", "85-89", "90-94", "95-99", "100 +" };
    XAxis x1 = new XAxis();
    conf.addxAxis(x1);
    x1.setCategories(categories);
    x1.setReversed(false);
    XAxis x2 = new XAxis();
    conf.addxAxis(x2);
    x2.setCategories(categories);
    x2.setOpposite(true);
    x2.setReversed(false);
    x2.setLinkedTo(x1);
    YAxis y = new YAxis();
    y.setMin(-4000000);
    y.setMax(4000000);
    y.setTitle(new AxisTitle(""));
    conf.addyAxis(y);
    PlotOptionsSeries plot = new PlotOptionsSeries();
    plot.setStacking(Stacking.NORMAL);
    conf.setPlotOptions(plot);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("'<b>'+ this.series.name +', age '+ this.point.category +'</b><br/>'+ 'Population: '+ Highcharts.numberFormat(Math.abs(this.point.y), 0)");
    conf.setTooltip(tooltip);
    conf.addSeries(new ListSeries("Male", -1746181, -1884428, -2089758, -2222362, -2537431, -2507081, -2443179, -2664537, -3556505, -3680231, -3143062, -2721122, -2229181, -2227768, -2176300, -1329968, -836804, -354784, -90569, -28367, -3878));
    conf.addSeries(new ListSeries("Female", 1656154, 1787564, 1981671, 2108575, 2403438, 2366003, 2301402, 2519874, 3360596, 3493473, 3050775, 2759560, 2304444, 2426504, 2568938, 1785638, 1447162, 1005011, 330870, 130632, 21208));
    chart.drawChart(conf);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 55 with ListSeries

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

the class BasicBar method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.BAR);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Historic World Population by Region");
    conf.setSubTitle("Source: Wikipedia.org");
    XAxis x = new XAxis();
    x.setCategories("Africa", "America", "Asia", "Europe", "Oceania");
    x.setTitle((String) null);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    AxisTitle title = new AxisTitle("Population (millions)");
    title.setAlign(VerticalAlign.MIDDLE);
    y.setTitle(title);
    conf.addyAxis(y);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.series.name +': '+ this.y +' millions'");
    conf.setTooltip(tooltip);
    PlotOptionsBar plot = new PlotOptionsBar();
    plot.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(plot);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-100);
    legend.setY(100);
    legend.setFloating(true);
    legend.setBorderWidth(1);
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    legend.setShadow(true);
    conf.setLegend(legend);
    conf.disableCredits();
    List<Series> series = new ArrayList<Series>();
    series.add(new ListSeries("Year 1800", 107, 31, 635, 203, 2));
    series.add(new ListSeries("Year 1900", 133, 156, 947, 408, 6));
    series.add(new ListSeries("Year 2008", 973, 914, 4054, 732, 34));
    conf.setSeries(series);
    chart.drawChart(conf);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) ArrayList(java.util.ArrayList) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) PlotOptionsBar(com.vaadin.addon.charts.model.PlotOptionsBar) XAxis(com.vaadin.addon.charts.model.XAxis) Series(com.vaadin.addon.charts.model.Series) ListSeries(com.vaadin.addon.charts.model.ListSeries) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

ListSeries (com.vaadin.addon.charts.model.ListSeries)88 Chart (com.vaadin.addon.charts.Chart)76 Configuration (com.vaadin.addon.charts.model.Configuration)70 YAxis (com.vaadin.addon.charts.model.YAxis)46 XAxis (com.vaadin.addon.charts.model.XAxis)35 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)31 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)25 Tooltip (com.vaadin.addon.charts.model.Tooltip)24 Legend (com.vaadin.addon.charts.model.Legend)18 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)18 DataLabels (com.vaadin.addon.charts.model.DataLabels)17 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)16 Title (com.vaadin.addon.charts.model.Title)15 Labels (com.vaadin.addon.charts.model.Labels)11 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)11 Marker (com.vaadin.addon.charts.model.Marker)10 VerticalLayout (com.vaadin.ui.VerticalLayout)9 Hover (com.vaadin.addon.charts.model.Hover)8 States (com.vaadin.addon.charts.model.States)8 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)8