Search in sources :

Example 36 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class BasicBarNoTitle method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.BAR);
    Configuration conf = chart.getConfiguration();
    conf.getTitle().setText(null);
    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)

Example 37 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class BasicColumn method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Monthly Average Rainfall");
    conf.setSubTitle("Source: WorldClimate.com");
    XAxis x = new XAxis();
    x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    y.setTitle("Rainfall (mm)");
    conf.addyAxis(y);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(100);
    legend.setY(70);
    legend.setFloating(true);
    legend.setShadow(true);
    conf.setLegend(legend);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.x +': '+ this.y +' mm'");
    conf.setTooltip(tooltip);
    PlotOptionsColumn plot = new PlotOptionsColumn();
    plot.setPointPadding(0.2);
    plot.setBorderWidth(0);
    conf.addSeries(new ListSeries("Tokyo", 49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4));
    conf.addSeries(new ListSeries("New York", 83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3));
    conf.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2));
    conf.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1));
    chart.drawChart(conf);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) 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) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 38 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class AreaWithMissingPoints method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.AREA);
    Configuration conf = chart.getConfiguration();
    conf.getChart().setSpacingBottom(30);
    conf.setTitle(new Title("Fruit consumption *"));
    Subtitle subTitle = new Subtitle("* Jane\'s banana consumption is unknown");
    subTitle.setFloating(true);
    subTitle.setY(15);
    subTitle.setAlign(HorizontalAlign.RIGHT);
    subTitle.setVerticalAlign(VerticalAlign.BOTTOM);
    conf.setSubTitle(subTitle);
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Apples", "Pears", "Oranges", "Bananas", "Grapes", "Plums", "Strawberries", "Raspberries");
    conf.addxAxis(xAxis);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setFloating(true);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(150);
    legend.setY(100);
    legend.setBorderWidth(1);
    legend.setBackgroundColor(new SolidColor("#ffffff"));
    conf.setLegend(legend);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setFillOpacity(0.5);
    conf.setPlotOptions(plotOptions);
    conf.addSeries(new ListSeries("John", 0, 1, 4, 4, 5, 2, 3, 7));
    conf.addSeries(new ListSeries("Jane", 1, 0, 3, null, 3, 1, 2, 1));
    chart.drawChart(conf);
    return chart;
}
Also used : Subtitle(com.vaadin.addon.charts.model.Subtitle) Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) ListSeries(com.vaadin.addon.charts.model.ListSeries) Title(com.vaadin.addon.charts.model.Title) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis)

Example 39 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class InvertedAxes method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.AREA);
    Configuration conf = chart.getConfiguration();
    conf.getChart().setInverted(true);
    conf.setTitle(new Title("Average fruit consumption during one week"));
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setTitle(new AxisTitle("Number of units"));
    yAxis.setMin(0);
    conf.addyAxis(yAxis);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setFloating(true);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-150);
    legend.setY(100);
    legend.setBorderWidth(1);
    legend.setBackgroundColor(new SolidColor("#ffffff"));
    conf.setLegend(legend);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setFillOpacity(0.5);
    conf.setPlotOptions(plotOptions);
    conf.addSeries(new ListSeries("John", 3, 4, 3, 5, 4, 10, 12));
    conf.addSeries(new ListSeries("Jane", 1, 3, 4, 3, 3, 5, 4));
    chart.drawChart(conf);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Title(com.vaadin.addon.charts.model.Title) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) 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 40 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class ToggledSeriesVisibility method getChart.

@Override
protected Component getChart() {
    chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Monthly Average Rainfall");
    conf.setSubTitle("Source: WorldClimate.com");
    XAxis x = new XAxis();
    x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    y.setTitle("Rainfall (mm)");
    conf.addyAxis(y);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(100);
    legend.setY(70);
    legend.setFloating(true);
    legend.setShadow(true);
    conf.setLegend(legend);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.x +': '+ this.y +' mm'");
    conf.setTooltip(tooltip);
    PlotOptionsColumn plot = new PlotOptionsColumn();
    plot.setPointPadding(0.2);
    plot.setBorderWidth(0);
    conf.addSeries(tokyo);
    conf.addSeries(newYork);
    conf.addSeries(berlin);
    conf.addSeries(london);
    chart.addLegendItemClickListener(new LegendItemClickListener() {

        @Override
        public void onClick(LegendItemClickEvent event) {
            /*
                 * Visibility of the series is also toggled from legend clicks
                 * by default. Still developers might wish to override this
                 * behavior if the visibility is also controlled by other
                 * components like here or if e.g. multiple charts are bound
                 * together (hiding series in one chart should hide related data
                 * in other chart as well).
                 */
            ListSeries series = (ListSeries) event.getSeries();
            /*
                 * Toggle checked in option group. As a side effect (via value
                 * change listener, see setup method) the visibility will change
                 * in the chart as well.
                 */
            if (series.isVisible()) {
                checkBoxGroup.deselect(series);
            } else {
                checkBoxGroup.select(series);
            }
        }
    });
    chart.drawChart(conf);
    return chart;
}
Also used : LegendItemClickListener(com.vaadin.addon.charts.LegendItemClickListener) Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) LegendItemClickEvent(com.vaadin.addon.charts.LegendItemClickEvent) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

SolidColor (com.vaadin.addon.charts.model.style.SolidColor)82 Configuration (com.vaadin.addon.charts.model.Configuration)55 Chart (com.vaadin.addon.charts.Chart)54 YAxis (com.vaadin.addon.charts.model.YAxis)40 DataSeries (com.vaadin.addon.charts.model.DataSeries)27 ListSeries (com.vaadin.addon.charts.model.ListSeries)26 XAxis (com.vaadin.addon.charts.model.XAxis)26 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)25 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)19 DataLabels (com.vaadin.addon.charts.model.DataLabels)18 Legend (com.vaadin.addon.charts.model.Legend)17 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)15 Marker (com.vaadin.addon.charts.model.Marker)14 Tooltip (com.vaadin.addon.charts.model.Tooltip)14 Style (com.vaadin.addon.charts.model.style.Style)14 Labels (com.vaadin.addon.charts.model.Labels)12 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)11 Random (java.util.Random)10 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)9 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8