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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations