use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.
the class WindRose method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.getChart().setPolar(true);
conf.getChart().setInverted(false);
conf.setTitle("Wind rose for South Shore Met Station, Oregon");
conf.setSubTitle("Source: or.water.usgs.gov");
Pane pane = new Pane();
pane.setSize("85%");
conf.addPane(pane);
conf.getLegend().setReversed(false);
conf.getLegend().setAlign(HorizontalAlign.RIGHT);
conf.getLegend().setVerticalAlign(VerticalAlign.TOP);
conf.getLegend().setY(100);
conf.getLegend().setLayout(LayoutDirection.VERTICAL);
XAxis axis = new XAxis();
axis.setCategories("< 0.5 m/s", "0.5-2 m/s", "2-4 m/s", "4-6 m/s", "6-8 m/s", "8-10 m/s", "> 10 m/s");
axis.setTickmarkPlacement(TickmarkPlacement.ON);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
yAxis.setEndOnTick(false);
yAxis.setShowLastLabel(true);
yAxis.setTitle(new AxisTitle("Frequency (%)"));
Labels labels = new Labels();
labels.setFormatter("function() {return this.value + '%';}");
yAxis.setLabels(labels);
conf.addxAxis(axis);
conf.addyAxis(yAxis);
conf.getTooltip().setValueSuffix("%");
PlotOptionsColumn series = new PlotOptionsColumn();
series.setStacking(Stacking.NORMAL);
series.setShadow(false);
series.setGroupPadding(0);
series.setPointPlacement(PointPlacement.ON);
conf.setPlotOptions(series);
ListSeries n = new ListSeries("N", 1.81, 1.78, 0.16, 0.00, 0.00, 0.00, 0.00);
ListSeries nne = new ListSeries("NNE", 0.62, 1.09, 0.00, 0.00, 0.00, 0.00, 0.00);
ListSeries ne = new ListSeries("NE", 0.82, 0.82, 0.07, 0.00, 0.00, 0.00, 0.00);
ListSeries ene = new ListSeries("ENE", 0.59, 1.22, 0.07, 0.00, 0.00, 0.00, 0.00);
ListSeries e = new ListSeries("E", 0.62, 2.20, 0.49, 0.00, 0.00, 0.00, 0.00);
ListSeries ese = new ListSeries("ESE", 1.22, 2.01, 1.55, 0.30, 0.13, 0.00, 0.00);
ListSeries se = new ListSeries("SE", 1.61, 3.06, 2.37, 2.14, 1.74, 0.39, 0.13);
ListSeries sse = new ListSeries("SSE", 2.04, 3.42, 1.97, 0.86, 0.53, 0.49, 0.00);
ListSeries s = new ListSeries("S", 2.66, 4.74, 0.43, 0.00, 0.00, 0.00, 0.00);
ListSeries ssw = new ListSeries("SSW", 2.96, 4.14, 0.26, 0.00, 0.00, 0.00, 0.00);
ListSeries sw = new ListSeries("SW", 2.53, 4.01, 1.22, 0.49, 0.13, 0.00, 0.00);
ListSeries wsw = new ListSeries("WSW", 1.97, 2.66, 1.97, 0.79, 0.30, 0.00, 0.00);
ListSeries w = new ListSeries("W", 1.64, 1.71, 0.92, 1.45, 0.26, 0.10, 0.00);
ListSeries wnw = new ListSeries("WNW", 1.32, 2.40, 0.99, 1.61, 0.33, 0.00, 0.00);
ListSeries nw = new ListSeries("NW", 1.58, 4.28, 1.28, 0.76, 0.66, 0.69, 0.03);
ListSeries nnw = new ListSeries("NNW", 1.51, 5.00, 1.32, 0.13, 0.23, 0.13, 0.07);
conf.setSeries(n, nne, ne, ene, e, ese, se, sse, s, ssw, sw, wsw, w, wnw, nw, nnw);
// transpose data "matrix"
conf.reverseListSeries();
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.
the class Basic3DColumn method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle("Monthly Average Rainfall");
conf.setSubTitle("Source: WorldClimate.com");
XAxis x = new XAxis();
x.setCategories("Jan", "Feb", "Mar", "Apr");
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
y.setTitle("Rainfall (mm)");
conf.addyAxis(y);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.x +': '+ this.y +' mm'");
conf.setTooltip(tooltip);
PlotOptionsColumn plot = new PlotOptionsColumn();
plot.setPointPadding(0.2);
plot.setBorderWidth(0);
plot.setGroupZPadding(10);
conf.setPlotOptions(plot);
Options3d options3d = new Options3d();
options3d.setEnabled(true);
options3d.setAlpha(5);
options3d.setBeta(30);
options3d.setDepth(100);
options3d.setViewDistance(200);
Frame frame = new Frame();
options3d.setFrame(frame);
conf.getChart().setOptions3d(options3d);
conf.addSeries(new ListSeries("Tokyo", 49.9, 71.5, 106.4, 129.2));
conf.addSeries(new ListSeries("New York", 83.6, 78.8, 98.5, 93.4));
conf.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4));
conf.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.
the class ErrorBarExample method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
Color[] colors = getThemeColors();
// Enable xy zooming, test also with touch devices
conf.getChart().setZoomType(ZoomType.XY);
conf.setTitle("Temperature vs Rainfall");
conf.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
YAxis primaryAxis = conf.getyAxis();
AxisTitle title = new AxisTitle("Temperature");
Style style = new Style();
style.setColor(colors[0]);
title.setStyle(style);
primaryAxis.setTitle(title);
Labels labels = new Labels();
labels.setFormatter("this.value + '°C'");
primaryAxis.setLabels(labels);
YAxis secondaryAxis = new YAxis();
conf.addyAxis(secondaryAxis);
title = new AxisTitle("Rainfall");
secondaryAxis.setTitle(title);
style = new Style();
style.setColor(colors[1]);
title.setStyle(style);
labels = new Labels();
labels.setFormatter("this.value + ' mm'");
labels.setStyle(style);
secondaryAxis.setLabels(labels);
secondaryAxis.setOpposite(true);
conf.getTooltip().setShared(true);
DataSeries rainfall = new DataSeries("Rainfall");
PlotOptionsColumn column = new PlotOptionsColumn();
column.setColor(colors[1]);
SeriesTooltip tooltip = new SeriesTooltip();
tooltip.setPointFormat("<span style='font-weight: bold; color: {series.color}'>{series.name}</span>: <b>{point.y:.1f} mm</b> ");
column.setTooltip(tooltip);
rainfall.setPlotOptions(column);
conf.addSeries(rainfall);
rainfall.setyAxis(secondaryAxis);
DataSeries rainfallError = new DataSeries("Rainfall");
conf.addSeries(rainfallError);
rainfallError.setyAxis(secondaryAxis);
PlotOptionsErrorbar rainErrorOptions = new PlotOptionsErrorbar();
tooltip = new SeriesTooltip();
tooltip.setPointFormat("(error range: {point.low}-{point.high} mm)<br/>");
rainErrorOptions.setTooltip(tooltip);
rainfallError.setPlotOptions(rainErrorOptions);
DataSeries temperature = new DataSeries("Temperature");
conf.addSeries(temperature);
PlotOptionsSpline tempOptions = new PlotOptionsSpline();
tempOptions.setColor(colors[0]);
tooltip = new SeriesTooltip();
tooltip.setPointFormat("<span style='font-weight: bold; color: {series.color}'>{series.name}</span>: <b>{point.y:.1f}°C");
tempOptions.setTooltip(tooltip);
temperature.setPlotOptions(tempOptions);
DataSeries temperatureErrors = new DataSeries("Temperature error");
conf.addSeries(temperatureErrors);
PlotOptionsErrorbar tempErrorOptions = new PlotOptionsErrorbar();
SolidColor green = new SolidColor("green");
tempErrorOptions.setStemColor(green);
tempErrorOptions.setWhiskerColor(green);
tooltip = new SeriesTooltip();
tooltip.setPointFormat("(error range: {point.low}-{point.high}°C)<br/>");
tempErrorOptions.setTooltip(tooltip);
temperatureErrors.setPlotOptions(tempErrorOptions);
// Populate series
for (Data d : DATA) {
DataSeriesItem item = new DataSeriesItem();
item.setY(d.rainfall);
rainfall.add(item);
item = new DataSeriesItem();
item.setLow(d.rainfallErrorLow);
item.setHigh(d.rainfallErrorHigh);
rainfallError.add(item);
item = new DataSeriesItem();
item.setY(d.temperature);
temperature.add(item);
item = new DataSeriesItem();
item.setLow(d.temperatureErrorLow);
item.setHigh(d.temperatureErrorHigh);
temperatureErrors.add(item);
}
return chart;
}
use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.
the class GettingStarted method addColumnsSnippet1.
public void addColumnsSnippet1(List<WeatherInfo> weatherInfo) {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
ListDataProvider<WeatherInfo> dataProvider = new ListDataProvider<>(weatherInfo);
DataProviderSeries<WeatherInfo> humidity = new DataProviderSeries<>(dataProvider);
humidity.setName("Humidity");
humidity.setX(WeatherInfo::getInstant);
humidity.setY(WeatherInfo::getMeanHumidity);
humidity.setPlotOptions(new PlotOptionsColumn());
conf.addSeries(humidity);
}
use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.
the class ChartConfiguration method plotOptionsSnippet2.
public void plotOptionsSnippet2(Configuration conf) {
ListSeries series = new ListSeries(50, 60, 70, 80);
PlotOptionsColumn plotOptions = new PlotOptionsColumn();
plotOptions.setStacking(Stacking.NORMAL);
series.setPlotOptions(plotOptions);
}
Aggregations