Class: GeoChoroplethChart

GeoChoroplethChart

The geo choropleth chart is designed as an easy way to create a crossfilter driven choropleth map from GeoJson data. This chart implementation was inspired by the great d3 choropleth example.

Examples:


new GeoChoroplethChart(parent [, chartGroup])

Create a Geo Choropleth Chart.

Parameters:
Name Type Argument Description
parent String | node | d3.selection

Any valid d3 single selector specifying a dom block element such as a div; or a dom element or d3 selection.

chartGroup String <optional>

The name of the chart group this chart instance should be placed in. Interaction with a chart will only trigger events and redraws within the chart's group.

Mixes In:
Source:
Example
// create a choropleth chart under '#us-chart' element using the default global chart group
var chart1 = new GeoChoroplethChart('#us-chart');
// create a choropleth chart under '#us-chart2' element using chart group A
var chart2 = new CompositeChart('#us-chart2', 'chartGroupA');

Classes

GeoChoroplethChart

Methods


geoJsons()

Returns all GeoJson layers currently registered with this chart. The returned array is a reference to this chart's internal data structure, so any modification to this array will also modify this chart's internal registration.

Source:
Returns:
Type
Array.<{name:String, data: Object, accessor: function()}>

geoPath()

Returns the d3.geoPath object used to render the projection and features. Can be useful for figuring out the bounding box of the feature set and thus a way to calculate scale and translation for the projection.

Source:
See:
Returns:
Type
d3.geoPath

overlayGeoJson(json, name, keyAccessor)

mandatory

Use this function to insert a new GeoJson map layer. This function can be invoked multiple times if you have multiple GeoJson data layers to render on top of each other. If you overlay multiple layers with the same name the new overlay will override the existing one.

Parameters:
Name Type Description
json _geoJson

a geojson feed

name String

name of the layer

keyAccessor function

accessor function used to extract 'key' from the GeoJson data. The key extracted by this function should match the keys returned by the crossfilter groups.

Source:
See:
Returns:
Type
GeoChoroplethChart
Example
// insert a layer for rendering US states
chart.overlayGeoJson(statesJson.features, 'state', function(d) {
     return d.properties.name;
});

projection( [projection])

Gets or sets a custom geo projection function. See the available d3 geo projection functions.

Starting version 3.0 it has been deprecated to rely on the default projection being d3.geoAlbersUsa(). Please set it explicitly. Considering that null is also a valid value for projection, if you need projection to be null please set it explicitly to null.

Parameters:
Name Type Argument Default Description
projection d3.projection <optional>
d3.geoAlbersUsa()
Source:
See:
Returns:
Type
d3.projection | GeoChoroplethChart

removeGeoJson(name)

Remove a GeoJson layer from this chart by name

Parameters:
Name Type Description
name String
Source:
Returns:
Type
GeoChoroplethChart