Coder Social home page Coder Social logo

d3.chart.choropleth's Introduction

d3.chart.choropleth

A d3.chart based choropleth map with an easily modified domain and built-in color-brewer colors based on a quantize scale.

YlGnBu color brew:

YlGnBu

OrRd color brew:

OrRd

Sample Use

// YlGnBu color brew, custom domain
var chart_1 = d3.select('#map1')
  .append("svg")
  .attr("height", 500)
  .attr("width", 480)
  .chart("Choropleth")
  .domain([0, 15])
  .range('YlGnBu')
  .projection(d3.geo.albersUsa())
  .scale(500);

// OrRd color brew, wider domain
var chart_2 = d3.select('#map2')
  .append("svg")
  .attr("height", 500)
  .attr("width", 480)
  .chart("Choropleth")
  .domain([0, 25])
  .range('OrRd')
  .projection(d3.geo.albersUsa())
  .scale(500);

API

Sample API Documentation:

<instance>.height(newHeight)

Description:

When value provided sets the height of the map. If no value provided, defaults to 500 for bl.ocks integration.

Parameters:

  • newHeight - Integer, optional, new height

Uses:

Example:

var map = d3.select("#map")
  .append("svg")
  .chart("Choropleth")
  .height(500);

<instance>.width(newWidth)

Description:

When value provided sets the width of the map. If no value provided, defaults to 960 for bl.ocks integration.

Parameters:

  • newWidth - Integer, optional, new width

Uses:

Example:

var map = d3.select("#map")
  .append("svg")
  .chart("Choropleth")
  .width(900);

<instance>.range(newRange)

Description:

When value provided sets the color range for the map, based on the color brewer colors. Must pass one of the following:

  • BuGn
  • BuPu
  • GnBu
  • OrRd
  • PuBu
  • PuBuGn
  • PuRd
  • RdPu
  • YlGn
  • YlGnBu
  • YlOrBr
  • YlOrRd

Defaults to YlGnBu.

Parameters:

  • newRange - String, optional, new color range

Uses:

Example:

var map = d3.select("#map")
  .append("svg")
  .chart("Choropleth")
  .range('RdPu');

<instance>.domain(newDomain)

Description:

When value provided sets the quantize scale domain for the map. Defaults to [0, data.max]

Parameters:

  • newDomain - Array, optional, new quantize scale domain

Uses:

Example:

var map = d3.select("#map")
  .append("svg")
  .chart("Choropleth")
  .domain([10, 50]);

<instance>.projection(newProjection)

Description:

When value provided sets the map projection. Defaults to d3.geo.mercator. See the D3 projections page for additional projection options.

Parameters:

  • newProjection - d3.geo projection, optional, new projection

Uses:

Example:

var map = d3.select("#map")
  .append("svg")
  .chart("Choropleth")
  .projection(d3.geo.stereographic());

<instance>.scale(newScale)

Description:

When value provided sets the map scale. Defaults to 1000.

Parameters:

  • newScale - Integer, optional, new map scale

Uses:

Example:

var map = d3.select("#map")
  .append("svg")
  .chart("Choropleth")
  .scale(100)

d3.chart.choropleth's People

Contributors

wrobstory avatar

Watchers

Carl V. Lewis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.