Skip to content

Commit d000ebd

Browse files
committed
Update README
1 parent bde46b9 commit d000ebd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
Released December 4, 2021.
66

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.
7+
Plot can now produce [legends for *color* and *opacity* scales](https://github.com/observablehq/plot/blob/main/README.md#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-
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.
9+
The new [Plot.image](https://github.com/observablehq/plot/blob/main/README.md#image) mark centers an image on the given *xy* position.
1010

1111
All marks now support a new *opacity* option, either as a constant or a channel bound to the *opacity* scale, which sets the mark’s object opacity. The *strokeOpacity* or *fillOpacity* options should be preferred for performance, but the *opacity* option is needed for some cases (such as images).
1212

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ For an inline legend, use the *scale*.**legend** option:
235235

236236
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.
237237

238-
#### *chart*.legend(*name*[, *options*])
238+
#### *plot*.legend(*name*, *options*)
239239

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.
240+
Returns a suitable legend for the given *plot*’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.
241241

242242
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:
243243

@@ -263,9 +263,13 @@ Continuous color legends are rendered as a ramp, and can be configured with the
263263
* *options*.**marginBottom** - the legend’s bottom margin
264264
* *options*.**marginLeft** - the legend’s left margin
265265

266-
#### Plot.legend({[*name*]: *scale*, ...*options*})
266+
#### Plot.legend(*options*)
267267

268-
Returns a legend for the given *scale* definition, passing the options described in the previous section.
268+
Returns a standalone legend for the given *scale* definition, passing the *options* described in the previous section. For example:
269+
270+
```js
271+
Plot.legend({color: {type: "linear"}})
272+
```
269273

270274
### Position options
271275

0 commit comments

Comments
 (0)