Search in sources :

Example 56 with ListSeries

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

the class BarWithLegendLabelFormatter method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.BAR);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Historic World Population by Region");
    conf.setSubTitle("Source: Wikipedia.org");
    Legend legend = new Legend();
    legend.setLabelFormatter("function() { return this.name + ' (click to hide)'; }");
    conf.setLegend(legend);
    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);
    return chart;
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries) Series(com.vaadin.addon.charts.model.Series) Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) ArrayList(java.util.ArrayList) Chart(com.vaadin.addon.charts.Chart)

Example 57 with ListSeries

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

the class PointClickCoordinatesColumnChart method addSeries.

@Override
protected void addSeries(Configuration conf) {
    conf.addSeries(new ListSeries("Tokyo", 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(new ListSeries("New York", 83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3));
    conf.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2));
    conf.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1));
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries)

Example 58 with ListSeries

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

the class VUMeter method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart();
    chart.setWidth("600px");
    chart.setHeight("200px");
    GradientColor gradient = GradientColor.createLinear(0, 0, 0, 1);
    gradient.addColorStop(0, new SolidColor("#FFF4C6"));
    gradient.addColorStop(0.3, new SolidColor("#FFFFFF"));
    gradient.addColorStop(1, new SolidColor("#FFF4C6"));
    final Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.GAUGE);
    configuration.getChart().setPlotBackgroundColor(gradient);
    configuration.getChart().setPlotBackgroundImage(null);
    configuration.getChart().setPlotBorderWidth(1);
    configuration.setTitle("VU meter");
    Pane pane1 = new Pane(-45, 45);
    Pane pane2 = new Pane(-45, 45);
    pane1.setBackground(new Background[] {});
    pane2.setBackground(new Background[] {});
    pane1.setCenter("25%", "145%");
    pane2.setCenter("75%", "145%");
    pane1.setSize("300px");
    pane2.setSize("300");
    configuration.addPane(pane1);
    configuration.addPane(pane2);
    PlotBand plotBand1 = new PlotBand(0, 6, new SolidColor("#C02316"));
    plotBand1.setInnerRadius("100%");
    plotBand1.setOuterRadius("105%");
    PlotBand plotBand2 = new PlotBand(0, 6, new SolidColor("#C02316"));
    plotBand2.setInnerRadius("100%");
    plotBand2.setOuterRadius("105%");
    YAxis yAxis = new YAxis();
    yAxis.setPane(pane1);
    yAxis.setTitle("VU<br/><span style=\"font-size:8px\">Channel A</span>");
    yAxis.getTitle().setY(-40);
    yAxis.setMin(-20);
    yAxis.setMax(6);
    yAxis.setTickPosition(TickPosition.OUTSIDE);
    yAxis.setMinorTickPosition(TickPosition.OUTSIDE);
    Labels labels = new Labels();
    labels.setDistance(20);
    labels.setRotationPerpendicular();
    yAxis.setLabels(labels);
    yAxis.setPlotBands(plotBand1);
    YAxis yAxis2 = new YAxis();
    yAxis2.setPane(pane2);
    yAxis2.setTitle("VU<br/><span style=\"font-size:8px\">Channel B</span>");
    yAxis2.getTitle().setY(-40);
    yAxis2.setMin(-20);
    yAxis2.setMax(6);
    yAxis2.setTickPosition(TickPosition.OUTSIDE);
    yAxis2.setMinorTickPosition(TickPosition.OUTSIDE);
    labels = new Labels();
    labels.setDistance(20);
    labels.setRotationPerpendicular();
    yAxis2.setLabels(labels);
    yAxis2.setPlotBands(plotBand2);
    configuration.addyAxis(yAxis);
    configuration.addyAxis(yAxis2);
    PlotOptionsGauge gauge = new PlotOptionsGauge();
    gauge.setDataLabels(new DataLabels(false));
    gauge.setDial(new Dial());
    gauge.getDial().setRadius("100%");
    configuration.setPlotOptions(gauge);
    final ListSeries series1 = new ListSeries(-20);
    final ListSeries series2 = new ListSeries(-20);
    series1.setyAxis(0);
    series2.setyAxis(1);
    configuration.setSeries(series1, series2);
    runWhileAttached(chart, new Runnable() {

        final Random r = new Random(0);

        @Override
        public void run() {
            double left = series1.getData()[0].doubleValue();
            double inc = (r.nextDouble() - 0.5) * 3;
            double leftVal = left + inc;
            double rightVal = leftVal + inc / 3;
            if (leftVal < -20 || leftVal > 6) {
                leftVal = left - inc;
            }
            if (rightVal < -20 || rightVal > 6) {
                rightVal = leftVal;
            }
            series1.updatePoint(0, leftVal);
            series2.updatePoint(0, rightVal);
        }
    }, 500, 12000);
    chart.drawChart(configuration);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataLabels(com.vaadin.addon.charts.model.DataLabels) Labels(com.vaadin.addon.charts.model.Labels) Pane(com.vaadin.addon.charts.model.Pane) PlotOptionsGauge(com.vaadin.addon.charts.model.PlotOptionsGauge) Dial(com.vaadin.addon.charts.model.Dial) Random(java.util.Random) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 59 with ListSeries

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

the class PointClickCoordinatesBarChart method addSeries.

@Override
public void addSeries(Configuration conf) {
    conf.addSeries(new ListSeries("Year 1800", 107, 31, 635, 203, 2));
    conf.addSeries(new ListSeries("Year 1900", 133, 156, 947, 408, 6));
    conf.addSeries(new ListSeries("Year 2008", 973, 914, 4054, 732, 34));
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries)

Example 60 with ListSeries

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

the class LogarithmicAxis method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Logarithmic axis demo");
    configuration.getxAxis().setTickInterval(1);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setType(AxisType.LOGARITHMIC);
    yAxis.setMinorTickInterval("0.1");
    configuration.getTooltip().setHeaderFormat("<b>{series.name}</b><br />");
    configuration.getTooltip().setPointFormat("x = {point.x}, y = {point.y}");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setPointStart(1);
    configuration.setPlotOptions(plotOptions);
    ListSeries ls = new ListSeries(1, 2, 4, 8, 16, 32, 64, 128, 256, 512);
    configuration.setSeries(ls);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) Chart(com.vaadin.addon.charts.Chart) 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