Search in sources :

Example 21 with AxisTitle

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

the class StackedArea method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.AREA);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Historic and Estimated Worldwide Population Growth 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("Billions"));
    Labels labels = new Labels();
    labels.setFormatter("this.value / 1000");
    yAxis.setLabels(labels);
    conf.addyAxis(yAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.x +': '+ Highcharts.numberFormat(this.y, 0, ',') +' millions'");
    conf.setTooltip(tooltip);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setStacking(Stacking.NORMAL);
    conf.setPlotOptions(plotOptions);
    List<Series> series = new ArrayList<Series>();
    series.add(new ListSeries("Asia", 502, 635, 809, 947, 1402, 3634, 5268));
    series.add(new ListSeries("Africa", 106, 107, 111, 133, 221, 767, 1766));
    series.add(new ListSeries("Europe", 163, 203, 276, 408, 547, 729, 628));
    series.add(new ListSeries("America", 18, 31, 54, 156, 339, 818, 1201));
    series.add(new ListSeries("Ocenia", 2, 2, 2, 6, 13, 30, 46));
    conf.setSeries(series);
    chart.drawChart(conf);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) ArrayList(java.util.ArrayList) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Title(com.vaadin.addon.charts.model.Title) Labels(com.vaadin.addon.charts.model.Labels) XAxis(com.vaadin.addon.charts.model.XAxis) Subtitle(com.vaadin.addon.charts.model.Subtitle) Series(com.vaadin.addon.charts.model.Series) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) 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 22 with AxisTitle

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

the class MasterDetailChart method getDetailChart.

private Chart getDetailChart() {
    Chart detailChart = new Chart();
    detailChart.setHeight("100%");
    detailChart.setWidth("100%");
    Configuration configuration = detailChart.getConfiguration();
    configuration.getCredits().setEnabled(false);
    configuration.setTitle("Historical USD to EUR Exchange Rate");
    configuration.setSubTitle("Select an area by dragging across the lower chart");
    configuration.getxAxis().setType(AxisType.DATETIME);
    configuration.getyAxis().setTitle(new AxisTitle((String) null));
    configuration.getyAxis().setMinRange(0.1);
    configuration.getTooltip().setFormatter("function() {var point = this.points[0];return '<b>'+ point.series.name +'</b><br/>'+Highcharts.dateFormat('%A %B %e %Y', this.x) + ':<br/>'+'1 USD = '+ Highcharts.numberFormat(point.y, 2) +' EUR';}");
    configuration.getTooltip().setShared(true);
    PlotOptionsLine series = new PlotOptionsLine();
    series.setPointInterval(DAY_IN_MILLIS);
    configuration.setPlotOptions(series);
    States states = new States();
    Hover hover = new Hover();
    hover.setRadius(3);
    states.setHover(hover);
    Marker marker = series.getMarker();
    marker.setEnabled(false);
    marker.setStates(states);
    marker.setRadius(2);
    series.setAnimation(false);
    ListSeries seriesList = new ListSeries();
    PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
    plotOptionsLine.setPointInterval(DAY_IN_MILLIS);
    plotOptionsLine.setPointStart(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
    seriesList.setPlotOptions(plotOptionsLine);
    seriesList.setName("USD to EUR");
    seriesList.setData(FULL_DEMO_DATA_SET);
    configuration.getLegend().setEnabled(false);
    configuration.setExporting(false);
    configuration.addSeries(seriesList);
    detailChart.drawChart(configuration);
    return detailChart;
}
Also used : States(com.vaadin.addon.charts.model.States) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) Hover(com.vaadin.addon.charts.model.Hover) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart)

Example 23 with AxisTitle

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

the class MasterDetailChart method getMasterChart.

private Chart getMasterChart() {
    Chart masterChart = new Chart(ChartType.AREA);
    masterChart.setHeight("80px");
    masterChart.setWidth("100%");
    masterChart.setId("master-chart");
    Configuration configuration = masterChart.getConfiguration();
    configuration.getChart().setZoomType(ZoomType.X);
    configuration.getChart().setReflow(false);
    configuration.getChart().setBorderWidth(0);
    configuration.getChart().setBackgroundColor(null);
    configuration.getChart().setMarginLeft(50);
    configuration.getChart().setMarginRight(20);
    configuration.getTitle().setText("");
    configuration.getxAxis().setType(AxisType.DATETIME);
    configuration.getxAxis().setShowLastLabel(true);
    configuration.getxAxis().setMinRange(14 * DAY_IN_MILLIS);
    configuration.getxAxis().setTitle(new AxisTitle(""));
    PlotBand mask = new PlotBand();
    mask.setColor(new SolidColor(0, 0, 0, 0.2));
    mask.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
    mask.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
    configuration.getxAxis().setPlotBands(mask);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setGridLineWidth(0);
    yAxis.setLabels(new Labels(false));
    yAxis.setTitle(new AxisTitle(""));
    yAxis.setMin(0.6);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setEnabled(false);
    configuration.getLegend().setEnabled(false);
    configuration.getCredits().setEnabled(false);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Hover hover = new Hover();
    hover.setLineWidth(1);
    States states = new States();
    states.setHover(hover);
    plotOptions.setStates(states);
    plotOptions.setEnableMouseTracking(false);
    plotOptions.setAnimation(false);
    configuration.setPlotOptions(plotOptions);
    ListSeries ls = new ListSeries();
    PlotOptionsArea masterPlotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor(69, 114, 167, 1));
    fillColor.addColorStop(1, new SolidColor(69, 114, 167, 0.5));
    masterPlotOptions.setFillColor(fillColor);
    masterPlotOptions.setPointInterval(24 * 3600 * 1000);
    masterPlotOptions.setMarker(new Marker(false));
    masterPlotOptions.setPointStart(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
    ls.setPlotOptions(masterPlotOptions);
    ls.setName("USD to EUR");
    ls.setData(FULL_DEMO_DATA_SET);
    configuration.addSeries(ls);
    masterChart.drawChart(configuration);
    return masterChart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Labels(com.vaadin.addon.charts.model.Labels) Marker(com.vaadin.addon.charts.model.Marker) States(com.vaadin.addon.charts.model.States) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) ListSeries(com.vaadin.addon.charts.model.ListSeries) Hover(com.vaadin.addon.charts.model.Hover) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 24 with AxisTitle

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

