use of com.vaadin.addon.charts.model.Marker in project charts by vaadin.
the class ChartTypes method chartTypesScatterSnippet1.
public void chartTypesScatterSnippet1() {
Chart chart = new Chart(ChartType.SCATTER);
chart.setWidth("500px");
chart.setHeight("500px");
// Modify the default configuration a bit
Configuration conf = chart.getConfiguration();
conf.setTitle("Random Sphere");
// Disable legend
conf.getLegend().setEnabled(false);
PlotOptionsScatter options = new PlotOptionsScatter();
// ... Give overall plot options here ...
conf.setPlotOptions(options);
DataSeries series = new DataSeries();
for (int i = 0; i < 300; i++) {
double lng = Math.random() * 2 * Math.PI;
double lat = Math.random() * Math.PI - Math.PI / 2;
double x = Math.cos(lat) * Math.sin(lng);
double y = Math.sin(lat);
double z = Math.cos(lng) * Math.cos(lat);
DataSeriesItem point = new DataSeriesItem(x, y);
Marker marker = new Marker();
// Make settings as described later
point.setMarker(marker);
series.add(point);
}
conf.addSeries(series);
}
use of com.vaadin.addon.charts.model.Marker in project charts by vaadin.
the class ChartTypes method chartTypesScatterMarkerSymbolsSnippet1.
public void chartTypesScatterMarkerSymbolsSnippet1() {
Marker marker = new Marker();
marker.setSymbol(MarkerSymbolEnum.DIAMOND);
}
use of com.vaadin.addon.charts.model.Marker in project charts by vaadin.
the class ChartTypes method chartTypesScatterMarkersSnippet1.
public void chartTypesScatterMarkersSnippet1() {
double x = 1.0;
double y = 1.2;
DataSeriesItem point = new DataSeriesItem(x, y);
Marker marker = new Marker();
// ... Make any settings ...
point.setMarker(marker);
DataSeries series = new DataSeries();
series.add(point);
}
use of com.vaadin.addon.charts.model.Marker 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);
}
Aggregations