Skip to content

Commit c66f717

Browse files
Filmbostock
andauthored
0.6.12 (#1934)
* 0.6.12 CHANGELOG.md * cha-cha-changes * 0.6.12 * more badges * observable10 --------- Co-authored-by: Mike Bostock <[email protected]>
1 parent c8f9f32 commit c66f717

14 files changed

+134
-14
lines changed

CHANGELOG.md

+118
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,124 @@
22

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

5+
## 0.6.12
6+
7+
[Released December 7, 2023.](https://github.com/observablehq/plot/releases/tag/v0.6.12)
8+
9+
To better support dark mode, we’ve made a breaking change to default styles: the background color is now `unset` (transparent) instead of `white`. Additionally, marks that expect to use the same color as the background (for instance, the tip mark) now use the CSS custom property `--plot-background` instead of `white`.
10+
11+
As since [version 0.6.6](#066), you can override Plot’s styles via the `plot-d6a7b5` class. For example, the following stylesheet applies a dark background and white foreground:
12+
13+
```css
14+
.plot-d6a7b5 {
15+
--plot-background: #333;
16+
background: var(--plot-background);
17+
color: white;
18+
}
19+
```
20+
21+
Previously Plot forced you to choose between [rect](https://observablehq.com/plot/marks/rect), [bar](https://observablehq.com/plot/marks/bar), and [cell](https://observablehq.com/plot/marks/cell) based on whether the *x* and *y* scales were ordinal or quantitative. Rejoice: the [rect mark](https://observablehq.com/plot/marks/rect) now supports *band* scales so you can simply use rect in all cases! 🎉 (The bar and cell marks still offer conveniences for ordinal scales, so use them if you like.)
22+
23+
<img src="./img/rect-band.png" width="626" alt="A bar chart showing the relative frequency of English letters.">
24+
25+
```js
26+
Plot.rectY(alphabet, {x: "letter", y: "frequency"}).plot()
27+
```
28+
29+
Categorical color scales now default to the new *observable10* color scheme by [Jeff Pettiross](https://github.com/pettiross). These colors are intended as a drop-in replacement for *tableau10* with similar ease of discrimination and ordering, but with a slightly more saturated vibe that helps charts pop.
30+
31+
<img src="./img/observable10.png" width="600" alt="Color swatches of the ten colors in the observable10 color scheme: blue, yellow, red, teal, purple, pink, brown, light blue, green, and gray.">
32+
33+
```js
34+
Plot.cellX(d3.range(10)).plot({color: {type: "categorical"}})
35+
```
36+
37+
The new [difference mark](https://observablehq.com/plot/marks/difference) puts a metric in context by comparing it to another metric or constant value. Like the [area mark](https://observablehq.com/plot/marks/area), the region between two lines is filled; unlike the area mark, alternating color shows when the metric is above or below the comparison.
38+
39+
<img src="./img/difference-zero.png" width="630" alt="A difference chart showing a moving average of global temperature anomaly; positive anomalies are shown in green, and negative anomalies are shown in blue.">
40+
41+
```js
42+
Plot.differenceY(gistemp, Plot.windowY(28, {x: "Date", y: "Anomaly"})).plot()
43+
```
44+
45+
The chart above shows a moving average of global temperature anomaly; above-average temperatures are shown in green and below-average temperatures are shown in blue.
46+
47+
The difference mark can also compare a metric to its earlier self, showing change over time. The chart below shows the year-over-year change in Apple stock price; the gray region represents an increase over last year while the red region represents a decrease.
48+
49+
<img src="./img/difference-shift.png" width="630" alt="A difference chart showing the year-over-year change in Apple stock price; the gray region represents an increase over last year, while the red region represents a decrease.">
50+
51+
```js
52+
Plot.differenceY(
53+
aapl,
54+
Plot.shiftX("year", {
55+
x: "Date",
56+
y: "Close",
57+
positiveFillOpacity: 0.2,
58+
positiveFill: "currentColor",
59+
negativeFillOpacity: 0.8,
60+
negativeFill: "red"
61+
})
62+
).plot()
63+
```
64+
65+
The chart above is constructed using the new [shift transform](https://observablehq.com/plot/transforms/shift), which derives a time-shifted copy of a metric for the given time interval, enabling year–over-year, month-over-month, or any other period-over-period comparison.
66+
67+
The new [find reducer](https://observablehq.com/plot/transforms/group#find) allows you to pivot data with the [bin](https://observablehq.com/plot/transforms/bin) and [group](https://observablehq.com/plot/transforms/group) transforms, effectively turning “tall” data (with fewer columns) into “wide” data (with more columns). For example, say you have time-series data that has separate rows for observed daily temperatures in San Francisco (SF) and San Jose (SJ):
68+
69+
```csv
70+
date,station,tmax,tmin
71+
2020-12-31,SJ,59,43
72+
2020-12-31,SF,60,47
73+
2020-12-30,SJ,58,33
74+
2020-12-30,SF,57,40
75+
2020-12-29,SJ,62,38
76+
2020-12-29,SF,61,41
77+
2020-12-28,SJ,57,43
78+
2020-12-28,SF,56,47
79+
2020-12-27,SJ,62,43
80+
2020-12-27,SF,57,46
81+
2020-12-26,SJ,60,46
82+
2020-12-26,SF,61,49
83+
```
84+
85+
To compare the average minimum temperatures of San Francisco and San Jose as another difference chart:
86+
87+
<img src="./img/difference-find.png" width="630" alt="A difference chart showing moving averages of daily minimum temperatures of San Francisco and San Jose; the green region represents when San Francisco was warmer than San Jose, and the blue region when San Francisco was cooler than San Jose.">
88+
89+
```js
90+
Plot.plot({
91+
x: {tickFormat: "%b"},
92+
y: {grid: true},
93+
marks: [
94+
Plot.ruleY([32]),
95+
Plot.differenceY(
96+
temperature,
97+
Plot.windowY(
98+
14,
99+
Plot.groupX(
100+
{y1: Plot.find((d) => d.station === "SJ"), y2: Plot.find((d) => d.station === "SF")},
101+
{x: "date", y: "tmin"}
102+
)
103+
)
104+
)
105+
]
106+
})
107+
```
108+
109+
The green region above represents when San Francisco was warmer than San Jose, and the blue region when San Francisco was cooler than San Jose.
110+
111+
The [tip mark](https://observablehq.com/plot/marks/tip) now supports a **preferredAnchor** option, providing greater control over tip placement: if the tip fits within the frame at the preferred anchor, this anchor will be used. (In contrast, the **anchor** option uses the specified anchor regardless of whether it will fit.) The tip mark now also prefers the *bottom* anchor by default for a more traditional, less comic-like appearance.
112+
113+
The [**marker** option](https://observablehq.com/plot/features/markers) now supports new marker types: *tick*, *tick-x*, and *tick-y*. The [bin](https://observablehq.com/plot/transforms/bin) and [group](https://observablehq.com/plot/transforms/group) transforms now pass _data_ to reducers. The [group](https://observablehq.com/plot/transforms/group) and [hexbin](https://observablehq.com/plot/transforms/hexbin) transforms now support _x_ and _y_ reducers.
114+
115+
This release includes several additional fixes:
116+
117+
* The default axis for a *time* scale now uses local time.
118+
* The text mark’s **lineWidth** option is now more accurate when **monospace** is true.
119+
* The tip mark no longer truncates **title** text.
120+
* The scale **type** option is now case-insensitive.
121+
* Transform type definitions have correct overload precedence.
122+
5123
## 0.6.11
6124

7125
[Released September 20, 2023.](https://github.com/observablehq/plot/releases/tag/v0.6.11)

docs/features/markers.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ The following named markers are supported:
5656
* *dot* - a filled *circle* without a stroke and 2.5px radius
5757
* *circle*, equivalent to *circle-fill* - a filled circle with a white stroke and 3px radius
5858
* *circle-stroke* - a hollow circle with a colored stroke and a white fill and 3px radius
59-
* *tick* - a small opposing line
60-
* *tick-x* - a small horizontal line
61-
* *tick-y* - a small vertical line
59+
* *tick* <VersionBadge version="0.6.12" pr="1872" /> - a small opposing line
60+
* *tick-x* <VersionBadge version="0.6.12" pr="1872" /> - a small horizontal line
61+
* *tick-y* <VersionBadge version="0.6.12" pr="1872" /> - a small vertical line
6262

6363
If **marker** is true, it defaults to *circle*. If **marker** is a function, it will be called with a given *color* and must return an [SVG marker element](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/marker).
6464

docs/features/scales.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const align = ref(0.5);
1111
const radius = ref(8);
1212
const schemeq = ref("turbo");
1313
const schemed = ref("rdbu");
14-
const schemeo = ref("Tableau10");
14+
const schemeo = ref("Observable10");
1515
const interpolateq = ref("rgb");
1616
const anomaly = gistemp.map((d) => d.Anomaly);
1717
const aapl = shallowRef([]);
@@ -457,6 +457,7 @@ Plot also provides color schemes for discrete data. Use the *categorical* type f
457457
<option>Accent</option>
458458
<option>Category10</option>
459459
<option>Dark2</option>
460+
<option>Observable10</option>
460461
<option>Paired</option>
461462
<option>Pastel1</option>
462463
<option>Pastel2</option>
@@ -730,7 +731,7 @@ Plot.plot({
730731

731732
The normal scale types — *linear*, *sqrt*, *pow*, *log*, *symlog*, and *ordinal* — can be used to encode color. In addition, Plot supports special scale types for color:
732733

733-
* *categorical* - like *ordinal*, but defaults to *tableau10*
734+
* *categorical* - like *ordinal*, but defaults to *observable10*
734735
* *sequential* - like *linear*
735736
* *cyclical* - like *linear*, but defaults to *rainbow*
736737
* *threshold* - discretizes using thresholds given as the **domain**; defaults to *rdylbu*
@@ -878,6 +879,7 @@ Plot.plot({
878879
["Accent", d3.schemeAccent],
879880
["Category10", d3.schemeCategory10],
880881
["Dark2", d3.schemeDark2],
882+
["Observable10", Plot.scale({color: {type: "categorical"}}).range],
881883
["Paired", d3.schemePaired],
882884
["Pastel1", d3.schemePastel1],
883885
["Pastel2", d3.schemePastel2],

docs/marks/difference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ onMounted(() => {
1818

1919
</script>
2020

21-
# Difference mark <VersionBadge pr="1896" />
21+
# Difference mark <VersionBadge version="0.6.12" pr="1896" />
2222

2323
The **difference mark** puts a metric in context by comparing it. Like the [area mark](./area.md), the region between two lines is filled; unlike the area mark, alternating color shows when the metric is above or below the comparison value.
2424

docs/marks/tip.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Plot.plot({
184184
```
185185
:::
186186

187-
If you don’t specify an explicit **anchor**, the tip mark will choose one automatically, using the **preferredAnchor** <VersionBadge pr="1872" /> if it fits. The preferred anchor defaults to *bottom*, except when using the **tip** option and the [pointerY pointing mode](../interactions/pointer.md), in which case it defaults to *left*. In some cases, it may not be possible to fit the tip within the plot’s frame; consider setting the plot’s **style** to `overflow: visible;` to prevent the tip from being truncated.
187+
If you don’t specify an explicit **anchor**, the tip mark will choose one automatically, using the **preferredAnchor** <VersionBadge version="0.6.12" pr="1872" /> if it fits. The preferred anchor defaults to *bottom*, except when using the **tip** option and the [pointerY pointing mode](../interactions/pointer.md), in which case it defaults to *left*. In some cases, it may not be possible to fit the tip within the plot’s frame; consider setting the plot’s **style** to `overflow: visible;` to prevent the tip from being truncated.
188188

189189
The tip mark is compatible with transforms that derive **x** and **y** dynamically from data, such as the [centroid transform](../transforms/centroid.md) which computes polygon centroids. Below, a map of the United States shows state names. We reduce the size of the tips by setting the **textPadding** option to 3 pixels instead of the default 8.
190190

docs/transforms/group.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ The following named reducers are supported:
368368
* *deviation* - the standard deviation
369369
* *variance* - the variance per [Welford’s algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm)
370370
* *identity* - the array of values
371-
* *x* - the group’s *x* value (when grouping on *x*)
372-
* *y* - the group’s *y* value (when grouping on *y*)
371+
* *x* <VersionBadge version="0.6.12" pr="1916" /> - the group’s *x* value (when grouping on *x*)
372+
* *y* <VersionBadge version="0.6.12" pr="1916" /> - the group’s *y* value (when grouping on *y*)
373373

374374
In addition, a reducer may be specified as:
375375

@@ -440,7 +440,7 @@ Plot.groupZ({x: "proportion"}, {fill: "species"})
440440

441441
Groups on the first channel of **z**, **fill**, or **stroke**, if any. If none of **z**, **fill**, or **stroke** are channels, then all data (within each facet) is placed into a single group.
442442

443-
## find(*test*) {#find}
443+
## find(*test*) {#find} <VersionBadge version="0.6.12" pr="1914" />
444444

445445
```js
446446
Plot.groupX(

docs/transforms/hexbin.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ The following named reducers are supported:
197197
* *variance* - the variance per [Welford’s algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm)
198198
* *mode* - the value with the most occurrences
199199
* *identity* - the array of values
200-
* *x* - the hexagon’s *x* center
201-
* *y* - the hexagon’s *y* center
200+
* *x* <VersionBadge version="0.6.12" pr="1916" /> - the hexagon’s *x* center
201+
* *y* <VersionBadge version="0.6.12" pr="1916" /> - the hexagon’s *y* center
202202

203203
In addition, a reducer may be specified as:
204204

docs/transforms/shift.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ onMounted(() => {
1313

1414
</script>
1515

16-
# Shift transform <VersionBadge pr="1896" />
16+
# Shift transform <VersionBadge version="0.6.12" pr="1896" />
1717

1818
The **shift transform** is a specialized [map transform](./map.md) that derives an output **x1** channel by shifting the **x** channel; it can be used with the [difference mark](../marks/difference.md) to show change over time. For example, the chart below shows the price of Apple stock. The <span style="border-bottom: solid #01ab63 3px;">green region</span> shows when the price went up over the given interval, while the <span style="border-bottom: solid #4269d0 3px;">blue region</span> shows when the price went down.
1919

img/difference-find.png

55.8 KB
Loading

img/difference-shift.png

81.8 KB
Loading

img/difference-zero.png

61.4 KB
Loading

img/observable10.png

6.23 KB
Loading

img/rect-band.png

16.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.11",
4+
"version": "0.6.12",
55
"author": {
66
"name": "Observable, Inc.",
77
"url": "https://observablehq.com"

0 commit comments

Comments
 (0)