Search in sources :

Example 26 with PlotOptionsColumn

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

the class ColumnWithRotatedLabels method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.getChart().setMargin(50, 80, 100, 50);
    conf.setTitle(new Title("World's largest cities per 2008"));
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Tokyo", "Jakarta", "New York", "Seoul", "Manila", "Mumbai", "Sao Paulo", "Mexico City", "Dehli", "Osaka", "Cairo", "Kolkata", "Los Angeles", "Shanghai", "Moscow", "Beijing", "Buenos Aires", "Guangzhou", "Shenzhen", "Istanbul");
    Labels labels = new Labels();
    labels.setRotation(-45);
    labels.setAlign(HorizontalAlign.RIGHT);
    Style style = new Style();
    style.setFontSize("13px");
    style.setFontFamily("Verdana, sans-serif");
    labels.setStyle(style);
    xAxis.setLabels(labels);
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setMin(0);
    yAxis.setTitle(new AxisTitle("Population (millions)"));
    conf.addyAxis(yAxis);
    Legend legend = new Legend();
    legend.setEnabled(false);
    conf.setLegend(legend);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("'<b>'+ this.x +'</b><br/>'+'Population in 2008: '" + "+ Highcharts.numberFormat(this.y, 1) +' millions'");
    conf.setTooltip(tooltip);
    ListSeries serie = new ListSeries("Population", new Number[] { 34.4, 21.8, 20.1, 20, 19.6, 19.5, 19.1, 18.4, 18, 17.3, 16.8, 15, 14.7, 14.5, 13.3, 12.8, 12.4, 11.8, 11.7, 11.2 });
    DataLabels dataLabels = new DataLabels();
    dataLabels.setEnabled(true);
    dataLabels.setRotation(-90);
    dataLabels.setColor(new SolidColor(255, 255, 255));
    dataLabels.setAlign(HorizontalAlign.RIGHT);
    dataLabels.setX(4);
    dataLabels.setY(10);
    dataLabels.setFormatter("this.y");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setDataLabels(dataLabels);
    serie.setPlotOptions(plotOptionsColumn);
    conf.addSeries(serie);
    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) DataLabels(com.vaadin.addon.charts.model.DataLabels) Labels(com.vaadin.addon.charts.model.Labels) XAxis(com.vaadin.addon.charts.model.XAxis) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) 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 27 with PlotOptionsColumn

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

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

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

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

the class BasicColumnWithPointWidthAndRange method getChart.

@Override
protected Component getChart() {
    chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Visualize point width and point range");
    plotOptions = new PlotOptionsColumn();
    // plotOptions.setPointRange(10);
    plotOptions.setPointWidth(100);
    conf.setPlotOptions(plotOptions);
    DataSeries dataSeries = new DataSeries();
    dataSeries.addData(new Number[][] { { 0, 1 }, { 2, 2 }, { 10, 3 } });
    conf.setSeries(dataSeries);
    chart.drawChart(conf);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart)

Aggregations

PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)37 Chart (com.vaadin.addon.charts.Chart)34 Configuration (com.vaadin.addon.charts.model.Configuration)30 YAxis (com.vaadin.addon.charts.model.YAxis)28 XAxis (com.vaadin.addon.charts.model.XAxis)26 Tooltip (com.vaadin.addon.charts.model.Tooltip)20 ListSeries (com.vaadin.addon.charts.model.ListSeries)16 DataSeries (com.vaadin.addon.charts.model.DataSeries)13 DataLabels (com.vaadin.addon.charts.model.DataLabels)11 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)11 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)10 Style (com.vaadin.addon.charts.model.style.Style)9 Legend (com.vaadin.addon.charts.model.Legend)8 Title (com.vaadin.addon.charts.model.Title)8 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)7 Labels (com.vaadin.addon.charts.model.Labels)5 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)5 DrilldownCallback (com.vaadin.addon.charts.DrilldownCallback)4 DrilldownEvent (com.vaadin.addon.charts.DrilldownEvent)4 DataProviderSeries (com.vaadin.addon.charts.model.DataProviderSeries)4