@ac-kit/model-chart 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/README.md +68 -4
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +3 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/render/capabilities.d.ts +13 -0
  8. package/dist/render/capabilities.d.ts.map +1 -1
  9. package/dist/render/capabilities.js +8 -0
  10. package/dist/render/capabilities.js.map +1 -1
  11. package/dist/resolve/__fixtures__/vega-lite-views.json +4727 -0
  12. package/dist/resolve/_guides.d.ts +4 -1
  13. package/dist/resolve/_guides.d.ts.map +1 -1
  14. package/dist/resolve/_guides.js +12 -3
  15. package/dist/resolve/_guides.js.map +1 -1
  16. package/dist/resolve/color-scheme.d.ts +21 -0
  17. package/dist/resolve/color-scheme.d.ts.map +1 -0
  18. package/dist/resolve/color-scheme.js +42 -0
  19. package/dist/resolve/color-scheme.js.map +1 -0
  20. package/dist/resolve/mark-geometry.d.ts +154 -0
  21. package/dist/resolve/mark-geometry.d.ts.map +1 -0
  22. package/dist/resolve/mark-geometry.js +517 -0
  23. package/dist/resolve/mark-geometry.js.map +1 -0
  24. package/dist/resolve/scale-tick-labels.d.ts +39 -0
  25. package/dist/resolve/scale-tick-labels.d.ts.map +1 -0
  26. package/dist/resolve/scale-tick-labels.js +158 -0
  27. package/dist/resolve/scale-tick-labels.js.map +1 -0
  28. package/dist/resolve/scale.d.ts +10 -2
  29. package/dist/resolve/scale.d.ts.map +1 -1
  30. package/dist/resolve/scale.js +24 -4
  31. package/dist/resolve/scale.js.map +1 -1
  32. package/dist/resolve/view-types.d.ts +6 -3
  33. package/dist/resolve/view-types.d.ts.map +1 -1
  34. package/dist/resolve/view.d.ts.map +1 -1
  35. package/dist/resolve/view.js +88 -0
  36. package/dist/resolve/view.js.map +1 -1
  37. package/dist/spec/channel.d.ts +1 -1
  38. package/dist/spec/channel.d.ts.map +1 -1
  39. package/dist/spec/channel.js +2 -0
  40. package/dist/spec/channel.js.map +1 -1
  41. package/dist/testing/__fixtures__/vega-geometry.json +1434 -0
  42. package/dist/testing/index.d.ts +2 -0
  43. package/dist/testing/index.d.ts.map +1 -0
  44. package/dist/testing/index.js +2 -0
  45. package/dist/testing/index.js.map +1 -0
  46. package/dist/testing/vega-lite-cases.d.ts +164 -0
  47. package/dist/testing/vega-lite-cases.d.ts.map +1 -0
  48. package/dist/testing/vega-lite-cases.js +143 -0
  49. package/dist/testing/vega-lite-cases.js.map +1 -0
  50. package/package.json +18 -15
@@ -11,6 +11,9 @@ export declare function fieldsTitle_(fields: readonly FieldDescriptor[]): string
11
11
  * and any `hidden` hides it.
12
12
  */
13
13
  export declare function guideOf_(channel: ScaleChannel, scale: ResolvedScale, encodings: readonly FieldEncoding[]): ResolvedGuide;
14
- /** The guides of a panel, one per scale, in the order of `scales`. */
14
+ /**
15
+ * The guides of a panel, one per scale but the offsets', in the order of
16
+ * `scales`.
17
+ */
15
18
  export declare function panelGuides_(specs: readonly PlotSpec[], scales: ReadonlyMap<ScaleChannel, ResolvedScale>): ResolvedGuide[];
16
19
  //# sourceMappingURL=_guides.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_guides.d.ts","sourceRoot":"","sources":["../../src/resolve/_guides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAkBrD,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACvB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,SAAS,aAAa,EAAE,GACjC,aAAa,CAyBf;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAC3B,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,MAAM,EAAE,WAAW,CAAC,YAAY,EAAE,aAAa,CAAC,GAC9C,aAAa,EAAE,CAqBjB"}
