-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# book-exercises | ||
This repository contains the starting code files and solutions of the book D3.js in Action, third edition. | ||
This repository contains the starting code files and solutions of the book D3.js in Action, 3rd edition](https://www.manning.com/books/d3js-in-action-third-edition). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
# SVG Shapes Gallery | ||
|
||
This folder contains the starter `index.html` file for the SVG Shapes Gallery exercise of chapter 1. In this exercise, you will create basic SVG shapes with code. | ||
This folder contains the starter `index.html` file for the SVG Shapes Gallery exercise for chapter 1 of [D3.js in Action, 3rd edition](https://www.manning.com/books/d3js-in-action-third-edition). In this exercise, you will create basic SVG shapes with code. | ||
|
||
|
||
## Techniques learned in this exercise | ||
|
||
- Creating a responsive SVG container. | ||
- Creating, positioning, and styling basic SVG shapes like lines, rectangles, circles, and paths. | ||
- Creating and positioning SVG text. | ||
|
||
|
||
## How to run this project | ||
|
||
To view the project in your browser, locate the `index.html` file in your Windows Explorer (PC) or Finder (Mac). Right-click on the file to open a menu. Go to `Open with` and select a browser. We recommend working with Chrome or Firefox for their great inspector tools. The file will open in a new browser tab. | ||
To view the project in your browser, locate the `index.html` (in the *start* OR the *end* folder) file in your Windows Explorer (PC) or Finder (Mac). Right-click on the file to open a menu. Go to `Open with` and select a browser. We recommend working with Chrome or Firefox for their great inspector tools. The file will open in a new browser tab. | ||
|
||
Happy coding! 🤓 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
# Manipulating the DOM | ||
|
||
This folder contains the files for the coding exercise of chapter 2. In this exercise, you will start building a bar graph while learning how to manipulate the DOM with D3. | ||
|
||
|
||
## Techniques learned in this exercise | ||
|
||
- Selecting DOM elements with `d3.select()` and `d3.selectAll()`. | ||
- Adding elements to a selection with the `selection.append()` and the `selection.insert()` methods. | ||
- Setting and modifying the attributes of DOM elements with the `selection.attr()` method. | ||
- Setting and modifying the styles of DOM elements with the `selection.style()` method. | ||
|
||
|
||
## Development environment | ||
|
||
To run D3 projects, you'll need a web server. In chapter 1, we explained how to set up a local development environment using [VS Code](https://code.visualstudio.com/) and its [Live Server extension](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). | ||
|
||
If you use this setup, you can start the project by clicking on the "Go Live" option in the status bar, located at the bottom of your VS Code window. | ||
This folder contains the exercise files for chapter 2 of [D3.js in Action, 3rd edition](https://www.manning.com/books/d3js-in-action-third-edition). | ||
</br> | ||
The project contains a *start* and an *end* folder. To follow along with the book's instructions, write your code in the *start* folder. You'll find the solution in the *end* folder if ever you get stuck. | ||
|
||
## How to run the project | ||
To run this project, you'll need a local webserver. We recommend using [VS Code](https://code.visualstudio.com/)'s Live Server extension. You can find instructions on installing this extension in Appendix A of the book. | ||
1. Open the project folder (the *start* OR the *end* folder) in VS Code. | ||
2. To run the project with the Live Server extension, click the *Go live* button in the status bar of VS Code. | ||
3. The project should open automatically in your browser. | ||
|
||
## Structure of the project | ||
* The `/data` folder contains a CSV file names `data.csv`, extracted from the results of the [2021 State of the Industry Survey](https://www.datavisualizationsociety.org/survey) by the [Data Visualization Society](https://www.datavisualizationsociety.org). The columns are organized as follows: | ||
* `technology`: A list of technologies used for data visualization. | ||
* `count`: The number of respondents who mentioned using this tool. | ||
* The `/css` folder contains the CSS file `main.css`, where styles have been added for the responsive SVG container. | ||
* The `/js` folder contains the JavaScript file `main.js`. This is where we will build our bar chart. | ||
* `index.html` contains the markup and text that composes the project. The D3 library, `main.css`, and `main.js` are already loaded in this file. | ||
|
||
Happy D3 coding! 🤓 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
# Working with data | ||
|
||
This folder contains the files for the coding exercise of chapter 3. In this exercise, you will finish building the bar graph started in chapter 2 while learning how to work with data in D3 projects. | ||
|
||
|
||
## Techniques learned in this exercise | ||
|
||
- Loading a dataset into a project using `d3.csv()`. | ||
- Formatting the data in the callback function of `d3.csv()`. | ||
- Finding the maximum and minimum values in a dataset. | ||
- Generating DOM element with data-binding. | ||
- Using D3 linear and band scales. | ||
- Adding axis to a chart. | ||
|
||
|
||
## Development environment | ||
|
||
To run D3 projects, you'll need a web server. In chapter 1, we explained how to set up a local development environment using [VS Code](https://code.visualstudio.com/) and its [Live Server extension](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). | ||
|
||
If you use this setup, you can start the project by clicking on the "Go Live" option in the status bar, located at the bottom of your VS Code window. | ||
# Drawing lines, curves, and arcs | ||
This folder contains the exercise files for chapter 3 of [D3.js in Action, 3rd edition](https://www.manning.com/books/d3js-in-action-third-edition). | ||
</br> | ||
The folder is separated into subfolders corresponding to each section of the chapter. In these subfolders, you'll find a *start* and an *end* folder. To follow along with the book's instructions, write your code in the *start* folder. You'll find the solution in the *end* folder if ever you get stuck. | ||
When changing to the next section, you can choose to keep coding in the same files or use the *start* folder for that section. | ||
|
||
## Sections in this chapter | ||
* [3.2-Preparing_data](https://github.com/d3js-in-action-third-edition/code-files/tree/main/chapter_03/3.2-Preparing_data) | ||
* [3.3-Binding_data](https://github.com/d3js-in-action-third-edition/code-files/tree/main/chapter_03/3.3-Binding_data) | ||
* [3.4-Scales](https://github.com/d3js-in-action-third-edition/code-files/tree/main/chapter_03/3.4-Scales) | ||
|
||
## How to run the project | ||
To run this project, you'll need a local webserver. We recommend using [VS Code](https://code.visualstudio.com/)'s Live Server extension. You can find instructions on installing this extension in Appendix A of the book. | ||
1. Open the project folder (a *start* OR an *end* folder from the subsections mentioned above) in VS Code. | ||
2. To run the project with the Live Server extension, click the *Go live* button in the status bar of VS Code. | ||
3. The project should open automatically in your browser. | ||
|
||
## Structure of the project | ||
* The `/data` folder contains a CSV file names `data.csv`, extracted from the results of the [2021 State of the Industry Survey](https://www.datavisualizationsociety.org/survey) by the [Data Visualization Society](https://www.datavisualizationsociety.org). The columns are organized as follows: | ||
* `technology`: A list of technologies used for data visualization. | ||
* `count`: The number of respondents who mentioned using this tool. | ||
* The `/css` folder contains the CSS file `main.css`, where styles have been added for the responsive SVG container. | ||
* The `/js` folder contains the JavaScript file `main.js`. This is where we will build our bar chart. | ||
* `index.html` contains the markup and text that composes the project. The D3 library, `main.css`, and `main.js` are already loaded in this file. | ||
|
||
Happy D3 coding! 🤓 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters