use of com.vaadin.addon.charts.model.style.SolidColor 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.style.SolidColor in project charts by vaadin.
the class HighChartsDefaultTheme method setAxisDefaults.
protected void setAxisDefaults(AxisStyle style) {
style.setGridLineColor(PLOT_BORDER_COLOR);
style.setLineColor(new SolidColor("#C0D0E0"));
style.setLineWidth(1);
style.setTickColor(new SolidColor("#C0D0E0"));
style.setAlternateGridColor(new SolidColor(255, 255, 255, 0.0));
style.getTitle().setFontWeight(FontWeight.NORMAL);
style.getTitle().setColor(TITLE_FONT_COLOR);
style.getSubtitle().setFontSize("10px");
style.getSubtitle().setFontWeight(FontWeight.NORMAL);
style.getSubtitle().setColor(GRAY);
style.getLabels().setFontSize("11px");
style.getLabels().setFontWeight(FontWeight.NORMAL);
style.getLabels().setColor(GRAY);
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class VaadinTheme method setAxisDefaults.
protected void setAxisDefaults(AxisStyle style) {
style.setGridLineColor(GRID_COLOR);
style.setLineColor(GRID_COLOR);
style.setLineWidth(1);
style.setTickColor(GRID_COLOR);
style.setAlternateGridColor(new SolidColor(255, 255, 255, 0.0));
style.getTitle().setColor(TITLE_COLOR);
style.getTitle().setFontWeight(FontWeight.BOLD);
style.getSubtitle().setColor(SUBTITLE_COLOR);
style.getSubtitle().setFontSize("10px");
style.getSubtitle().setFontWeight(FontWeight.NORMAL);
style.getLabels().setFontWeight(FontWeight.NORMAL);
style.getLabels().setColor(LABEL_COLOR);
style.getLabels().setFontSize("12px");
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class ValoLightTheme method setAxisDefaults.
protected void setAxisDefaults(AxisStyle style) {
style.setGridLineColor(GRID_COLOR);
style.setLineColor(GRID_COLOR);
style.setLineWidth(0);
style.setTickWidth(0);
style.setTickColor(new SolidColor(192, 208, 224));
style.setAlternateGridColor(new SolidColor(255, 255, 255, 0.0));
style.getTitle().setColor(TEXT_COLOR);
style.getTitle().setFontWeight(FontWeight.NORMAL);
style.getSubtitle().setColor(SUBTITLE_COLOR);
style.getSubtitle().setFontSize("14px");
style.getSubtitle().setFontWeight(FontWeight.NORMAL);
style.getLabels().setFontWeight(FontWeight.NORMAL);
style.getLabels().setColor(LABEL_COLOR);
style.getLabels().setFontSize("14px");
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class ChartOptionsJSONSerializationTest method toJSON_itemWithRadialGradientColor_RadialGradientSerialized.
@Test
public void toJSON_itemWithRadialGradientColor_RadialGradientSerialized() {
GradientColor color = GradientColor.createRadial(0.5, 0.3, 0.7);
color.addColorStop(0, new SolidColor(255, 128, 0));
color.addColorStop(1, new SolidColor(128, 64, 0));
DataSeriesItem item = new DataSeriesItem("Foobar", 45.0);
item.setColor(color);
DataSeries series = new DataSeries();
series.add(item);
String expected = "{\"data\":[{\"name\":\"Foobar\",\"y\":45.0,\"color\":{\"stops\":[[0.0,\"#FF8000\"],[1.0,\"#804000\"]],\"radialGradient\":{\"cx\":0.5,\"cy\":0.3,\"r\":0.7}}}]}";
assertEquals(expected, toJSON(series));
}
Aggregations