Skip to content

Commit 3dc81af

Browse files
authored
Merge branch 'main' into fil/ts-delaunay
2 parents 1537c0d + e929e17 commit 3dc81af

File tree

9 files changed

+1019
-199
lines changed

9 files changed

+1019
-199
lines changed

src/channel.d.ts

+22-6
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ export type ChannelValueDenseBinSpec = ChannelValue | ({value: ChannelValue; sca
169169
* - *width* - impute from |*x2* - *x1*|
170170
* - *height* - impute from |*y2* - *y1*|
171171
* - null - impute from input order
172+
*
173+
* If the *x* channel is not defined, the *x2* channel will be used instead if
174+
* available, and similarly for *y* and *y2*; this is useful for marks that
175+
* implicitly stack. The *data* input is typically used in conjunction with a
176+
* custom **reduce** function, as when the built-in single-channel reducers are
177+
* insufficient.
172178
*/
173179
export type ChannelDomainValue = ChannelName | "data" | "width" | "height" | null;
174180

@@ -190,12 +196,22 @@ export interface ChannelDomainOptions {
190196
reverse?: boolean;
191197

192198
/**
193-
* If a positive number, limit the domain to the first *n* sorted values; if a
194-
* negative number, limit the domain to the last *-n* sorted values. Otherwise
195-
* slices the sorted domain from *lo* (inclusive) to *hi* (exclusive); if
196-
* either *lo* or *hi* are negative, it indicates an offset from the end of
197-
* the array; if *lo* is undefined it defaults to 0, and if *hi* is undefined
198-
* it defaults to Infinity.
199+
* If a positive number, limit the domain to the first *n* sorted values. If a
200+
* negative number, limit the domain to the last *-n* sorted values. Hence, a
201+
* positive **limit** with **reverse** true will return the top *n* values in
202+
* descending order.
203+
*
204+
* If an array [*lo*, *hi*], slices the sorted domain from *lo* (inclusive) to
205+
* *hi* (exclusive). As with [*array*.slice][1], if either *lo* or *hi* are
206+
* negative, it indicates an offset from the end of the array; if *lo* is
207+
* undefined it defaults to 0, and if *hi* is undefined it defaults to
208+
* Infinity.
209+
*
210+
* Note: limiting the imputed domain of one scale, say *x*, does not affect
211+
* the imputed domain of another scale, say *y*; each scale domain is imputed
212+
* independently.
213+
*
214+
* [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
199215
*/
200216
limit?: number | [lo?: number, hi?: number];
201217
}

src/legends.d.ts

+67-23
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
import type {ScaleName, ScaleOptions} from "./scales.js";
22

3-
/** The supported legend types. */
4-
export type LegendType = "ramp" | "swatches";
5-
63
/** Options for generating a scale legend. */
74
export interface LegendOptions {
85
/**
9-
* The desired legend type; currently supported only for a discrete *color*
10-
* scale of type *ordinal*, *quantile*, *quantize*, or *threshold*. One of:
6+
* The desired legend type; one of:
7+
*
8+
* - *ramp* - place labels underneath with a connecting line, and no wrapping
9+
* - *swatches* - place labels to the right, and allow wrapping
1110
*
12-
* * *ramp* - place labels underneath with a connecting line, and no wrapping
13-
* * *swatches* - place labels to the right, and allow wrapping
11+
* The legend type can currently only be configured for a discrete *color*
12+
* scale of type *ordinal*, *quantile*, *quantize*, or *threshold*; for other
13+
* *color* scale types, or for *opacity* or *symbol* scales, the legend type
14+
* cannot be changed.
1415
*/
15-
legend?: LegendType;
16+
legend?: "ramp" | "swatches";
1617

1718
/**
1819
* How to format tick values sampled from the scale’s domain. This may be a
1920
* function, which will be passed the tick value *t* and zero-based index *i*
2021
* and must return the corresponding string. If the domain is numbers, the
21-
* tick format may also be expressed as a [d3-format
22-
* string](https://github.com/d3/d3-format/blob/main/README.md#locale_format);
23-
* or if the domain is dates, the tick format may also be expressed as a
24-
* [d3-time-format
25-
* string](https://github.com/d3/d3-time-format/blob/main/README.md#locale_format).
22+
* tick format may also be expressed as a [d3-format string][1]; or if the
23+
* domain is dates, the tick format may also be expressed as a [d3-time-format
24+
* string][2].
25+
*
26+
* [1]: https://github.com/d3/d3-format/blob/main/README.md#locale_format
27+
* [2]: https://github.com/d3/d3-time-format/blob/main/README.md#locale_format
2628
*/
2729
tickFormat?: ScaleOptions["tickFormat"];
2830

2931
/**
30-
* The [CSS
31-
* font-variant](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant)
32-
* for tick labels. For non-ordinal scales, or ordinal scales without an
33-
* interval, this defaults to *tabular-nums*.
32+
* The [CSS font-variant][1] for tick labels. For non-ordinal scales, or
33+
* ordinal scales without an interval, this defaults to *tabular-nums*.
34+
*
35+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant
3436
*/
3537
fontVariant?: ScaleOptions["fontVariant"];
3638

@@ -43,35 +45,77 @@ export interface LegendOptions {
4345
*/
4446
className?: string | null;
4547

46-
/** The constant color for *opacity* scales. Defaults to black. */
48+
/** The constant color the ramp; defaults to black. For *ramp* *opacity* legends only. */
4749
color?: string;
48-
49-
// symbol options
50+
/** The desired fill color of symbols; use *color* for a redundant encoding. For *symbol* legends only. */
5051
fill?: string;
52+
/** The desired fill opacity of symbols. For *symbol* legends only. */
5153
fillOpacity?: number;
54+
/** The desired stroke color of symbols; use *color* for a redundant encoding. For *symbol* legends only. */
5255
stroke?: string;
56+
/** The desired stroke opacity of symbols. For *symbol* legends only. */
5357
strokeOpacity?: number;
58+
/** The desired stroke width of symbols. For *symbol* legends only. */
5459
strokeWidth?: number;
60+
/** The desired radius of symbols in pixels. For *symbol* legends only. */
5561
r?: number;
5662

57-
// dimensions
63+
/**
64+
* The width of the legend in pixels. For *ramp* legends, defaults to 240; for
65+
* *swatch* legends, defaults to undefined, allowing the swatches to wrap
66+
* based on content flow.
67+
*/
5868
width?: number;
69+
70+
/**
71+
* The height of the legend in pixels; defaults to 44 plus **tickSize**. For
72+
* *ramp* legends only.
73+
*/
5974
height?: number;
75+
76+
/** The top margin in pixels; defaults to 18. For *ramp* legends only. */
6077
marginTop?: number;
78+
/** The right margin in pixels; defaults to 0. For *ramp* legends only. */
6179
marginRight?: number;
80+
/** The bottom margin in pixels; defaults to 16 plus **tickSize**. For *ramp* legends only. */
6281
marginBottom?: number;
82+
/** The left margin in pixels; defaults to 0. For *ramp* legends only. */
6383
marginLeft?: number;
6484

65-
// ramp options
85+
/** A textual label to place above the legend. For *ramp* legends only. */
6686
label?: string | null;
87+
88+
/**
89+
* The desired approximate number of axis ticks, or an explicit array of tick
90+
* values, or an interval such as *day* or *month*. For *ramp* legends only.
91+
*/
6792
ticks?: ScaleOptions["ticks"];
93+
94+
/**
95+
* The length of axis tick marks in pixels; negative values extend in the
96+
* opposite direction. For *ramp* legends only.
97+
*/
6898
tickSize?: ScaleOptions["tickSize"];
99+
100+
/**
101+
* If true, round the output value to the nearest integer (pixel); useful for
102+
* crisp edges when rendering. For *ramp* legends only.
103+
*/
69104
round?: ScaleOptions["round"];
70105

71-
// swatches options
106+
/**
107+
* The [CSS columns property][1], for a multi-column layout. For *swatches*
108+
* legends only.
109+
*
110+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/columns
111+
*/
72112
columns?: string;
113+
114+
/** The swatch width and height in pixels; defaults to 15; For *swatches* legends only. */
73115
swatchSize?: number;
116+
/** The swatch width in pixels; defaults to **swatchSize**; For *swatches* legends only. */
74117
swatchWidth?: number;
118+
/** The swatch height in pixels; defaults to **swatchSize**; For *swatches* legends only. */
75119
swatchHeight?: number;
76120
}
77121

0 commit comments

Comments
 (0)