Skip to content

Commit 0b7b5e9

Browse files
authored
Merge branch 'main' into mbostock/more-color
2 parents b8e9bd1 + a063b22 commit 0b7b5e9

File tree

851 files changed

+153845
-16581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

851 files changed

+153845
-16581
lines changed

.github/workflows/deploy.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy
2+
3+
on:
4+
workflow_dispatch: {}
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pages: write
13+
id-token: write
14+
environment:
15+
name: github-pages
16+
url: ${{ steps.deployment.outputs.page_url }}
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: 16
22+
cache: 'yarn'
23+
- run: yarn --frozen-lockfile
24+
- run: yarn prepublishOnly
25+
- run: yarn docs:build
26+
- uses: actions/configure-pages@v3
27+
- uses: actions/upload-pages-artifact@v1
28+
with:
29+
path: docs/.vitepress/dist
30+
- name: Deploy
31+
id: deployment
32+
uses: actions/deploy-pages@v1

.github/workflows/node.js.yml renamed to .github/workflows/test.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
2-
3-
name: Node.js CI
1+
name: Test
42

53
on:
64
push:
@@ -11,22 +9,20 @@ on:
119
jobs:
1210
build:
1311
runs-on: ubuntu-latest
14-
15-
strategy:
16-
matrix:
17-
node-version: [16.x]
18-
1912
steps:
2013
- uses: actions/checkout@v3
2114
- uses: actions/setup-node@v3
2215
with:
23-
node-version: ${{ matrix.node-version }}
16+
node-version: 16
17+
cache: 'yarn'
2418
- run: yarn --frozen-lockfile
2519
- run: |
2620
echo ::add-matcher::.github/eslint.json
2721
yarn run eslint src test --format=compact
2822
- run: yarn run prettier --check src test
2923
- run: yarn test:mocha
24+
- run: yarn prepublishOnly
25+
- run: yarn docs:build
3026
- uses: actions/upload-artifact@v3
3127
if: failure()
3228
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
coverage/
23
dist/
34
docs/.vitepress/cache
45
docs/.vitepress/dist

CHANGELOG-2021.md

Lines changed: 419 additions & 0 deletions
Large diffs are not rendered by default.

CHANGELOG-2022.md

Lines changed: 666 additions & 0 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 384 additions & 1110 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Observable Plot - Contributing
22

