Search in sources :

Example 71 with Configuration

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);
}
Also used : DataProviderSeries(com.vaadin.addon.charts.model.DataProviderSeries) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsOhlc(com.vaadin.addon.charts.model.PlotOptionsOhlc) Chart(com.vaadin.addon.charts.Chart)

Example 72 with Configuration

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);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) 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)

Example 73 with Configuration

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);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Background(com.vaadin.addon.charts.model.Background) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Pane(com.vaadin.addon.charts.model.Pane) Chart(com.vaadin.addon.charts.Chart)

Example 74 with Configuration

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);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsFlags(com.vaadin.addon.charts.model.PlotOptionsFlags) FlagItem(com.vaadin.addon.charts.model.FlagItem) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart)

Example 75 with Configuration

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);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ArrayList(java.util.ArrayList) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) Before(org.junit.Before)

Aggregations

Configuration (com.vaadin.addon.charts.model.Configuration)257 Chart (com.vaadin.addon.charts.Chart)196 YAxis (com.vaadin.addon.charts.model.YAxis)100 DataSeries (com.vaadin.addon.charts.model.DataSeries)72 ListSeries (com.vaadin.addon.charts.model.ListSeries)70 XAxis (com.vaadin.addon.charts.model.XAxis)65 Test (org.junit.Test)58 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)56 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)54 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)51 Tooltip (com.vaadin.addon.charts.model.Tooltip)42 DataLabels (com.vaadin.addon.charts.model.DataLabels)41 Legend (com.vaadin.addon.charts.model.Legend)30 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)30 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)27 Elements (org.jsoup.select.Elements)27 Marker (com.vaadin.addon.charts.model.Marker)22 DesignContext (com.vaadin.ui.declarative.DesignContext)22 Element (org.jsoup.nodes.Element)22 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)20