Skip to content

Commit 2b3db1d

Browse files
committed
small fixes and typos
1 parent 5d5c239 commit 2b3db1d

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ d3.select("div").html(`<strong>Hello</strong>`);
417417

418418
[![Open in CodePen][codepen]](https://codepen.io/sgratzl/pen/POVKRj)
419419

420-
The function come in different shapes: as setter (previous examples) as in a getter version. In the later case the value of the first element in the list will be returned. e.g. `circle.attr('cx')`
420+
The function come in different shapes: as setter (previous examples) as in a getter version. In the later case the value of the first element in the list will be returned. e.g., `circle.attr('cx')`
421421

422422
### DOM Manipulation
423423

@@ -442,7 +442,7 @@ The basic idea of D3 is binding data items to DOM elements and manipulate them a
442442

443443
![D3 Data Join Set Relationship](i/join_types.png)
444444

445-
For each of the cases we have to tell D3 what to do. e.g. when we have more data items than DOM elements, we are in the _enter_ phase and need to specify a way how to create the remaining ones. Similarly if we have more DOM elements than data items we are in the _exit_ phase and need to take care of removing the superfluous ones.
445+
For each of the cases we have to tell D3 what to do. e.g., when we have more data items than DOM elements, we are in the _enter_ phase and need to specify a way how to create the remaining ones. Similarly if we have more DOM elements than data items we are in the _exit_ phase and need to take care of removing the superfluous ones.
446446

447447
Basic workflow:
448448

@@ -652,7 +652,7 @@ D3 provides different scales:
652652
### Colors
653653

654654
With version 5 D3 extracted the color schemes to it on repository located at
655-
https://github.com/d3/d3-scale-chromatic. Including both D3 standard schemes (e.g. `d3.schemeCategory10`) but also the ones from [ColorBrewer](https://colorbrewer2.org/) (e.g. `d3.schemeSet3`). These can be used as `range` for an ordinal scale.
655+
https://github.com/d3/d3-scale-chromatic. Including both D3 standard schemes (e.g., `d3.schemeCategory10`) but also the ones from [ColorBrewer](https://colorbrewer2.org/) (e.g., `d3.schemeSet3`). These can be used as `range` for an ordinal scale.
656656

657657
```js
658658
const cscale = d3.scaleOrdinal().domain(["a", "b", "c"]).range(d3.schemeCategory10);
@@ -835,7 +835,7 @@ One interactive visualization is nice multiple coordinated ones are better. Comb
835835

836836
const state = {
837837
data: [],
838-
// e.g. user selection
838+
// e.g., user selection
839839
}
840840

841841
function filterData() {
@@ -847,7 +847,7 @@ function wrangleData(filtered) {
847847
}
848848

849849
function createVis() {
850-
// initialized for creating the visualizations, e.g. setup SVG, init scales, ...
850+
// initialized for creating the visualizations, e.g., setup SVG, init scales, ...
851851

852852
function update(new_data) {
853853
// updates the specific visualization with the given data
@@ -870,14 +870,14 @@ function updateApp() {
870870
vis(new_data);
871871
}
872872

873-
// init interaction, e.g. listen to click events
873+
// init interaction, e.g., listen to click events
874874
d3.select(...).on('click', () => {
875875
// update state
876876
updateApp();
877877
})
878878

879879
d3.json(...).then((data) => {
880-
// load data, e.g. via d3.json and update app afterwards
880+
// load data, e.g., via d3.json and update app afterwards
881881
state.data = data;
882882
updateApp();
883883
});
@@ -898,7 +898,7 @@ MCV Inital Setup: [mcv01_initial.html](examples/mcv01_initial.html) [![Open in C
898898

899899
## Layouts
900900

901-
D3 provides a bunch of standard layouts. A layout does not actually render the visualization but prepares your data, such that you can render, e.g. a pie chart. Most of the time the work with helper tools for SVG from D3. e.g. the `d3.pie()` works best with `d3.arc()`.
901+
D3 provides a bunch of standard layouts. A layout does not actually render the visualization but prepares your data, such that you can render, e.g., a pie chart. Most of the time the work with helper tools for SVG from D3. e.g., the `d3.pie()` works best with `d3.arc()`.
902902

903903
### Pie Layout
904904

@@ -934,7 +934,7 @@ Pie chart layout: [mcv02_piechart.html](examples/mcv02_piechart.html) [![Open in
934934

935935
## Interaction And Filtering
936936

937-
So far the visualizations doesn't influence each other and the user can only filter data using form elements (drop downs, checkboxes). More intuitive is to interact with the visualization directly, e.g. by clicking on a bar to select this bar and filter all other visualizations to this selected subset.
937+
So far the visualizations doesn't influence each other and the user can only filter data using form elements (drop downs, checkboxes). More intuitive is to interact with the visualization directly, e.g., by clicking on a bar to select this bar and filter all other visualizations to this selected subset.
938938

939939
---
940940

@@ -966,7 +966,7 @@ In addition to the simple `.transition()` D3 provides a more fine granular way t
966966

967967
- `.duration()` to define the duration of the animation.
968968
- `.delay()` to delay the animation.
969-
- `.ease()` to define the way how the interpolation should be performed, e.g. linear with ease in/out, ...
969+
- `.ease()` to define the way how the interpolation should be performed, e.g., linear with ease in/out, ...
970970

971971
Each variant allows like most D3 data bound functions either a constant as an argument (`.duration(2000)`) or a function that returns the value for the given data element (`.duration((d, i) => i * 1000)`). By naming a transition `.transition(name)` multiple transitions of different bindings can be synchronized. `.interrupt()` can be used to abort a currently running animation. For more information see [D3-Transition](https://github.com/d3/d3-transition/)
972972

@@ -1138,12 +1138,12 @@ npm install d3 @types/d3
11381138

11391139
Due to some heavy typing a D3 Selection (such as returned by `d3.select` or `d3.selectAll`) has four generic arguments:
11401140

1141-
1. the element type of the selected element, e.g. `d3.selectAll("div")` will be a `HTMLDivElement`.
1142-
1. the data type bound to this element, e.g. `d3.selectAll("div").data([1, 2, 3])` will be a `number`.
1143-
1. the element type of the parent element, e.g. `d3.select("body").selectAll("div").data([1, 2, 3])` will be a `HTMLBodyElement`.
1144-
1. the data type of the parent element, e.g. `d3.select("body").datum("data").selectAll("div").data([1, 2, 3])` will be a `string`.
1141+
1. the element type of the selected element, e.g., `d3.selectAll("div")` will be a `HTMLDivElement`.
1142+
1. the data type bound to this element, e.g., `d3.selectAll("div").data([1, 2, 3])` will be a `number`.
1143+
1. the element type of the parent element, e.g., `d3.select("body").selectAll("div").data([1, 2, 3])` will be a `HTMLBodyElement`.
1144+
1. the data type of the parent element, e.g., `d3.select("body").datum("data").selectAll("div").data([1, 2, 3])` will be a `string`.
11451145

1146-
In my experience the third and fourth argument are barely of any use of which it can be simplified and set to e.g. `unknown` or `any`. However, one has to fully define a selection if you wanna explicitly define a variable containing a D3 selection,
1146+
In my experience the third and fourth argument are barely of any use of which it can be simplified and set to e.g., `unknown` or `any`. However, one has to fully define a selection if you wanna explicitly define a variable containing a D3 selection,
11471147

11481148
```ts
11491149
import * as d3 from "d3";
@@ -1153,15 +1153,15 @@ let rects: Selection<SVGRectElement, number, SVGGElement, unknown>;
11531153
rects = d3.select("g").selectAll("rect").data([1, 2, 3]);
11541154
```
11551155

1156-
One can specify the type in more detail by specifing the generic argument of the function. This is useful when the selector is more complex that just the element type. e.g. `d3.select<SVGGElement, unknown>(".chart")`. One also has to specify the generic arguments when using scales that are not just numbers but e.g. a linear scale for generating colors. `d3.scaleLinear<string, number>().domain([0, 1]).range(["white", "black"]);
1156+
One can specify the type in more detail by specifing the generic argument of the function. This is useful when the selector is more complex that just the element type. e.g., `d3.select<SVGGElement, unknown>(".chart")`. One also has to specify the generic arguments when using scales that are not just numbers but e.g., a linear scale for generating colors as `d3.scaleLinear<string, number>().domain([0, 1]).range(["white", "black"]);`.
11571157

11581158
---
11591159

11601160
Barchart final results in TypeScript [barchart07_final_ts.html](examples/barchart07_final_ts.html) [![Open in CodePen][codepen]](https://codepen.io/sgratzl/pen/gObqdEG)
11611161

1162-
## Hints
1162+
### Hints
11631163

1164-
### Axis
1164+
#### Axis
11651165

11661166
The typings declare that an axis `d3.axisLeft`, ... can just be called on a `SVGGElement` thus one has to make sure that the typings are correct of the selection. For example:
11671167

0 commit comments

Comments
 (0)