Search in sources :

Example 71 with XAxis

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

the class ChartTypes method chartTypePolarSnippet2.

public void chartTypePolarSnippet2() {
    Chart chart = new Chart(ChartType.LINE);
    // Enable the polar projection
    Configuration conf = chart.getConfiguration();
    // Define the sector of the polar projection
    // Full circle
    Pane pane = new Pane(0, 360);
    conf.addPane(pane);
    // Define the X axis and set its value range
    XAxis axis = new XAxis();
    axis.setMin(0);
    axis.setMax(360);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Pane(com.vaadin.addon.charts.model.Pane) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis)

Example 72 with XAxis

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

the class ChartTypes method chartTypesHeatMap.

public void chartTypesHeatMap() {
    Chart chart = new Chart(ChartType.HEATMAP);
    chart.setWidth("600px");
    chart.setHeight("300px");
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Heat Data");
    // Set colors for the extremes
    conf.getColorAxis().setMinColor(SolidColor.AQUA);
    conf.getColorAxis().setMaxColor(SolidColor.RED);
    // Set up border and data labels
    PlotOptionsHeatmap plotOptions = new PlotOptionsHeatmap();
    plotOptions.setBorderColor(SolidColor.WHITE);
    plotOptions.setBorderWidth(2);
    plotOptions.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(plotOptions);
    // Create some data
    HeatSeries series = new HeatSeries();
    // Jan High
    series.addHeatPoint(0, 0, 10.9);
    // Jan Low
    series.addHeatPoint(0, 1, -51.5);
    // Feb High
    series.addHeatPoint(1, 0, 11.8);
    // Dec Low
    series.addHeatPoint(11, 1, -47.0);
    conf.addSeries(series);
    // Set the category labels on the X axis
    XAxis xaxis = new XAxis();
    xaxis.setTitle("Month");
    xaxis.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    conf.addxAxis(xaxis);
    // Set the category labels on the Y axis
    YAxis yaxis = new YAxis();
    yaxis.setTitle("");
    yaxis.setCategories("High C", "Low C");
    conf.addyAxis(yaxis);
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) HeatSeries(com.vaadin.addon.charts.model.HeatSeries) PlotOptionsHeatmap(com.vaadin.addon.charts.model.PlotOptionsHeatmap) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 73 with XAxis

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

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

the class ChartTypes method chartTypeSpiderWebSnippet1.

public void chartTypeSpiderWebSnippet1() {
    Chart chart = new Chart(ChartType.LINE);
    // Modify the default configuration a bit
    Configuration conf = chart.getConfiguration();
    conf.getChart().setPolar(true);
    // Create the range series
    // Source: http://ilmatieteenlaitos.fi/lampotilaennatyksia
    ListSeries series = new ListSeries("Temperature Extremes", 10.9, 11.8, 17.5, 25.5, 31.0, 33.8, 37.2, 33.8, 28.8, 19.4, 14.1, 10.8);
    conf.addSeries(series);
    // Set the category labels on the X axis correspondingly
    XAxis xaxis = new XAxis();
    xaxis.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    xaxis.setTickmarkPlacement(TickmarkPlacement.ON);
    xaxis.setLineWidth(0);
    conf.addxAxis(xaxis);
    // Configure the Y axis
    YAxis yaxis = new YAxis();
    // Webby look
    yaxis.setGridLineInterpolation("polygon");
    yaxis.setMin(0);
    yaxis.setTickInterval(10);
    yaxis.getLabels().setStep(1);
    conf.addyAxis(yaxis);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 75 with XAxis

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

the class ConfigurationTest method setup.

@Before
public void setup() {
    ListSeries row1 = new ListSeries("row1", 1, 2);
    ListSeries row2 = new ListSeries("row2", 4, 5);
    ListSeries row3 = new ListSeries("row3", 7, 8);
    ListSeries row4 = new ListSeries("row4", 10, 11);
    String[] cols = { "col1", "col2" };
    Chart chart = new Chart(ChartType.COLUMN);
    conf = chart.getConfiguration();
    XAxis axis = new XAxis();
    axis.setCategories(cols);
    conf.addxAxis(axis);
    conf.setSeries(row1, row2, row3, row4);
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) Before(org.junit.Before)

Aggregations

XAxis (com.vaadin.addon.charts.model.XAxis)78 Chart (com.vaadin.addon.charts.Chart)71 Configuration (com.vaadin.addon.charts.model.Configuration)65 YAxis (com.vaadin.addon.charts.model.YAxis)63 Tooltip (com.vaadin.addon.charts.model.Tooltip)39 ListSeries (com.vaadin.addon.charts.model.ListSeries)35 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)26 DataSeries (com.vaadin.addon.charts.model.DataSeries)26 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)26 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)26 Legend (com.vaadin.addon.charts.model.Legend)20 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)17 DataLabels (com.vaadin.addon.charts.model.DataLabels)16 Title (com.vaadin.addon.charts.model.Title)16 Labels (com.vaadin.addon.charts.model.Labels)9 Style (com.vaadin.addon.charts.model.style.Style)9 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)8 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8 ArrayList (java.util.ArrayList)8 Marker (com.vaadin.addon.charts.model.Marker)7