Search in sources :

Example 6 with DataSeriesItem3d

use of com.vaadin.addon.charts.model.DataSeriesItem3d in project charts by vaadin.

the class PointClickCoordinatesScatterChart method fillSeries.

private void fillSeries(DataSeries higherX, DataSeries higherY, DataSeries higherZ) {
    Random random = new Random(7);
    for (int i = 0; i < 300; i++) {
        double lng = random.nextDouble() * 2 * Math.PI;
        double lat = random.nextDouble() * 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);
        DataSeriesItem3d point = new DataSeriesItem3d(x, y, z);
        if (x > y && x > z) {
            higherX.add(point);
        } else if (y > x && y > z) {
            higherY.add(point);
        } else {
            higherZ.add(point);
        }
    }
}
Also used : DataSeriesItem3d(com.vaadin.addon.charts.model.DataSeriesItem3d) Random(java.util.Random)

Example 7 with DataSeriesItem3d

use of com.vaadin.addon.charts.model.DataSeriesItem3d in project charts by vaadin.

the class BubbleChartMaxSizePercentage method item.

public DataSeriesItem item(int x, int y, int z) {
    DataSeriesItem3d dataSeriesItem = new DataSeriesItem3d();
    dataSeriesItem.setX(x);
    dataSeriesItem.setY(y);
    dataSeriesItem.setZ(z);
    return dataSeriesItem;
}
Also used : DataSeriesItem3d(com.vaadin.addon.charts.model.DataSeriesItem3d)

Example 8 with DataSeriesItem3d

use of com.vaadin.addon.charts.model.DataSeriesItem3d 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 9 with DataSeriesItem3d

use of com.vaadin.addon.charts.model.DataSeriesItem3d in project charts by vaadin.

the class BasicUse method basicUse3dDataSnippet1.

public void basicUse3dDataSnippet1() {
    Chart chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    Options3d options3d = new Options3d();
    double[][] points = { // x, y, z
    { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 0.0, -1.0 } };
    DataSeries series = new DataSeries();
    for (int i = 0; i < points.length; i++) {
        double x = points[i][0];
        double y = points[i][1];
        double z = points[i][2];
        // Scale the depth coordinate, as the depth axis is
        // not scaled automatically
        DataSeriesItem3d item = new DataSeriesItem3d(x, y, z * options3d.getDepth().doubleValue());
        series.add(item);
    }
    conf.addSeries(series);
}
Also used : DataSeriesItem3d(com.vaadin.addon.charts.model.DataSeriesItem3d) Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) Options3d(com.vaadin.addon.charts.model.Options3d)

Aggregations

DataSeriesItem3d (com.vaadin.addon.charts.model.DataSeriesItem3d)9 DataSeries (com.vaadin.addon.charts.model.DataSeries)3 Random (java.util.Random)3 Chart (com.vaadin.addon.charts.Chart)2 Configuration (com.vaadin.addon.charts.model.Configuration)2 Marker (com.vaadin.addon.charts.model.Marker)2 Options3d (com.vaadin.addon.charts.model.Options3d)2 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)2 PlotOptionsBubble (com.vaadin.addon.charts.model.PlotOptionsBubble)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