Skip to content

Commit 0f9e3af

Browse files
mbostockFil
andauthored
* draft changelog * tip * edits * format * edits, document tip **format** * delimiter = character * document tip option as an options object * edits * 0.6.11 * Update CHANGELOG --------- Co-authored-by: Philippe Rivière <fil@rezo.net>
1 parent f55155b commit 0f9e3af

File tree

9 files changed

+93
-6
lines changed

9 files changed

+93
-6
lines changed

CHANGELOG.md

+56
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/features/marks.md

+1-1
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

+1-1
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

+31-1
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
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

+1-1
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

+1-1
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

+2-1
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

0 commit comments

Comments
 (0)