GeoChart

image not found image not found

Contents:

For using the GeoChart or MapsChart a Google API-Key is required. This API key can be requested here.

Optimal data structure (database):

Labeling X-Axis

"United States"

327414000

"Japan"

126490000

"Russia"

146877088

…​

Optimal object structure (Java)

public class GeoChartObject {
    private String country;
    private Integer value;

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }
}

Here you can find a list of all valid codes and countries: Country codes

Example

// Create model
final ChartModel model = ChartModel.New()
    .addColumn(Column.New(Column.Type.STRING, "Country"))
    .addColumn(Column.New(Column.Type.NUMBER, "Popularity"));

// Add items to model
model.addRow("Germany", 200);
model.addRow("United States", 300);
model.addRow("Brazil", 400);
model.addRow("Canada", 500);
model.addRow("France", 600);
model.addRow("RU", 700);

API and methods

Properties

API Key

Some charts require an API key from Google. You can get a key here: https://developers.google.com/maps/documentation/javascript/get-api-key

geoChart.setMapsApiKey("123456789wertzuiopü");

DatalessRegionColor

Color assigned to the regions without associated data.

geoChart.setDatalessRegionColor("white");

DefaultColor

The color to use for data points in a "geochart" when the location (e.g. 'US' ) is present, but the value is either null or unspecified. This is different from datalessRegionColor, the color used when the data is missing.

geoChart.setDefaultColor("white");

DisplayMode

What kind of "Geochart" it is. The DataTable format must match the specified value. The following values are supported:

  • 'auto' - selection based on the format of the DataTable.

  • regions' - Colors the regions on the "Geochart".

  • 'markers' - Places markers on the regions.

  • 'text' - label the regions with text from the DataTable.

    geoChart.setDisplayMode(DisplayMode.MARKERS);

MarkerOpacy

The opacity of the markings, where 0.0 stands for completely transparent and 1.0 for completely opaque.

geoChart.setMarkerOpacity(0.8);

Resolution

The resolution of the "Geochart" borders. Choose one of the following values:

  • "Countries" - Supported for all regions, except for US state regions.

  • "Provinces" - Supported only for country regions and US state regions. Not supported for all countries; please test a country to see if this option is supported.

  • 'metros' - Supported only for US country region and US state regions.

geoChart.setResolution(Resolution.COUNTRIES);

MagnifyingGlass

If this option is enabled, a magnifying glass will open when the user hovers over an overloaded marker.

Note: This feature is not supported in browsers that support SVG do not support, i.e. Internet Explorer version 8 or earlier.

geoChart.setMagnifyingGlass(MagnifyingGlass.New(true, 5));