D3JS by images

source: https://www.slideshare.net/kurotanshi/study4tw-d3js

https://www.slideshare.net/helxsz/d3-36763651

d3.js patterns

https://bocoup.com/blog/reusability-with-d3

D3.js Charts Pattern Progression

Step 1: Configuration Variables

Step 2: Easy Repetition Through Functions

 

D3.js Charts Pattern Progression

Step 2: Easy Repetition Through Functions

 

The next step is to wrap this code into a generation function, which reduces initialization to just one line. The function takes in three arguments: the data, a DOM target, and an options object which can be used to overwrite default configuration variables. Take a look at how this can be done:

function drawChart(dom, data, options) {

Method Chaining and Selections

New Pattern for Updatable Charts

  1. Repeatable – A chart can be instantiated more than once in a given context, each visualizing a different data set.
  2. Modifiable – Chart definitions (source code) can be easily re-factored by other developers to suit their needs.
  3. Configurable – Chart behavior can be altered at run-time through a consistent API.
  4. Extensible – New charts can be defined in terms of existing charts.


https://bocoup.com/blog/reusability-with-d3

d3.js code rules

https://northlandia.wordpress.com/2014/10/23/ten-best-practices-for-coding-with-d3/

Put each new method on its own indented line.

: If your code breaks, look for a wayward semicolon.

The methods depend on how the operand was created.

Assign each block to a logical variable (the block’s ‘name’).

Assign each new element a class name identical to the block name.

Always pass the block’s name as a class selector to the .selectAll method, even when creating an empty selection.

Assign static or default styles using a CSS stylesheet.

use .style instead of .attr.

d3js examples

By Jesús Estévez

d3js examples

interesting d3js information done by other people

  • 719