mode helix
NOW LIVEEmpower your end users with Explorations in Mode.Try it now

Choropleth map

Choropleth maps are thematic maps in which areas are shaded based on the prevalence of a particular variable. They are a great way of showing how a measurement varies across a geographic area.

Below is an example of choropleth map showing the rate of excessive drinkers by county. The darker the region, the higher the percentage of excessive drinkers. This makes it easy to pick out certain states as having particularly high rates of excessive drinkers (looking at you, Wisconsin), while others have very low rates (shout out to Utah).

View Mode Analysis

Click Powered by Mode to clone this example and make your own choropleth map. Learn more about using HTML to customize your reports.

Create a choropleth map

Add the stylesheet links and script tags to the top of the HTML:

<link rel="stylesheet" href="https://mode.github.io/alamode/alamode.min.css">
<script src="https://d3js.org/d3-geo.v1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.4/queue.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/topojson/1.1.0/topojson.min.js"></script>
<script src="https://mode.github.io/alamode/alamode.min.js"></script>

Add the customizable snippet at the bottom of the HTML:

<script>

alamode.countyChoropleth(
  {
    query_name: "Query 1",
    width: 800,
    county_id_column: "county_id",
    value_column: "rate",
    title: "Excessive drinking rates",
    color_gradient: ["#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850"]
  }
)

</script>

You can customize the map by editing the parameters in the snippet:

  • html_element: If not provided, the map will be added as the last element in the report. To place it elsewhere, select an element in your report with this parameter.
  • width: The width of the map. Defaults to 950. The map will always stay the same ratio.
  • height: The height of the HTML element containing the map. The map itself will resize according to the width value provided.
  • query_name: The name of the query that returns the map's dataset. If you update the name of the query, you’ll need to update it here as well.
  • county_id_column: The dataset column that returns each county's FIPS code.
  • value_column: The dataset column that returns the value that determine how each county is shaded.
  • title: The map's title.
  • color_gradient: A list of colors to show in the map. Colors should be listed from low to high.
decorative particle

Get our weekly data newsletter

Work-related distractions for every data enthusiast.