Search in sources :

Example 26 with Marker

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

Example 27 with Marker

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

Example 28 with Marker

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

Example 29 with Marker

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);
}
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)

Aggregations

Marker (com.vaadin.addon.charts.model.Marker)29 Chart (com.vaadin.addon.charts.Chart)23 Configuration (com.vaadin.addon.charts.model.Configuration)22 YAxis (com.vaadin.addon.charts.model.YAxis)16 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)15 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)14 DataSeries (com.vaadin.addon.charts.model.DataSeries)13 Hover (com.vaadin.addon.charts.model.Hover)11 ListSeries (com.vaadin.addon.charts.model.ListSeries)11 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)9 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)9 States (com.vaadin.addon.charts.model.States)9 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)8 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)7 XAxis (com.vaadin.addon.charts.model.XAxis)7 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)5 Labels (com.vaadin.addon.charts.model.Labels)4 PlotBand (com.vaadin.addon.charts.model.PlotBand)3 Color (com.vaadin.addon.charts.model.style.Color)3 ParseException (java.text.ParseException)3