Skip to content

Commit

Permalink
add new type defs to docs; update type style; adjust some
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Jun 28, 2024
1 parent 1bc0bc2 commit db5cfc0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
26 changes: 13 additions & 13 deletions src/content/guide/03-layercake-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The component also exports an `element` prop that represents the main wrapper, i
</LayerCake>
```

### data `Array`
### data `Array<Object|Array<any>>|Object`

A list of data items. If this is not a flat data array of objects, you'll also need to set [flatData](/guide#flatdata).

Expand All @@ -34,7 +34,7 @@ A list of data items. If this is not a flat data array of objects, you'll also n
>
```

### x `String|Function|Number|Array`
### x `String|Function|Number|Array<String|Function|Number>|undefined`

The key in each row of data that corresponds to the x-field. This can be a string, number (usually relating to an index of an array), an accessor function, or any combination of those types. This property gets converted to a function when you access it through the context.

Expand Down Expand Up @@ -109,15 +109,15 @@ The x- and y-accessors would then look like this:

Calls to `x(dataRow)` in this scenario will return the two-value array. Calls to `xGet(dataRow)` will return a two-value array, mapped through the [xScale](/guide#xscale).

### y `String|Function|Number|Array`
### y `String|Function|Number|Array<String|Function|Number>|undefined`

Same as [x](/guide#x) but for the y dimension.

### z `String|Function|Number|Array`
### z `String|Function|Number|Array<String|Function|Number>|undefined`

Same as [x](/guide#x) but for the z dimension.

### r `String|Function|Number|Array`
### r `String|Function|Number|Array<String|Function|Number>|undefined`

Same as [x](/guide#x) but for the r dimension.

Expand Down Expand Up @@ -179,7 +179,7 @@ Same as [xScale](/guide#xscale) but for the z scale. The default is `d3.scaleLin

Same as [xScale](/guide#xscale) but for the r scale. The default is [`d3.scaleSqrt()`](https://github.com/d3/d3-scale#scalesqrt).

### xDomain `Array:[min: Number|null, max: Number|null]|String[]|Number[]|Function`
### xDomain `Array:[min: Number|null, max: Number|null]|Array<Number|String>|Function`

Set a min or max on the x scale. If you want to inherit the value from the data's extent, set that value to `null`.

Expand Down Expand Up @@ -211,15 +211,15 @@ If you set a [`scaleBand`](https://github.com/d3/d3-scale#scaleband), [`scalePoi
>
```

### yDomain `Array:[min: Number|null, max: Number|null]|String[]|Number[]|Function`
### yDomain `Array:[min: Number|null, max: Number|null]|Array<Number|String>|Function`

Same as [xDomain](/guide#xdomain) but for the y scale.

### zDomain `Array:[min: Number|null, max: Number|null]|String[]|Number[]|Function`
### zDomain `Array:[min: Number|null, max: Number|null]|Array<Number|String>|Function`

Same as [xDomain](/guide#xdomain) but for the z scale.

### rDomain `Array:[min: Number|null, max: Number|null]|String[]|Number[]|Function`
### rDomain `Array:[min: Number|null, max: Number|null]|Array<Number|String>|Function`

Same as [xDomain](/guide#xdomain) but for the r scale.

Expand Down Expand Up @@ -281,7 +281,7 @@ Same as [xNice](/guide#xnice) but for the z domain.

Same as [xNice](/guide#xnice) but for the r domain.

### xRange `Function|Array:[min: Number, max: Number]|String[]|Number[]`
### xRange `Function|Array:[min: Number, max: Number]|Array<Number|String>`

Override the default x range of `[0, width]` by setting it here to an array or function with argument `({ width, height})` that returns an array.

Expand All @@ -301,19 +301,19 @@ It can also be a function:
>
```

### yRange `Function|Array:[min: Number, max: Number]|String[]|Number[]`
### yRange `Function|Array:[min: Number, max: Number]|Array<Number|String>`

Same as [xRange](/guide#xrange) but for the y scale. Override the default y range of `[0, height]` by setting it here to an array or function with argument `({ width, height})` that returns an array.

This overrides setting [yReverse](/guide#yreverse) to `true`.

### zRange `Function|Array:[min: Number, max: Number]|String[]|Number[]`
### zRange `Function|Array:[min: Number, max: Number]|Array<Number|String>`

Same as [xRange](/guide#xrange) but for the z scale. Override the default z range of `[0, width]` by setting it here to an array or function with argument `({ width, height})` that returns an array.

This overrides setting [zReverse](/guide#zreverse) to `true`.

### rRange `Function|Array:[min: Number, max: Number]|String[]|Number[]`
### rRange `Function|Array:[min: Number, max: Number]|Array<Number|String>`

Same as [xRange](/guide#xrange) but for the r scale. Override the default y range of `[1, 25]` by setting it here to an array or function with argument `({ width, height})` that returns an array. The r scale defaults to `d3.scaleSqrt` so make sure you don't use a zero in your range.

Expand Down
20 changes: 10 additions & 10 deletions src/lib/LayerCake.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
/** @type {Array<Object>|Object} [data=[]] If `data` is not a flat array of objects and you want to use any of the scales, set a flat version of the data via the `flatData` prop. */
export let data = [];
/** @type {[min: Number|null, max: Number|null]|String[]|Number[]|Function|undefined} [xDomain] Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
/** @type {[min: Number|null, max: Number|null]|Array<String|Number>|Function|undefined} [xDomain] Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
export let xDomain = undefined;
/** @type {[min: Number|null, max: Number|null]|String[]|Number[]|Function|undefined} [yDomain] Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
/** @type {[min: Number|null, max: Number|null]|Array<String|Number>|Function|undefined} [yDomain] Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
export let yDomain = undefined;
/** @type {[min: Number|null, max: Number|null]|String[]|Number[]|Function|undefined} [zDomain] Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
/** @type {[min: Number|null, max: Number|null]|Array<String|Number>|Function|undefined} [zDomain] Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
export let zDomain = undefined;
/** @type {[min: Number|null, max: Number|null]|String[]|Number[]|Function|undefined} [rDomain] Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
/** @type {[min: Number|null, max: Number|null]|Array<String|Number>|Function|undefined} [rDomain] Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
export let rDomain = undefined;
/** @type {Boolean|Number} [xNice=false] Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the x domain. */
export let xNice = false;
Expand All @@ -94,17 +94,17 @@
export let zScale = defaultScales.z;
/** @type {Function} [rScale=d3.scaleSqrt] The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. */
export let rScale = defaultScales.r;
/** @type {[min: Number, max: Number]|Function|String[]|Number[]|undefined} [xRange] Override the default x range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `xReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
/** @type {[min: Number, max: Number]|Function|Array<String|Number>|undefined} [xRange] Override the default x range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `xReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
export let xRange = undefined;
/** @type {[min: Number, max: Number]|Function|String[]|Number[]|undefined} [xRange] Override the default y range of `[0, height]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `yReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
/** @type {[min: Number, max: Number]|Function|Array<String|Number>|undefined} [xRange] Override the default y range of `[0, height]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `yReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
export let yRange = undefined;
/** @type {[min: Number, max: Number]|Function|String[]|Number[]|undefined} [zRange] Override the default z range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `zReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
/** @type {[min: Number, max: Number]|Function|Array<String|Number>|undefined} [zRange] Override the default z range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `zReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
export let zRange = undefined;
/** @type {[min: Number, max: Number]|Function|String[]|Number[]|undefined} [rRange] Override the default r range of `[1, 25]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `rReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
/** @type {[min: Number, max: Number]|Function|Array<String|Number>|undefined} [rRange] Override the default r range of `[1, 25]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `rReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
export let rRange = undefined;
/** @type {Boolean} [xReverse=false] Reverse the default x range. By default this is `false` and the range is `[0, width]`. Ignored if you set the xRange prop. */
export let xReverse = false;
/** @type {Boolean} [yReverse=true] Reverse the default y range. By default this is `true` and the range is `[height, 0]` unless using an ordinal scale with a `.bandwidth` method for `yScale`. Ignored if you set the `yRange` prop. */
/** @type {Boolean|undefined} [yReverse=true] Reverse the default y range. By default this is set dynamically and will be `true` – setting the range to `[height, 0]` unless the `yScale` has a `.bandwidth` method. Dynamic behavior is overridden if the user sets the prop. Ignored if you set the `yRange` prop. */
export let yReverse = undefined;
/** @type {Boolean} [zReverse=false] Reverse the default z range. By default this is `false` and the range is `[0, width]`. Ignored if you set the zRange prop. */
export let zReverse = false;
Expand All @@ -123,7 +123,7 @@
/** @type {{ x?: [min: Number, max: Number], y?: [min: Number, max: Number], r?: [min: Number, max: Number], z?: [min: Number, max: Number] }} [extents] Manually set the extents of the x, y or r scale as a two-dimensional array of the min and max you want. Setting values here will skip any dynamic extent calculation of the data for that dimension. */
export let extents = {};
/** @type {Array<Object>|undefined} [flatData=data] A flat version of data. */
/** @type {Array<Object|Array<any>>|undefined} [flatData=data] A flat version of data. */
export let flatData = undefined;
/** @type {Object} custom Any extra configuration values you want available on the LayerCake context. This could be useful for color lookups or additional constants. */
Expand Down

0 comments on commit db5cfc0

Please sign in to comment.