Search in sources :

Example 71 with ListSeries

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

the class BasicLineWithShadow 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().setShadow(true);
    ListSeries ls = new ListSeries();
    ls.setData(1, 2, 3, 4, 5, 6, 7);
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Chart(com.vaadin.addon.charts.Chart)

Example 72 with ListSeries

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

the class BasicLineWithTickCount method getChart.

@Override
protected Component getChart() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(false);
    layout.setMargin(false);
    final Chart chart = new Chart(ChartType.LINE);
    chart.setHeight("400px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    XAxis xAxis = configuration.getxAxis();
    Labels xLabels = new Labels();
    xLabels.setAutoRotation(new Number[] { -10, -20, -30, -40, 50, -60, -70, -80, -90 });
    xAxis.setLabels(xLabels);
    final YAxis yAxis = configuration.getyAxis();
    yAxis.setTickAmount(10);
    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);
    layout.addComponent(chart);
    final Slider slider = new Slider("Tick count (2 - 16)", 2, 16);
    slider.setWidth("200px");
    slider.setValue(10d);
    layout.addComponent(slider);
    layout.addComponent(new Button("Set max amount", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            slider.setValue(16d);
        }
    }));
    slider.addValueChangeListener(event -> {
        double newValue = slider.getValue();
        yAxis.setTickAmount(newValue);
        chart.drawChart();
    });
    return layout;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Slider(com.vaadin.ui.Slider) ListSeries(com.vaadin.addon.charts.model.ListSeries) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) Labels(com.vaadin.addon.charts.model.Labels) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 73 with ListSeries

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

the class BasicLineWithTickPositions method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setId("chart");
    Configuration config = chart.getConfiguration();
    config.setTitle("Customized crosshairs");
    config.getxAxis().setTickPositions(new Integer[] { 1, 2, 4, 8, 16 });
    config.getxAxis().setGridLineWidth(1);
    config.getyAxis().setTickPositions(new Integer[] { 0, 160, 240, 280, 300, 310 });
    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) Chart(com.vaadin.addon.charts.Chart)

Example 74 with ListSeries

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

the class Basic3DColumnWithGradientBackground method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Monthly Average Rainfall");
    conf.setSubTitle("Source: WorldClimate.com");
    XAxis x = new XAxis();
    x.setCategories(new String[] { "Jan", "Feb", "Mar", "Apr" });
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    y.setTitle("Rainfall (mm)");
    conf.addyAxis(y);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.x +': '+ this.y +' mm'");
    conf.setTooltip(tooltip);
    PlotOptionsColumn plot = new PlotOptionsColumn();
    plot.setPointPadding(0.2);
    plot.setBorderWidth(0);
    plot.setGroupZPadding(10);
    conf.setPlotOptions(plot);
    Options3d options3d = new Options3d();
    options3d.setEnabled(true);
    options3d.setAlpha(5);
    options3d.setBeta(30);
    options3d.setDepth(100);
    options3d.setViewDistance(200);
    Frame frame = new Frame();
    options3d.setFrame(frame);
    frame.setBack(new Back());
    GradientColor c = GradientColor.createLinear(0, 0, 1, 0);
    c.addColorStop(0, SolidColor.RED);
    c.addColorStop(1, SolidColor.AQUAMARINE);
    frame.getBack().setColor(c);
    frame.getBack().setSize(1);
    conf.getChart().setOptions3d(options3d);
    conf.addSeries(new ListSeries("Tokyo", 49.9, 71.5, 106.4, 129.2));
    chart.drawChart(conf);
    return chart;
}
Also used : Frame(com.vaadin.addon.charts.model.Frame) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) Back(com.vaadin.addon.charts.model.Back) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) Options3d(com.vaadin.addon.charts.model.Options3d) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 75 with ListSeries

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

the class BorderColorTest method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.BAR);
    chart.setHeight("450px");
    chart.setWidth("100%");
    chart.getConfiguration().addSeries(new ListSeries(1, 2, 3));
    chart.getConfiguration().getChart().setBorderWidth(5);
    chart.getConfiguration().getChart().setBorderColor(new SolidColor("green"));
    chart.getConfiguration().getChart().setBorderRadius(25);
    return chart;
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart)

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