Search in sources :

Example 1 with PlotOptionsBubble

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;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsBubble(com.vaadin.addon.charts.model.PlotOptionsBubble) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart)

Example 2 with PlotOptionsBubble

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;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsBubble(com.vaadin.addon.charts.model.PlotOptionsBubble) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart)

Example 3 with PlotOptionsBubble

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);
}
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 4 with PlotOptionsBubble

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

Aggregations

PlotOptionsBubble (com.vaadin.addon.charts.model.PlotOptionsBubble)4 Chart (com.vaadin.addon.charts.Chart)3 Configuration (com.vaadin.addon.charts.model.Configuration)3 DataSeries (com.vaadin.addon.charts.model.DataSeries)3 DataSeriesItem3d (com.vaadin.addon.charts.model.DataSeriesItem3d)1 Marker (com.vaadin.addon.charts.model.Marker)1 XAxis (com.vaadin.addon.charts.model.XAxis)1 YAxis (com.vaadin.addon.charts.model.YAxis)1 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)1 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)1 Test (org.junit.Test)1