Search in sources :

Example 31 with DataSeries

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

the class ChartTypes method chartTypesScatterMarkerPropertiesSnippet1.

public void chartTypesScatterMarkerPropertiesSnippet1() {
    double x = 1.0;
    double y = 1.2;
    double z = 1.45;
    DataSeries series = new DataSeries();
    DataSeriesItem point = new DataSeriesItem(x, y);
    Marker marker = new Marker();
    // Set line width and color
    // Normally zero width
    marker.setLineWidth(1);
    marker.setLineColor(SolidColor.BLACK);
    // Set RGB fill color
    int level = (int) Math.round((1 - z) * 127);
    marker.setFillColor(new SolidColor(255 - level, 0, level));
    point.setMarker(marker);
    marker.setRadius((z + 1) * 5);
    series.add(point);
}
Also used : SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 32 with DataSeries

use of com.vaadin.addon.charts.model.DataSeries 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 33 with DataSeries

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

the class GettingStarted method configuringTheColors.

public void configuringTheColors() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    DataSeries girls = new DataSeries("Girls");
    DataSeries boys = new DataSeries("Boys");
    PlotOptionsLine girlsOpts = new PlotOptionsLine();
    girlsOpts.setColor(SolidColor.HOTPINK);
    girls.setPlotOptions(girlsOpts);
    PlotOptionsLine boysOpts = new PlotOptionsLine();
    boysOpts.setColor(SolidColor.BLUE);
    boys.setPlotOptions(boysOpts);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart)

Example 34 with DataSeries

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

the class ChartData method asynchronousDrilldown.

public void asynchronousDrilldown(Chart chart) {
    DataSeries series = new DataSeries();
    DataSeriesItem mainItem = new DataSeriesItem("MSIE", 55.11);
    series.addItemWithDrilldown(mainItem);
    chart.setDrilldownCallback(new DrilldownCallback() {

        @Override
        public Series handleDrilldown(DrilldownEvent event) {
            DataSeries drillDownSeries = new DataSeries("MSIE versions");
            drillDownSeries.add(new DataSeriesItem("MSIE 6.0", 10.85));
            drillDownSeries.add(new DataSeriesItem("MSIE 7.0", 7.35));
            drillDownSeries.add(new DataSeriesItem("MSIE 8.0", 33.06));
            drillDownSeries.add(new DataSeriesItem("MSIE 9.0", 2.81));
            return drillDownSeries;
        }
    });
}
Also used : DataProviderSeries(com.vaadin.addon.charts.model.DataProviderSeries) Series(com.vaadin.addon.charts.model.Series) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) ListSeries(com.vaadin.addon.charts.model.ListSeries) DataSeries(com.vaadin.addon.charts.model.DataSeries) DrilldownCallback(com.vaadin.addon.charts.DrilldownCallback) DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) DrilldownEvent(com.vaadin.addon.charts.DrilldownEvent)

Example 35 with DataSeries

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

the class ChartTypes method chartTypesOhlcSnippet1.

public void chartTypesOhlcSnippet1() {
    Chart chart = new Chart(ChartType.OHLC);
    chart.setTimeline(true);
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("AAPL Stock Price");
    DataSeries dataSeries = new DataSeries();
    Collection<OhlcData> dataBank = null;
    for (OhlcData data : dataBank) {
        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);
    chart.drawChart(configuration);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) OhlcItem(com.vaadin.addon.charts.model.OhlcItem) 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