Search in sources :

Example 1 with MapSeries

use of com.vaadin.demo.chartplugin.model.MapSeries in project charts by vaadin.

the class ChartPluginExamples method createHeatMap.

public static Chart createHeatMap() {
    final Chart chart = new Chart(CustomChartTypes.MAP);
    chart.setWidth("800px");
    chart.setHeight("500px");
    final Configuration configuration = chart.getConfiguration();
    ChartModel model = new ChartModel();
    configuration.setChart(model);
    model.setType(CustomChartTypes.MAP);
    model.setBorderWidth(1);
    model.setZoomType(ZoomType.XY);
    model.setInverted(false);
    configuration.getTitle().setText("Vaadin Charts Test for complex highcharts plugin");
    XAxis xAxis = configuration.getxAxis();
    xAxis.setEndOnTick(false);
    xAxis.setGridLineWidth(0);
    xAxis.getLabels().setEnabled(false);
    xAxis.setLineWidth(0);
    xAxis.setMinPadding(0);
    xAxis.setMaxPadding(0);
    xAxis.setStartOnTick(false);
    xAxis.setTickWidth(0);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setEndOnTick(false);
    yAxis.setGridLineWidth(0);
    yAxis.getLabels().setEnabled(false);
    yAxis.setLineWidth(0);
    yAxis.setMinPadding(0);
    yAxis.setMaxPadding(0);
    yAxis.setStartOnTick(false);
    yAxis.setTickWidth(0);
    yAxis.setTitle("");
    yAxis.setReversed(true);
    Legend legend = configuration.getLegend();
    legend.setHorizontalAlign(HorizontalAlign.LEFT);
    legend.setVerticalAlign(VerticalAlign.BOTTOM);
    legend.setFloating(true);
    legend.setLayout(LayoutDirection.VERTICAL);
    configuration.setExporting(false);
    MapSeries series = new MapSeries();
    series.addValueRange(new ValueRange(null, 3, new SolidColor(19, 64, 117, 0.05)));
    series.addValueRange(new ValueRange(3, 10, new SolidColor(19, 64, 117, 0.2)));
    series.addValueRange(new ValueRange(10, 30, new SolidColor(19, 64, 117, 0.4)));
    series.addValueRange(new ValueRange(30, 100, new SolidColor(19, 64, 117, 0.5)));
    series.addValueRange(new ValueRange(100, 300, new SolidColor(19, 64, 117, 0.6)));
    series.addValueRange(new ValueRange(300, 1000, new SolidColor(19, 64, 117, 0.8)));
    series.addValueRange(new ValueRange(1000, null, new SolidColor(19, 64, 117, 1)));
    Random random = new Random();
    for (String c : Locale.getISOCountries()) {
        DataSeriesItem p = new DataSeriesItem(c.toLowerCase(), random.nextInt(1200));
        series.add(p);
    }
    configuration.addSeries(series);
    chart.drawChart(configuration);
    return chart;
}
Also used : ValueRange(com.vaadin.demo.chartplugin.model.ValueRange) Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Random(java.util.Random) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) ChartModel(com.vaadin.addon.charts.model.ChartModel) MapSeries(com.vaadin.demo.chartplugin.model.MapSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

Chart (com.vaadin.addon.charts.Chart)1 ChartModel (com.vaadin.addon.charts.model.ChartModel)1 Configuration (com.vaadin.addon.charts.model.Configuration)1 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)1 Legend (com.vaadin.addon.charts.model.Legend)1 XAxis (com.vaadin.addon.charts.model.XAxis)1 YAxis (com.vaadin.addon.charts.model.YAxis)1 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)1 MapSeries (com.vaadin.demo.chartplugin.model.MapSeries)1 ValueRange (com.vaadin.demo.chartplugin.model.ValueRange)1 Random (java.util.Random)1