├── 01 nvd3
├── Readme.md
├── 00 Lines
│ ├── pictures
│ │ ├── 06_pie.png
│ │ ├── 00A_libs.png
│ │ ├── 00C_Main1.png
│ │ ├── 00C_Main2.png
│ │ ├── 00C_Main3.png
│ │ ├── 00B_Series1.png
│ │ ├── 00B_Series2.png
│ │ ├── 00B_Series3.png
│ │ ├── 02_vertical.png
│ │ ├── 03_twolines.png
│ │ ├── 02_Chart_Original.png
│ │ └── 02_Chart_Bar_Padding.png
│ ├── index.html
│ ├── main.js
│ └── data.js
└── 01 BubbleChart
│ ├── data.js
│ ├── index.html
│ ├── main.js
│ └── readme.md
├── 02 d3js-es5
├── Readme.md
├── 06 Pie
│ ├── data.js
│ ├── styles.css
│ ├── index.html
│ └── main.js
├── 04 BarChartRefactor
│ ├── data.js
│ ├── styles.css
│ ├── index.html
│ └── main.js
├── 03 BarChartAxis
│ ├── styles.css
│ ├── index.html
│ ├── main.js
│ └── readme.md
├── 00 SVG
│ ├── styles.css
│ ├── index.html
│ └── readme.md
├── 05 Lines
│ ├── styles.css
│ ├── data.js
│ ├── index.html
│ └── main.js
└── 02 BarChart
│ ├── index.html
│ ├── main.js
│ └── readme.md
├── 00 basics
├── .gitignore
├── 04 SVG
│ ├── styles.css
│ ├── index.html
│ └── readme.md
├── 05 SVG 2
│ ├── styles.css
│ ├── index.html
│ └── readme.md
├── 00 HTML
│ ├── index.html
│ └── readme.md
├── 02 DOM
│ ├── styles.css
│ ├── main.js
│ ├── index.html
│ └── readme.md
├── 03 DOM 2
│ ├── src
│ │ ├── styles.css
│ │ └── index.ts
│ ├── package.json
│ ├── index.html
│ └── readme.md
└── 01 CSS
│ ├── index.html
│ ├── styles.css
│ └── readme.md
├── readme.md
├── 03 d3js-typescript
├── 01 Lines
│ ├── .prettierrc
│ ├── src
│ │ ├── app.ts
│ │ ├── index.html
│ │ ├── d3
│ │ │ ├── title.d3.ts
│ │ │ ├── linechart.data.ts
│ │ │ └── linechart.d3.ts
│ │ └── app.scss
│ ├── .gitignore
│ ├── .babelrc
│ ├── tsconfig.json
│ ├── webpack.prod.js
│ ├── webpack.dev.js
│ ├── package.json
│ ├── webpack.config.js
│ └── tslint.json
├── 02 Bars
│ ├── .prettierrc
│ ├── src
│ │ ├── app.ts
│ │ ├── index.html
│ │ ├── d3
│ │ │ ├── title.d3.ts
│ │ │ ├── barchart.data.ts
│ │ │ └── barchart.d3.ts
│ │ └── app.scss
│ ├── .gitignore
│ ├── .babelrc
│ ├── tsconfig.json
│ ├── webpack.prod.js
│ ├── webpack.dev.js
│ ├── package.json
│ ├── webpack.config.js
│ ├── tslint.json
│ └── Readme.md
├── 00 Playground
│ ├── .prettierrc
│ ├── src
│ │ ├── app.ts
│ │ ├── index.html
│ │ ├── d3
│ │ │ └── title.d3.ts
│ │ └── app.scss
│ ├── .gitignore
│ ├── .babelrc
│ ├── tsconfig.json
│ ├── webpack.prod.js
│ ├── webpack.dev.js
│ ├── package.json
│ ├── tslint.json
│ └── webpack.config.js
├── 991 Basic Map
│ ├── .prettierrc
│ ├── src
│ │ ├── app.ts
│ │ ├── index.html
│ │ ├── d3
│ │ │ ├── title.d3.ts
│ │ │ ├── world-mercator.d3.ts
│ │ │ └── world-platee-carre.d3.ts
│ │ └── app.scss
│ ├── .gitignore
│ ├── .babelrc
│ ├── tsconfig.json
│ ├── webpack.prod.js
│ ├── webpack.dev.js
│ ├── package.json
│ ├── tslint.json
│ └── webpack.config.js
├── 993 Spain Cloropleth
│ ├── src
│ │ ├── d3
│ │ │ ├── styles.scss
│ │ │ ├── title.d3.ts
│ │ │ ├── effects.d3.ts
│ │ │ └── spain.d3.ts
│ │ ├── app.ts
│ │ ├── index.html
│ │ └── app.scss
│ ├── .prettierrc
│ ├── .babelrc
│ ├── .gitignore
│ ├── tsconfig.json
│ ├── webpack.prod.js
│ ├── webpack.dev.js
│ ├── package.json
│ ├── tslint.json
│ └── webpack.config.js
├── 992 Map Interaction
│ ├── .prettierrc
│ ├── src
│ │ ├── app.ts
│ │ ├── index.html
│ │ ├── d3
│ │ │ ├── title.d3.ts
│ │ │ └── countries.d3.ts
│ │ ├── app.scss
│ │ └── data
│ │ │ └── population.tsv
│ ├── .babelrc
│ ├── .gitignore
│ ├── tsconfig.json
│ ├── webpack.prod.js
│ ├── webpack.dev.js
│ ├── package.json
│ ├── tslint.json
│ └── webpack.config.js
└── 994 World Population
│ ├── .prettierrc
│ ├── src
│ ├── app.ts
│ ├── index.html
│ ├── d3
│ │ ├── title.d3.ts
│ │ ├── net-population.d3.ts
│ │ └── birth-rate.d3.ts
│ └── app.scss
│ ├── .babelrc
│ ├── .gitignore
│ ├── tsconfig.json
│ ├── webpack.prod.js
│ ├── webpack.dev.js
│ ├── package.json
│ ├── tslint.json
│ └── webpack.config.js
├── .gitignore
└── LICENSE
/01 nvd3/Readme.md:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/02 d3js-es5/Readme.md:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/00 basics/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .cache
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # D3.js From Scratch
2 |
3 | D3.js course from scratch, based on examples. Designed for UMA Big Data Master classes.
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "trailingComma": "es5",
4 | "singleQuote": false
5 | }
6 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "trailingComma": "es5",
4 | "singleQuote": false
5 | }
6 |
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/06_pie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/06_pie.png
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "trailingComma": "es5",
4 | "singleQuote": false
5 | }
6 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "trailingComma": "es5",
4 | "singleQuote": false
5 | }
6 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/src/d3/styles.scss:
--------------------------------------------------------------------------------
1 | .with-shadow {
2 | filter: drop-shadow(12px 12px 7px rbga(0,0,0,0.5))
3 | }
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/00A_libs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/00A_libs.png
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/00C_Main1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/00C_Main1.png
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/00C_Main2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/00C_Main2.png
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/00C_Main3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/00C_Main3.png
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/src/app.ts:
--------------------------------------------------------------------------------
1 | import "./app.scss";
2 |
3 | // Import here your D3 visualizations.
4 | import "./d3/linechart.d3";
5 |
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/00B_Series1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/00B_Series1.png
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/00B_Series2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/00B_Series2.png
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/00B_Series3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/00B_Series3.png
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/02_vertical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/02_vertical.png
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/03_twolines.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/03_twolines.png
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/src/app.ts:
--------------------------------------------------------------------------------
1 | import "./app.scss";
2 |
3 | // Import here your D3 visualizations.
4 | import "./d3/title.d3";
5 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "trailingComma": "es5",
4 | "singleQuote": false
5 | }
6 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "trailingComma": "es5",
4 | "singleQuote": false
5 | }
6 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "trailingComma": "es5",
4 | "singleQuote": false
5 | }
6 |
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/02_Chart_Original.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/02_Chart_Original.png
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/pictures/02_Chart_Bar_Padding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lemoncode/d3js-from-scratch/master/01 nvd3/00 Lines/pictures/02_Chart_Bar_Padding.png
--------------------------------------------------------------------------------
/02 d3js-es5/06 Pie/data.js:
--------------------------------------------------------------------------------
1 | var totalSales = [
2 | { product: 'Hoodie', sales: 7 },
3 | { product: 'Jacket', sales: 6 },
4 | { product: 'Snuggie', sales: 9 },
5 | ];
6 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/src/app.ts:
--------------------------------------------------------------------------------
1 | import "./app.scss";
2 |
3 | // Import here your D3 visualizations.
4 | import "./d3/title.d3";
5 | import "./d3/barchart.d3";
6 |
--------------------------------------------------------------------------------
/02 d3js-es5/04 BarChartRefactor/data.js:
--------------------------------------------------------------------------------
1 | var totalSales = [
2 | { product: 'Hoodie', sales: 7 },
3 | { product: 'Jacket', sales: 6 },
4 | { product: 'Snuggie', sales: 9 },
5 | ];
6 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/src/app.ts:
--------------------------------------------------------------------------------
1 | import "./app.scss";
2 |
3 | // Import here your D3 visualizations.
4 | import "./d3/title.d3";
5 | import "./d3/countries.d3";
6 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/src/app.ts:
--------------------------------------------------------------------------------
1 | import "./app.scss";
2 |
3 | // Import here your D3 visualizations.
4 | import "./d3/title.d3";
5 | import "./d3/spain.d3";
6 |
--------------------------------------------------------------------------------
/02 d3js-es5/06 Pie/styles.css:
--------------------------------------------------------------------------------
1 | .axis text {
2 | font: 10px sans-serif;
3 | }
4 |
5 | .axis path,
6 | .axis line {
7 | fill: none;
8 | stroke: #000;
9 | shape-rendering: crispEdges;
10 | }
11 |
--------------------------------------------------------------------------------
/02 d3js-es5/03 BarChartAxis/styles.css:
--------------------------------------------------------------------------------
1 | .axis text {
2 | font: 10px sans-serif;
3 | }
4 |
5 | .axis path,
6 | .axis line {
7 | fill: none;
8 | stroke: #000;
9 | shape-rendering: crispEdges;
10 | }
11 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/src/app.ts:
--------------------------------------------------------------------------------
1 | import "./app.scss";
2 |
3 | // Import here your D3 visualizations.
4 | import "./d3/title.d3";
5 | // import "./d3/world.d3";
6 | import "./d3/birth-rate.d3";
7 |
--------------------------------------------------------------------------------
/02 d3js-es5/04 BarChartRefactor/styles.css:
--------------------------------------------------------------------------------
1 | .axis text {
2 | font: 10px sans-serif;
3 | }
4 |
5 | .axis path,
6 | .axis line {
7 | fill: none;
8 | stroke: #000;
9 | shape-rendering: crispEdges;
10 | }
11 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/src/app.ts:
--------------------------------------------------------------------------------
1 | import "./app.scss";
2 |
3 | // Import here your D3 visualizations.
4 | import "./d3/title.d3";
5 | import "./d3/world-mercator.d3";
6 | import "./d3/world-platee-carre.d3";
7 |
--------------------------------------------------------------------------------
/00 basics/04 SVG/styles.css:
--------------------------------------------------------------------------------
1 | .red {
2 | fill: red; /* not background-color! */
3 | }
4 |
5 | .fancy {
6 | fill: none;
7 | stroke: black; /* similar to border-color */
8 | stroke-width: 3pt; /* similar to border-width */
9 | stroke-dasharray: 3,5,10;
10 | }
11 |
--------------------------------------------------------------------------------
/00 basics/05 SVG 2/styles.css:
--------------------------------------------------------------------------------
1 | .red {
2 | fill: red; /* not background-color! */
3 | }
4 |
5 | .fancy {
6 | fill: none;
7 | stroke: black; /* similar to border-color */
8 | stroke-width: 3pt; /* similar to border-width */
9 | stroke-dasharray: 3,5,10;
10 | }
11 |
--------------------------------------------------------------------------------
/02 d3js-es5/00 SVG/styles.css:
--------------------------------------------------------------------------------
1 | .red {
2 | fill: red; /* not background-color! */
3 | }
4 |
5 | .fancy {
6 | fill: none;
7 | stroke: black; /* similar to border-color */
8 | stroke-width: 3pt; /* similar to border-width */
9 | stroke-dasharray: 3,5,10;
10 | }
11 |
--------------------------------------------------------------------------------
/02 d3js-es5/05 Lines/styles.css:
--------------------------------------------------------------------------------
1 | .axis text {
2 | font: 10px sans-serif;
3 | }
4 |
5 | .axis path,
6 | .axis line {
7 | fill: none;
8 | stroke: #000;
9 | shape-rendering: crispEdges;
10 | }
11 |
12 | .line {
13 | fill: none;
14 | stroke: steelblue;
15 | stroke-width: 2px;
16 | }
17 |
--------------------------------------------------------------------------------
/02 d3js-es5/05 Lines/data.js:
--------------------------------------------------------------------------------
1 |
2 | var totalSales = [
3 | { month: new Date(2016,10, 01), sales: 6500 },
4 | { month: new Date(2016,11, 01), sales: 5400 },
5 | { month: new Date(2016,12, 01), sales: 3500 },
6 | { month: new Date(2017,1, 01), sales: 9000 },
7 | { month: new Date(2017,2, 01), sales: 8500 },
8 | ];
9 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | D3.js Playground
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | D3.js Playground
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | D3.js Playground
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | D3.js Playground
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | D3.js Playground
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | D3.js Playground
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | D3.js Playground
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/src/d3/title.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 |
3 | // Lets add a card in our root node.
4 | const card = select("#root")
5 | .append("div")
6 | .attr("class", "card");
7 |
8 | // This card will contain a title for our visualization.
9 | card
10 | .append("h1")
11 | .text("Basic Map with D3.js");
12 |
13 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/src/d3/title.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 |
3 | // Lets add a card in our root node.
4 | const card = select("#root")
5 | .append("div")
6 | .attr("class", "card");
7 |
8 | // This card will contain a title for our visualization.
9 | card
10 | .append("h1")
11 | .text("Basic Map with D3.js");
12 |
13 |
--------------------------------------------------------------------------------
/00 basics/00 HTML/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | TITLE GOES HERE
6 |
7 |
8 |
9 | MAIN CONTENT GOES HERE
10 |
11 |
12 |
13 | HTML Basics tutorial
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/src/d3/title.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 |
3 | // Lets add a card in our root node.
4 | const card = select("#root")
5 | .append("div")
6 | .attr("class", "card");
7 |
8 | // This card will contain a title for our visualization.
9 | card
10 | .append("h1")
11 | .text("Basic Map with D3.js");
12 |
13 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/src/d3/title.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 |
3 | // Lets add a card in our root node.
4 | const card = select("#root")
5 | .append("div")
6 | .attr("class", "card");
7 |
8 | // This card will contain a title for our visualization.
9 | card
10 | .append("h1")
11 | .text("Basic Map with D3.js");
12 |
13 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/.gitignore:
--------------------------------------------------------------------------------
1 | # Common aux folders
2 | .awcache/
3 | .vscode/
4 | .idea/
5 |
6 | # Dependencies & Build
7 | node_modules/
8 | dist/
9 |
10 | # Aux files
11 | *.log
12 | */src/**/*.orig
13 | */src/**/*.js.map
14 |
15 | # Win
16 | desktop.ini
17 |
18 | # MacOs
19 | .DS_Store
20 |
21 | # Yarn
22 | yarn.lock
23 |
24 | # NPM
25 | package-lock.json
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/.gitignore:
--------------------------------------------------------------------------------
1 | # Common aux folders
2 | .awcache/
3 | .vscode/
4 | .idea/
5 |
6 | # Dependencies & Build
7 | node_modules/
8 | dist/
9 |
10 | # Aux files
11 | *.log
12 | */src/**/*.orig
13 | */src/**/*.js.map
14 |
15 | # Win
16 | desktop.ini
17 |
18 | # MacOs
19 | .DS_Store
20 |
21 | # Yarn
22 | yarn.lock
23 |
24 | # NPM
25 | package-lock.json
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/.gitignore:
--------------------------------------------------------------------------------
1 | # Common aux folders
2 | .awcache/
3 | .vscode/
4 | .idea/
5 |
6 | # Dependencies & Build
7 | node_modules/
8 | dist/
9 |
10 | # Aux files
11 | *.log
12 | */src/**/*.orig
13 | */src/**/*.js.map
14 |
15 | # Win
16 | desktop.ini
17 |
18 | # MacOs
19 | .DS_Store
20 |
21 | # Yarn
22 | yarn.lock
23 |
24 | # NPM
25 | package-lock.json
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false,
7 | "useBuiltIns": "usage"
8 | }
9 | ],
10 | "@babel/preset-typescript"
11 | ],
12 | "plugins": [
13 | "@babel/proposal-class-properties",
14 | "@babel/proposal-object-rest-spread"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false,
7 | "useBuiltIns": "usage"
8 | }
9 | ],
10 | "@babel/preset-typescript"
11 | ],
12 | "plugins": [
13 | "@babel/proposal-class-properties",
14 | "@babel/proposal-object-rest-spread"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/.gitignore:
--------------------------------------------------------------------------------
1 | # Common aux folders
2 | .awcache/
3 | .vscode/
4 | .idea/
5 |
6 | # Dependencies & Build
7 | node_modules/
8 | dist/
9 |
10 | # Aux files
11 | *.log
12 | */src/**/*.orig
13 | */src/**/*.js.map
14 |
15 | # Win
16 | desktop.ini
17 |
18 | # MacOs
19 | .DS_Store
20 |
21 | # Yarn
22 | yarn.lock
23 |
24 | # NPM
25 | package-lock.json
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Common aux folders
2 | .awcache/
3 | .vscode/
4 | .idea/
5 |
6 | # Dependencies & Build
7 | */**/node_modules/
8 | */**/dist/
9 |
10 | # Aux files
11 | */**/*.log
12 | */src/**/*.orig
13 | */src/**/*.js.map
14 |
15 | # Win
16 | */**/desktop.ini
17 |
18 | # MacOs
19 | */**.DS_Store
20 |
21 | # Yarn
22 | */**/yarn.lock
23 |
24 | # NPM
25 | */**/package-lock.json
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false,
7 | "useBuiltIns": "usage"
8 | }
9 | ],
10 | "@babel/preset-typescript"
11 | ],
12 | "plugins": [
13 | "@babel/proposal-class-properties",
14 | "@babel/proposal-object-rest-spread"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false,
7 | "useBuiltIns": "usage"
8 | }
9 | ],
10 | "@babel/preset-typescript"
11 | ],
12 | "plugins": [
13 | "@babel/proposal-class-properties",
14 | "@babel/proposal-object-rest-spread"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/src/d3/title.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 |
3 | // Lets add a card in our root node.
4 | const card = select("#root")
5 | .append("div")
6 | .attr("class", "card");
7 |
8 | // This card will contain a title for our visualization.
9 | card
10 | .append("h1")
11 | .text("Map Interaction with D3.js");
12 |
13 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/src/d3/title.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 |
3 | // Lets add a card in our root node.
4 | const card = select("#root")
5 | .append("div")
6 | .attr("class", "card");
7 |
8 | // This card will contain a title for our visualization.
9 | card
10 | .append("h1")
11 | .text("Spain Cloropleth with D3.js");
12 |
13 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/src/d3/title.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 |
3 | // Lets add a card in our root node.
4 | const card = select("#root")
5 | .append("div")
6 | .attr("class", "card");
7 |
8 | // This card will contain a title for our visualization.
9 | card
10 | .append("h1")
11 | .text("World Population with D3.js");
12 |
13 |
--------------------------------------------------------------------------------
/02 d3js-es5/02 BarChart/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false,
7 | "useBuiltIns": "usage"
8 | }
9 | ],
10 | "@babel/preset-typescript"
11 | ],
12 | "plugins": [
13 | "@babel/proposal-class-properties",
14 | "@babel/proposal-object-rest-spread"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/.gitignore:
--------------------------------------------------------------------------------
1 | # Common aux folders
2 | .awcache/
3 | .vscode/
4 | .idea/
5 |
6 | # Dependencies & Build
7 | node_modules/
8 | dist/
9 |
10 | # Aux files
11 | *.log
12 | */src/**/*.orig
13 | */src/**/*.js.map
14 |
15 | # Win
16 | desktop.ini
17 |
18 | # MacOs
19 | .DS_Store
20 |
21 | # Yarn
22 | yarn.lock
23 |
24 | # NPM
25 | package-lock.json
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false,
7 | "useBuiltIns": "usage"
8 | }
9 | ],
10 | "@babel/preset-typescript"
11 | ],
12 | "plugins": [
13 | "@babel/proposal-class-properties",
14 | "@babel/proposal-object-rest-spread"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/.gitignore:
--------------------------------------------------------------------------------
1 | # Common aux folders
2 | .awcache/
3 | .vscode/
4 | .idea/
5 |
6 | # Dependencies & Build
7 | node_modules/
8 | dist/
9 |
10 | # Aux files
11 | *.log
12 | */src/**/*.orig
13 | */src/**/*.js.map
14 |
15 | # Win
16 | desktop.ini
17 |
18 | # MacOs
19 | .DS_Store
20 |
21 | # Yarn
22 | yarn.lock
23 |
24 | # NPM
25 | package-lock.json
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false,
7 | "useBuiltIns": "usage"
8 | }
9 | ],
10 | "@babel/preset-typescript"
11 | ],
12 | "plugins": [
13 | "@babel/proposal-class-properties",
14 | "@babel/proposal-object-rest-spread"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/.gitignore:
--------------------------------------------------------------------------------
1 | # Common aux folders
2 | .awcache/
3 | .vscode/
4 | .idea/
5 |
6 | # Dependencies & Build
7 | node_modules/
8 | dist/
9 |
10 | # Aux files
11 | *.log
12 | */src/**/*.orig
13 | */src/**/*.js.map
14 |
15 | # Win
16 | desktop.ini
17 |
18 | # MacOs
19 | .DS_Store
20 |
21 | # Yarn
22 | yarn.lock
23 |
24 | # NPM
25 | package-lock.json
--------------------------------------------------------------------------------
/02 d3js-es5/03 BarChartAxis/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/00 basics/02 DOM/styles.css:
--------------------------------------------------------------------------------
1 | /* Applied to all tags */
2 | p {
3 | color: blue;
4 | }
5 |
6 | /* Applied to all tags with the class "red" */
7 | .red {
8 | background: red;
9 | }
10 |
11 | /* Applied to the tag with the id "some-id" */
12 | #some-id {
13 | font-style: italic;
14 | }
15 |
16 | /* Applied only to
tags that are inside
tags */
17 | li p {
18 | color: #0C0;
19 | }
20 |
--------------------------------------------------------------------------------
/00 basics/03 DOM 2/src/styles.css:
--------------------------------------------------------------------------------
1 | /* Applied to all tags */
2 | p {
3 | color: blue;
4 | }
5 |
6 | /* Applied to all tags with the class "red" */
7 | .red {
8 | background: red;
9 | }
10 |
11 | /* Applied to the tag with the id "some-id" */
12 | #some-id {
13 | font-style: italic;
14 | }
15 |
16 | /* Applied only to
tags that are inside
tags */
17 | li p {
18 | color: #0c0;
19 | }
20 |
--------------------------------------------------------------------------------
/02 d3js-es5/05 Lines/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/02 d3js-es5/06 Pie/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/02 d3js-es5/04 BarChartRefactor/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "es6",
5 | "moduleResolution": "node",
6 | "declaration": false,
7 | "noImplicitAny": false,
8 | "sourceMap": true,
9 | "jsx": "react",
10 | "noLib": false,
11 | "suppressImplicitAnyIndexErrors": true
12 | },
13 | "compileOnSave": false,
14 | "exclude": [
15 | "node_modules"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "es6",
5 | "moduleResolution": "node",
6 | "declaration": false,
7 | "noImplicitAny": false,
8 | "sourceMap": true,
9 | "jsx": "react",
10 | "noLib": false,
11 | "suppressImplicitAnyIndexErrors": true
12 | },
13 | "compileOnSave": false,
14 | "exclude": [
15 | "node_modules"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "es6",
5 | "moduleResolution": "node",
6 | "declaration": false,
7 | "noImplicitAny": false,
8 | "sourceMap": true,
9 | "jsx": "react",
10 | "noLib": false,
11 | "suppressImplicitAnyIndexErrors": true
12 | },
13 | "compileOnSave": false,
14 | "exclude": [
15 | "node_modules"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "es6",
5 | "moduleResolution": "node",
6 | "declaration": false,
7 | "noImplicitAny": false,
8 | "sourceMap": true,
9 | "jsx": "react",
10 | "noLib": false,
11 | "suppressImplicitAnyIndexErrors": true
12 | },
13 | "compileOnSave": false,
14 | "exclude": [
15 | "node_modules"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "es6",
5 | "moduleResolution": "node",
6 | "declaration": false,
7 | "noImplicitAny": false,
8 | "sourceMap": true,
9 | "jsx": "react",
10 | "noLib": false,
11 | "suppressImplicitAnyIndexErrors": true
12 | },
13 | "compileOnSave": false,
14 | "exclude": [
15 | "node_modules"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "es6",
5 | "moduleResolution": "node",
6 | "declaration": false,
7 | "noImplicitAny": false,
8 | "sourceMap": true,
9 | "jsx": "react",
10 | "noLib": false,
11 | "suppressImplicitAnyIndexErrors": true
12 | },
13 | "compileOnSave": false,
14 | "exclude": [
15 | "node_modules"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "es6",
5 | "moduleResolution": "node",
6 | "declaration": false,
7 | "noImplicitAny": false,
8 | "sourceMap": true,
9 | "jsx": "react",
10 | "noLib": false,
11 | "suppressImplicitAnyIndexErrors": true,
12 | "allowSyntheticDefaultImports": true
13 | },
14 | "compileOnSave": false,
15 | "exclude": [
16 | "node_modules"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/00 basics/03 DOM 2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test",
3 | "version": "1.0.0",
4 | "description": "Let's play now with events and javascript.",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "parcel index.html --open",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "devDependencies": {
13 | "@types/d3": "^5.7.2",
14 | "parcel": "^1.12.4"
15 | },
16 | "dependencies": {
17 | "d3": "^5.15.0",
18 | "typescript": "^3.8.3"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/00 basics/01 CSS/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Normal paragraph
11 |
12 |
Red paragraph
13 |
14 |
15 |
16 | - Unique element
17 | - Another list element
18 | -
19 |
Paragraph inside list element
20 | Second paragraph
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/00 basics/05 SVG 2/index.html:
--------------------------------------------------------------------------------
1 |
20 |
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/webpack.prod.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5 |
6 | module.exports = merge(base, {
7 | mode: "production",
8 | devtool: "none",
9 | output: {
10 | filename: "[name].js",
11 | },
12 | plugins: [
13 | new BundleAnalyzerPlugin({
14 | analyzerMode: "static",
15 | openAnalyzer: false,
16 | reportFilename: "report/report.html",
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/webpack.prod.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5 |
6 | module.exports = merge(base, {
7 | mode: "production",
8 | devtool: "none",
9 | output: {
10 | filename: "[name].js",
11 | },
12 | plugins: [
13 | new BundleAnalyzerPlugin({
14 | analyzerMode: "static",
15 | openAnalyzer: false,
16 | reportFilename: "report/report.html",
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/webpack.prod.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5 |
6 | module.exports = merge(base, {
7 | mode: "production",
8 | devtool: "none",
9 | output: {
10 | filename: "[name].js",
11 | },
12 | plugins: [
13 | new BundleAnalyzerPlugin({
14 | analyzerMode: "static",
15 | openAnalyzer: false,
16 | reportFilename: "report/report.html",
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/webpack.prod.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5 |
6 | module.exports = merge(base, {
7 | mode: "production",
8 | devtool: "none",
9 | output: {
10 | filename: "[name].js",
11 | },
12 | plugins: [
13 | new BundleAnalyzerPlugin({
14 | analyzerMode: "static",
15 | openAnalyzer: false,
16 | reportFilename: "report/report.html",
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/webpack.prod.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5 |
6 | module.exports = merge(base, {
7 | mode: "production",
8 | devtool: "none",
9 | output: {
10 | filename: "[name].js",
11 | },
12 | plugins: [
13 | new BundleAnalyzerPlugin({
14 | analyzerMode: "static",
15 | openAnalyzer: false,
16 | reportFilename: "report/report.html",
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/webpack.prod.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5 |
6 | module.exports = merge(base, {
7 | mode: "production",
8 | devtool: "none",
9 | output: {
10 | filename: "[name].js",
11 | },
12 | plugins: [
13 | new BundleAnalyzerPlugin({
14 | analyzerMode: "static",
15 | openAnalyzer: false,
16 | reportFilename: "report/report.html",
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/webpack.prod.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5 |
6 | module.exports = merge(base, {
7 | mode: "production",
8 | devtool: "none",
9 | output: {
10 | filename: "[name].js",
11 | },
12 | plugins: [
13 | new BundleAnalyzerPlugin({
14 | analyzerMode: "static",
15 | openAnalyzer: false,
16 | reportFilename: "report/report.html",
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/00 basics/02 DOM/main.js:
--------------------------------------------------------------------------------
1 | // DOM API
2 | var element = document.getElementById('some-id');
3 | // Unique element
4 | var plenght = document.getElementsByTagName('p').length;
5 | // 4
6 | var reds = document.getElementsByClassName('red');
7 | // [Red paragraph
]
8 | console.log(reds[0].innerText);
9 | // "Red paragraph"
10 |
11 | // D3 Selection API
12 | var one = d3.select('p').size(); // select() only finds one
13 | // 1
14 | var many = d3.selectAll('p').size(); // selectAll() finds all
15 | // 4
16 | var reds = d3.selectAll('.red');
17 | // [ > Array[1] ]
18 | console.log(reds.text());
19 | // "Red paragraph"
20 |
--------------------------------------------------------------------------------
/00 basics/03 DOM 2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Normal paragraph
11 |
12 |
Red paragraph
13 |
14 |
15 |
16 | - Unique element
17 | - Another list element
18 | -
19 |
Paragraph inside list element
20 | Second paragraph
21 |
22 |
23 |
24 | Click on me!
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/00 basics/04 SVG/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/00 basics/02 DOM/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Normal paragraph
11 |
12 |
Red paragraph
13 |
14 |
15 |
16 | - Unique element
17 | - Another list element
18 | -
19 |
Paragraph inside list element
20 | Second paragraph
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/webpack.dev.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const path = require("path");
5 |
6 | const basePath = __dirname;
7 |
8 | module.exports = merge(base, {
9 | mode: "development",
10 | devtool: "eval-source-map",
11 | output: {
12 | filename: "[name].[hash].js",
13 | },
14 | devServer: {
15 | contentBase: path.join(basePath, "dist"),
16 | inline: true,
17 | host: "localhost",
18 | port: 4301,
19 | historyApiFallback: true,
20 | hot: true,
21 | stats: "minimal"
22 | },
23 | plugins: [
24 | new webpack.HotModuleReplacementPlugin(),
25 | new webpack.NamedModulesPlugin()
26 | ],
27 | });
28 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/webpack.dev.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const path = require("path");
5 |
6 | const basePath = __dirname;
7 |
8 | module.exports = merge(base, {
9 | mode: "development",
10 | devtool: "eval-source-map",
11 | output: {
12 | filename: "[name].[hash].js",
13 | },
14 | devServer: {
15 | contentBase: path.join(basePath, "dist"),
16 | inline: true,
17 | host: "localhost",
18 | port: 4301,
19 | historyApiFallback: true,
20 | hot: true,
21 | stats: "minimal"
22 | },
23 | plugins: [
24 | new webpack.HotModuleReplacementPlugin(),
25 | new webpack.NamedModulesPlugin()
26 | ],
27 | });
28 |
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/webpack.dev.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const path = require("path");
5 |
6 | const basePath = __dirname;
7 |
8 | module.exports = merge(base, {
9 | mode: "development",
10 | devtool: "eval-source-map",
11 | output: {
12 | filename: "[name].[hash].js",
13 | },
14 | devServer: {
15 | contentBase: path.join(basePath, "dist"),
16 | inline: true,
17 | host: "localhost",
18 | port: 4301,
19 | historyApiFallback: true,
20 | hot: true,
21 | stats: "minimal"
22 | },
23 | plugins: [
24 | new webpack.HotModuleReplacementPlugin(),
25 | new webpack.NamedModulesPlugin()
26 | ],
27 | });
28 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/webpack.dev.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const path = require("path");
5 |
6 | const basePath = __dirname;
7 |
8 | module.exports = merge(base, {
9 | mode: "development",
10 | devtool: "eval-source-map",
11 | output: {
12 | filename: "[name].[hash].js",
13 | },
14 | devServer: {
15 | contentBase: path.join(basePath, "dist"),
16 | inline: true,
17 | host: "localhost",
18 | port: 4301,
19 | historyApiFallback: true,
20 | hot: true,
21 | stats: "minimal"
22 | },
23 | plugins: [
24 | new webpack.HotModuleReplacementPlugin(),
25 | new webpack.NamedModulesPlugin()
26 | ],
27 | });
28 |
--------------------------------------------------------------------------------
/01 nvd3/01 BubbleChart/data.js:
--------------------------------------------------------------------------------
1 | function randomData(groups, points) { //# groups,# points per group
2 | // smiley and thin-x are our custom symbols!
3 | var data = [],
4 | shapes = ['thin-x', 'circle', 'cross', 'triangle-up', 'triangle-down', 'diamond', 'square'],
5 | random = d3.random.normal();
6 |
7 | for (i = 0; i < groups; i++) {
8 | data.push({
9 | key: 'Group ' + i,
10 | values: []
11 | });
12 |
13 | for (j = 0; j < points; j++) {
14 | data[i].values.push({
15 | x: random(),
16 | y: random(),
17 | size: Math.round(Math.random() * 100) / 100,
18 | shape: shapes[j % shapes.length]
19 | });
20 | }
21 | }
22 |
23 | return data;
24 | }
25 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/webpack.dev.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const path = require("path");
5 |
6 | const basePath = __dirname;
7 |
8 | module.exports = merge(base, {
9 | mode: "development",
10 | devtool: "eval-source-map",
11 | output: {
12 | filename: "[name].[hash].js",
13 | },
14 | devServer: {
15 | contentBase: path.join(basePath, "dist"),
16 | inline: true,
17 | host: "localhost",
18 | port: 4302,
19 | historyApiFallback: true,
20 | hot: true,
21 | stats: "minimal"
22 | },
23 | plugins: [
24 | new webpack.HotModuleReplacementPlugin(),
25 | new webpack.NamedModulesPlugin()
26 | ],
27 | });
28 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/webpack.dev.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const path = require("path");
5 |
6 | const basePath = __dirname;
7 |
8 | module.exports = merge(base, {
9 | mode: "development",
10 | devtool: "eval-source-map",
11 | output: {
12 | filename: "[name].[hash].js",
13 | },
14 | devServer: {
15 | contentBase: path.join(basePath, "dist"),
16 | inline: true,
17 | host: "localhost",
18 | port: 4303,
19 | historyApiFallback: true,
20 | hot: true,
21 | stats: "minimal"
22 | },
23 | plugins: [
24 | new webpack.HotModuleReplacementPlugin(),
25 | new webpack.NamedModulesPlugin()
26 | ],
27 | });
28 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/webpack.dev.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const merge = require("webpack-merge");
3 | const base = require("./webpack.config.js");
4 | const path = require("path");
5 |
6 | const basePath = __dirname;
7 |
8 | module.exports = merge(base, {
9 | mode: "development",
10 | devtool: "eval-source-map",
11 | output: {
12 | filename: "[name].[hash].js",
13 | },
14 | devServer: {
15 | contentBase: path.join(basePath, "dist"),
16 | inline: true,
17 | host: "localhost",
18 | port: 4304,
19 | historyApiFallback: true,
20 | hot: true,
21 | stats: "minimal"
22 | },
23 | plugins: [
24 | new webpack.HotModuleReplacementPlugin(),
25 | new webpack.NamedModulesPlugin()
26 | ],
27 | });
28 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/src/app.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700');
2 |
3 | :global{
4 | body {
5 | font-family: 'Montserrat', sans-serif;
6 | font-weight: 300;
7 | display: flex;
8 | flex-direction: column;
9 | justify-content: flex-start;
10 | align-items: stretch;
11 | margin: 0;
12 | padding: 2rem;
13 | background-color: #e2e1e0;
14 | }
15 |
16 | .card {
17 | display: flex;
18 | flex-direction: column;
19 | justify-content: flex-start;
20 | align-items: center;
21 | min-height: 5rem;
22 | padding: 1rem;
23 | margin-bottom: 2rem;
24 | background-color: #fff;
25 | border-radius: 2px;
26 | box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/src/app.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700');
2 |
3 | :global{
4 | body {
5 | font-family: 'Montserrat', sans-serif;
6 | font-weight: 300;
7 | display: flex;
8 | flex-direction: column;
9 | justify-content: flex-start;
10 | align-items: stretch;
11 | margin: 0;
12 | padding: 2rem;
13 | background-color: #e2e1e0;
14 | }
15 |
16 | .card {
17 | display: flex;
18 | flex-direction: column;
19 | justify-content: flex-start;
20 | align-items: center;
21 | min-height: 5rem;
22 | padding: 1rem;
23 | margin-bottom: 2rem;
24 | background-color: #fff;
25 | border-radius: 2px;
26 | box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/src/app.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700');
2 |
3 | :global{
4 | body {
5 | font-family: 'Montserrat', sans-serif;
6 | font-weight: 300;
7 | display: flex;
8 | flex-direction: column;
9 | justify-content: flex-start;
10 | align-items: stretch;
11 | margin: 0;
12 | padding: 2rem;
13 | background-color: #e2e1e0;
14 | }
15 |
16 | .card {
17 | display: flex;
18 | flex-direction: column;
19 | justify-content: flex-start;
20 | align-items: center;
21 | min-height: 5rem;
22 | padding: 1rem;
23 | margin-bottom: 2rem;
24 | background-color: #fff;
25 | border-radius: 2px;
26 | box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/src/app.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700');
2 |
3 | :global{
4 | body {
5 | font-family: 'Montserrat', sans-serif;
6 | font-weight: 300;
7 | display: flex;
8 | flex-direction: column;
9 | justify-content: flex-start;
10 | align-items: stretch;
11 | margin: 0;
12 | padding: 2rem;
13 | background-color: #e2e1e0;
14 | }
15 |
16 | .card {
17 | display: flex;
18 | flex-direction: column;
19 | justify-content: flex-start;
20 | align-items: center;
21 | min-height: 5rem;
22 | padding: 1rem;
23 | margin-bottom: 2rem;
24 | background-color: #fff;
25 | border-radius: 2px;
26 | box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/src/app.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700');
2 |
3 | :global{
4 | body {
5 | font-family: 'Montserrat', sans-serif;
6 | font-weight: 300;
7 | display: flex;
8 | flex-direction: column;
9 | justify-content: flex-start;
10 | align-items: stretch;
11 | margin: 0;
12 | padding: 2rem;
13 | background-color: #e2e1e0;
14 | }
15 |
16 | .card {
17 | display: flex;
18 | flex-direction: column;
19 | justify-content: flex-start;
20 | align-items: center;
21 | min-height: 5rem;
22 | padding: 1rem;
23 | margin-bottom: 2rem;
24 | background-color: #fff;
25 | border-radius: 2px;
26 | box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/src/app.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700');
2 |
3 | :global{
4 | body {
5 | font-family: 'Montserrat', sans-serif;
6 | font-weight: 300;
7 | display: flex;
8 | flex-direction: column;
9 | justify-content: flex-start;
10 | align-items: stretch;
11 | margin: 0;
12 | padding: 2rem;
13 | background-color: #e2e1e0;
14 | }
15 |
16 | .card {
17 | display: flex;
18 | flex-direction: column;
19 | justify-content: flex-start;
20 | align-items: center;
21 | min-height: 5rem;
22 | padding: 1rem;
23 | margin-bottom: 2rem;
24 | background-color: #fff;
25 | border-radius: 2px;
26 | box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/src/app.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700');
2 |
3 | :global{
4 | body {
5 | font-family: 'Montserrat', sans-serif;
6 | font-weight: 300;
7 | display: flex;
8 | flex-direction: column;
9 | justify-content: flex-start;
10 | align-items: stretch;
11 | margin: 0;
12 | padding: 2rem;
13 | background-color: #e2e1e0;
14 | }
15 |
16 | .card {
17 | display: flex;
18 | flex-direction: column;
19 | justify-content: flex-start;
20 | align-items: center;
21 | min-height: 5rem;
22 | padding: 1rem;
23 | margin-bottom: 2rem;
24 | background-color: #fff;
25 | border-radius: 2px;
26 | box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/src/d3/linechart.data.ts:
--------------------------------------------------------------------------------
1 | export const avgTemp = [14, 13, 14, 16, 19, 25, 29, 29, 27, 21, 17, 17];
2 | export const minTemp = [11, 10, 11, 13, 16, 21, 24, 25, 23, 17, 14, 14];
3 | export const maxTemp = [17, 16, 17, 19, 23, 27, 31, 31, 28, 23, 19, 19];
4 |
5 | export interface TempStat {
6 | id: string;
7 | name: string;
8 | values: number[];
9 | }
10 |
11 | export const malagaStats: TempStat[] = [
12 | {
13 | id: "avg",
14 | name: "Average Temp",
15 | values: [14, 13, 14, 16, 19, 25, 29, 29, 27, 21, 17, 17],
16 | },
17 | {
18 | id: "min",
19 | name: "Min Temp",
20 | values: [11, 10, 11, 13, 16, 21, 24, 25, 23, 17, 14, 14],
21 | },
22 | {
23 | id: "max",
24 | name: "Max Temp",
25 | values: [17, 16, 17, 19, 23, 27, 31, 31, 28, 23, 19, 19],
26 | }
27 | ];
--------------------------------------------------------------------------------
/01 nvd3/01 BubbleChart/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/src/d3/effects.d3.ts:
--------------------------------------------------------------------------------
1 | export const defineGlowEffect = (defsSelection) => {
2 | const id = "glow"
3 | const stdDeviation = 0.55;
4 | const colorMatrix = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0";
5 |
6 | const filter = defsSelection.append("filter")
7 | .attr("id", id)
8 | .attr("x", "-50%")
9 | .attr("y", "-50%")
10 | .attr("width", "200%")
11 | .attr("height", "200%")
12 | filter.append("feColorMatrix")
13 | .attr("type", "matrix")
14 | .attr("values", colorMatrix);
15 | filter.append("feGaussianBlur")
16 | // .attr("in", "SourceGraphics")
17 | .attr("stdDeviation", stdDeviation)
18 | .attr("result", "coloredBlur");
19 | const feMerge = filter.append("feMerge")
20 | feMerge.append("feMergeNode")
21 | .attr("in", "coloredBlur");
22 | feMerge.append("feMergeNode")
23 | .attr("in", "SourceGraphic");
24 |
25 | return `url(#${id})`;
26 | }
27 |
28 |
29 |
--------------------------------------------------------------------------------
/00 basics/03 DOM 2/src/index.ts:
--------------------------------------------------------------------------------
1 | import * as d3 from "d3";
2 |
3 | // DOM API
4 | var element = document.getElementById("some-id");
5 | // Unique element
6 | console.log(element);
7 |
8 | var plength = document.getElementsByTagName("p").length;
9 | // 4
10 | console.log(plength);
11 |
12 | var reds = document.getElementsByClassName("red");
13 | // [Red paragraph
]
14 | console.log(reds[0].innerHTML);
15 | // "Red paragraph"
16 |
17 | // D3 Selection API
18 | var one = d3.select("p").size(); // select() only finds one
19 | console.log(one);
20 |
21 | // 1
22 | var many = d3.selectAll("p").size(); // selectAll() finds all
23 | console.log(many);
24 |
25 | // 4
26 | var redElements = d3.selectAll(".red");
27 | // [ > Array[1] ]
28 | console.log(redElements.text());
29 | // "Red paragraph"
30 |
31 | var clickMe = document.getElementById("click-me");
32 | clickMe.onclick = function() {
33 | if (this.style.backgroundColor) {
34 | this.style.backgroundColor = "";
35 | } else {
36 | this.style.backgroundColor = "red";
37 | }
38 | };
39 |
--------------------------------------------------------------------------------
/01 nvd3/01 BubbleChart/main.js:
--------------------------------------------------------------------------------
1 | // register our custom symbols to nvd3
2 | // make sure your path is valid given any size because size scales if the chart scales.
3 | nv.utils.symbolMap.set('thin-x', function(size) {
4 | size = Math.sqrt(size);
5 | return 'M' + (-size/2) + ',' + (-size/2) +
6 | 'l' + size + ',' + size +
7 | 'm0,' + -(size) +
8 | 'l' + (-size) + ',' + size;
9 | });
10 |
11 | // create the chart
12 | var chart;
13 | nv.addGraph(function() {
14 | chart = nv.models.scatterChart()
15 | .showDistX(true)
16 | .showDistY(true)
17 | .useVoronoi(true)
18 | .color(d3.scale.category10().range())
19 | .duration(300)
20 | ;
21 |
22 | chart.xAxis.tickFormat(d3.format('.02f'));
23 | chart.yAxis.tickFormat(d3.format('.02f'));
24 |
25 | d3.select('#test1 svg')
26 | .datum(randomData(4,40))
27 | .call(chart);
28 |
29 | nv.utils.windowResize(chart.update);
30 |
31 | return chart;
32 | });
33 |
34 |
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/src/d3/barchart.data.ts:
--------------------------------------------------------------------------------
1 | // Generador de datos aleatorios en formato de array de n posiciones.
2 | const randomArrayGenerator = n => Array.from({length: n}, () => Math.random());
3 |
4 | // Otra forma podría ser Array(n).fill(0).map(n => Math.random());
5 |
6 |
7 | // Singleton inicializado con datos aleatorios. Array de 20 posiciones.
8 | export let randomData = randomArrayGenerator(20);
9 |
10 | // Creamos un mecanismo para modifcar estos datos aleatorios cada segundo.
11 | // Simula una fuente de datos 'real-time'. Permitimos la suscripción de un
12 | // callback para informar a la visualización de que hubo modificaciones.
13 | export const startRealTimeDataV1 = (onDataChange: (newData) => void) => {
14 | setInterval(() => {
15 | randomData = randomArrayGenerator(20);
16 | onDataChange && onDataChange(randomData);
17 | }, 1000);
18 | }
19 |
20 | export const startRealTimeDataV2 = (onDataChange: (data: any[]) => void) => {
21 | setInterval(() => {
22 | const n = Math.random() * 10 + 10; // [10, 20]
23 | onDataChange && onDataChange(randomArrayGenerator(n));
24 | }, 1500);
25 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Lemoncode
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/main.js:
--------------------------------------------------------------------------------
1 |
2 | // Wrapping in nv.addGraph allows for '0 timeout render', stores rendered charts in nv.graphs, and may do more in the future... it's NOT required
3 | var chart;
4 | var data;
5 | var legendPosition = "top";
6 |
7 | nv.addGraph(function() {
8 | chart = nv.models.lineChart()
9 | .options({
10 | duration: 300,
11 | useInteractiveGuideline: true
12 | })
13 | ;
14 | // chart sub-models (ie. xAxis, yAxis, etc) when accessed directly, return themselves, not the parent chart, so need to chain separately
15 | chart.xAxis
16 | .axisLabel("Time (s)")
17 | .tickFormat(d3.format(',.1f'))
18 | .staggerLabels(true)
19 | ;
20 | chart.yAxis
21 | .axisLabel('Voltage (v)')
22 | .tickFormat(function(d) {
23 | if (d == null) {
24 | return 'N/A';
25 | }
26 | return d3.format(',.2f')(d);
27 | })
28 | ;
29 | data = sinAndCos();
30 | d3.select('#chart1').append('svg')
31 | .datum(data)
32 | .call(chart);
33 | nv.utils.windowResize(chart.update);
34 | return chart;
35 | });
36 |
--------------------------------------------------------------------------------
/02 d3js-es5/00 SVG/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/01 nvd3/00 Lines/data.js:
--------------------------------------------------------------------------------
1 | function sinAndCos() {
2 | var sin = [],
3 | sin2 = [],
4 | cos = [],
5 | rand = [],
6 | rand2 = []
7 | ;
8 | for (var i = 0; i < 100; i++) {
9 | sin.push({x: i, y: i % 10 == 5 ? null : Math.sin(i/10) }); //the nulls are to show how defined works
10 | sin2.push({x: i, y: Math.sin(i/5) * 0.4 - 0.25});
11 | cos.push({x: i, y: .5 * Math.cos(i/10)});
12 | rand.push({x:i, y: Math.random() / 10});
13 | rand2.push({x: i, y: Math.cos(i/10) + Math.random() / 10 })
14 | }
15 | return [
16 | {
17 | area: true,
18 | values: sin,
19 | key: "Sine Wave",
20 | color: "#ff7f0e",
21 | strokeWidth: 4,
22 | classed: 'dashed'
23 | },
24 | {
25 | values: cos,
26 | key: "Cosine Wave",
27 | color: "#2ca02c"
28 | },
29 | {
30 | values: rand,
31 | key: "Random Points",
32 | color: "#2222ff"
33 | },
34 | {
35 | values: rand2,
36 | key: "Random Cosine",
37 | color: "#667711",
38 | strokeWidth: 3.5
39 | },
40 | {
41 | area: true,
42 | values: sin2,
43 | key: "Fill opacity",
44 | color: "#EF9CFB",
45 | fillOpacity: .1
46 | }
47 | ];
48 | }
49 |
--------------------------------------------------------------------------------
/00 basics/05 SVG 2/readme.md:
--------------------------------------------------------------------------------
1 | # Path and transformations
2 |
3 | Let's play a bit with paths and transformation.
4 |
5 | # Steps
6 |
7 | - Let's define our initial HTML
8 |
9 | ```html
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
22 | ```
23 |
24 | - In SVG we can create a group of element and apply transformations (translations, rotations...), let' draw some text.
25 |
26 | _index.html_
27 |
28 | ```diff
29 |
34 | ```
35 |
36 | - One interesting element is the polygon path:
37 |
38 | ```html
39 |
40 |
43 |
45 |
46 | ```
47 |
48 | - You can as well close the curve:
49 |
50 | ```html
51 |
52 |
54 |
55 |
56 | ```
57 |
58 | > Let's play with the transformations, one of the things we can do is to rotate the shape:
59 |
60 | https://developer.mozilla.org/es/docs/Web/SVG/Attribute/transform
--------------------------------------------------------------------------------
/03 d3js-typescript/02 Bars/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3js-playground",
3 | "version": "1.0.0",
4 | "description": "D3.js playground",
5 | "scripts": {
6 | "start": "webpack-dev-server --config=webpack.dev.js",
7 | "build:dev": "rimraf dist && webpack --config webpack.dev.js",
8 | "build:prod": "rimraf dist && webpack -p --config webpack.prod.js"
9 | },
10 | "author": "Javier Calzado",
11 | "license": "MIT",
12 | "dependencies": {
13 | "@babel/polyfill": "^7.2.5",
14 | "d3": "^5.7.0"
15 | },
16 | "devDependencies": {
17 | "@babel/cli": "^7.2.3",
18 | "@babel/core": "^7.2.2",
19 | "@babel/plugin-proposal-class-properties": "^7.2.3",
20 | "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
21 | "@babel/preset-env": "^7.2.3",
22 | "@babel/preset-typescript": "^7.1.0",
23 | "@types/d3": "^5.5.0",
24 | "@types/node": "^10.12.18",
25 | "babel-loader": "^8.0.5",
26 | "css-loader": "^2.1.0",
27 | "file-loader": "^3.0.1",
28 | "html-webpack-plugin": "^3.2.0",
29 | "json-loader": "^0.5.7",
30 | "node-sass": "^4.9.0",
31 | "prettier": "^1.15.3",
32 | "resolve-url-loader": "^2.3.0",
33 | "rimraf": "^2.6.2",
34 | "sass-loader": "^7.0.1",
35 | "style-loader": "^0.23.1",
36 | "ts-lint": "^4.5.1",
37 | "typescript": "^3.1.2",
38 | "url-loader": "^1.1.1",
39 | "webpack": "^4.20.2",
40 | "webpack-bundle-analyzer": "^3.0.2",
41 | "webpack-cli": "^3.1.2",
42 | "webpack-dev-server": "^3.1.14",
43 | "webpack-merge": "^4.1.4"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/03 d3js-typescript/01 Lines/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3js-playground",
3 | "version": "1.0.0",
4 | "description": "D3.js playground",
5 | "scripts": {
6 | "start": "webpack-dev-server --config=webpack.dev.js",
7 | "build:dev": "rimraf dist && webpack --config webpack.dev.js",
8 | "build:prod": "rimraf dist && webpack -p --config webpack.prod.js"
9 | },
10 | "author": "Javier Calzado",
11 | "license": "MIT",
12 | "dependencies": {
13 | "@babel/polyfill": "^7.2.5",
14 | "d3": "^5.7.0"
15 | },
16 | "devDependencies": {
17 | "@babel/cli": "^7.2.3",
18 | "@babel/core": "^7.2.2",
19 | "@babel/plugin-proposal-class-properties": "^7.2.3",
20 | "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
21 | "@babel/preset-env": "^7.2.3",
22 | "@babel/preset-typescript": "^7.1.0",
23 | "@types/d3": "^5.5.0",
24 | "@types/node": "^10.12.18",
25 | "babel-loader": "^8.0.5",
26 | "css-loader": "^2.1.0",
27 | "file-loader": "^3.0.1",
28 | "html-webpack-plugin": "^3.2.0",
29 | "json-loader": "^0.5.7",
30 | "node-sass": "^4.9.0",
31 | "prettier": "^1.15.3",
32 | "resolve-url-loader": "^2.3.0",
33 | "rimraf": "^2.6.2",
34 | "sass-loader": "^7.0.1",
35 | "style-loader": "^0.23.1",
36 | "ts-lint": "^4.5.1",
37 | "typescript": "^3.1.2",
38 | "url-loader": "^1.1.1",
39 | "webpack": "^4.20.2",
40 | "webpack-bundle-analyzer": "^3.0.2",
41 | "webpack-cli": "^3.1.2",
42 | "webpack-dev-server": "^3.1.14",
43 | "webpack-merge": "^4.1.4"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/03 d3js-typescript/00 Playground/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3js-playground",
3 | "version": "1.0.0",
4 | "description": "D3.js playground",
5 | "scripts": {
6 | "start": "webpack-dev-server --config=webpack.dev.js",
7 | "build:dev": "rimraf dist && webpack --config webpack.dev.js",
8 | "build:prod": "rimraf dist && webpack -p --config webpack.prod.js"
9 | },
10 | "author": "Javier Calzado",
11 | "license": "MIT",
12 | "dependencies": {
13 | "@babel/polyfill": "^7.2.5",
14 | "d3": "^5.7.0"
15 | },
16 | "devDependencies": {
17 | "@babel/cli": "^7.2.3",
18 | "@babel/core": "^7.2.2",
19 | "@babel/plugin-proposal-class-properties": "^7.2.3",
20 | "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
21 | "@babel/preset-env": "^7.2.3",
22 | "@babel/preset-typescript": "^7.1.0",
23 | "@types/d3": "^5.5.0",
24 | "@types/node": "^10.12.18",
25 | "babel-loader": "^8.0.5",
26 | "css-loader": "^2.1.0",
27 | "file-loader": "^3.0.1",
28 | "html-webpack-plugin": "^3.2.0",
29 | "json-loader": "^0.5.7",
30 | "node-sass": "^4.9.0",
31 | "prettier": "^1.15.3",
32 | "resolve-url-loader": "^2.3.0",
33 | "rimraf": "^2.6.2",
34 | "sass-loader": "^7.0.1",
35 | "style-loader": "^0.23.1",
36 | "ts-lint": "^4.5.1",
37 | "typescript": "^3.1.2",
38 | "url-loader": "^1.1.1",
39 | "webpack": "^4.20.2",
40 | "webpack-bundle-analyzer": "^3.0.2",
41 | "webpack-cli": "^3.1.2",
42 | "webpack-dev-server": "^3.1.14",
43 | "webpack-merge": "^4.1.4"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3js-basic-map",
3 | "version": "1.0.0",
4 | "description": "D3.js Basic Map Demo",
5 | "scripts": {
6 | "start": "webpack-dev-server --config=webpack.dev.js",
7 | "build:dev": "rimraf dist && webpack --config webpack.dev.js",
8 | "build:prod": "rimraf dist && webpack -p --config webpack.prod.js"
9 | },
10 | "author": "Javier Calzado",
11 | "license": "MIT",
12 | "dependencies": {
13 | "@babel/polyfill": "^7.2.5",
14 | "d3": "^5.7.0"
15 | },
16 | "devDependencies": {
17 | "@babel/cli": "^7.2.3",
18 | "@babel/core": "^7.2.2",
19 | "@babel/plugin-proposal-class-properties": "^7.2.3",
20 | "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
21 | "@babel/preset-env": "^7.2.3",
22 | "@babel/preset-typescript": "^7.1.0",
23 | "@types/d3": "^5.5.0",
24 | "@types/node": "^10.12.18",
25 | "babel-loader": "^8.0.5",
26 | "css-loader": "^2.1.0",
27 | "file-loader": "^3.0.1",
28 | "html-webpack-plugin": "^3.2.0",
29 | "json-loader": "^0.5.7",
30 | "node-sass": "^4.9.0",
31 | "prettier": "^1.15.3",
32 | "resolve-url-loader": "^2.3.0",
33 | "rimraf": "^2.6.2",
34 | "sass-loader": "^7.0.1",
35 | "style-loader": "^0.23.1",
36 | "ts-lint": "^4.5.1",
37 | "typescript": "^3.1.2",
38 | "url-loader": "^1.1.1",
39 | "webpack": "^4.20.2",
40 | "webpack-bundle-analyzer": "^3.0.2",
41 | "webpack-cli": "^3.1.2",
42 | "webpack-dev-server": "^3.1.14",
43 | "webpack-merge": "^4.1.4"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/03 d3js-typescript/992 Map Interaction/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3js-map-interaction",
3 | "version": "1.0.0",
4 | "description": "D3.js Map Interaction Demo",
5 | "scripts": {
6 | "start": "webpack-dev-server --config=webpack.dev.js",
7 | "build:dev": "rimraf dist && webpack --config webpack.dev.js",
8 | "build:prod": "rimraf dist && webpack -p --config webpack.prod.js"
9 | },
10 | "author": "Javier Calzado",
11 | "license": "MIT",
12 | "dependencies": {
13 | "@babel/polyfill": "^7.2.5",
14 | "d3": "^5.7.0"
15 | },
16 | "devDependencies": {
17 | "@babel/cli": "^7.2.3",
18 | "@babel/core": "^7.2.2",
19 | "@babel/plugin-proposal-class-properties": "^7.2.3",
20 | "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
21 | "@babel/preset-env": "^7.2.3",
22 | "@babel/preset-typescript": "^7.1.0",
23 | "@types/d3": "^5.5.0",
24 | "@types/node": "^10.12.18",
25 | "babel-loader": "^8.0.5",
26 | "css-loader": "^2.1.0",
27 | "file-loader": "^3.0.1",
28 | "html-webpack-plugin": "^3.2.0",
29 | "json-loader": "^0.5.7",
30 | "node-sass": "^4.9.0",
31 | "prettier": "^1.15.3",
32 | "resolve-url-loader": "^2.3.0",
33 | "rimraf": "^2.6.2",
34 | "sass-loader": "^7.0.1",
35 | "style-loader": "^0.23.1",
36 | "ts-lint": "^4.5.1",
37 | "typescript": "^3.1.2",
38 | "url-loader": "^1.1.1",
39 | "webpack": "^4.20.2",
40 | "webpack-bundle-analyzer": "^3.0.2",
41 | "webpack-cli": "^3.1.2",
42 | "webpack-dev-server": "^3.1.14",
43 | "webpack-merge": "^4.1.4"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/03 d3js-typescript/994 World Population/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3js-world-population",
3 | "version": "1.0.0",
4 | "description": "D3.js World Population Demo",
5 | "scripts": {
6 | "start": "webpack-dev-server --config=webpack.dev.js",
7 | "build:dev": "rimraf dist && webpack --config webpack.dev.js",
8 | "build:prod": "rimraf dist && webpack -p --config webpack.prod.js"
9 | },
10 | "author": "Javier Calzado",
11 | "license": "MIT",
12 | "dependencies": {
13 | "@babel/polyfill": "^7.2.5",
14 | "d3": "^5.7.0"
15 | },
16 | "devDependencies": {
17 | "@babel/cli": "^7.2.3",
18 | "@babel/core": "^7.2.2",
19 | "@babel/plugin-proposal-class-properties": "^7.2.3",
20 | "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
21 | "@babel/preset-env": "^7.2.3",
22 | "@babel/preset-typescript": "^7.1.0",
23 | "@types/d3": "^5.5.0",
24 | "@types/node": "^10.12.18",
25 | "babel-loader": "^8.0.5",
26 | "css-loader": "^2.1.0",
27 | "file-loader": "^3.0.1",
28 | "html-webpack-plugin": "^3.2.0",
29 | "json-loader": "^0.5.7",
30 | "node-sass": "^4.9.0",
31 | "prettier": "^1.15.3",
32 | "resolve-url-loader": "^2.3.0",
33 | "rimraf": "^2.6.2",
34 | "sass-loader": "^7.0.1",
35 | "style-loader": "^0.23.1",
36 | "ts-lint": "^4.5.1",
37 | "typescript": "^3.1.2",
38 | "url-loader": "^1.1.1",
39 | "webpack": "^4.20.2",
40 | "webpack-bundle-analyzer": "^3.0.2",
41 | "webpack-cli": "^3.1.2",
42 | "webpack-dev-server": "^3.1.14",
43 | "webpack-merge": "^4.1.4"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/03 d3js-typescript/993 Spain Cloropleth/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3js-spain-cloropleth",
3 | "version": "1.0.0",
4 | "description": "D3.js Spain Cloropleth Demo",
5 | "scripts": {
6 | "start": "webpack-dev-server --config=webpack.dev.js",
7 | "build:dev": "rimraf dist && webpack --config webpack.dev.js",
8 | "build:prod": "rimraf dist && webpack -p --config webpack.prod.js"
9 | },
10 | "author": "Javier Calzado",
11 | "license": "MIT",
12 | "dependencies": {
13 | "@babel/polyfill": "^7.2.5",
14 | "d3": "^5.7.0",
15 | "d3-composite-projections": "^1.2.0",
16 | "topojson": "^3.0.2"
17 | },
18 | "devDependencies": {
19 | "@babel/cli": "^7.2.3",
20 | "@babel/core": "^7.2.2",
21 | "@babel/plugin-proposal-class-properties": "^7.2.3",
22 | "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
23 | "@babel/preset-env": "^7.2.3",
24 | "@babel/preset-typescript": "^7.1.0",
25 | "@types/d3": "^5.5.0",
26 | "@types/node": "^10.12.18",
27 | "@types/topojson": "^3.2.1",
28 | "babel-loader": "^8.0.5",
29 | "css-loader": "^2.1.0",
30 | "file-loader": "^3.0.1",
31 | "html-webpack-plugin": "^3.2.0",
32 | "json-loader": "^0.5.7",
33 | "node-sass": "^4.9.0",
34 | "prettier": "^1.15.3",
35 | "resolve-url-loader": "^2.3.0",
36 | "rimraf": "^2.6.2",
37 | "sass-loader": "^7.0.1",
38 | "style-loader": "^0.23.1",
39 | "ts-lint": "^4.5.1",
40 | "typescript": "^3.1.2",
41 | "url-loader": "^1.1.1",
42 | "webpack": "^4.20.2",
43 | "webpack-bundle-analyzer": "^3.0.2",
44 | "webpack-cli": "^3.1.2",
45 | "webpack-dev-server": "^3.1.14",
46 | "webpack-merge": "^4.1.4"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/00 basics/01 CSS/styles.css:
--------------------------------------------------------------------------------
1 | /* Applied to all tags */
2 | p {
3 | color: blue;
4 | }
5 |
6 | /* Applied to all tags with the class "red" */
7 | .red {
8 | background: red;
9 | }
10 |
11 | /* Applied to the tag with the id "some-id" */
12 | #some-id {
13 | font-style: italic;
14 | }
15 |
16 | /* Applied only to
tags that are inside
tags */
17 | li p {
18 | color: #0C0;
19 | }
20 |
21 | body {
22 | font-family: sans-serif;
23 | }
24 |
25 | /* Applied to all tags */
26 | p {
27 | color: blue;
28 | }
29 |
30 | /* Applied to all tags with the class "red" */
31 | .red {
32 | background: red;
33 | }
34 |
35 | /* Applied to the tag with the id "some-id" */
36 | #some-id {
37 | font-style: italic;
38 | }
39 |
40 | /* Applied only to
tags that are inside
tags */
41 | li p {
42 | color: #0c0;
43 | }
44 |
45 | h2 {
46 | font: 400 40px/1.5 Helvetica, Verdana, sans-serif;
47 | margin: 0;
48 | padding: 0;
49 | }
50 |
51 | ul {
52 | list-style-type: none;
53 | margin: 0;
54 | padding: 0;
55 | }
56 |
57 | ul li {
58 | font: 200 20px/1.5 Helvetica, Verdana, sans-serif;
59 | border-bottom: 1px solid #ccc;
60 | }
61 |
62 | ul li:last-child {
63 | border: none;
64 | }
65 |
66 | ul li a {
67 | text-decoration: none;
68 | color: #000;
69 | display: block;
70 | width: 100%;
71 |
72 | -webkit-transition: font-size 0.3s ease, background-color 0.3s ease;
73 | -moz-transition: font-size 0.3s ease, background-color 0.3s ease;
74 | -o-transition: font-size 0.3s ease, background-color 0.3s ease;
75 | -ms-transition: font-size 0.3s ease, background-color 0.3s ease;
76 | transition: font-size 0.3s ease, background-color 0.3s ease;
77 | }
78 |
79 | ul li a:hover {
80 | font-size: 30px;
81 | background: #f6f6f6;
82 | }
83 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/src/d3/world-mercator.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 | import { geoMercator, geoPath } from "d3-geo";
3 | import { json } from "d3-fetch";
4 | import { FeatureCollection } from 'geojson';
5 |
6 | // (*) Lets define a width and height for the SVG user space
7 | // coordinate system (viewBox), also a padding to avoid
8 | // overflows.
9 | const width = 960;
10 | const height = 880;
11 | const padding = 20;
12 |
13 | // (*) Lets add a card for our map.
14 | const card = select("#root")
15 | .append("div")
16 | .attr("class", "card");
17 |
18 | // (*) Now the SVG canvas with the viewBox.
19 | const svg = card
20 | .append("svg")
21 | .attr("width", "100%")
22 | .attr("height", "100%")
23 | .attr("viewBox", `${-padding} ${-padding} ${width + 2*padding} ${height + 2*padding}`);
24 |
25 | // (*) Lets create a projection, which basically is a math
26 | // function to develop a 3D surface into a flat surface.
27 | // In practice, it transforms geographic coordinates into
28 | // projected coordinates. There are plenty of different
29 | // projections, and depending on our target application,
30 | // we will select one or another. A good general purpose
31 | // projection is spherical mercator (used extensively by
32 | // web map providers such as Google Maps) also known as
33 | // webMercator or pseudoMercator. Another one extended
34 | // is equirectangular AKA Platee-Carree.
35 | const mercatorProjection = geoMercator()
36 | .translate([width/2, height/2]);
37 |
38 | // (*) A path in SVG is described in a very specific manner.
39 | // Lets use a utility provided by d3 to create the proper
40 | // SVG coordinates for a path from user space coordinates.
41 | const pathCreator = geoPath()
42 | .projection(mercatorProjection);
43 |
44 | // (*) Finally, lets paint our path in the svg by loading
45 | // locally the world geojson.
46 | json(require("../data/world.geojson")).then((worldData =>
47 | svg.append("path")
48 | .attr("d", pathCreator(worldData))
49 | ));
50 |
51 |
--------------------------------------------------------------------------------
/03 d3js-typescript/991 Basic Map/src/d3/world-platee-carre.d3.ts:
--------------------------------------------------------------------------------
1 | import { select } from "d3-selection";
2 | import { geoEquirectangular, geoPath } from "d3-geo";
3 | import { json } from "d3-fetch";
4 | import { FeatureCollection } from 'geojson';
5 |
6 | // (*)Lets define a width and height for the SVG user space
7 | // coordinate system (viewBox), also a padding to avoid
8 | // overflows.
9 | const width = 960;
10 | const height = 460;
11 | const padding = 20;
12 |
13 | // (*) Lets add a card for our map.
14 | const card = select("#root")
15 | .append("div")
16 | .attr("class", "card");
17 |
18 | // (*) Now the SVG canvas with the viewBox.
19 | const svg = card
20 | .append("svg")
21 | .attr("width", "100%")
22 | .attr("height", "100%")
23 | .attr("viewBox", `${-padding} ${-padding} ${width + 2*padding} ${height + 2*padding}`);
24 |
25 | // (*) Lets create a projection, which basically is a math
26 | // function to develop a 3D surface into a flat surface.
27 | // In practice, it transforms geographic coordinates into
28 | // projected coordinates. There are plenty of different
29 | // projections, and depending on our target application,
30 | // we will select one or another. A good general purpose
31 | // projection is spherical mercator (used extensively by
32 | // web map providers such as Google Maps) also known as
33 | // webMercator or pseudoMercator. Another one extended
34 | // is equirectangular AKA Platee-Carree.
35 | const plateeProjection = geoEquirectangular()
36 | .translate([width/2, height/2]);
37 |
38 | // (*) A path in SVG is described in a very specific manner.
39 | // Lets use a utility provided by d3 to create the proper
40 | // SVG coordinates for a path from user space coordinates.
41 | const pathCreator = geoPath()
42 | .projection(plateeProjection);
43 |
44 | // (*) Finally, lets paint our path in the svg by loading
45 | // locally the world geojson.
46 | json(require("../data/world.geojson")).then((worldData =>
47 | svg.append("path")
48 | .attr("d", pathCreator(worldData))
49 | ));
--------------------------------------------------------------------------------
/00 basics/04 SVG/readme.md:
--------------------------------------------------------------------------------
1 | # Intro
2 |
3 | Let's start playing with vector graphics, we will use the SVG HTML standard.
4 |
5 | # Steps
6 |
7 | - Let's start by creating an index.html
8 |
9 | _index.html_
10 |
11 | ```html
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ```
23 |
24 | - Now let's create an SVG container
25 |
26 | _index.html_
27 |
28 | ```diff
29 |
30 | +
32 |
33 | ```
34 |
35 | - Let's draw a circle
36 |
37 | _index.html_
38 |
39 | ```diff
40 |
43 | ```
44 |
45 | - SVG elements support CSS styling (altough some class names are different to what we are used):
46 |
47 | _styles.css_
48 |
49 | ```css
50 | .red {
51 | fill: red; /* not background-color! */
52 | }
53 | ```
54 |
55 | _index.html_
56 |
57 | ```diff
58 |
62 |