Search in sources :

Example 61 with Chart

use of com.vaadin.addon.charts.Chart 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 62 with Chart

use of com.vaadin.addon.charts.Chart 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)

Example 63 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class ChartTypes method chartTypesWaterfallPlotoptions.

public void chartTypesWaterfallPlotoptions() {
    // Define the colors
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    final Color balanceColor = SolidColor.BLACK;
    final Color positiveColor = SolidColor.BLUE;
    final Color negativeColor = SolidColor.RED;
    // Configure the colors
    PlotOptionsWaterfall options = new PlotOptionsWaterfall();
    options.setUpColor(positiveColor);
    options.setColor(negativeColor);
    // Configure the labels
    DataLabels labels = new DataLabels(true);
    labels.setVerticalAlign(VerticalAlign.TOP);
    labels.setY(-20);
    labels.setFormatter("Math.floor(this.y/1000) + 'k'");
    Style style = new Style();
    style.setColor(SolidColor.BLACK);
    style.setFontWeight(FontWeight.BOLD);
    labels.setStyle(style);
    options.setDataLabels(labels);
    options.setPointPadding(0);
    conf.setPlotOptions(options);
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Color(com.vaadin.addon.charts.model.style.Color) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) PlotOptionsWaterfall(com.vaadin.addon.charts.model.PlotOptionsWaterfall) DashStyle(com.vaadin.addon.charts.model.DashStyle) Style(com.vaadin.addon.charts.model.style.Style) Chart(com.vaadin.addon.charts.Chart)

Example 64 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class ChartTypes method chartTypesPieSnippet1.

public void chartTypesPieSnippet1() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    PlotOptionsPie options = new PlotOptionsPie();
    // Non-0 results in a donut
    options.setInnerSize("0");
    // Default
    options.setSize("75%");
    // Default
    options.setCenter("50%", "50%");
    conf.setPlotOptions(options);
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) Configuration(com.vaadin.addon.charts.model.Configuration) Chart(com.vaadin.addon.charts.Chart)

Example 65 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class ChartTypes method chartTypesBoxplotSnippet1.

public void chartTypesBoxplotSnippet1() {
    Chart chart = new Chart(ChartType.BOXPLOT);
    chart.setWidth("400px");
    chart.setHeight("300px");
    // Modify the default configuration a bit
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Orienteering Split Times");
    conf.getLegend().setEnabled(false);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Chart(com.vaadin.addon.charts.Chart)

Aggregations

Chart (com.vaadin.addon.charts.Chart)243 Configuration (com.vaadin.addon.charts.model.Configuration)196 YAxis (com.vaadin.addon.charts.model.YAxis)105 DataSeries (com.vaadin.addon.charts.model.DataSeries)81 ListSeries (com.vaadin.addon.charts.model.ListSeries)76 XAxis (com.vaadin.addon.charts.model.XAxis)71 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)57 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)55 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)50 DataLabels (com.vaadin.addon.charts.model.DataLabels)45 Tooltip (com.vaadin.addon.charts.model.Tooltip)44 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)34 Legend (com.vaadin.addon.charts.model.Legend)29 Marker (com.vaadin.addon.charts.model.Marker)23 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)21 Style (com.vaadin.addon.charts.model.style.Style)20 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)19 Labels (com.vaadin.addon.charts.model.Labels)18 VerticalLayout (com.vaadin.ui.VerticalLayout)18 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)16