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