the class MultipleAxes method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    Color[] colors = getThemeColors();
    conf.getChart().setZoomType(ZoomType.XY);
    conf.setTitle("Average Monthly Weather Data for Tokyo");
    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 y1 = new YAxis();
    Labels labels = new Labels();
    labels.setFormatter("return this.value +'°C'");
    Style style = new Style();
    style.setColor(colors[1]);
    labels.setStyle(style);
    y1.setLabels(labels);
    y1.setOpposite(true);
    AxisTitle title = new AxisTitle("Temperature");
    style = new Style();
    style.setColor(colors[1]);
    y1.setTitle(title);
    conf.addyAxis(y1);
    YAxis y2 = new YAxis();
    y2.setGridLineWidth(0);
    title = new AxisTitle("Rainfall");
    style = new Style();
    style.setColor(colors[0]);
    y2.setTitle(title);
    labels = new Labels();
    labels.setFormatter("this.value +' mm'");
    style = new Style();
    style.setColor(colors[0]);
    labels.setStyle(style);
    y2.setLabels(labels);
    conf.addyAxis(y2);
    YAxis y3 = new YAxis();
    y3.setGridLineWidth(0);
    conf.addyAxis(y3);
    title = new AxisTitle("Sea-Level Pressure");
    style = new Style();
    style.setColor(colors[2]);
    y3.setTitle(title);
    labels = new Labels();
    labels.setFormatter("this.value +' mb'");
    style = new Style();
    style.setColor(colors[2]);
    labels.setStyle(style);
    y3.setLabels(labels);
    y3.setOpposite(true);
    chart.drawChart(conf);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("function() { " + "var unit = { 'Rainfall': 'mm', 'Temperature': '°C', 'Sea-Level Pressure': 'mb' }[this.series.name];" + "return ''+ this.x +': '+ this.y +' '+ unit; }");
    conf.setTooltip(tooltip);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setX(120);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setY(80);
    legend.setFloating(true);
    conf.setLegend(legend);
    DataSeries series = new DataSeries();
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setColor(colors[0]);
    series.setPlotOptions(plotOptionsColumn);
    series.setName("Rainfall");
    series.setyAxis(1);
    series.setData(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(series);
    series = new DataSeries();
    PlotOptionsSpline plotOptionsSpline = new PlotOptionsSpline();
    plotOptionsSpline.setColor(colors[2]);
    series.setPlotOptions(plotOptionsSpline);
    series.setName("Sea-Level Pressure");
    series.setyAxis(2);
    series.setData(1016, 1016, 1015.9, 1015.5, 1012.3, 1009.5, 1009.6, 1010.2, 1013.1, 1016.9, 1018.2, 1016.7);
    conf.addSeries(series);
    series = new DataSeries();
    plotOptionsSpline = new PlotOptionsSpline();
    plotOptionsSpline.setColor(colors[1]);
    series.setPlotOptions(plotOptionsSpline);
    series.setName("Temperature");
    series.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);
    conf.addSeries(series);
    chart.drawChart(conf);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Color(com.vaadin.addon.charts.model.style.Color) Tooltip(com.vaadin.addon.charts.model.Tooltip) Labels(com.vaadin.addon.charts.model.Labels) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) Style(com.vaadin.addon.charts.model.style.Style) DataSeries(com.vaadin.addon.charts.model.DataSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 25 with AxisTitle

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

the class ColumnWithShapedLabels 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"));
    conf.addyAxis(yAxis);
    PlotOptionsColumn plotOptions = new PlotOptionsColumn();
    plotOptions.setStacking(Stacking.NORMAL);
    DataLabels labels = new DataLabels(true);
    labels.setBackgroundColor(SolidColor.BURLYWOOD);
    labels.setColor(new SolidColor("white"));
    labels.setShape(Shape.DIAMOND);
    Style style = new Style();
    style.setTextShadow("0 0 3px black");
    labels.setStyle(style);
    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 : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) 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) Style(com.vaadin.addon.charts.model.style.Style) 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