Skip to content

Latest commit

 

History

History
46 lines (22 loc) · 1.2 KB

d3.md

File metadata and controls

46 lines (22 loc) · 1.2 KB

Basics

  • All operations in the library are chained to the d3 instance.

  • D3 is modularized, so you can only import the modules you need to reduce your build size.

Adding Data

  • .data() is chained to a selection, and binds it with the data passed in as an argument.

  • .enter() reconciles the data and elements that data is bound to: it creates any necessary extra elements if there is a mismatch between those and the number of data items via .append().

Chloropleth Maps

Events

  • Don't use arrow functions for input interactions, the scoping of this in that instance leads to problems.

Key Concepts

  • It will save you a lot of aggravation, especially when you need to transform data in some way, to set accessor functions for certain data points.

Scales

  • Scales exist to convert values from whatever domain they originally belong to, to a pixel domain.

  • scaleLinear() deals with numbers that, well, scale in a linear fashion

  • scaleTime() works with units of time

Selections

  • select() selects the element passed into this method as an argument.

  • selectAll() selects all specified elements.

Time

  • timeParse() takes a string and converts it into a date object.