Search in sources :

Example 16 with DataSeries

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

the class TimeDataWithIrregularIntervalsAndLocalizedTexts method getChart.

@Override
protected Component getChart() {
    // localizations
    final Lang fi = new Lang();
    fi.setDecimalPoint(",");
    fi.setShortMonths(new String[] { "Tammi", "Helmi", "Maalis", "Huhti", "Touko", "Kesä", "Heinä", "Elo", "Syys", "Loka", "Marras", "Joulu" });
    fi.setMonths(new String[] { "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu" });
    fi.setWeekdays(new String[] { "Ma", "Ti", "Ke", "To", "Pe", "La", "Su" });
    final Lang en = new Lang();
    en.setDecimalPoint(".");
    en.setShortMonths(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
    en.setMonths(new String[] { "January", "February", "March", "April", "May", "June", "Jule", "August", "September", "October", "November", "December" });
    en.setWeekdays(new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" });
    final Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    final Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.SPLINE);
    configuration.getTitle().setText("Lumen syvyys Vikjafjellet-tunturilla, Norja");
    configuration.getSubTitle().setText("Lokalisointiesimerkki");
    configuration.getTooltip().setFormatter("");
    configuration.getxAxis().setType(AxisType.DATETIME);
    configuration.getxAxis().setDateTimeLabelFormats(new DateTimeLabelFormats());
    configuration.getxAxis().getDateTimeLabelFormats().setMonth("%B");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Lumen syvyys (m)"));
    yAxis.setMin(0);
    DataSeries ls = new DataSeries();
    PlotOptionsSpline plotOptionsSpline = new PlotOptionsSpline();
    plotOptionsSpline.setDataLabels(new DataLabels(true));
    plotOptionsSpline.setEnableMouseTracking(false);
    plotOptionsSpline.getDataLabels().setFormatter("return Highcharts.dateFormat('%a %d %B',this.x);");
    ls.setPlotOptions(plotOptionsSpline);
    ls.setName("Talvi 2009-2010");
    Object[][] data3 = getData3();
    for (int i = 0; i < data3.length; i++) {
        Object[] ds = data3[i];
        DataSeriesItem item = new DataSeriesItem((Date) ds[0], (Double) ds[1]);
        ls.add(item);
    }
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    final Button enButton = new Button("English");
    enButton.setId("en-button");
    enButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            ChartOptions.get().setLang(en);
        }
    });
    final Button fiButton = new Button("Finnish");
    fiButton.setId("fi-button");
    fiButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            ChartOptions.get().setLang(fi);
        }
    });
    HorizontalLayout horizontalLayout = new HorizontalLayout(enButton, fiButton);
    horizontalLayout.setSpacing(false);
    VerticalLayout verticalLayout = new VerticalLayout(horizontalLayout, chart);
    verticalLayout.setSpacing(false);
    verticalLayout.setMargin(false);
    return verticalLayout;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) ClickEvent(com.vaadin.ui.Button.ClickEvent) Lang(com.vaadin.addon.charts.model.Lang) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) DataSeries(com.vaadin.addon.charts.model.DataSeries) DateTimeLabelFormats(com.vaadin.addon.charts.model.DateTimeLabelFormats) 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 17 with DataSeries

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

the class ServerSideEvents method createDataSeries.

