Skip to content

Commit dab590c

Browse files
mbostockchaichontat
authored andcommitted
version badge (observablehq#1793)
* version badge * fix anchor parsing
1 parent e603e0f commit dab590c

29 files changed

+55
-39
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script setup>
2+
3+
const {version} = defineProps(["version"]);
4+
5+
</script>
6+
<template>
7+
<Badge type="tip">
8+
<a :href="`https://github.com/observablehq/plot/releases/tag/v${version}`" :title="`added in v${version}`" target="_blank" rel="external" style="color: inherit;">
9+
^{{ version }}
10+
</a>
11+
</Badge>
12+
</template>

docs/.vitepress/theme/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {useData} from "vitepress";
33
import {watch} from "vue";
44
import PlotRender from "../../components/PlotRender.js";
55
import CustomLayout from "./CustomLayout.vue";
6+
import VersionBadge from "./VersionBadge.vue";
67
import "./custom.css";
78

89
export default {
@@ -11,6 +12,7 @@ export default {
1112
enhanceApp({app, router}) {
1213
Object.defineProperty(app.config.globalProperties, "$dark", {get: () => useData().isDark.value});
1314
app.component("PlotRender", PlotRender);
15+
app.component("VersionBadge", VersionBadge);
1416
enableAnalytics(router);
1517
}
1618
};

docs/components/links.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import {readdir, readFile, stat} from "fs/promises";
22

33
// Anchors can be derived from headers, or explicitly written as {#names}.
44
export function getAnchors(text) {
5+
text = text.replace(/<(?:Version)?Badge[^/]*\/>/g, ""); // ignore badges
56
const anchors = [];
67
for (const [, header] of text.matchAll(/^#+ ([*\w][*().,\w\d -]+)\n/gm)) {
78
anchors.push(
89
header
9-
.replaceAll(/[^\w\d\s]+/g, " ")
10+
.replace(/[^\w\d\s]+/g, " ")
1011
.trim()
11-
.replaceAll(/ +/g, "-")
12+
.replace(/ +/g, "-")
1213
.toLowerCase()
1314
);
1415
}

docs/features/curves.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The following named curve methods are supported:
7979
* *step* - a piecewise constant function where *y* changes at the midpoint of *x*
8080
* *step-after* - a piecewise constant function where *y* changes after *x*
8181
* *step-before* - a piecewise constant function where *x* changes after *y*
82-
* *auto* - like *linear*, but use the (possibly spherical) [projection](./projections.md), if any
82+
* *auto* - like *linear*, but use the (possibly spherical) [projection](./projections.md), if any <VersionBadge version="0.6.1" />
8383

8484
If **curve** is a function, it will be invoked with a given *context* in the same fashion as a [D3 curve factory](https://d3js.org/d3-shape/curve#custom-curves). The *auto* curve is only available for the [line mark](../marks/line.md) and [link mark](../marks/link.md) and is typically used in conjunction with a spherical [projection](./projections.md) to interpolate along [geodesics](https://en.wikipedia.org/wiki/Geodesic).
8585

docs/features/facets.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Plot.plot({
232232

233233
## Mark facet options
234234

235-
Facets can be defined for each mark via the **fx** or **fy** channels. The **fx** and **fy** channels are computed prior to the [mark’s transform](./transforms.md), if any (*i.e.*, facet channels are not transformed). Alternatively, the [**facet** plot option](#plot-facet-options) allows top-level faceting based on data.
235+
Facets can be defined for each mark via the **fx** or **fy** channels. <VersionBadge version="0.6.1" /> The **fx** and **fy** channels are computed prior to the [mark’s transform](./transforms.md), if any (*i.e.*, facet channels are not transformed). Alternatively, the [**facet** plot option](#plot-facet-options) allows top-level faceting based on data.
236236

237237
Faceting can be explicitly enabled or disabled on a mark with the **facet** option, which accepts the following values:
238238

@@ -245,7 +245,7 @@ Faceting can be explicitly enabled or disabled on a mark with the **facet** opti
245245
When mark-level faceting is used, the default *auto* setting is equivalent to *include*: the mark will be faceted if either the **fx** or **fy** channel option (or both) is specified. The null or false option will disable faceting, while *exclude* draws the subset of the mark’s data *not* in the current facet. When a mark uses *super* faceting, it is not allowed to use position scales (*x*, *y*, *fx*, or *fy*); *super* faceting is intended for decorations, such as labels and legends.
246246

247247

248-
The **facetAnchor** option controls the placement of the mark with respect to the facets. Based on the value, the mark will be displayed on:
248+
The **facetAnchor** option <VersionBadge version="0.6.3" /> controls the placement of the mark with respect to the facets. Based on the value, the mark will be displayed on:
249249

250250
* null - non-empty facets
251251
* *top*, *right*, *bottom*, or *left* - the given side

docs/features/legends.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Categorical and ordinal color legends are rendered as swatches, unless the **leg
8989
* **columns** - the number of swatches per row
9090
* **marginLeft** - the legend’s left margin
9191
* **className** - a class name, that defaults to a randomly generated string scoping the styles
92-
* **opacity** - the swatch fill opacity
92+
* **opacity** - the swatch fill opacity <VersionBadge version="0.6.5" />
9393
* **width** - the legend’s width (in pixels)
9494

9595
Symbol legends are rendered as swatches and support the options above in addition to the following options:

docs/features/marks.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ All marks support the following style options:
476476
* **strokeDashoffset** - the [stroke dash offset](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dashoffset) (typically in pixels)
477477
* **opacity** - object opacity (a number between 0 and 1)
478478
* **mixBlendMode** - the [blend mode](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode) (*e.g.*, *multiply*)
479-
* **imageFilter** - a CSS [filter](https://developer.mozilla.org/en-US/docs/Web/CSS/filter) (*e.g.*, *blur(5px)*)
479+
* **imageFilter** - a CSS [filter](https://developer.mozilla.org/en-US/docs/Web/CSS/filter) (*e.g.*, *blur(5px)*) <VersionBadge version="0.6.7" />
480480
* **shapeRendering** - the [shape-rendering mode](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering) (*e.g.*, *crispEdges*)
481481
* **paintOrder** - the [paint order](https://developer.mozilla.org/en-US/docs/Web/CSS/paint-order) (*e.g.*, *stroke*)
482482
* **dx** - horizontal offset (in pixels; defaults to 0)
@@ -486,7 +486,7 @@ All marks support the following style options:
486486
* **ariaHidden** - if true, hide this content from the accessibility tree
487487
* **pointerEvents** - the [pointer events](https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events) (*e.g.*, *none*)
488488
* **clip** - whether and how to clip the mark
489-
* **tip** - whether to generate an implicit [pointer](../interactions/pointer.md) [tip](../marks/tip.md)
489+
* **tip** - whether to generate an implicit [pointer](../interactions/pointer.md) [tip](../marks/tip.md) <VersionBadge version="0.6.7" />
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

docs/features/plots.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ The default **width** is 640. On Observable, the width can be set to the [standa
218218
Plot does not adjust margins automatically to make room for long tick labels. If your *y* axis labels are too long, you can increase the **marginLeft** to make more room. Also consider using a different **tickFormat** for short labels (*e.g.*, `s` for SI prefix notation), or a scale **transform** (say to convert units to millions or billions).
219219
:::
220220

221-
The **aspectRatio** option<a id="aspectratio" class="header-anchor" href="#aspectratio" aria-label="Permalink to &quot;aspectRatio&quot;"></a>, if not null, computes a default **height** such that a variation of one unit in the *x* dimension is represented by the corresponding number of pixels as a variation in the *y* dimension of one unit.
221+
The **aspectRatio** option<a id="aspectRatio" class="header-anchor" href="#aspectRatio" aria-label="Permalink to &quot;aspectRatio&quot;"></a> <VersionBadge version="0.6.4" />, if not null, computes a default **height** such that a variation of one unit in the *x* dimension is represented by the corresponding number of pixels as a variation in the *y* dimension of one unit.
222222

223223
<p>
224224
<label class="label-input">

docs/features/projections.md

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

2929
</script>
3030

31-
# Projections
31+
# Projections <VersionBadge version="0.6.1" />
3232

3333
A **projection** maps abstract coordinates in *x* and *y* to pixel positions on screen. Most often, abstract coordinates are spherical (degrees longitude and latitude), as when rendering a geographic map. For example, below we show earthquakes in the last seven days with a magnitude of 2.5 or higher as reported by the [USGS](https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php). Use the slider to adjust the *orthographic* projection’s center of longitude.
3434

docs/features/scales.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ The default range depends on the scale: for position scales (*x*, *y*, *fx*, and
703703

704704
The behavior of the **unknown** scale option depends on the scale type. For quantitative and temporal scales, the unknown value is used whenever the input value is undefined, null, or NaN. For ordinal or categorical scales, the unknown value is returned for any input value outside the domain. For band or point scales, the unknown option has no effect; it is effectively always equal to undefined. If the unknown option is set to undefined (the default), or null or NaN, then the affected input values will be considered undefined and filtered from the output.
705705

706-
For data at regular intervals, such as integer values or daily samples, the [**interval** option](#scale-transforms) can be used to enforce uniformity. The specified *interval* — such as d3.utcMonth — must expose an *interval*.floor(*value*), *interval*.offset(*value*), and *interval*.range(*start*, *stop*) functions. The option can also be specified as a number, in which case it will be promoted to a numeric interval with the given step. The option can alternatively be specified as a string (*second*, *minute*, *hour*, *day*, *week*, *month*, *quarter*, *half*, *year*, *monday*, *tuesday*, *wednesday*, *thursday*, *friday*, *saturday*, *sunday*) naming the corresponding time interval, or a skip interval consisting of a number followed by the interval name (possibly pluralized), such as *3 months* or *10 years*. This option sets the default *scale*.transform to the given interval’s *interval*.floor function. In addition, the default *scale*.domain is an array of uniformly-spaced values spanning the extent of the values associated with the scale.
706+
For data at regular intervals, such as integer values or daily samples, the [**interval** option](#scale-transforms) can be used to enforce uniformity. The specified *interval* — such as d3.utcMonth — must expose an *interval*.floor(*value*), *interval*.offset(*value*), and *interval*.range(*start*, *stop*) functions. The option can also be specified as a number, in which case it will be promoted to a numeric interval with the given step. The option can alternatively be specified as a string (*second*, *minute*, *hour*, *day*, *week*, *month*, *quarter*, *half*, *year*, *monday*, *tuesday*, *wednesday*, *thursday*, *friday*, *saturday*, *sunday*) <VersionBadge version="0.6.2" /> naming the corresponding time interval, or a skip interval consisting of a number followed by the interval name (possibly pluralized), such as *3 months* or *10 years*. This option sets the default *scale*.transform to the given interval’s *interval*.floor function. In addition, the default *scale*.domain is an array of uniformly-spaced values spanning the extent of the values associated with the scale.
707707

708708
Quantitative scales can be further customized with additional options:
709709

@@ -943,7 +943,7 @@ Plot implicitly generates an [axis mark](../marks/axis.md) for position scales i
943943
* **fontVariant** - the font-variant attribute for ticks; 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*
946-
* **labelArrow** - the label arrow: *auto* (default), *up*, *right*, *down*, *left*, *none*, or true
946+
* **labelArrow** - the label arrow: *auto* (default), *up*, *right*, *down*, *left*, *none*, or true <VersionBadge version="0.6.7" />
947947
* **labelOffset** - the label position offset (in pixels; default depends on margins and orientation)
948948
* **ariaLabel** - a short label representing the axis in the accessibility tree
949949
* **ariaDescription** - a textual description for the axis

docs/features/transforms.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,15 @@ This helper for constructing derived columns returns a [*column*, *setColumn*] a
236236

237237
This method is used by Plot’s transforms to derive channels; the associated columns are populated (derived) when the **transform** option function is invoked.
238238

239-
## identity {#identity}
239+
## identity <VersionBadge version="0.6.2" /> {#identity}
240240

241241
```js
242242
Plot.contour(data, {width: w, height: h, fill: Plot.identity})
243243
```
244244

245245
This channel helper returns a source array as-is, avoiding an extra copy when defining a channel as being equal to the data.
246246

247-
## indexOf {#indexOf}
247+
## indexOf <VersionBadge version="0.6.6" /> {#indexOf}
248248

249249
```js
250250
Plot.lineY(numbers, {x: Plot.indexOf, y: Plot.identity})

docs/interactions/crosshair.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import penguins from "../data/penguins.ts";
88

99
</script>
1010

11-
# Crosshair mark
11+
# Crosshair mark <VersionBadge version="0.6.7" />
1212

1313
The **crosshair mark** shows the *x* (horizontal↔︎ position) and *y* (vertical↕︎ position) value of the point closest to the [pointer](./pointer.md) on the bottom and left sides of the frame, respectively.
1414

docs/interactions/pointer.md

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

2222
</script>
2323

24-
# Pointer transform
24+
# Pointer transform <VersionBadge version="0.6.7" />
2525

2626
The **pointer transform** filters a mark interactively such that only the point closest to the pointer is rendered. It is typically used to show details on hover, often with a [tip](../marks/tip.md) or [crosshair](./crosshair.md) mark, but it can be paired with any mark.
2727

docs/marks/auto.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ onMounted(() => {
1515

1616
</script>
1717

18-
# Auto mark
18+
# Auto mark <VersionBadge version="0.6.3" />
1919

2020
The magic ✨ **auto mark** automatically selects a mark type that best represents the given dimensions of the data according to some simple heuristics. The auto mark — which powers [Observable’s chart cell](https://observablehq.com/@observablehq/chart-cell) — is intended to support fast exploratory analysis where the goal is to get a useful plot as quickly as possible. For example, two quantitative dimensions make a scatterplot:
2121

@@ -228,7 +228,7 @@ Plot.auto(olympians, {x: "weight", y: "height", color: "count"}) // equivalent t
228228

229229
Returns an automatically-chosen mark with the given *data* and *options*, suitable for a quick view of the data.
230230

231-
## autoSpec(*data*, *options*) {#autoSpec}
231+
## autoSpec(*data*, *options*) <VersionBadge version="0.6.4" /> {#autoSpec}
232232

233233
```js
234234
Plot.autoSpec(olympians, {x: "weight", y: "height", color: "count"})

docs/marks/axis.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const responses = [
2121

2222
</script>
2323

24-
# Axis mark
24+
# Axis mark <VersionBadge version="0.6.3" />
2525

2626
The **axis mark** conveys the meaning of a position [scale](../features/scales.md): _x_ or _y_, and _fx_ or _fy_ when [faceting](../features/facets.md). Plot automatically adds default axis marks as needed, but you can customize the appearance of axes either through scale options or by explicitly declaring an axis mark.
2727

@@ -143,7 +143,7 @@ Plot.plot({
143143
```
144144
:::
145145

146-
Time axes default to a consistent multi-line tick format, [à la Datawrapper](https://blog.datawrapper.de/new-axis-ticks/), for example showing the first month of each quarter, and the year:
146+
Time axes default to a consistent multi-line tick format <VersionBadge version="0.6.9" />, [à la Datawrapper](https://blog.datawrapper.de/new-axis-ticks/), for example showing the first month of each quarter, and the year:
147147

148148
:::plot https://observablehq.com/@observablehq/plot-datawrapper-style-date-axis
149149
```js
@@ -345,7 +345,7 @@ In addition to the [standard mark options](../features/marks.md), the axis mark
345345
* **fontVariant** - the ticks’ font-variant; defaults to *tabular-nums* for quantitative axes
346346
* **label** - a string to label the axis; defaults to the scale’s label, perhaps with an arrow
347347
* **labelAnchor** - the label anchor: *top*, *right*, *bottom*, *left*, or *center*
348-
* **labelArrow** - the label arrow: *auto* (default), *up*, *right*, *down*, *left*, *none*, or true
348+
* **labelArrow** - the label arrow: *auto* (default), *up*, *right*, *down*, *left*, *none*, or true <VersionBadge version="0.6.7" />
349349
* **labelOffset** - the label position offset (in pixels; default depends on margins and orientation)
350350
* **color** - the color of the ticks and labels (defaults to *currentColor*)
351351
* **textStroke** - the color of the stroke around tick labels (defaults to *none*)

docs/marks/bollinger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const k = ref(2);
1010

1111
</script>
1212

13-
# Bollinger mark
13+
# Bollinger mark <Badge type="warning" text="prerelease" />
1414

1515
The **bollinger mark** is a [composite mark](../features/marks.md#marks) consisting of a [line](./line.md) representing a moving average and an [area](./area.md) representing volatility as a band; the band thickness is proportional to the deviation of nearby values. The bollinger mark is often used to analyze the price of financial instruments such as stocks.
1616

docs/marks/contour.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function mandelbrot(x, y) {
2323

2424
</script>
2525

26-
# Contour mark
26+
# Contour mark <VersionBadge version="0.6.2" />
2727

2828
:::tip
2929
To produce a heatmap instead of contours, see the [raster mark](./raster.md). For contours of estimated point density, see the [density mark](./density.md).

docs/marks/frame.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Plot.plot({
9393
Or: `Plot.rect({length: 1}, {fy: ["Gentoo"], stroke: "currentColor"})`.
9494
:::
9595

96-
The **anchor** option, if specified to a value of *left*, *right*, *top* or *bottom*, draws only that side of the frame. In that case, the **fill** and **rx**, **ry** options are ignored.
96+
The **anchor** option <VersionBadge version="0.6.3" />, if specified to a value of *left*, *right*, *top* or *bottom*, draws only that side of the frame. In that case, the **fill** and **rx**, **ry** options are ignored.
9797

9898
:::plot
9999
```js

docs/marks/geo.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ onMounted(() => {
3131

3232
</script>
3333

34-
# Geo mark
34+
# Geo mark <VersionBadge version="0.6.1" />
3535

3636
The **geo mark** draws geographic features — polygons, lines, points, and other geometry — often as thematic maps. It works with Plot’s [projection system](../features/projections.md). For example, the [choropleth map](https://en.wikipedia.org/wiki/Choropleth_map) below shows unemployment by county in the United States.
3737

@@ -184,15 +184,15 @@ Plot.geo(counties, {fill: (d) => d.properties.rate})
184184

185185
Returns a new geo mark with the given *data* and *options*. If *data* is a GeoJSON feature collection, then the mark’s data is *data*.features; if *data* is a GeoJSON geometry collection, then the mark’s data is *data*.geometries; if *data* is some other GeoJSON object, then the mark’s data is the single-element array [*data*]. If the **geometry** option is not specified, *data* is assumed to be a GeoJSON object or an iterable of GeoJSON objects.
186186

187-
## sphere(*options*) {#sphere}
187+
## sphere(*options*) <VersionBadge version="0.6.1" /> {#sphere}
188188

189189
```js
190190
Plot.sphere()
191191
```
192192

193193
Returns a new geo mark with a *Sphere* geometry object and the given *options*.
194194

195-
## graticule(*options*) {#graticule}
195+
## graticule(*options*) <VersionBadge version="0.6.1" /> {#graticule}
196196

197197
```js
198198
Plot.graticule()

docs/marks/grid.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const atop = ref(true);
99

1010
</script>
1111

12-
# Grid mark
12+
# Grid mark <VersionBadge version="0.6.3" />
1313

1414
The **grid mark** is a specially-configured [rule](./rule.md) for drawing an axis-aligned grid. Like the [axis mark](./axis.md), a grid mark is automatically generated by Plot when you use the **grid** scale option. But you can also declare a grid mark explicitly, for example to draw grid lines atop rather than below bars.
1515

0 commit comments

Comments
 (0)