use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class ChartTypes method chartTypesOhlcSnippet2.
public void chartTypesOhlcSnippet2() {
Chart chart = new Chart(ChartType.OHLC);
Configuration configuration = chart.getConfiguration();
// Create a DataProvider filled with stock price data
DataProvider<OhlcData, ?> dataProvider = initDataProvider();
// Wrap the container in a data series
DataProviderSeries<OhlcData> dataSeries = new DataProviderSeries<>(dataProvider);
dataSeries.setX(OhlcData::getDate);
dataSeries.setLow(OhlcData::getLow);
dataSeries.setHigh(OhlcData::getHigh);
dataSeries.setClose(OhlcData::getClose);
dataSeries.setOpen(OhlcData::getOpen);
PlotOptionsOhlc plotOptionsOhlc = new PlotOptionsOhlc();
plotOptionsOhlc.setTurboThreshold(0);
dataSeries.setPlotOptions(plotOptionsOhlc);
configuration.setSeries(dataSeries);
}
use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class ChartTypes method chartTypesWaterfallDataModel.
public void chartTypesWaterfallDataModel() {
// Define the colors
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
// The data
DataSeries series = new DataSeries();
// The beginning balance
DataSeriesItem start = new DataSeriesItem("Start", 306503);
SolidColor balanceColor = SolidColor.KHAKI;
start.setColor(balanceColor);
series.add(start);
// Deltas
series.add(new DataSeriesItem("Predators", -3330));
series.add(new DataSeriesItem("Slaughter", -103332));
series.add(new DataSeriesItem("Reproduction", +104052));
WaterFallSum end = new WaterFallSum("End");
end.setColor(balanceColor);
// Not intermediate (default)
end.setIntermediate(false);
series.add(end);
conf.addSeries(series);
}
use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class ChartTypes method chartTypesSolidGaugeConfSnippet2.
public void chartTypesSolidGaugeConfSnippet2() {
Chart chart = new Chart(ChartType.SOLIDGAUGE);
Configuration conf = chart.getConfiguration();
Pane pane = conf.getPane();
Background bkg = new Background();
// Gray
bkg.setBackgroundColor(new SolidColor("#eeeeee"));
// To make it an arc and not circle
bkg.setInnerRadius("60%");
// Default - not necessary
bkg.setOuterRadius("100%");
// solid or arc
bkg.setShape("arc");
pane.setBackground(bkg);
}
use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class ChartTypes method chartTypesFlagsExample.
public void chartTypesFlagsExample() {
Chart chart = new Chart(ChartType.SPLINE);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("USD to EUR exchange rate");
configuration.getxAxis().setType(AxisType.DATETIME);
// A data series to annotate with flags
DataSeries dataSeries = new DataSeries();
dataSeries.setId("dataseries");
dataSeries.addData(new Number[][] { { 1434499200000l, 0.8821 }, { 1434585600000l, 0.8802 }, { 1434672000000l, 0.8808 }, { 1434844800000l, 0.8794 }, { 1434931200000l, 0.8818 }, { 1435017600000l, 0.8952 }, { 1435104000000l, 0.8924 }, { 1435190400000l, 0.8925 }, { 1435276800000l, 0.8955 } });
// Flags on the data series
DataSeries flagsOnSeries = new DataSeries();
flagsOnSeries.setName("Flags on series");
PlotOptionsFlags plotOptionsFlags = new PlotOptionsFlags();
plotOptionsFlags.setShape(FlagShape.SQUAREPIN);
plotOptionsFlags.setOnSeries("dataseries");
flagsOnSeries.setPlotOptions(plotOptionsFlags);
flagsOnSeries.add(new FlagItem(1434585600000l, "First Series Flag", "First Series Flag Tooltip Text"));
flagsOnSeries.add(new FlagItem(1435017600000l, "Second Series Flag"));
// Flags on the X axis
DataSeries flagsOnAxis = new DataSeries();
flagsOnAxis.setPlotOptions(new PlotOptionsFlags());
flagsOnAxis.setName("Flags on axis");
flagsOnAxis.add(new FlagItem(1434844800000l, "First Axis Flag", "First Axis Flag Tooltip Text"));
flagsOnAxis.add(new FlagItem(1435190400000l, "Second Axis Flag"));
configuration.setSeries(dataSeries, flagsOnSeries, flagsOnAxis);
}
use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class PlotBandTest method setup.
@Before
public void setup() {
Chart chart = new Chart(ChartType.PIE);
Configuration conf = chart.getConfiguration();
axis = new XAxis();
conf.addxAxis(axis);
plotBand1 = new PlotBand();
plotBand1.setFrom(1);
plotBand1.setTo(2);
plotBand1.setColor(SolidColor.ALICEBLUE);
plotBand2 = new PlotBand();
plotBand2.setFrom(2);
plotBand2.setTo(3);
plotBand2.setColor(SolidColor.ANTIQUEWHITE);
plotBand3 = new PlotBand();
plotBand3.setFrom(3);
plotBand3.setTo(4);
plotBand3.setColor(SolidColor.AQUA);
List<PlotBand> plotbands = new ArrayList<PlotBand>();
plotbands.add(plotBand1);
plotbands.add(plotBand2);
plotbands.add(plotBand3);
axis.setPlotBands(plotBand1, plotBand2, plotBand3);
}
Aggregations