private DataSeries createDataSeries(Number yvalue) {
    final DataSeries series = new DataSeries();
    series.add(new DataSeriesItem(20, yvalue));
    series.add(new DataSeriesItem(40, yvalue.intValue() + 10));
    series.add(new DataSeriesItem(60, yvalue.intValue() - 15));
    series.add(new DataSeriesItem(80, yvalue));
    series.setId("" + id);
    series.setName("Test Series " + id);
    ++id;
    return series;
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 18 with DataSeries

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

the class WebXYChartSelection method createScatterChart.

private Chart createScatterChart() {
    final Chart scatterChart = new Chart(ChartType.SCATTER);
    scatterChart.setId("chart");
    scatterChart.getConfiguration().getChart().setZoomType(ZoomType.XY);
    scatterChart.getConfiguration().disableCredits();
    scatterChart.getConfiguration().setTitle("Selections as area ranges");
    scatterChart.getConfiguration().setSubTitle("Drag with mouse to make selections. Click the legend items to toggle visibility.");
    PlotOptionsScatter scatterOptions = new PlotOptionsScatter();
    scatterOptions.setAnimation(false);
    scatterOptions.setPointStart(1);
    DataSeries series = new DataSeries();
    series.setPlotOptions(scatterOptions);
    series.setName("Original");
    Random random = new Random(0);
    for (int i = 0; i < 20; i++) {
        DataSeriesItem dsi = new DataSeriesItem();
        dsi.setY(random.nextInt(10));
        dsi.setX(random.nextInt(10));
        series.add(dsi);
    }
    scatterChart.getConfiguration().addSeries(series);
    scatterChart.addChartSelectionListener(new ChartSelectionListener() {

        @Override
        public void onSelection(ChartSelectionEvent event) {
            double xStart = event.getSelectionStart();
            double xEnd = event.getSelectionEnd();
            double yStart = event.getValueStart();
            double yEnd = event.getValueEnd();
            Number[][] data = new Number[][] { { xStart, yStart, yEnd }, { xEnd, yStart, yEnd } };
            PlotOptionsArearange areaRangePlot = new PlotOptionsArearange();
            areaRangePlot.setFillOpacity(0.1f);
            areaRangePlot.setLineWidth(0);
            RangeSeries selectionSeries = new RangeSeries("Selection", data);
            selectionSeries.setPlotOptions(areaRangePlot);
            scatterChart.getConfiguration().addSeries(selectionSeries);
            scatterChart.drawChart();
            areaRangePlot.setAnimation(false);
        }
    });
    scatterChart.drawChart();
    return scatterChart;
}
Also used : PlotOptionsScatter(com.vaadin.addon.charts.model.PlotOptionsScatter) Random(java.util.Random) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) DataSeries(com.vaadin.addon.charts.model.DataSeries) ChartSelectionEvent(com.vaadin.addon.charts.ChartSelectionEvent) ChartSelectionListener(com.vaadin.addon.charts.ChartSelectionListener) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) PlotOptionsArearange(com.vaadin.addon.charts.model.PlotOptionsArearange)

Example 19 with DataSeries

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

the class LibraryData method getChart.

@Override
protected Component getChart() {
    chart = new Chart(ChartType.BAR);
    chart.setSizeFull();
    Configuration config = chart.getConfiguration();
    boolean inverted = config.getChart().getInverted();
    config.getChart().setInverted(!inverted);
    config.getLegend().setEnabled(false);
    YAxis axis = new YAxis();
    axis.setTitle("Pages");
    config.addyAxis(axis);
    series = new DataSeries();
    config.setSeries(series);
    updateChart();
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 20 with DataSeries

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

the class BubbleChartMaxSizePercentage method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.BUBBLE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle((String) null);
    DataSeries dataSeries = new DataSeries();
    dataSeries.add(item(9, 81, 13));
    dataSeries.add(item(98, 5, 39));
    dataSeries.add(item(51, 50, 23));
    dataSeries.add(item(41, 22, -36));
    dataSeries.add(item(58, 24, -30));
    dataSeries.add(item(78, 37, -16));
    dataSeries.add(item(55, 56, 3));
    dataSeries.add(item(18, 45, 20));
    dataSeries.add(item(42, 44, -22));
    dataSeries.add(item(3, 52, 9));
    dataSeries.add(item(31, 50, 47));
    dataSeries.add(item(79, 91, 13));
    dataSeries.add(item(93, 23, -27));
    dataSeries.add(item(44, 83, -28));
    PlotOptionsBubble opts = new PlotOptionsBubble();
    opts.setNegativeColor(getThemeColors()[3]);
    opts.setMaxSize(50, Unit.PERCENTAGE);
    opts.setMinSize("3");
    conf.setPlotOptions(opts);
    conf.addSeries(dataSeries);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsBubble(com.vaadin.addon.charts.model.PlotOptionsBubble) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart)

Aggregations

DataSeries (com.vaadin.addon.charts.model.DataSeries)118 Chart (com.vaadin.addon.charts.Chart)81 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)81 Configuration (com.vaadin.addon.charts.model.Configuration)71 YAxis (com.vaadin.addon.charts.model.YAxis)38 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)26 XAxis (com.vaadin.addon.charts.model.XAxis)25 DataLabels (com.vaadin.addon.charts.model.DataLabels)21 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)17 Tooltip (com.vaadin.addon.charts.model.Tooltip)15 Test (org.junit.Test)15 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)14 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)14 Marker (com.vaadin.addon.charts.model.Marker)13 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)13 Style (com.vaadin.addon.charts.model.style.Style)10 Random (java.util.Random)10 Legend (com.vaadin.addon.charts.model.Legend)9 PlotLine (com.vaadin.addon.charts.model.PlotLine)9 StockPrices (com.vaadin.addon.charts.examples.timeline.util.StockPrices)8