Skip to content

Commit 2967384

Browse files
authored
Merge branch 'main' into fil/voronoi-initializer
2 parents 7d2c523 + 32cd301 commit 2967384

File tree

15 files changed

+125
-37
lines changed

15 files changed

+125
-37
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [main]
88

99
jobs:
10-
build:
10+
test:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
@@ -16,11 +16,12 @@ jobs:
1616
node-version: 16
1717
cache: 'yarn'
1818
- run: yarn --frozen-lockfile
19+
- run: yarn test:mocha
20+
- run: yarn test:tsc
1921
- run: |
2022
echo ::add-matcher::.github/eslint.json
2123
yarn run eslint src test --format=compact
22-
- run: yarn run prettier --check src test
23-
- run: yarn test:mocha
24+
- run: yarn test:prettier
2425
- run: yarn prepublishOnly
2526
- run: yarn docs:build
2627
- uses: actions/upload-artifact@v3

CHANGELOG.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,62 @@
22

33
Year: **Current (2023)** · [2022](./CHANGELOG-2022.md) · [2021](./CHANGELOG-2021.md)
44

5+
## 0.6.11
6+
7+
[Released September 20, 2023.](https://github.com/observablehq/plot/releases/tag/v0.6.11)
8+
9+
The **tip** mark option can now pass options to the derived [tip mark](https://observablehq.com/plot/marks/tip); the options object can also specify the **pointer** option to control the derived tip’s pointer mode (_x_, _y_, or _xy_). The new **format** tip mark option enables greater control over order and formatting of channels.
10+
11+
<img src="./img/tip-custom.png" width="674" alt="A tip with a custom order and formatting of the channel values.">
12+
13+
```js
14+
Plot.dot(olympians, {
15+
x: "weight",
16+
y: "height",
17+
stroke: "sex",
18+
channels: {
19+
name: "name",
20+
nationality: "nationality",
21+
sport: "sport"
22+
},
23+
tip: {
24+
format: {
25+
name: true, // show name first
26+
y: (d) => `${d}m`, // units in meters
27+
x: (d) => `${d}kg`, // units in kilograms
28+
stroke: false // suppress stroke channel
29+
}
30+
}
31+
}).plot()
32+
```
33+
34+
Axes for ordinal scales now generalize the scale’s temporal or quantitative **interval** if any, resulting in more readable ticks. For instance, the bar chart below of monthly values now sports multi-line tick labels.
35+
36+
<img src="./img/temporal-ordinal.png" width="672" alt="A temporal bar chart with a multi-line axis.">
37+
38+
```js
39+
Plot.plot({
40+
x: {interval: "month"},
41+
marks: [
42+
Plot.barY(aapl, Plot.groupX({y: "median"}, {x: "Date", y: "Close"}))
43+
]
44+
})
45+
```
46+
47+
Plot now recognizes CSS Color Module [Level 4](https://www.w3.org/TR/css-color-4/) and [Level 5](https://www.w3.org/TR/css-color-5/) syntax as literal colors, making it easier to use modern color syntax such as [oklab()](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklab), [color-mix()](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix), and alternative color spaces such as [display-p3](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color).
48+
49+
A channel value can now be given a label by specifying it as a {value, label} object; this may affect the label used in axes, legends, and tips.
50+
51+
This release also includes numerous bug fixes:
52+
- exposed ordinal domains are now correctly deduplicated;
53+
- the default symbol set is now inferred correctly when **fill** is *currentColor*;
54+
- the **fontVariant** axis option now applies to the axis label in addition to ticks;
55+
- the tip mark is no longer briefly visible before asynchronous rendering;
56+
- the bin transform no longer generates undefined colors for empty bins;
57+
- the bin transform now uses the **interval** option to reduce *x1* & *x2* (and *y1* & *y2*);
58+
- the stack transform now correctly handles the *exclude* **facet** option;
59+
- the tree transform now correctly handles escaping with the **delimiter** option.
60+
561
## 0.6.10
662

763
[Released August 14, 2023.](https://github.com/observablehq/plot/releases/tag/v0.6.10)

docs/.vitepress/theme/custom.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
}
1414

1515
:root {
16+
--vp-c-red: #f43f5e;
17+
--vp-c-green: #10b981;
1618
--vp-c-blue: #0092ff;
1719
--vp-c-purple: #a463f2;
1820
--vp-c-brand-1: var(--vp-c-purple-1);

docs/community.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ Please star ⭐️ our [GitHub repo](https://github.com/observablehq/plot) to sh
1010

1111
Plot is getting better all the time; catch up on [recent releases](https://github.com/observablehq/plot/releases) by reading our [CHANGELOG](https://github.com/observablehq/plot/blob/main/CHANGELOG.md).
1212

13-
For email updates, sign up for the [Observable Plot Twist](https://observablehq.com/@observablehq/plot-twist-newsletter-signup) newsletter. (See our [back issues](https://observablehq.com/collection/@observablehq/newsletters/2) and [blog](https://observablehq.com/blog), too.) This monthly newsletter will let you know about new features in Plot, inspiring work by the community, upcoming workshops and community events, and more.
14-
1513
And of course, follow us on [Observable](https://observablehq.com/@observablehq?tab=profile), [Mastodon](https://vis.social/@observablehq), [Twitter](https://twitter.com/observablehq), and [LinkedIn](https://www.linkedin.com/company/observable)!
1614

1715
## Getting help

docs/features/marks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ All marks support the following style options:
490490

491491
If the **clip** option is *frame* (or equivalently true), the mark is clipped to the frame’s dimensions; if the **clip** option is null (or equivalently false), the mark is not clipped. If the **clip** option is *sphere*, then a [geographic projection](./projections.md) is required and the mark will be clipped to the projected sphere (_e.g._, the front hemisphere when using the orthographic projection).
492492

493-
If the **tip** option is true, a [tip mark](../marks/tip.md) with the [pointer transform](../interactions/pointer.md) will be derived from this mark and placed atop all other marks, offering details on demand. If the **tip** option is set to *x*, *y*, or *xy*, [pointerX](../interactions/pointer.md#pointerX), [pointerY](../interactions/pointer.md#pointerY), or [pointer](../interactions/pointer.md#pointer) will be used, respectively; otherwise the pointing mode will be chosen automatically. (If the **tip** mark option is truthy, the **title** channel is no longer applied using an SVG title element as this would conflict with the tip mark.)
493+
If the **tip** option is true, a [tip mark](../marks/tip.md) with the [pointer transform](../interactions/pointer.md) will be derived from this mark and placed atop all other marks, offering details on demand. If the **tip** option is set to an options object, these options will be passed to the derived tip mark. If the **tip** option (or, if an object, its **pointer** option) is set to *x*, *y*, or *xy*, [pointerX](../interactions/pointer.md#pointerX), [pointerY](../interactions/pointer.md#pointerY), or [pointer](../interactions/pointer.md#pointer) will be used, respectively; otherwise the pointing mode will be chosen automatically. (If the **tip** mark option is truthy, the **title** channel is no longer applied using an SVG title element as this would conflict with the tip mark.)
494494

495495
For all marks except [text](../marks/text.md), the **dx** and **dy** options are rendered as a transform property, possibly including a 0.5px offset on low-density screens.
496496

docs/features/scales.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ Plot implicitly generates an [axis mark](../marks/axis.md) for position scales i
940940
* **tickPadding** - the separation between the tick and its label (in pixels; default 3)
941941
* **tickFormat** - either a function or specifier string to format tick values; see [Formats](./formats.md)
942942
* **tickRotate** - whether to rotate tick labels (an angle in degrees clockwise; default 0)
943-
* **fontVariant** - the font-variant attribute for ticks; defaults to *tabular-nums* if quantitative
943+
* **fontVariant** - the font-variant attribute; defaults to *tabular-nums* if quantitative
944944
* **label** - a string to label the axis
945945
* **labelAnchor** - the label anchor: *top*, *right*, *bottom*, *left*, or *center*
946946
* **labelArrow** - the label arrow: *auto* (default), *up*, *right*, *down*, *left*, *none*, or true <VersionBadge version="0.6.7" />

docs/marks/tip.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,37 @@ Plot.rectY(olympians, Plot.binX({y: "sum"}, {x: "weight", y: (d) => d.sex === "m
129129
```
130130
:::
131131

132-
The tip mark does not provide options for formatting channel names or values. When a channel is bound to a scale, the scale’s label is shown instead of the channel name. If you desire greater customization, please upvote [#1612](https://github.com/observablehq/plot/issues/1612).
132+
The order and formatting of channels in the tip can be customized with the **format** option <VersionBadge version="0.6.11" pr="1823" />, which accepts a key-value object mapping channel names to formats. Each [format](../features/formats.md) can be a string (for number or time formats), a function that receives the value as input and returns a string, true to use the default format, and null or false to suppress. The order of channels in the tip follows their order in the format object followed by any additional channels.
133+
134+
A channel’s label can be specified alongside its value as a {value, label} object; if a channel label is not specified, the associated scale’s label is used, if any; if there is no associated scale, or if the scale has no label, the channel name is used instead.
135+
136+
:::plot defer https://observablehq.com/@observablehq/plot-tip-format
137+
```js
138+
Plot.dot(olympians, {
139+
x: "weight",
140+
y: "height",
141+
stroke: "sex",
142+
channels: {
143+
name: "name",
144+
nationality: {
145+
value: "nationality",
146+
label: "country"
147+
},
148+
sport: "sport"
149+
},
150+
tip: {
151+
format: {
152+
name: true,
153+
sport: true,
154+
nationality: true,
155+
y: (d) => `${d}m`,
156+
x: (d) => `${d}kg`,
157+
stroke: false
158+
}
159+
}
160+
}).plot()
161+
```
162+
:::
133163

134164
The tip mark supports nine different orientations specified by the **anchor** option: the four sides (*top*, *right*, *bottom*, *left*), the four corners (*top-left*, *top-right*, *bottom-right*, *bottom-left*), and *middle*. Note that when *middle* is used, the tip will obscure its anchor point.
135165

docs/transforms/tree.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Given a text file, you can use `text.split("\n")` to split the contents into mul
6060
The following options control how the tabular data is organized into a hierarchy:
6161

6262
* **path** - a column specifying each node’s hierarchy location; defaults to identity
63-
* **delimiter** - the path separator; defaults to forward slash (/)
63+
* **delimiter** - the path separator, a single character; defaults to forward slash (/)
6464

6565
The **path** column is typically slash-separated, as with UNIX-based file systems or URLs.
6666

img/temporal-ordinal.png

11.9 KB
Loading

img/tip-custom.png

84.2 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@observablehq/plot",
33
"description": "A JavaScript library for exploratory data visualization.",
4-
"version": "0.6.10",
4+
"version": "0.6.11",
55
"author": {
66
"name": "Observable, Inc.",
77
"url": "https://observablehq.com"

src/channel.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export type ChannelName =
5656
| "y"
5757
| "y1"
5858
| "y2"
59-
| "z";
59+
| "z"
60+
| (string & Record<never, never>); // custom channel; see also https://github.com/microsoft/TypeScript/issues/29729
6061

6162
/**
6263
* An object literal of channel definitions. This is also used to represent

src/transforms/bin.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export type BinYInputs<T> = Omit<T, "y"> & {y?: ChannelValueBinSpec} & BinOption
164164
export type BinInputs<T> = Omit<T, "x" | "y"> & {x?: ChannelValueBinSpec; y?: ChannelValueBinSpec} & BinOptions;
165165

166166
/** Output channels (and options) for the bin transform. */
167-
export type BinOutputs = ChannelReducers<BinReducer> & GroupOutputOptions<BinReducer> & BinOptions;
167+
export type BinOutputs = ChannelReducers<BinReducer> | (GroupOutputOptions<BinReducer> & BinOptions);
168168

169169
/**
170170
* Bins on the **x** channel; then subdivides bins on the first channel of

src/transforms/group.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface GroupOutputOptions<T = Reducer> {
3939
}
4040

4141
/** Output channels (and options) for the group transform. */
42-
export type GroupOutputs = ChannelReducers & GroupOutputOptions;
42+
export type GroupOutputs = ChannelReducers | GroupOutputOptions;
4343

4444
/**
4545
* Groups on the first channel of **z**, **fill**, or **stroke**, if any, and

yarn.lock

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -419,17 +419,17 @@
419419
isoformat "^0.2.0"
420420

421421
"@observablehq/runtime@^5.7.3":
422-
version "5.9.2"
423-
resolved "https://registry.yarnpkg.com/@observablehq/runtime/-/runtime-5.9.2.tgz#a786886da93dfaf55582e1586b607520d9703bcb"
424-
integrity sha512-cRnlbTrVG5Y5FESJ3K8DiH59Ic72025e7vWVkTClGKecjyXQnpalh9Nbt1krHT9TP+nj2SclgtkiJC6bR3fMHg==
422+
version "5.9.3"
423+
resolved "https://registry.yarnpkg.com/@observablehq/runtime/-/runtime-5.9.3.tgz#a4a766b8eee7d6d2ee2ed29bb3e73d777fc9bcaf"
424+
integrity sha512-dRgqbClP4QiOSlInp6NaBXRPK7fJ2LtyPY/xppR8p9COTgwAPlP0/wHL8d1OD4f6AgwWXMqotiZqmduXsZgkSQ==
425425
dependencies:
426426
"@observablehq/inspector" "^5.0.0"
427427
"@observablehq/stdlib" "^5.0.0"
428428

429429
"@observablehq/stdlib@^5.0.0":
430-
version "5.8.2"
431-
resolved "https://registry.yarnpkg.com/@observablehq/stdlib/-/stdlib-5.8.2.tgz#0e5f73064783ed9d23a20feecd4a42bdfb996a30"
432-
integrity sha512-68Xo97UJzJNOTDkZFSOqpGifMJ7KCXGXB0EljWIYzu9CzpaAjiakdJgMm2h7xHdPRh8HKoFIEPqeVg7YKjQh0Q==
430+
version "5.8.3"
431+
resolved "https://registry.yarnpkg.com/@observablehq/stdlib/-/stdlib-5.8.3.tgz#5ddd760c60aa9102c9b1323230cbe4c9da248d3d"
432+
integrity sha512-XmuwqzAMZ8H0ICJfzd5wV3WD6nLlC2XwhMIdu2QDZppTSxGafATMSbgZ2JaiNPCejenkpERGmoC3W83FUGuNeg==
433433
dependencies:
434434
d3-array "^3.2.0"
435435
d3-dsv "^3.0.1"
@@ -720,9 +720,9 @@
720720
integrity sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==
721721

722722
"@types/geojson@*":
723-
version "7946.0.10"
724-
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.10.tgz#6dfbf5ea17142f7f9a043809f1cd4c448cb68249"
725-
integrity sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==
723+
version "7946.0.11"
724+
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.11.tgz#012c17cb2256ad8de78560da851ab914a7b9b40e"
725+
integrity sha512-L7A0AINMXQpVwxHJ4jxD6/XjZ4NDufaRlUJHjNIFKYUFBH1SvOW+neaqb0VTRSLW5suSrSu19ObFEFnfNcr+qg==
726726

727727
"@types/json-schema@^7.0.12":
728728
version "7.0.13"
@@ -735,9 +735,9 @@
735735
integrity sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==
736736

737737
"@types/node@^20.5.0":
738-
version "20.6.2"
739-
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.2.tgz#a065925409f59657022e9063275cd0b9bd7e1b12"
740-
integrity sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw==
738+
version "20.6.3"
739+
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.3.tgz#5b763b321cd3b80f6b8dde7a37e1a77ff9358dd9"
740+
integrity sha512-HksnYH4Ljr4VQgEy2lTStbCKv/P590tmPe5HqOnv9Gprffgv5WXAY+Y5Gqniu0GGqeTCUdBnzC3QSrzPkBkAMA==
741741

742742
743743
version "1.20.2"
@@ -1971,9 +1971,9 @@ glob@^8.0.3, glob@^8.1.0:
19711971
once "^1.3.0"
19721972

19731973
globals@^13.19.0:
1974-
version "13.21.0"
1975-
resolved "https://registry.yarnpkg.com/globals/-/globals-13.21.0.tgz#163aae12f34ef502f5153cfbdd3600f36c63c571"
1976-
integrity sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==
1974+
version "13.22.0"
1975+
resolved "https://registry.yarnpkg.com/globals/-/globals-13.22.0.tgz#0c9fcb9c48a2494fbb5edbfee644285543eba9d8"
1976+
integrity sha512-H1Ddc/PbZHTDVJSnj8kWptIRSD6AM3pK+mKytuIVF4uoBV7rshFlhhvA58ceJ5wp3Er58w6zj7bykMpYXt3ETw==
19771977
dependencies:
19781978
type-fest "^0.20.2"
19791979

@@ -2856,9 +2856,9 @@ slash@^3.0.0:
28562856
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
28572857

28582858
smob@^1.0.0:
2859-
version "1.4.0"
2860-
resolved "https://registry.yarnpkg.com/smob/-/smob-1.4.0.tgz#ac9751fe54b1fc1fc8286a628d4e7f824273b95a"
2861-
integrity sha512-MqR3fVulhjWuRNSMydnTlweu38UhQ0HXM4buStD/S3mc/BzX3CuM9OmhyQpmtYCvoYdl5ris6TI0ZqH355Ymqg==
2859+
version "1.4.1"
2860+
resolved "https://registry.yarnpkg.com/smob/-/smob-1.4.1.tgz#66270e7df6a7527664816c5b577a23f17ba6f5b5"
2861+
integrity sha512-9LK+E7Hv5R9u4g4C3p+jjLstaLe11MDsL21UpYaCNmapvMkYhqCV4A/f/3gyH8QjMyh6l68q9xC85vihY9ahMQ==
28622862

28632863
source-map-js@^1.0.2:
28642864
version "1.0.2"
@@ -2948,9 +2948,9 @@ tar@^6.1.11:
29482948
yallist "^4.0.0"
29492949

29502950
terser@^5.17.4:
2951-
version "5.19.4"
2952-
resolved "https://registry.yarnpkg.com/terser/-/terser-5.19.4.tgz#941426fa482bf9b40a0308ab2b3cd0cf7c775ebd"
2953-
integrity sha512-6p1DjHeuluwxDXcuT9VR8p64klWJKo1ILiy19s6C9+0Bh2+NWTX6nD9EPppiER4ICkHDVB1RkVpin/YW2nQn/g==
2951+
version "5.20.0"
2952+
resolved "https://registry.yarnpkg.com/terser/-/terser-5.20.0.tgz#ea42aea62578703e33def47d5c5b93c49772423e"
2953+
integrity sha512-e56ETryaQDyebBwJIWYB2TT6f2EZ0fL0sW/JRXNMN26zZdKi2u/E/5my5lG6jNxym6qsrVXfFRmOdV42zlAgLQ==
29542954
dependencies:
29552955
"@jridgewell/source-map" "^0.3.3"
29562956
acorn "^8.8.2"
@@ -3065,9 +3065,9 @@ vite@^4.4.9:
30653065
fsevents "~2.3.2"
30663066

30673067
vitepress@^1.0.0-rc.12:
3068-
version "1.0.0-rc.14"
3069-
resolved "https://registry.yarnpkg.com/vitepress/-/vitepress-1.0.0-rc.14.tgz#d014df7890ca26d3ef73a5c05b2a73cc659e961c"
3070-
integrity sha512-yChIeXOAcNvVnSVjhziH1vte0uhKb00PuZf7KdIMfx3ixTMAz73Nn+6gREvCv0SdH+anteGUKz5eljv0ygcgGQ==
3068+
version "1.0.0-rc.15"
3069+
resolved "https://registry.yarnpkg.com/vitepress/-/vitepress-1.0.0-rc.15.tgz#a0810e91ed2bb6000ea78c084a7263d7519840de"
3070+
integrity sha512-5criiHoEibkT/du7t6wQ2xQVsuTNuirQZbMAi0M9Hp0YzJoJvEX68Ej9p2PtNC84bYb/CxAh5QkMtMutk03lHw==
30713071
dependencies:
30723072
"@docsearch/css" "^3.5.2"
30733073
"@docsearch/js" "^3.5.2"

0 commit comments

Comments
 (0)