Search in sources :

Example 36 with AxisTitle

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

the class BasicLineWithHTMLLegend method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getChart().setMarginRight(130);
    configuration.getChart().setMarginBottom(25);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(-5d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.HIGH);
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    configuration.setPlotOptions(plotOptions);
    Legend legend = configuration.getLegend();
    legend.setUseHTML(true);
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-10d);
    legend.setY(100d);
    legend.setBorderWidth(0);
    ListSeries ls = new ListSeries();
    ls.setName("<i>Tokyo</i>");
    ls.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("<span style='font-family:serif;'>New York</span>");
    ls.setData(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("Berlin");
    ls.setData(-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("London");
    ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    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) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) 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 AxisTitle

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

the class BasicLineWithRedGridLines method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getChart().setMarginRight(130);
    configuration.getChart().setMarginBottom(25);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(-5d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.MIDDLE);
    yAxis.setGridLineColor(new SolidColor("red"));
    yAxis.setGridLineDashStyle(DashStyle.DASHDOT);
    yAxis.setGridLineWidth(3);
    XAxis xAxis = configuration.getxAxis();
    xAxis.setGridLineColor(new SolidColor(0, 255, 0, 0.5));
    xAxis.setGridLineWidth(4);
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    configuration.setPlotOptions(plotOptions);
    ListSeries ls = new ListSeries();
    ls.setName("Tokyo");
    ls.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("New York");
    ls.setData(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("Berlin");
    ls.setData(-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("London");
    ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) 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 38 with AxisTitle

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

the class LineWithMissingPoint method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getChart().setMarginRight(130);
    configuration.getChart().setMarginBottom(25);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(-5d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.HIGH);
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    configuration.setPlotOptions(plotOptions);
    Legend legend = configuration.getLegend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-10d);
    legend.setY(100d);
    legend.setBorderWidth(0);
    DataSeries ds = new DataSeries();
    DataSeriesItem item = new DataSeriesItem(1, 2);
    item.setName("a");
    ds.add(item);
    item = new DataSeriesItem(2, 2);
    item.setName("b");
    ds.add(item);
    item = new DataSeriesItem(3, 2);
    item.setName("c");
    ds.add(item);
    item = new DataSeriesItem(4, null);
    item.setName("d");
    ds.add(item);
    item = new DataSeriesItem(5, 2);
    item.setName("e");
    ds.add(item);
    item = new DataSeriesItem(6, 2);
    item.setName("f");
    ds.add(item);
    configuration.addSeries(ds);
    chart.drawChart(configuration);
    System.out.println(configuration);
    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) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 39 with AxisTitle

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

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

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