D3 Flashcards

1
Q

D3

A

= Data-Driven Documents

A library that provides a mechanism for connecting arbitrary data to documents (DOM elements), allowing the appearance and behaviour of the documents. to be driven by the data.

VISUALISATION is provided by HTML, CSS, or SVG, D3 focuses on the DATA. It is actually a collection of integrated JS tools for manipulating data structures necessary to create data visualisations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does D3 work?

A

DATA drives documents that display D3 visualisations. By ADDING, CHANGING, or REMOVING data, you directly affect the way your chart appears on the screen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Typical D3 Script

A
  1. selects HTML or SVG elements
  2. binds them to individual data items
  3. removes, updates, or appends graphical elements automatically, when necessary.
    * individual data items can be accessed in callbacks in the methods that set values for styles, attributes, and transforms.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

D3’s actual data visualisation part

A

Contains tools that are applied to previously selected DOM nodes and data:

  • layout generators
  • scales
  • axis generators
  • map projections
  • shape generators
  • colour scemes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does d3’s .data() do?

A

Sets the data to drive creation of the elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does d3’s .enter() do?

A

Creates a selection to add elements per data item.

It binds the data to the selection of elements creating the array of placeholders of the same size as the data array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When is d3’s .transition() called?

A

Before the attributes and styles that are to be changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which d3 modules are enough to create an animated interactive bar chart?

A
  • selection

- transition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What categories of d3 modules exist?

A

Modules for:

  1. data manipulation
  2. document manipulation
  3. interactivity and animation
  4. colours
  5. asynchronous operation and packaging
  6. 2D geometry
  7. spherical geometry and geographic maps
  8. layouts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When to use canvas in D3?

A

Use it in all or part of your app

-> if you have memory problems due to excessive objects created in the DOM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

HTML canvas how to

A
  1. setup the graphic context (practically all the canvas API consists of methods and properties called from the graphic context.

const ctx = canvas.getContext(‘2d’)

  1. before drawing, you set properties such as font, fillStyle, strokeStyle

ctx. fillStyle = ‘red’;
ctx. lineWidth=’10’;

  1. then you fill or stroke rectangles and add arbitrary paths.

ctx. fillRect(50,50,50,50);
ctx. strokeRect(50,50,50,50):

How well did you know this?
1
Not at all
2
3
4
5
Perfectly