Search in sources :

Example 76 with SolidColor

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);
}
Also used : DataSeriesItem3d(com.vaadin.addon.charts.model.DataSeriesItem3d) Configuration(com.vaadin.addon.charts.model.Configuration) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) PlotOptionsBubble(com.vaadin.addon.charts.model.PlotOptionsBubble) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker) XAxis(com.vaadin.addon.charts.model.XAxis) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 77 with SolidColor

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);
}
Also used : SolidColor(com.vaadin.addon.charts.model.style.SolidColor)

Example 78 with SolidColor

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");
}
Also used : SolidColor(com.vaadin.addon.charts.model.style.SolidColor)

Example 79 with SolidColor

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");
}
Also used : SolidColor(com.vaadin.addon.charts.model.style.SolidColor)

Example 80 with SolidColor

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));
}
Also used : GradientColor(com.vaadin.addon.charts.model.style.GradientColor) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Test(org.junit.Test)

Aggregations

SolidColor (com.vaadin.addon.charts.model.style.SolidColor)82 Configuration (com.vaadin.addon.charts.model.Configuration)55 Chart (com.vaadin.addon.charts.Chart)54 YAxis (com.vaadin.addon.charts.model.YAxis)40 DataSeries (com.vaadin.addon.charts.model.DataSeries)27 ListSeries (com.vaadin.addon.charts.model.ListSeries)26 XAxis (com.vaadin.addon.charts.model.XAxis)26 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)25 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)19 DataLabels (com.vaadin.addon.charts.model.DataLabels)18 Legend (com.vaadin.addon.charts.model.Legend)17 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)15 Marker (com.vaadin.addon.charts.model.Marker)14 Tooltip (com.vaadin.addon.charts.model.Tooltip)14 Style (com.vaadin.addon.charts.model.style.Style)14 Labels (com.vaadin.addon.charts.model.Labels)12 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)11 Random (java.util.Random)10 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)9 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8