use of com.vaadin.addon.charts.model.Pane 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.Pane in project charts by vaadin.
the class ConfigurationObjectJSONSerializationTest method toString_PaneListWithTwoItems_SerializedAsPaneArray.
@Test
public void toString_PaneListWithTwoItems_SerializedAsPaneArray() {
PaneList paneList = new PaneList();
paneList.addPane(new Pane());
paneList.addPane(new Pane());
ObjectContainer object = new ObjectContainer(paneList);
String paneJson1 = "{\"paneIndex\":0}";
String paneJson2 = "{\"paneIndex\":1}";
String expected = String.format("{\"object\":[%s,%s]}", paneJson1, paneJson2);
assertEquals(expected, toJSON(object));
}
use of com.vaadin.addon.charts.model.Pane in project charts by vaadin.
the class ConfigurationObjectJSONSerializationTest method toString_PaneListWithOneItem_SerializedAsSinglePane.
@Test
public void toString_PaneListWithOneItem_SerializedAsSinglePane() {
PaneList paneList = new PaneList();
paneList.addPane(new Pane());
ObjectContainer object = new ObjectContainer(paneList);
String paneJson = "{\"paneIndex\":0}";
assertEquals("{\"object\":" + paneJson + "}", toJSON(object));
}
use of com.vaadin.addon.charts.model.Pane in project charts by vaadin.
the class SolidGauge method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setWidth(500, Unit.PIXELS);
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SOLIDGAUGE);
configuration.getTitle().setText("Speed");
Pane pane = new Pane();
pane.setCenter("50%", "85%");
pane.setSize("140%");
pane.setStartAngle(-90);
pane.setEndAngle(90);
configuration.addPane(pane);
configuration.getTooltip().setEnabled(false);
Background bkg = new Background();
bkg.setBackgroundColor(new SolidColor("#eeeeee"));
bkg.setInnerRadius("60%");
bkg.setOuterRadius("100%");
bkg.setShape("arc");
bkg.setBorderWidth(0);
pane.setBackground(bkg);
YAxis yaxis = configuration.getyAxis();
yaxis.setLineWidth(0);
yaxis.setTickInterval(200);
yaxis.setTickWidth(0);
yaxis.setMin(0);
yaxis.setMax(200);
yaxis.setTitle("");
yaxis.getTitle().setY(-70);
yaxis.setLabels(new Labels());
yaxis.getLabels().setY(16);
Stop stop1 = new Stop(0.1f, SolidColor.GREEN);
Stop stop2 = new Stop(0.5f, SolidColor.YELLOW);
Stop stop3 = new Stop(0.9f, SolidColor.RED);
yaxis.setStops(stop1, stop2, stop3);
PlotOptionsSolidgauge plotOptions = new PlotOptionsSolidgauge();
plotOptions.setTooltip(new SeriesTooltip());
plotOptions.getTooltip().setValueSuffix(" km/h");
DataLabels labels = new DataLabels();
labels.setY(5);
labels.setBorderWidth(0);
labels.setUseHTML(true);
labels.setFormat("<div style=\"text-align:center\"><span style=\"font-size:25px;\">{y}</span><br/>" + " <span style=\"font-size:12pxg\">km/h</span></div>");
plotOptions.setDataLabels(labels);
configuration.setPlotOptions(plotOptions);
final ListSeries series = new ListSeries("Speed", 80);
configuration.setSeries(series);
runWhileAttached(chart, new Runnable() {
Random r = new Random(0);
@Override
public void run() {
Integer oldValue = series.getData()[0].intValue();
Integer newValue = (int) (oldValue + (r.nextDouble() - 0.5) * 20.0);
if (newValue > 200) {
newValue = 200;
} else if (newValue < 0) {
newValue = 0;
}
series.updatePoint(0, newValue);
}
}, 3000, 12000);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.Pane in project charts by vaadin.
the class Spiderweb method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.LINE);
Configuration conf = chart.getConfiguration();
conf.getChart().setPolar(true);
conf.setTitle("Budget vs spending");
conf.getTitle().setX(-80);
Pane pane = new Pane();
pane.setSize(80, Unit.PERCENTAGE);
conf.addPane(pane);
XAxis axis = new XAxis();
axis.setCategories("Sales", "Marketing", "Development", "Customer Support", "Information Technology", "Administration");
axis.setTickmarkPlacement(TickmarkPlacement.ON);
axis.setLineWidth(0);
YAxis yaxs = new YAxis();
yaxs.setGridLineInterpolation("polygon");
yaxs.setMin(0);
yaxs.setLineWidth(0);
conf.addxAxis(axis);
conf.addyAxis(yaxs);
conf.getTooltip().setShared(true);
conf.getTooltip().setValuePrefix("$");
conf.getLegend().setAlign(HorizontalAlign.RIGHT);
conf.getLegend().setVerticalAlign(VerticalAlign.TOP);
conf.getLegend().setY(100);
conf.getLegend().setLayout(LayoutDirection.VERTICAL);
ListSeries line1 = new ListSeries(43000, 19000, 60000, 35000, 17000, 10000);
ListSeries line2 = new ListSeries(50000, 39000, 42000, 31000, 26000, 14000);
PlotOptionsLine plotOptions = new PlotOptionsLine();
plotOptions.setPointPlacement(PointPlacement.ON);
line1.setPlotOptions(plotOptions);
line1.setName("Allocated Budget");
plotOptions = new PlotOptionsLine();
plotOptions.setPointPlacement(PointPlacement.ON);
line2.setPlotOptions(plotOptions);
line2.setName("Actual Spending");
conf.setSeries(line1, line2);
chart.drawChart(conf);
return chart;
}
Aggregations