Search in sources :

Example 16 with Title

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

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

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

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

the class ColoredContainerSeries method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.AREA);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Colored ContainerDataSeries"));
    conf.addxAxis(new XAxis());
    YAxis yAxis = new YAxis();
    yAxis.setTitle("Numbers");
    conf.addyAxis(yAxis);
    Collection<Test> col = new ArrayList<>();
    col.add(new Test(10, "TEN"));
    col.add(new Test(11, "ELEVEN"));
    col.add(new Test(12, "TWELVE"));
    DataProvider<Test, ?> ds = new ListDataProvider<>(col);
    DataProviderSeries<Test> chartDS = new DataProviderSeries<>(ds);
    chartDS.setName("Test Series");
    chartDS.setY(Test::getNumber);
    chartDS.setPointName(Test::getName);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setFillColor(SolidColor.CORNFLOWERBLUE);
    plotOptions.setColor(SolidColor.GOLDENROD);
    chartDS.setPlotOptions(plotOptions);
    // conf.setPlotOptions(plotOptions);
    conf.setSeries(chartDS);
    chart.drawChart(conf);
    return chart;
}
Also used : ListDataProvider(com.vaadin.data.provider.ListDataProvider) DataProviderSeries(com.vaadin.addon.charts.model.DataProviderSeries) Configuration(com.vaadin.addon.charts.model.Configuration) ArrayList(java.util.ArrayList) Title(com.vaadin.addon.charts.model.Title) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

Title (com.vaadin.addon.charts.model.Title)19 Configuration (com.vaadin.addon.charts.model.Configuration)17 Chart (com.vaadin.addon.charts.Chart)16 XAxis (com.vaadin.addon.charts.model.XAxis)16 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)15 ListSeries (com.vaadin.addon.charts.model.ListSeries)15 YAxis (com.vaadin.addon.charts.model.YAxis)13 Tooltip (com.vaadin.addon.charts.model.Tooltip)12 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)8 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)7 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)6 Legend (com.vaadin.addon.charts.model.Legend)5 DataLabels (com.vaadin.addon.charts.model.DataLabels)4 Subtitle (com.vaadin.addon.charts.model.Subtitle)4 Style (com.vaadin.addon.charts.model.style.Style)4 Labels (com.vaadin.addon.charts.model.Labels)3 Test (org.junit.Test)3 Credits (com.vaadin.addon.charts.model.Credits)2 LegendTitle (com.vaadin.addon.charts.model.LegendTitle)2 Marker (com.vaadin.addon.charts.model.Marker)2