ThoughtSpot acquires Mode to define the next generation of collaborative BI >>Learn More

Zipcode 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 how high the total wages are by zipcode. The darker the region, the higher the wages. This makes it easy to pick out certain zipcode areas as having particularly high or low total wages.

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.zipcodeChoropleth(
  {
	query_name: "Query 1",
	width: 800,
	zipcode_column: "zip9",
	value_column: "total_wages",
	title: "Total Wages by Zipcode",
	color_gradient: ["#a3c1e0", "#82a7cc", "#739cc6", "#6595c6", "#548bc4", "#3f7cba", "#3174b7", "#2166ac"]
  }
)

</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.
  • zipcode_column: The dataset column that returns zipcodes. Note that zipcodes should be 5 digits, including those that start with leading zeros.
  • value_column: The dataset column that returns the value that determine how each zipcode area 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.

Get more from your data

Your team can be up and running in 30 minutes or less.