use of com.vaadin.addon.charts.model.PlotOptionsBubble in project charts by vaadin.
the class BubbleChartMaxSizePercentage method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.BUBBLE);
Configuration conf = chart.getConfiguration();
conf.setTitle((String) null);
DataSeries dataSeries = new DataSeries();
dataSeries.add(item(9, 81, 13));
dataSeries.add(item(98, 5, 39));
dataSeries.add(item(51, 50, 23));
dataSeries.add(item(41, 22, -36));
dataSeries.add(item(58, 24, -30));
dataSeries.add(item(78, 37, -16));
dataSeries.add(item(55, 56, 3));
dataSeries.add(item(18, 45, 20));
dataSeries.add(item(42, 44, -22));
dataSeries.add(item(3, 52, 9));
dataSeries.add(item(31, 50, 47));
dataSeries.add(item(79, 91, 13));
dataSeries.add(item(93, 23, -27));
dataSeries.add(item(44, 83, -28));
PlotOptionsBubble opts = new PlotOptionsBubble();
opts.setNegativeColor(getThemeColors()[3]);
opts.setMaxSize(50, Unit.PERCENTAGE);
opts.setMinSize("3");
conf.setPlotOptions(opts);
conf.addSeries(dataSeries);
return chart;
}
use of com.vaadin.addon.charts.model.PlotOptionsBubble in project charts by vaadin.
the class BubbleChartExample method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.BUBBLE);
Configuration conf = chart.getConfiguration();
conf.setTitle((String) null);
DataSeries dataSeries = new DataSeries();
dataSeries.add(item(9, 81, 13));
dataSeries.add(item(98, 5, 39));
dataSeries.add(item(51, 50, 23));
dataSeries.add(item(41, 22, -36));
dataSeries.add(item(58, 24, -30));
dataSeries.add(item(78, 37, -16));
dataSeries.add(item(55, 56, 3));
dataSeries.add(item(18, 45, 20));
dataSeries.add(item(42, 44, -22));
dataSeries.add(item(3, 52, 9));
dataSeries.add(item(31, 18, 47));
dataSeries.add(item(79, 91, 13));
dataSeries.add(item(93, 23, -27));
dataSeries.add(item(44, 83, -28));
PlotOptionsBubble opts = new PlotOptionsBubble();
opts.setNegativeColor(getThemeColors()[3]);
opts.setMaxSize("120");
opts.setMinSize("3");
conf.setPlotOptions(opts);
conf.addSeries(dataSeries);
DataSeries dataSeries2 = new DataSeries("Negative bubbles hidden");
dataSeries2.add(item(13, 30, 10));
dataSeries2.add(item(23, 20, -10));
dataSeries2.add(item(23, 40, 10));
opts = new PlotOptionsBubble();
opts.setDisplayNegative(false);
dataSeries2.setPlotOptions(opts);
conf.addSeries(dataSeries2);
return chart;
}
use of com.vaadin.addon.charts.model.PlotOptionsBubble in project charts by vaadin.
the class ChartTypes method chartTypesBubbleSnippet1.
public void chartTypesBubbleSnippet1() {
// Create a bubble chart
Chart chart = new Chart(ChartType.BUBBLE);
chart.setWidth("640px");
chart.setHeight("350px");
// Modify the default configuration a bit
Configuration conf = chart.getConfiguration();
conf.setTitle("Champagne Consumption by Country");
// Disable legend
conf.getLegend().setEnabled(false);
conf.getTooltip().setFormatter("this.point.name + ': ' + " + "Math.round(100*(this.point.z * this.point.z))/100.0 + " + "' M bottles'");
// World map as background
String url = VaadinServlet.getCurrent().getServletContext().getContextPath() + "/VAADIN/themes/mytheme/img/map.png";
conf.getChart().setPlotBackgroundImage(url);
// Show more bubbly bubbles with spherical color gradient
PlotOptionsBubble plotOptions = new PlotOptionsBubble();
Marker marker = new Marker();
GradientColor color = GradientColor.createRadial(0.4, 0.3, 0.7);
color.addColorStop(0.0, new SolidColor(255, 255, 255, 0.5));
color.addColorStop(1.0, new SolidColor(170, 70, 67, 0.5));
marker.setFillColor(color);
plotOptions.setMarker(marker);
conf.setPlotOptions(plotOptions);
// Source: CIVC - Les expeditions de vins de Champagne en 2011
DataSeries series = new DataSeries("Countries");
Object[][] data = { { "France", 181.6 }, { "United Kingdom", 34.53 }, { "United States", 19.37 } };
for (Object[] country : data) {
String name = (String) country[0];
double amount = (Double) country[1];
Coordinate pos = new Coordinate();
DataSeriesItem3d item = new DataSeriesItem3d();
item.setX(pos.longitude * Math.cos(pos.latitude / 2.0 * (Math.PI / 160)));
item.setY(pos.latitude * 1.2);
item.setZ(Math.sqrt(amount));
item.setName(name);
series.add(item);
}
conf.addSeries(series);
// Set the category labels on the axis correspondingly
XAxis xaxis = new XAxis();
xaxis.setExtremes(-180, 180);
conf.addxAxis(xaxis);
// Set the Y axis title
YAxis yaxis = new YAxis();
yaxis.setExtremes(-90, 90);
conf.addyAxis(yaxis);
}
use of com.vaadin.addon.charts.model.PlotOptionsBubble in project charts by vaadin.
the class PlotOptionsTest method plotOptions_setSizeWithCMUnit_raiseException.
@Test(expected = IllegalArgumentException.class)
public void plotOptions_setSizeWithCMUnit_raiseException() {
PlotOptionsBubble plotOptions = new PlotOptionsBubble();
plotOptions.setMaxSize(10, Sizeable.Unit.CM);
}
Aggregations