1
+ {"version":3,"file":"_guides.d.ts","sourceRoot":"","sources":["../../src/resolve/_guides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAkBrD,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACvB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,SAAS,aAAa,EAAE,GACjC,aAAa,CA2Bf;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,MAAM,EAAE,WAAW,CAAC,YAAY,EAAE,aAAa,CAAC,GAC9C,aAAa,EAAE,CAyBjB"}
@@ -33,8 +33,10 @@ export function guideOf_(channel, scale, encodings) {
33
33
  fieldsTitle_(scale.fields);
34
34
  const grid = axes.find((axis) => axis?.grid !== undefined)?.grid ??
35
35
  (kind === "axis" &&
36
- (channel === "x" || channel === "y") &&
37
- CONTINUOUS_KINDS_.has(scale.kind));
36
+ (channel === "theta" ||
37
+ channel === "radius" ||
38
+ ((channel === "x" || channel === "y") &&
39
+ CONTINUOUS_KINDS_.has(scale.kind))));
38
40
  return {
39
41
  kind,
40
42
  channel,
@@ -45,10 +47,17 @@ export function guideOf_(channel, scale, encodings) {
45
47
  tickValues: axes.find((axis) => axis?.tickValues !== undefined)?.tickValues,
46
48
  };
47
49
  }
48
- /** The guides of a panel, one per scale, in the order of `scales`. */
50
+ /**
51
+ * The guides of a panel, one per scale but the offsets', in the order of
52
+ * `scales`.
53
+ */
49
54
  export function panelGuides_(specs, scales) {
50
55
  const guides = [];
51
56
  for (const [channel, scale] of scales) {
57
+ // an offset reads as its parent axis' categories and the marks' colours
58
+ if (channel === "xOffset" || channel === "yOffset") {
59
+ continue;
60
+ }
52
61
  const encodings = [];
53
62
  for (const spec of specs) {
54
63
  for (const [encoded, encoding] of Object.entries(spec.encoding)) {
@@ -1 +1 @@
1
- {"version":3,"file":"_guides.js","sourceRoot":"","sources":["../../src/resolve/_guides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,uBAAuB,CAAC;AAIzE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,MAAM,cAAc,GAA8B,IAAI,GAAG,CAAC;IACzD,GAAG;IACH,GAAG;IACH,GAAG;IACH,OAAO;IACP,QAAQ;CACR,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAuC,IAAI,GAAG,CAAC;IACrE,QAAQ;IACR,KAAK;IACL,KAAK;IACL,QAAQ;IACR,MAAM;CACN,CAAC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,MAAkC;IAC9D,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,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AAI,MAAM,EAAE,CAAC;QACvC,wEAAwE;QACxE,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACpD,SAAS;QACV,CAAC;QACD,MAAM,SAAS,GAAoB,EAAE,CAAC;QACtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAG3D,EAAE,CAAC;gBACL,IACC,QAAQ,KAAK,SAAS;oBACtB,eAAe,CAAC,QAAQ,CAAC;oBACzB,cAAc,CAAC,OAAO,CAAC,KAAK,OAAO,EAClC,CAAC;oBACF,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC1B,CAAC;YACF,CAAC;QACF,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type CategoricalPaletteName, type RampName } from "@ac-kit/math-color";
2
+ /** A `ColorSchemeSpec.name` found among `@ac-kit/math-color`'s schemes. */
3
+ export type NamedColorScheme = {
4
+ readonly kind: "ramp";
5
+ readonly name: RampName;
6
+ } | {
7
+ readonly kind: "palette";
8
+ readonly name: CategoricalPaletteName;
9
+ };
10
+ /**
11
+ * The `@ac-kit/math-color` scheme a spec's colour scheme names: a categorical
12
+ * palette (`"tableau10"`, `"category10"`, …) or a sequential or diverging ramp
13
+ * (`"viridis"`, `"redBlue"`, …), compared without case, `-`, `_` or spaces,
14
+ * Vega's and ColorBrewer's short names included (`"rdbu"`, `"ylgnbu"`,
15
+ * `"gray"`). `undefined` for a name math-color does not have, which a renderer
16
+ * reports and replaces with its theme's scheme.
17
+ *
18
+ * O(name length).
19
+ */
20
+ export declare function namedColorScheme(name: string): NamedColorScheme | undefined;
21
+ //# sourceMappingURL=color-scheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-scheme.d.ts","sourceRoot":"","sources":["../../src/resolve/color-scheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,sBAAsB,EAE3B,KAAK,QAAQ,EAEb,MAAM,oBAAoB,CAAC;AAE5B,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAAC;AA8BvE;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAS3E"}
@@ -0,0 +1,42 @@
1
+ import { CATEGORICAL_PALETTE_NAMES, DIVERGING_RAMP_NAMES, SEQUENTIAL_RAMP_NAMES, } from "@ac-kit/math-color";
2
+ // Vega's and ColorBrewer's short names for math-color's ramps.
3
+ const ALIASES_ = {
4
+ rdbu: "redBlue",
5
+ rdylbu: "redYellowBlue",
6
+ rdylgn: "redYellowGreen",
7
+ brbg: "brownGreen",
8
+ prgn: "purpleGreen",
9
+ piyg: "pinkGreen",
10
+ puor: "purpleOrange",
11
+ ylgnbu: "yellowGreenBlue",
12
+ gray: "greys",
13
+ grays: "greys",
14
+ };
15
+ function key_(name) {
16
+ return name.toLowerCase().replaceAll(/[-_\s]/gu, "");
17
+ }
18
+ const RAMPS_ = new Map([
19
+ ...[...SEQUENTIAL_RAMP_NAMES, ...DIVERGING_RAMP_NAMES].map((name) => [key_(name), name]),
20
+ ...Object.entries(ALIASES_),
21
+ ]);
22
+ const PALETTES_ = new Map(CATEGORICAL_PALETTE_NAMES.map((name) => [key_(name), name]));
23
+ /**
24
+ * The `@ac-kit/math-color` scheme a spec's colour scheme names: a categorical
25
+ * palette (`"tableau10"`, `"category10"`, …) or a sequential or diverging ramp
26
+ * (`"viridis"`, `"redBlue"`, …), compared without case, `-`, `_` or spaces,
27
+ * Vega's and ColorBrewer's short names included (`"rdbu"`, `"ylgnbu"`,
28
+ * `"gray"`). `undefined` for a name math-color does not have, which a renderer
29
+ * reports and replaces with its theme's scheme.
30
+ *
31
+ * O(name length).
32
+ */
33
+ export function namedColorScheme(name) {
34
+ const key = key_(name);
35
+ const palette = PALETTES_.get(key);
36
+ if (palette !== undefined) {
37
+ return { kind: "palette", name: palette };
38
+ }
39
+ const ramp = RAMPS_.get(key);
40
+ return ramp === undefined ? undefined : { kind: "ramp", name: ramp };
41
+ }
42
+ //# sourceMappingURL=color-scheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-scheme.js","sourceRoot":"","sources":["../../src/resolve/color-scheme.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,yBAAyB,EAEzB,oBAAoB,EAEpB,qBAAqB,GACrB,MAAM,oBAAoB,CAAC;AAO5B,+DAA+D;AAC/D,MAAM,QAAQ,GAAuC;IACpD,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,gBAAgB;IACxB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,iBAAiB;IACzB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,OAAO;CACd,CAAC;AAEF,SAAS,IAAI,CAAC,IAAY;IACzB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,MAAM,GAAkC,IAAI,GAAG,CAAmB;IACvE,GAAG,CAAC,GAAG,qBAAqB,EAAE,GAAG,oBAAoB,CAAC,CAAC,GAAG,CACzD,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAU,CACrC;IACD,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;CAC3B,CAAC,CAAC;AACH,MAAM,SAAS,GAAgD,IAAI,GAAG,CACrE,yBAAyB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAU,CAAC,CACpE,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC3C,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAE7B,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtE,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { type Value } from "@ac-kit/model-dataset";
2
+ import type { Channel } from "../spec/channel.js";
3
+ import type { ResolvedScale } from "./scale.js";
4
+ import type { ResolvedLayer } from "./view-types.js";
5
+ /** Where along its band a discrete position stands. */
6
+ export type BandPart = "start" | "center" | "end";
7
+ /** Options of {@link layerChannelNumbers}. */
8
+ export type LayerChannelNumbersOptions = {
9
+ /**
10
+ * For a grid's x or y lattice axis: the shift from each cell's centre, in
11
+ * cells; −½ and ½ give its edges. Default 0.
12
+ */
13
+ readonly edge?: number;
14
+ };
15
+ /** Options of {@link layerPositions}. */
16
+ export type LayerPositionsOptions = LayerChannelNumbersOptions & {
17
+ /** Where along a band (or an offset's sub-band) to stand. Default `"center"`. */
18
+ readonly part?: BandPart;
19
+ };
20
+ /**
21
+ * The share of the least gap between distinct positions that a mark spanning a
22
+ * continuous position takes, when nothing else gives its width: a bar or a
23
+ * rectangle on a continuous axis without its `2` channel, or the span of an
24
+ * offset under a continuous parent.
25
+ */
26
+ export declare const CONTINUOUS_BAND_FILL = 0.9;
27
+ /**
28
+ * The numbers of a channel per mark, in data units: a frame column as numbers
29
+ * (NaN where missing or not numeric, time as epoch milliseconds), a grid's
30
+ * values, or a lattice axis' cell centres (cell `i` is column `i mod columns`,
31
+ * row `⌊i / columns⌋`; `edge` shifts them by cells), or a constant repeated.
32
+ * `undefined` when the layer does not encode the channel.
33
+ *
34
+ * O(marks); allocates the result (a grid's values are returned as they are).
35
+ */
36
+ export declare function layerChannelNumbers(layer: ResolvedLayer, channel: Channel, options?: LayerChannelNumbersOptions): Float64Array | undefined;
37
+ /**
38
+ * The normalised position of one value on a position scale: a continuous
39
+ * scale's `scaleNormalize`, a band or point scale's band at `part`. NaN for a
40
+ * missing value, a category outside the domain, or a scale that places nothing
41
+ * (ordinal, binning, identity).
42
+ *
43
+ * O(1) for continuous scales, O(domain) for discrete ones.
44
+ */
45
+ export declare function scaleValuePosition(scale: ResolvedScale, value: Value, part?: BandPart): number;
46
+ /**
47
+ * The normalised positions ([0, 1] along the plot, `reverse` applied) of a
48
+ * position channel per mark: continuous scales through `scaleNormalizeArray`,
49
+ * band and point scales at `part` of each band (see `scaleBandGeometry`); NaN
50
+ * for a missing value or a category outside the domain.
51
+ *
52
+ * - With an `xOffset` (`yOffset`) field, x and x2 (y and y2) land within their
53
+ * span instead: a band offset's sub-band at `part`, across the parent's
54
+ * bandwidth (a point parent's whole step, a continuous parent's
55
+ * {@link CONTINUOUS_BAND_FILL} of the least gap between its positions); a
56
+ * continuous or point offset's position (a jitter), widened at `start` and
57
+ * `end` by that share of its own least gap.
58
+ * - A constant (`{ value }`) stands where the scale of the axis' field channel
59
+ * (x2 for x, x for x2, …) puts it.
60
+ * - An offset with no parent position spans the whole plot.
61
+ *
62
+ * `undefined` when the channel has no position: absent, or on a scale that
63
+ * places nothing (ordinal, binning, identity).
64
+ *
65
+ * O(marks), O(marks log marks) where a least gap is needed; allocates the
66
+ * result.
67
+ */
68
+ export declare function layerPositions(layer: ResolvedLayer, channel: Channel, options?: LayerPositionsOptions): Float64Array | undefined;
69
+ /**
70
+ * The normalised baseline of a value axis: where 0 stands when its continuous
71
+ * domain holds it, else the domain's low end (its high end when reversed); 0
72
+ * for a discrete or absent scale. A log domain never holds 0.
73
+ *
74
+ * O(1).
75
+ */
76
+ export declare function layerBaseline(layer: ResolvedLayer, channel: "x" | "y"): number;
77
+ /** The boxes of a bar, rect or arc layer; see {@link layerBoxes}. */
78
+ export type LayerBoxes = {
79
+ /** The marks drawn, ascending: every side finite. */
80
+ readonly rows: Int32Array;
81
+ /**
82
+ * Per drawn mark, `x0, y0, x1, y1` in the panel's unit square, along the x
83
+ * and y channels (not transposed), `x0 ≤ x1` and `y0 ≤ y1`.
84
+ */
85
+ readonly boxes: Float64Array;
86
+ /**
87
+ * The axis a bar grows along from its baseline (its value axis without a `2`
88
+ * channel); `undefined` for a rect, or a bar between two channels.
89
+ */
90
+ readonly grows: "x" | "y" | undefined;
91
+ };
92
+ /** Options of {@link layerBoxes}. */
93
+ export type LayerBoxesOptions = {
94
+ /**
95
+ * The marks shown, ascending (the others hidden, through a legend): only they
96
+ * are returned, and a continuous rect's width is the least gap between their
97
+ * positions. Default: every mark.
98
+ */
99
+ readonly rows?: Int32Array;
100
+ };
101
+ /**
102
+ * Where each box of a `bar`, `rect` or `arc` layer sits, in the panel's unit
103
+ * square (polar space for an arc: read the layer with
104
+ * {@link polarSpaceLayer}):
105
+ *
106
+ * - A band position spans its band (or an offset's sub-band).
107
+ * - A position with its `2` channel spans the two.
108
+ * - A bar's value axis — the continuous one, y when both are — without its `2`
109
+ * channel grows from {@link layerBaseline}.
110
+ * - A rect over a grid's lattice spans each cell; a rect's continuous position
111
+ * without its `2` channel spans {@link CONTINUOUS_BAND_FILL} of the least gap
112
+ * between positions, centred.
113
+ * - An axis with no position spans the whole plot.
114
+ *
115
+ * A mark with a non-finite side, or a grid cell whose value is NaN for a rect,
116
+ * is not drawn.
117
+ *
118
+ * O(marks), plus O(marks log marks) where a least gap is needed.
119
+ */
120
+ export declare function layerBoxes(layer: ResolvedLayer, options?: LayerBoxesOptions): LayerBoxes;
121
+ /** The segments of a rule or link layer; see {@link layerSegments}. */
122
+ export type LayerSegments = {
123
+ /** The marks drawn, ascending: both ends finite. */
124
+ readonly rows: Int32Array;
125
+ /**
126
+ * Per drawn mark, `x0, y0, x1, y1` in the panel's unit square, along the x
127
+ * and y channels (not transposed).
128
+ */
129
+ readonly segments: Float64Array;
130
+ };
131
+ /**
132
+ * Where each segment of a `rule` (or a cartesian `link`) layer runs, in the
133
+ * panel's unit square:
134
+ *
135
+ * - X and y: from (x, y) to (x2 ?? x, y2 ?? y) — a rule with neither `2` channel
136
+ * drops from y to the baseline of its value axis ({@link layerBaseline});
137
+ * - X alone: a vertical line at x (to x2) from y2's position, else across the
138
+ * whole plot;
139
+ * - Y alone: a horizontal line at y (to y2) across the whole plot.
140
+ *
141
+ * A mark with a non-finite end is not drawn. O(marks).
142
+ */
143
+ export declare function layerSegments(layer: ResolvedLayer): LayerSegments;
144
+ /**
145
+ * A layer of a polar panel read in polar space: `theta`, `theta2`, `radius` and
146
+ * `radius2` as `x`, `x2`, `y` and `y2` (any x or y it encodes dropped), so the
147
+ * cartesian geometry ({@link layerPositions}, {@link layerBoxes}) applies
148
+ * unchanged. Polar space is the unit square of the theta (x) and radius (y)
149
+ * scales, normalised; the renderer bends it into its disc.
150
+ *
151
+ * O(channels); allocates the layer record and its channel map.
152
+ */
153
+ export declare function polarSpaceLayer(layer: ResolvedLayer): ResolvedLayer;
154
+ //# sourceMappingURL=mark-geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"m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