Skip to content

Commit 7d18179

Browse files
authored
document ordinal aspectRatio (#2255)
1 parent 283d8e1 commit 7d18179

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

docs/features/plots.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ The default **width** is 640. On Observable, the width can be set to the [standa
224224
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).
225225
:::
226226

227-
The **aspectRatio** option<a id="aspectRatio" 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.
227+
The **aspectRatio** option<a id="aspectRatio" 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. The **aspectRatio** option is recommended only when *x* and *y* domains share the same units, such as millimeters. When a position scale is [ordinal](./scales.md#discrete-scales) (*point* or *band*), consecutive domain values are treated as one unit length apart; for example, if both *x* and *y* are ordinal, then an aspect ratio of one produces a square grid.
228228

229229
<p>
230230
<label class="label-input">

docs/features/scales.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Plot.plot({
292292
```
293293
:::
294294

295-
Positions scales also have a **round** option which forces the scale to snap to integer pixels. This defaults to true for point and band scales, and false for quantitative scales. Use caution with high-cardinality ordinal domains (*i.e.*, a point or band scale used to encode many different values), as rounding can lead to “wasted” space or even zero-width bands.
295+
Position scales also have a **round** option which forces the scale to snap to integer pixels. This defaults to true for point and band scales, and false for quantitative scales. Use caution with high-cardinality ordinal domains (*i.e.*, a point or band scale used to encode many different values), as rounding can lead to “wasted” space or even zero-width bands.
296296

297297
## Color scales
298298

src/plot.d.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ export interface PlotOptions extends ScaleDefaults {
3030
* height. Given an aspect ratio of *dx* / *dy*, and assuming that the *x* and
3131
* *y* scales represent equivalent units (say, degrees Celsius or meters),
3232
* computes a default height such that *dx* pixels along *x* represents the
33-
* same variation as *dy* pixels along *y*. Note: when faceting, set the *fx*
34-
* and *fy* scales’ **round** option to false for an exact aspect ratio.
33+
* same variation as *dy* pixels along *y*. When *x* or *y* is ordinal,
34+
* consecutive domain values are treated as one unit length apart. Note: when
35+
* faceting, set the *fx* and *fy* scales’ **round** option to false for an
36+
* exact aspect ratio.
3537
*/
3638
aspectRatio?: number | boolean | null;
3739

0 commit comments

Comments
 (0)