Skip to content

Commit 5b395aa

Browse files
committed
Update README, CHANGELOG
1 parent 643b4d2 commit 5b395aa

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
## 0.3.0
44

5-
Released… TK
5+
Released December 4, 2021.
66

7-
The [Plot.image(*data*[, *options*])](https://github.com/observablehq/plot/blob/main/README.md#plotimage) mark centers an image on a certain *xy* position. See the [Plot: Image documentation notebook](https://observablehq.com/@observablehq/plot-image) for details.
7+
Plot can now produce [legends for *color* and *opacity* scales](https://observablehq.com/@observablehq/plot-legends)! The new *plot*.legend(*name*) function returns a legend for the scale with the given *name* (*color* or *opacity*). Alternatively, the top-level plot *scale*.**legend** option generates an inline legend. The new standalone Plot.**legend**(*options*) function allows you to create a legend independently of a chart. Two forms of color legend are provided: *swatches* for ordinal or discrete scales (*e.g.*, threshold color scales), and *ramp* for continuous scales.
88

9-
Color legends! The new *plot*.legend(name) function returns a legend for the corresponding scale (only "color" and "opacity" are supported at the moment). Use the *legend*: true option in the plot’s color scale definition to wrap the legend with the plot in a figure element. A stand-alone Plot.**legend** function allows to create a legend independently of any chart. Two types of color legends are provided: *swatches* for ordinal scales, and *ramp* for continuous scales. See the [Plot: legends documentation notebook](https://observablehq.com/@observablehq/plot-legends) for details.
9+
The new [Plot.image(*data*[, *options*])](https://github.com/observablehq/plot/blob/main/README.md#plotimage) mark centers an image on the given *xy* position.
1010

11-
Plot.**scale**("x") now builds a scale.apply function, allowing to use the returned scale directly on data, or to create a custom legend; when applicable, a scale.invert function is also returned, which can be useful, for example, to build interactions.
11+
The scale definition returned by *plot*.**scale**(*name*) now includes a *scale*.apply function, allowing you to apply the scale’s encoding directly on the given data value. When applicable, a *scale*.invert function is also returned, which can be useful for interaction.
1212

1313
All quantitative scales now have a default domain.
1414

15-
The stylesheet is now inlined in the generated SVG element; to avoid namespace collisions, we use a randomly-generated class name which. Use the top-level **className** option to specify that class name. The default style now uses font-variant: tabular-nums for a better alignment of numbers.
16-
17-
A new top-level *margin* option allows to set all of marginLeft, marginRight, marginTop, and marginBottom at once. (This shorthand notation is also available as a facet option.)
15+
Plot’s stylesheet is now inlined in the generated SVG element rather than injected into the document head. To avoid namespace collisions, we use a randomly-generated class name; use the top-level **className** option to specify a custom class name. The default style now uses font-variant: tabular-nums for a better alignment of numbers.
1816

17+
A new top-level *margin* option allows to set all of marginLeft, marginRight, marginTop, and marginBottom at once. This shorthand notation is also available as a facet option.
1918

2019
## 0.2.9
2120

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ In vanilla HTML, Plot can be imported as an ES module, say from Skypack:
2929
```html
3030
<script type="module">
3131
32-
import * as Plot from "https://cdn.skypack.dev/@observablehq/plot@0.2";
32+
import * as Plot from "https://cdn.skypack.dev/@observablehq/plot@0.3";
3333
3434
document.body.appendChild(Plot.plot(options));
3535
@@ -40,7 +40,7 @@ Plot is also available as a UMD bundle for legacy browsers.
4040

4141
```html
4242
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
43-
<script src="https://cdn.jsdelivr.net/npm/@observablehq/plot@0.2"></script>
43+
<script src="https://cdn.jsdelivr.net/npm/@observablehq/plot@0.3"></script>
4444
<script>
4545
4646
document.body.appendChild(Plot.plot(options));
@@ -229,9 +229,15 @@ The scale object is undefined if the associated plot has no scale with the given
229229

230230
Given a scale definition, Plot can generate a legend.
231231

232+
For an inline legend, use the *scale*.**legend** option:
233+
234+
* *scale*.**legend** - if truthy, generate a legend for the specified scale
235+
236+
Currently only *color* and *opacity* scales are supported. If the *scale*.**legend** option is true, the default legend will be produced for the scale; otherwise, the meaning of the *legend* option depends on the scale type. For quantitative color scales, it defaults to *ramp* but may be set to *swatches* for a discrete scale (most commonly for *threshold* color scales); for ordinal color scales, only the *swatches* value is supported.
237+
232238
#### *chart*.legend(*name*[, *options*])
233239

234-
Returns a suitable legend for the chart’s scale with the given *name*. Currently supports only *color* and *opacity* scales. An opacity scale is treated as a color scale with varying transparency.
240+
Returns a suitable legend for the chart’s scale with the given *name*. Currently only *color* and *opacity* scales are supported. An opacity scale is treated as a color scale with varying transparency.
235241

236242
Categorical and ordinal color legends are rendered as swatches, unless *options*.**legend** is set to *ramp*. The swatches can be configured with the following options:
237243

0 commit comments

Comments
 (0)