3-
Observable Plot is open source and released under the [ISC license](./LICENSE). You are welcome to [send us pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) to contribute bug fixes or new features. We also invite you to participate in [issues](https://github.com/observablehq/plot/issues) and [discussions](https://github.com/observablehq/plot/discussions). We use issues to track and diagnose bugs, as well as to debate and design enhancements to Plot. Discussions are intended for you to ask for help using Plot, or to share something cool you’ve built with Plot. (You can also ask for help on the [Observable Forum](https://talk.observablehq.com).)
3+
Observable Plot is open source and released under the [ISC license](./LICENSE). You are welcome to [send us pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) to contribute bug fixes or new features. We also invite you to participate in [issues](https://github.com/observablehq/plot/issues) and [discussions](https://github.com/observablehq/plot/discussions). We use issues to track and diagnose bugs, as well as to debate and design enhancements to Plot. Discussions are intended for you to ask for help using Plot, or to share something cool you’ve built with Plot. You can also ask for help on the [Observable Forum](https://talk.observablehq.com) and the [Observable community Slack](https://join.slack.com/t/observable-community/shared_invite/zt-1x7gs4fck-UHhEFxUXKHVE8Qt3XmJCig).
44

55
We request that you abide by our [code of conduct](https://observablehq.com/@observablehq/code-of-conduct) when contributing and participating in discussions.
66

@@ -42,6 +42,12 @@ Please run Prettier before submitting any pull request. Check “format on save
4242
yarn prettier --write .
4343
```
4444

45+
A test coverage report can be generated with [c8](https://github.com/bcoe/c8), in text and lcov formats, to help you identify which lines of code are not (yet!) covered by tests. Just run:
46+
47+
```bash
48+
yarn test:coverage
49+
```
50+
4551
### Unit tests
4652

4753
Unit tests live in `test` and have the `-test.js` file extension; see [`test/marks/area-test.js`](./test/marks/area-test.js) for example. Generally speaking, unit tests make specific, low-level assertions about the behavior of Plot’s API, including internals and helper methods. If you add a new feature, or change the behavior of an existing feature, please update the unit tests so that we can more easily maintain your contribution into the future. For example, here’s a unit test that tests how Plot formats months:
@@ -64,29 +70,29 @@ yarn run mocha --conditions=mocha --parallel --watch test/marks/bar-test.js
6470

6571
### Snapshot tests
6672

67-
Snapshot tests live in `test/plots` and are registered in [`test/plots/index.js`](./test/plots/index.js); see [`test/plots/aapl-bollinger.js`](./test/plots/aapl-bollinger.js) for example. Unlike unit tests which only test individual methods, snapshot tests actually visualize data—they’re more representative of how we expect people will use Plot. Snapshot tests can also serve as examples of how to use the Plot API, though note that some of the examples intentionally test edge case of the API and may not embody best practices. Each snapshot test defines a plot by exporting a default async function. For example, here’s a line chart using BLS unemployment data:
73+
Snapshot tests live in `test/plots` and are registered in [`test/plots/index.ts`](./test/plots/index.ts); see [`test/plots/aapl-bollinger.ts`](./test/plots/aapl-bollinger.ts) for example. Unlike unit tests which only test individual methods, snapshot tests actually visualize data—they’re more representative of how we expect people will use Plot. Snapshot tests can also serve as examples of how to use the Plot API, though note that some of the examples intentionally test edge case of the API and may not embody best practices. Each snapshot test defines a plot by exporting a default async function. For example, here’s a line chart using BLS unemployment data:
6874

69-
```js
75+
```ts
7076
import * as Plot from "@observablehq/plot";
7177
import * as d3 from "d3";
7278

73-
export default async function() {
74-
const bls = await d3.csv("data/bls-metro-unemployment.csv", d3.autoType);
79+
export async function lineUnemployment() {
80+
const bls = await d3.csv<any>("data/bls-metro-unemployment.csv", d3.autoType);
7581
return Plot.plot({
7682
marks: [
77-
Plot.line(bls, {x: "date", y: "unemployment", z: "division"}),
78-
Plot.ruleY([0])
83+
Plot.ruleY([0]),
84+
Plot.lineY(bls, {x: "date", y: "unemployment", z: "division"})
7985
]
8086
});
8187
}
8288
```
8389

84-
When a snapshot test is run, its output is compared against the SVG or HTML snapshot saved in the `test/output` folder. This makes it easier to review the effect of code changes and to catch unintended changes. Snapshot tests must have deterministic, reproducible behavior; they should not depend on live data, external servers, the current time, the weather, etc. To use randomness in a test, use a seeded random number generator such as [d3.randomLcg](https://github.com/d3/d3-random/blob/master/README.md#randomLcg).
90+
When a snapshot test is run, its output is compared against the SVG or HTML snapshot saved in the `test/output` folder. This makes it easier to review the effect of code changes and to catch unintended changes. Snapshot tests must have deterministic, reproducible behavior; they should not depend on live data, external servers, the current time, the weather, etc. To use randomness in a test, use a seeded random number generator such as [d3.randomLcg](https://d3js.org/d3-random#randomLcg).
8591

86-
To add a new snapshot test, create a new JavaScript file in the `test/plots` folder using the pattern shown above. Then export your snapshot test function from [`test/plots/index.js`](./test/plots/index.js). For example:
92+
To add a new snapshot test, create a new JavaScript file in the `test/plots` folder using the pattern shown above. Then export your snapshot test function from [`test/plots/index.ts`](./test/plots/index.ts). For example:
8793

8894
```js
89-
export {default as mobyDick} from "./moby-dick.js";
95+
export * from "./moby-dick.ts";
9096
```
9197

9298
The best thing about snapshot tests is that you can see the live result in your browser as you make changes to Plot’s source code! This lets you immediately assess visually what Plot is doing. To preview snapshot tests during development, Plot uses [Vite](https://vitejs.dev). To start Vite:
@@ -110,7 +116,7 @@ yarn test
110116

111117
## Documentation
112118

113-
When submitting a pull request, please remember to update Plot’s [README.md](./README.md) to reflect changes to the public API. You are also welcome to edit Plot’s [CHANGELOG.md](./CHANGELOG.md) to assist with writing future release notes. In addition, please reference any related [issues](https://github.com/observablehq/plot/issues) (or discussions) in your pull request description.
119+
When submitting a pull request, please remember to update Plot’s documentation to reflect changes to the public API. You are also welcome to edit Plot’s [CHANGELOG.md](./CHANGELOG.md) to assist with writing future release notes. In addition, please reference any related [issues](https://github.com/observablehq/plot/issues) (or discussions) in your pull request description.
114120

115121
If you’d like to share a live demonstration or motivating example of your change to Plot, you can regenerate Plot’s release bundle using Yarn:
116122

0 commit comments

Comments
 (0)