Search in sources :

Example 66 with ListSeries

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

the class PolarChart method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.getChart().setPolar(true);
    conf.setTitle("Polar Chart");
    Pane pane = new Pane(0, 360);
    conf.addPane(pane);
    pane.setBackground(new Background[] {});
    XAxis axis = new XAxis();
    axis.setTickInterval(45);
    axis.setMin(0);
    axis.setMax(360);
    Labels labels = new Labels();
    labels.setFormatter("function() {return this.value + '°';}");
    axis.setLabels(labels);
    YAxis yaxs = new YAxis();
    yaxs.setMin(0);
    conf.addxAxis(axis);
    conf.addyAxis(yaxs);
    PlotOptionsSeries series = new PlotOptionsSeries();
    PlotOptionsColumn column = new PlotOptionsColumn();
    series.setPointStart(0);
    series.setPointInterval(45);
    column.setPointPadding(0);
    column.setGroupPadding(0);
    conf.setPlotOptions(series, column);
    ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
    ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
    ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
    col.setPlotOptions(new PlotOptionsColumn());
    col.setName(ChartType.COLUMN.toString());
    line.setPlotOptions(new PlotOptionsLine());
    line.setName(ChartType.LINE.toString());
    area.setPlotOptions(new PlotOptionsArea());
    area.setName(ChartType.AREA.toString());
    conf.setSeries(col, line, area);
    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) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) Labels(com.vaadin.addon.charts.model.Labels) Pane(com.vaadin.addon.charts.model.Pane) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 67 with ListSeries

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

the class BasicLineWithCustomCrosshairLabels method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setTimeline(true);
    chart.setId("chart");
    Configuration config = chart.getConfiguration();
    config.setTitle("Customized crosshairs");
    config.getChart().setAnimation(false);
    Crosshair xCrossHair = new Crosshair();
    xCrossHair.getLabel().setEnabled(true);
    xCrossHair.getLabel().setBackgroundColor(new SolidColor("#ff0000"));
    xCrossHair.getLabel().setBorderColor(new SolidColor("#ff00ff"));
    xCrossHair.getLabel().setBorderWidth(3);
    config.getxAxis().setCrosshair(xCrossHair);
    Crosshair yCrossHair = new Crosshair();
    yCrossHair.setColor(new SolidColor("#880000"));
    yCrossHair.setDashStyle(DashStyle.DOT);
    yCrossHair.setWidth(5);
    yCrossHair.setZIndex(1);
    config.getyAxis().setCrosshair(yCrossHair);
    ListSeries ls = new ListSeries();
    ls.setName("Data");
    ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
    config.setSeries(ls);
    chart.drawChart(config);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart)

Example 68 with ListSeries

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

the class BasicLineWithCustomCrosshairs method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setId("chart");
    Configuration config = chart.getConfiguration();
    config.setTitle("Customized crosshairs");
    Crosshair xCrossHair = new Crosshair();
    xCrossHair.setColor(SolidColor.BLACK);
    xCrossHair.setDashStyle(DashStyle.SOLID);
    xCrossHair.setWidth(10);
    xCrossHair.setZIndex(0);
    config.getxAxis().setCrosshair(xCrossHair);
    Crosshair yCrossHair = new Crosshair();
    yCrossHair.setColor(new SolidColor("#880000"));
    yCrossHair.setDashStyle(DashStyle.DOT);
    yCrossHair.setWidth(5);
    yCrossHair.setZIndex(1);
    config.getyAxis().setCrosshair(yCrossHair);
    ListSeries ls = new ListSeries();
    ls.setName("Data");
    ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
    config.setSeries(ls);
    chart.drawChart(config);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart)

Example 69 with ListSeries

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

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

Aggregations

ListSeries (com.vaadin.addon.charts.model.ListSeries)88 Chart (com.vaadin.addon.charts.Chart)76 Configuration (com.vaadin.addon.charts.model.Configuration)70 YAxis (com.vaadin.addon.charts.model.YAxis)46 XAxis (com.vaadin.addon.charts.model.XAxis)35 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)31 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)25 Tooltip (com.vaadin.addon.charts.model.Tooltip)24 Legend (com.vaadin.addon.charts.model.Legend)18 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)18 DataLabels (com.vaadin.addon.charts.model.DataLabels)17 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)16 Title (com.vaadin.addon.charts.model.Title)15 Labels (com.vaadin.addon.charts.model.Labels)11 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)11 Marker (com.vaadin.addon.charts.model.Marker)10 VerticalLayout (com.vaadin.ui.VerticalLayout)9 Hover (com.vaadin.addon.charts.model.Hover)8 States (com.vaadin.addon.charts.model.States)8 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)8