Search in sources :

Example 71 with DataSeries

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

the class PointClickCoordinatesScatterChart method addSeries.

@Override
protected void addSeries(Configuration conf) {
    DataSeries higherX = new DataSeries();
    higherX.setName("Higher X");
    DataSeries higherY = new DataSeries();
    higherY.setName("Higher Y");
    DataSeries higherZ = new DataSeries();
    higherZ.setName("Higher Z");
    fillSeries(higherX, higherY, higherZ);
    conf.setSeries(higherX, higherY, higherZ);
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries)

Example 72 with DataSeries

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

the class Ohlc method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart(ChartType.OHLC);
    chart.setHeight("450px");
    chart.setWidth("100%");
    chart.setTimeline(true);
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("AAPL Stock Price");
    DataSeries dataSeries = new DataSeries();
    PlotOptionsOhlc plotOptionsOhlc = new PlotOptionsOhlc();
    DataGrouping grouping = new DataGrouping();
    grouping.addUnit(new TimeUnitMultiples(TimeUnit.WEEK, 1));
    grouping.addUnit(new TimeUnitMultiples(TimeUnit.MONTH, 1, 2, 3, 4, 6));
    plotOptionsOhlc.setDataGrouping(grouping);
    dataSeries.setPlotOptions(plotOptionsOhlc);
    for (StockPrices.OhlcData data : StockPrices.fetchAaplOhlcPrice()) {
        OhlcItem item = new OhlcItem();
        item.setX(data.getDate());
        item.setLow(data.getLow());
        item.setHigh(data.getHigh());
        item.setClose(data.getClose());
        item.setOpen(data.getOpen());
        dataSeries.add(item);
    }
    configuration.setSeries(dataSeries);
    RangeSelector rangeSelector = new RangeSelector();
    rangeSelector.setSelected(1);
    configuration.setRangeSelector(rangeSelector);
    chart.drawChart(configuration);
    return chart;
}
Also used : StockPrices(com.vaadin.addon.charts.examples.timeline.util.StockPrices) Configuration(com.vaadin.addon.charts.model.Configuration) TimeUnitMultiples(com.vaadin.addon.charts.model.TimeUnitMultiples) OhlcItem(com.vaadin.addon.charts.model.OhlcItem) RangeSelector(com.vaadin.addon.charts.model.RangeSelector) DataGrouping(com.vaadin.addon.charts.model.DataGrouping) DataSeries(com.vaadin.addon.charts.model.DataSeries) PlotOptionsOhlc(com.vaadin.addon.charts.model.PlotOptionsOhlc) Chart(com.vaadin.addon.charts.Chart)

Example 73 with DataSeries

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

the class RangeSelectorButtons method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    chart.setTimeline(true);
    Configuration configuration = chart.getConfiguration();
    YAxis yAxis = new YAxis();
    PlotLine plotLine = new PlotLine();
    plotLine.setValue(2);
    plotLine.setWidth(2);
    plotLine.setColor(SolidColor.SILVER);
    yAxis.setPlotLines(plotLine);
    configuration.addyAxis(yAxis);
    DataSeries aaplSeries = new DataSeries();
    for (StockPrices.PriceData data : StockPrices.fetchAaplPrice()) {
        DataSeriesItem item = new DataSeriesItem();
        item.setX(data.getDate());
        item.setY(data.getPrice());
        aaplSeries.add(item);
    }
    configuration.setSeries(aaplSeries);
    RangeSelector rangeSelector = new RangeSelector();
    rangeSelector.setSelected(1);
    RangeSelectorButton button = new RangeSelectorButton(MONTH, 3, "D");
    DataGrouping grouping = new DataGrouping();
    grouping.setForced(true);
    grouping.setUnits(new TimeUnitMultiples(TimeUnit.DAY, 1));
    button.setDataGrouping(grouping);
    rangeSelector.addButton(button);
    button = new RangeSelectorButton(YEAR, 1, "W");
    grouping = new DataGrouping();
    grouping.setForced(true);
    grouping.setUnits(new TimeUnitMultiples(TimeUnit.WEEK, 1));
    button.setDataGrouping(grouping);
    rangeSelector.addButton(button);
    button = new RangeSelectorButton(ALL, "M");
    grouping = new DataGrouping();
    grouping.setForced(true);
    grouping.setUnits(new TimeUnitMultiples(TimeUnit.MONTH, 1));
    button.setDataGrouping(grouping);
    rangeSelector.addButton(button);
    configuration.setRangeSelector(rangeSelector);
    chart.drawChart(configuration);
    return chart;
}
Also used : StockPrices(com.vaadin.addon.charts.examples.timeline.util.StockPrices) Configuration(com.vaadin.addon.charts.model.Configuration) TimeUnitMultiples(com.vaadin.addon.charts.model.TimeUnitMultiples) RangeSelector(com.vaadin.addon.charts.model.RangeSelector) DataGrouping(com.vaadin.addon.charts.model.DataGrouping) RangeSelectorButton(com.vaadin.addon.charts.model.RangeSelectorButton) PlotLine(com.vaadin.addon.charts.model.PlotLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 74 with DataSeries

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

the class SingleLineSeries method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    chart.setTimeline(true);
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("AAPL Stock Price");
    DataSeries dataSeries = new DataSeries();
    for (StockPrices.PriceData data : StockPrices.fetchAaplPrice()) {
        DataSeriesItem item = new DataSeriesItem();
        item.setX(data.getDate());
        item.setY(data.getPrice());
        dataSeries.add(item);
    }
    configuration.setSeries(dataSeries);
    RangeSelector rangeSelector = new RangeSelector();
    rangeSelector.setSelected(1);
    configuration.setRangeSelector(rangeSelector);
    chart.drawChart(configuration);
    return chart;
}
Also used : StockPrices(com.vaadin.addon.charts.examples.timeline.util.StockPrices) Configuration(com.vaadin.addon.charts.model.Configuration) RangeSelector(com.vaadin.addon.charts.model.RangeSelector) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 75 with DataSeries

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

the class WaterfallChartExample method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle((String) null);
    DataSeries dataSeries = new DataSeries();
    dataSeries.add(new DataSeriesItem("Start", 120000));
    dataSeries.add(new DataSeriesItem("Product Revenue", 569000));
    dataSeries.add(new DataSeriesItem("Service Revenue", 231000));
    WaterFallSum positiveBalanse = new WaterFallSum("Positive Balance");
    positiveBalanse.setColor(sumColor);
    positiveBalanse.setIntermediate(true);
    dataSeries.add(positiveBalanse);
    dataSeries.add(new DataSeriesItem("Fixed Costs", -342000));
    dataSeries.add(new DataSeriesItem("Variable Costs", -233000));
    WaterFallSum balance = new WaterFallSum("Balance");
    balance.setColor(sumColor);
    dataSeries.add(balance);
    PlotOptionsWaterfall opts = new PlotOptionsWaterfall();
    opts.setColor(color);
    opts.setUpColor(upColor);
    DataLabels dataLabels = new DataLabels(true);
    dataLabels.setVerticalAlign(VerticalAlign.TOP);
    dataLabels.setY(-30);
    dataLabels.setFormatter("this.y / 1000 + 'k'");
    opts.setDataLabels(dataLabels);
    dataSeries.setPlotOptions(opts);
    conf.addSeries(dataSeries);
    conf.getxAxis().setType(AxisType.CATEGORY);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsWaterfall(com.vaadin.addon.charts.model.PlotOptionsWaterfall) DataSeries(com.vaadin.addon.charts.model.DataSeries) WaterFallSum(com.vaadin.addon.charts.model.WaterFallSum) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

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