Search in sources :

Example 26 with AxisTitle

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

the class ChartWithExternalDataProviderWithChangingData method createChart.

public static Chart createChart(Series ds) {
    final Chart chart = new Chart(ChartType.AREA);
    final Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Data from Vaadin DataProvider");
    configuration.getLegend().setEnabled(false);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Data values"));
    yAxis.setMin(0.6);
    yAxis.setStartOnTick(false);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setShared(true);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor("#4572A7"));
    fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
    plotOptions.setFillColor(fillColor);
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Marker marker = plotOptions.getMarker();
    marker.setEnabled(false);
    Hover hoverState = new Hover(true);
    hoverState.setRadius(5);
    hoverState.setLineWidth(1);
    marker.getStates().setHover(hoverState);
    plotOptions.getStates().setHover(new Hover(true));
    plotOptions.setShadow(false);
    configuration.setPlotOptions(plotOptions);
    configuration.setSeries(ds);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Hover(com.vaadin.addon.charts.model.Hover) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 27 with AxisTitle

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

the class StackedAndGroupedColumn method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Total fruit consumption, grouped by gender"));
    XAxis xAxis = new XAxis();
    xAxis.setCategories(new String[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" });
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setAllowDecimals(false);
    yAxis.setMin(0);
    yAxis.setTitle(new AxisTitle("Number of fruits"));
    conf.addyAxis(yAxis);
    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);
    conf.setPlotOptions(plotOptions);
    ListSeries serie = new ListSeries("John", new Number[] { 5, 3, 4, 7, 2 });
    serie.setStack("male");
    conf.addSeries(serie);
    serie = new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 });
    serie.setStack("male");
    conf.addSeries(serie);
    serie = new ListSeries("Jane", new Number[] { 2, 5, 6, 2, 1 });
    serie.setStack("female");
    conf.addSeries(serie);
    serie = new ListSeries("Janet", new Number[] { 3, 0, 4, 4, 3 });
    serie.setStack("female");
    conf.addSeries(serie);
    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 AxisTitle

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

the class ContainerWithLotsOfData method createChart.

public static Chart createChart(Series container) {
    final Chart chart = new Chart();
    final Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.AREA);
    configuration.getTitle().setText("Data from Vaadin Container");
    configuration.getLegend().setEnabled(false);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Exchange rate"));
    yAxis.setMin(0.6);
    yAxis.setStartOnTick(false);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setShared(true);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor("#4572A7"));
    fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
    plotOptions.setFillColor(fillColor);
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Marker marker = plotOptions.getMarker();
    marker.setEnabled(false);
    Hover hoverState = new Hover(true);
    hoverState.setRadius(5);
    hoverState.setLineWidth(1);
    marker.getStates().setHover(hoverState);
    plotOptions.getStates().setHover(new Hover(true));
    plotOptions.setShadow(false);
    configuration.setPlotOptions(plotOptions);
    configuration.setSeries(container);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Hover(com.vaadin.addon.charts.model.Hover) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 29 with AxisTitle

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

the class PercentageArea method createNewChart.

public static Chart createNewChart() {
    Chart chart = new Chart(ChartType.AREA);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Historic and Estimated Worldwide Population Distribution by Region"));
    conf.setSubTitle(new Subtitle("Source: Wikipedia.org"));
    XAxis xAxis = new XAxis();
    xAxis.setTickmarkPlacement(TickmarkPlacement.ON);
    xAxis.setCategories("1750", "1800", "1850", "1900", "1950", "1999", "2050");
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setTitle(new AxisTitle("Percent"));
    conf.addyAxis(yAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.series.name + ': ' +this.x +': '+ Highcharts.numberFormat(this.percentage, 1) +'% ('+ Highcharts.numberFormat(this.y, 0, ',') +' millions)'");
    conf.setTooltip(tooltip);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setStacking(Stacking.PERCENT);
    plotOptions.setLineWidth(1);
    Marker marker = new Marker();
    plotOptions.setMarker(marker);
    conf.setPlotOptions(plotOptions);
    conf.addSeries(new ListSeries("Asia", 502, 635, 809, 947, 1402, 3634, 5268));
    conf.addSeries(new ListSeries("Africa", 106, 107, 111, 133, 221, 767, 1766));
    conf.addSeries(new ListSeries("Europe", 163, 203, 276, 408, 547, 729, 628));
    conf.addSeries(new ListSeries("America", 18, 31, 54, 156, 339, 818, 1201));
    conf.addSeries(new ListSeries("Ocenia", 2, 2, 2, 6, 13, 30, 46));
    chart.drawChart(conf);
    return chart;
}
Also used : Subtitle(com.vaadin.addon.charts.model.Subtitle) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) 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) Marker(com.vaadin.addon.charts.model.Marker) 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 30 with AxisTitle

use of com.vaadin.addon.charts.model.AxisTitle 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)

Aggregations

AxisTitle (com.vaadin.addon.charts.model.AxisTitle)53 Configuration (com.vaadin.addon.charts.model.Configuration)52 YAxis (com.vaadin.addon.charts.model.YAxis)50 Chart (com.vaadin.addon.charts.Chart)49 ListSeries (com.vaadin.addon.charts.model.ListSeries)30 XAxis (com.vaadin.addon.charts.model.XAxis)26 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)25 DataLabels (com.vaadin.addon.charts.model.DataLabels)18 DataSeries (com.vaadin.addon.charts.model.DataSeries)18 Tooltip (com.vaadin.addon.charts.model.Tooltip)16 Legend (com.vaadin.addon.charts.model.Legend)15 Marker (com.vaadin.addon.charts.model.Marker)14 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)12 Labels (com.vaadin.addon.charts.model.Labels)12 Title (com.vaadin.addon.charts.model.Title)12 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)11 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)11 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)10 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)10 Hover (com.vaadin.addon.charts.model.Hover)9