@octane-xplat/charts 0.18.0 → 0.20.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.
package/src/core/svg.ts CHANGED
@@ -8,77 +8,79 @@ import type { PlotBox } from './scales'
8
8
  * leaf overlay (.agents/docs/notes/primitive-notes.md). */
9
9
 
10
10
  function num(v: number): string {
11
- if (!Number.isFinite(v)) {
12
- return '0'
13
- }
11
+ if (!Number.isFinite(v)) {
12
+ return '0'
13
+ }
14
14
 
15
- return Number.isInteger(v) ? String(v) : String(+v.toFixed(2))
15
+ return Number.isInteger(v) ? String(v) : String(+v.toFixed(2))
16
16
  }
17
17
 
18
18
  function esc(v: string): string {
19
- return v
20
- .replaceAll('&', '&')
21
- .replaceAll('"', '"')
22
- .replaceAll('<', '&lt;')
23
- .replaceAll('>', '&gt;')
19
+ return v
20
+ .replaceAll('&', '&amp;')
21
+ .replaceAll('"', '&quot;')
22
+ .replaceAll('<', '&lt;')
23
+ .replaceAll('>', '&gt;')
24
24
  }
25
25
 
26
26
  function paintAttrs(m: Mark): string {
27
- let out = ''
28
- if (m.fill !== undefined) {
29
- out += ` fill="${esc(m.fill)}"`
30
- }
27
+ let out = ''
31
28
 
32
- if (m.fillOpacity !== undefined) {
33
- out += ` fill-opacity="${num(m.fillOpacity)}"`
34
- }
29
+ if (m.fill !== undefined) {
30
+ out += ` fill="${esc(m.fill)}"`
31
+ }
35
32
 
36
- if (m.stroke !== undefined) {
37
- out += ` stroke="${esc(m.stroke)}"`
38
- }
33
+ if (m.fillOpacity !== undefined) {
34
+ out += ` fill-opacity="${num(m.fillOpacity)}"`
35
+ }
39
36
 
40
- if (m.strokeOpacity !== undefined) {
41
- out += ` stroke-opacity="${num(m.strokeOpacity)}"`
42
- }
37
+ if (m.stroke !== undefined) {
38
+ out += ` stroke="${esc(m.stroke)}"`
39
+ }
43
40
 
44
- if (m.strokeWidth !== undefined) {
45
- out += ` stroke-width="${num(m.strokeWidth)}"`
46
- }
41
+ if (m.strokeOpacity !== undefined) {
42
+ out += ` stroke-opacity="${num(m.strokeOpacity)}"`
43
+ }
47
44
 
48
- if (m.strokeLinecap !== undefined) {
49
- out += ` stroke-linecap="${m.strokeLinecap}"`
50
- }
45
+ if (m.strokeWidth !== undefined) {
46
+ out += ` stroke-width="${num(m.strokeWidth)}"`
47
+ }
51
48
 
52
- if (m.transform !== undefined) {
53
- out += ` transform="${esc(m.transform)}"`
54
- }
49
+ if (m.strokeLinecap !== undefined) {
50
+ out += ` stroke-linecap="${m.strokeLinecap}"`
51
+ }
55
52
 
56
- return out
53
+ if (m.transform !== undefined) {
54
+ out += ` transform="${esc(m.transform)}"`
55
+ }
56
+
57
+ return out
57
58
  }
58
59
 
59
60
  function markXml(m: Mark): string {
60
- switch (m.kind) {
61
- case 'path':
62
- return `<path d="${esc(m.d)}"${paintAttrs(m)}/>`
63
- case 'rect':
64
- return `<rect x="${num(m.x)}" y="${num(m.y)}" width="${num(m.width)}" height="${num(m.height)}"${paintAttrs(m)}/>`
65
- case 'circle':
66
- return `<circle cx="${num(m.cx)}" cy="${num(m.cy)}" r="${num(m.r)}"${paintAttrs(m)}/>`
67
- case 'line':
68
- return `<line x1="${num(m.x1)}" y1="${num(m.y1)}" x2="${num(m.x2)}" y2="${num(m.y2)}"${paintAttrs(m)}/>`
69
- }
61
+ switch (m.kind) {
62
+ case 'path':
63
+ return `<path d="${esc(m.d)}"${paintAttrs(m)}/>`
64
+ case 'rect':
65
+ return `<rect x="${num(m.x)}" y="${num(m.y)}" width="${num(m.width)}" height="${num(m.height)}"${paintAttrs(m)}/>`
66
+ case 'circle':
67
+ return `<circle cx="${num(m.cx)}" cy="${num(m.cy)}" r="${num(m.r)}"${paintAttrs(m)}/>`
68
+ case 'line':
69
+ return `<line x1="${num(m.x1)}" y1="${num(m.y1)}" x2="${num(m.x2)}" y2="${num(m.y2)}"${paintAttrs(m)}/>`
70
+ }
70
71
  }
71
72
 
72
73
  /** Chart marks are plot-space; axis rules are chart-space. Paint order:
73
74
  * gridlines under the translated marks group, frame (spine + stubs) over. */
74
75
  export function svgDocument(
75
- marks: Mark[],
76
- grid: Mark[],
77
- frame: Mark[],
78
- plot: PlotBox,
79
- width: number,
80
- height: number,
76
+ marks: Mark[],
77
+ grid: Mark[],
78
+ frame: Mark[],
79
+ plot: PlotBox,
80
+ width: number,
81
+ height: number,
81
82
  ): string {
82
- const body = `${grid.map(markXml).join('')}<g transform="translate(${num(plot.x)} ${num(plot.y)})">${marks.map(markXml).join('')}</g>${frame.map(markXml).join('')}`
83
- return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${num(width)} ${num(height)}" width="${num(width)}" height="${num(height)}">${body}</svg>`
83
+ const body = `${grid.map(markXml).join('')}<g transform="translate(${num(plot.x)} ${num(plot.y)})">${marks.map(markXml).join('')}</g>${frame.map(markXml).join('')}`
84
+
85
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${num(width)} ${num(height)}" width="${num(width)}" height="${num(height)}">${body}</svg>`
84
86
  }
@@ -2,11 +2,11 @@
2
2
  // reach .tsrx; same convention as @octane-xplat/ui index.*.ts).
3
3
  export { Chart } from './Chart.macos.tsrx'
4
4
  export type {
5
- AxisSpec,
6
- ChartDatum,
7
- ChartHit,
8
- ChartMargin,
9
- ChartProps,
10
- ChartType,
11
- SeriesSpec,
5
+ AxisSpec,
6
+ ChartDatum,
7
+ ChartHit,
8
+ ChartMargin,
9
+ ChartProps,
10
+ ChartType,
11
+ SeriesSpec,
12
12
  } from './props'
package/src/index.ts CHANGED
@@ -2,11 +2,11 @@
2
2
  // reach .tsrx; same convention as @octane-xplat/ui index.*.ts).
3
3
  export { Chart } from './Chart.tsrx'
4
4
  export type {
5
- AxisSpec,
6
- ChartDatum,
7
- ChartHit,
8
- ChartMargin,
9
- ChartProps,
10
- ChartType,
11
- SeriesSpec,
5
+ AxisSpec,
6
+ ChartDatum,
7
+ ChartHit,
8
+ ChartMargin,
9
+ ChartProps,
10
+ ChartType,
11
+ SeriesSpec,
12
12
  } from './props'
package/src/index.web.ts CHANGED
@@ -2,11 +2,11 @@
2
2
  // reach .tsrx; same convention as @octane-xplat/ui index.*.ts).
3
3
  export { Chart } from './Chart.web.tsrx'
4
4
  export type {
5
- AxisSpec,
6
- ChartDatum,
7
- ChartHit,
8
- ChartMargin,
9
- ChartProps,
10
- ChartType,
11
- SeriesSpec,
5
+ AxisSpec,
6
+ ChartDatum,
7
+ ChartHit,
8
+ ChartMargin,
9
+ ChartProps,
10
+ ChartType,
11
+ SeriesSpec,
12
12
  } from './props'
package/src/props.ts CHANGED
@@ -4,87 +4,114 @@
4
4
 
5
5
  export type ChartType = 'line' | 'area' | 'bar' | 'pie' | 'scatter'
6
6
 
7
+ /** One plotted value. */
7
8
  export interface ChartDatum {
8
- /** Bar/pie: the category label. Line/area/scatter: number or Date. */
9
- x: number | string | Date
10
- y: number
11
- /** Per-datum color override — wins over the series color (pie slices,
12
- * scatter points, individual bars). */
13
- color?: string
9
+ /** Bar/pie: the category label. Line/area/scatter: number or Date. */
10
+ x: number | string | Date
11
+ /** Value on the quantitative axis. */
12
+ y: number
13
+ /** Per-datum color override — wins over the series color (pie slices,
14
+ * scatter points, individual bars). */
15
+ color?: string
14
16
  }
15
17
 
18
+ /** One named data series. */
16
19
  export interface SeriesSpec {
17
- name: string
18
- /** Series color — stroke for line/scatter, fill for area/bar. Falls back
19
- * to the built-in palette by series index. */
20
- color?: string
21
- values: ChartDatum[]
20
+ /** Legend/tooltip name for the series. */
21
+ name: string
22
+ /** Series color — stroke for line/scatter, fill for area/bar. Falls back
23
+ * to the built-in palette by series index. */
24
+ color?: string
25
+ /** The plotted values. */
26
+ values: ChartDatum[]
22
27
  }
23
28
 
29
+ /** Per-edge space inside the chart box reserved for axis labels — the
30
+ * plot area occupies the remainder. */
24
31
  export interface ChartMargin {
25
- top?: number
26
- right?: number
27
- bottom?: number
28
- left?: number
32
+ /** Top margin in px/dips. */
33
+ top?: number
34
+ /** Right margin in px/dips. */
35
+ right?: number
36
+ /** Bottom margin in px/dips — x-axis labels live here by default. */
37
+ bottom?: number
38
+ /** Left margin in px/dips — y-axis labels live here by default. */
39
+ left?: number
29
40
  }
30
41
 
31
42
  /** Axis decomposition — gridline, tick stub, and label toggle independently
32
43
  * (Swift Charts `AxisMarks` shape). Labels render as real positioned
33
44
  * elements in the overlay, never `<text>` in markup. */
34
45
  export interface AxisSpec {
35
- /** Tick labels in the margin. Default true. */
36
- labels?: boolean
37
- /** Tick stubs on the axis spine. Default true. */
38
- ticks?: boolean
39
- /** Gridlines across the plot area. Default false. */
40
- grid?: boolean
41
- /** Desired tick count hint — a hint, not a guarantee. */
42
- tickCount?: number
43
- /** Tick label formatter; receives the domain value. */
44
- format?: (value: number | string | Date) => string
46
+ /** Tick labels in the margin. Default true. */
47
+ labels?: boolean
48
+ /** Tick stubs on the axis spine. Default true. */
49
+ ticks?: boolean
50
+ /** Gridlines across the plot area. Default false. */
51
+ grid?: boolean
52
+ /** Desired tick count hint — a hint, not a guarantee. */
53
+ tickCount?: number
54
+ /** Tick label formatter; receives the domain value. */
55
+ format?: (value: number | string | Date) => string
45
56
  }
46
57
 
58
+ /** A resolved datum reference — `x`/`y` are the datum's values, not pixels. */
47
59
  /** A resolved datum reference — `x`/`y` are the datum's values, not pixels. */
48
60
  export interface ChartHit {
49
- series: number
50
- index: number
51
- x: number | string | Date
52
- y: number
61
+ /** Series index into `data`. */
62
+ series: number
63
+ /** Datum index within the series. */
64
+ index: number
65
+ /** The datum's x value. */
66
+ x: number | string | Date
67
+ /** Value on the quantitative axis. */
68
+ y: number
53
69
  }
54
70
 
71
+ /** Props for the `<Chart>` element — one component for every chart kind,
72
+ * each platform leaf rendering natively. */
55
73
  export interface ChartProps {
56
- type: ChartType
57
- data: SeriesSpec[]
58
- /** Explicit size in px (web) / dips (native). Without `height`, the leaf
59
- * fills its parent or derives height from `aspectRatio`. */
60
- width?: number
61
- height?: number
62
- /** width/height ratio used when `height` is unset. */
63
- aspectRatio?: number
64
- /** Space reserved inside the chart box for axis labels — labels live in
65
- * the margin band, the plot in the remainder. Defaults reserve room for
66
- * x labels (bottom) and y labels (left) when those axes show labels. */
67
- margin?: ChartMargin
68
- /** Bar only: stack series instead of grouping side by side. */
69
- stacked?: boolean
70
- /** Pie only: 0–<1 inner-radius fraction — any positive value renders a
71
- * donut. */
72
- innerRadiusRatio?: number
73
- xAxis?: AxisSpec
74
- yAxis?: AxisSpec
75
- /** Legend row of series swatches. `true` = 'bottom'. Pie legends list
76
- * slices, not series. */
77
- legend?: boolean | 'top' | 'bottom'
78
- /** Show a value callout at the scrub/hover cursor. */
79
- tooltip?: boolean
80
- /** Show a snap-to-x cursor rule while scrubbing. */
81
- crosshair?: boolean
82
- /** Tap/click a datum. */
83
- onPress?: (hit: ChartHit) => void
84
- /** Scrub position changes — `null` when the gesture ends or leaves. */
85
- onScrub?: (hit: ChartHit | null) => void
86
- accessibilityLabel?: string
87
- className?: any
88
- style?: any
89
- id?: string
74
+ /** Which chart kind to render. */
75
+ type: ChartType
76
+ /** Plotted series; most types read `values`, pie reads slice x/y. */
77
+ data: SeriesSpec[]
78
+ /** Explicit size in px (web) / dips (native). Without `height`, the leaf
79
+ * fills its parent or derives height from `aspectRatio`. */
80
+ width?: number
81
+ /** Explicit height — same units as `width`. */
82
+ height?: number
83
+ /** width/height ratio used when `height` is unset. */
84
+ aspectRatio?: number
85
+ /** Space reserved inside the chart box for axis labels — labels live in
86
+ * the margin band, the plot in the remainder. Defaults reserve room for
87
+ * x labels (bottom) and y labels (left) when those axes show labels. */
88
+ margin?: ChartMargin
89
+ /** Bar only: stack series instead of grouping side by side. */
90
+ stacked?: boolean
91
+ /** Pie only: 0–<1 inner-radius fraction — any positive value renders a
92
+ * donut. */
93
+ innerRadiusRatio?: number
94
+ /** X-axis presentation options. */
95
+ xAxis?: AxisSpec
96
+ /** Y-axis presentation options. */
97
+ yAxis?: AxisSpec
98
+ /** Legend row of series swatches. `true` = 'bottom'. Pie legends list
99
+ * slices, not series. */
100
+ legend?: boolean | 'top' | 'bottom'
101
+ /** Show a value callout at the scrub/hover cursor. */
102
+ tooltip?: boolean
103
+ /** Show a snap-to-x cursor rule while scrubbing. */
104
+ crosshair?: boolean
105
+ /** Tap/click a datum. */
106
+ onPress?: (hit: ChartHit) => void
107
+ /** Scrub position changes — `null` when the gesture ends or leaves. */
108
+ onScrub?: (hit: ChartHit | null) => void
109
+ /** Accessible description of the chart for assistive tech. */
110
+ accessibilityLabel?: string
111
+ /** Class list applied to the chart element. */
112
+ className?: any
113
+ /** Inline style (string CSS or object). */
114
+ style?: any
115
+ /** Element id passed through to the host element. */
116
+ id?: string
90
117
  }
@@ -1,61 +1,59 @@
1
-
2
-
3
1
  const kebab = (key: string) => key.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase())
4
2
 
5
3
  /** Anything accepted as a style value, including nested arrays. */
6
- export type StyleInput =
7
- | string
8
- | Record<string, any>
9
- | null
10
- | undefined
11
- | readonly StyleInput[]
4
+ export type StyleInput = string | Record<string, any> | null | undefined | readonly StyleInput[]
12
5
 
13
6
  /** Merge component-emitted style defaults under the authored `style` prop.
14
7
  * Authored keys win; array styles fold in order; a string style is appended
15
8
  * after the serialized defaults so its declarations override them too. */
16
9
  export function mergeStyle(
17
- base: Record<string, any>,
18
- style?: Record<string, any> | readonly (Record<string, any> | null | undefined)[] | null,
10
+ base: Record<string, any>,
11
+ style?: Record<string, any> | readonly (Record<string, any> | null | undefined)[] | null,
19
12
  ): Record<string, any>
13
+
20
14
  export function mergeStyle(
21
- base: Record<string, any>,
22
- style?: StyleInput,
15
+ base: Record<string, any>,
16
+ style?: StyleInput,
23
17
  ): string | Record<string, any>
18
+
24
19
  export function mergeStyle(
25
- base: Record<string, any>,
26
- style?: StyleInput,
20
+ base: Record<string, any>,
21
+ style?: StyleInput,
27
22
  ): string | Record<string, any> {
28
- if (style == null) {
29
- return base
30
- }
31
-
32
- let obj: Record<string, any> = { ...base }
33
- const strings: string[] = []
34
- const add = (s: StyleInput) => {
35
- if (s == null) {
36
- return
37
- }
38
- if (typeof s === 'string') {
39
- strings.push(s)
40
- } else if (Array.isArray(s)) {
41
- for (const part of s) {
42
- add(part)
43
- }
44
- } else {
45
- obj = { ...obj, ...s }
46
- }
47
- }
48
- add(style)
49
-
50
- if (strings.length === 0) {
51
- return obj
52
- }
53
-
54
- const prefix = Object.entries(obj)
55
- .filter(([, v]) => v != null)
56
- .map(([k, v]) => `${kebab(k)}:${v}`)
57
- .join(';')
58
- return [prefix, ...strings].filter(Boolean).join(';')
23
+ if (style == null) {
24
+ return base
25
+ }
26
+
27
+ let obj: Record<string, any> = { ...base }
28
+ const strings: string[] = []
29
+ const add = (s: StyleInput) => {
30
+ if (s == null) {
31
+ return
32
+ }
33
+
34
+ if (typeof s === 'string') {
35
+ strings.push(s)
36
+ } else if (Array.isArray(s)) {
37
+ for (const part of s) {
38
+ add(part)
39
+ }
40
+ } else {
41
+ obj = { ...obj, ...s }
42
+ }
43
+ }
44
+
45
+ add(style)
46
+
47
+ if (strings.length === 0) {
48
+ return obj
49
+ }
50
+
51
+ const prefix = Object.entries(obj)
52
+ .filter(([, v]) => v != null)
53
+ .map(([k, v]) => `${kebab(k)}:${v}`)
54
+ .join(';')
55
+
56
+ return [prefix, ...strings].filter(Boolean).join(';')
59
57
  }
60
58
 
61
59
  export type StyleProp = string | Record<string, any> | readonly StyleProp[] | null | undefined
@@ -1,34 +1,35 @@
1
1
  // Kept local to avoid coupling the charts leaf to private UI helpers.
2
2
  // Foundation's public ObjC API is available through the AppKit metadata bridge.
3
3
  declare const NSString: {
4
- stringWithString(value: string): {
5
- dataUsingEncoding(encoding: number): {
6
- base64EncodedStringWithOptions(options: number): string
7
- } | null
8
- }
4
+ stringWithString(value: string): {
5
+ dataUsingEncoding(encoding: number): {
6
+ base64EncodedStringWithOptions(options: number): string
7
+ } | null
8
+ }
9
9
  }
10
10
 
11
11
  export function svgDataUri(markup: string): string {
12
- const data = NSString.stringWithString(markup).dataUsingEncoding(4) // NSUTF8StringEncoding
13
- if (!data) {
14
- throw new Error('Unable to encode SVG as UTF-8')
15
- }
12
+ const data = NSString.stringWithString(markup).dataUsingEncoding(4) // NSUTF8StringEncoding
16
13
 
17
- return `data:image/svg+xml;base64,${data.base64EncodedStringWithOptions(0)}`
14
+ if (!data) {
15
+ throw new Error('Unable to encode SVG as UTF-8')
16
+ }
17
+
18
+ return `data:image/svg+xml;base64,${data.base64EncodedStringWithOptions(0)}`
18
19
  }
19
20
 
20
21
  /** Normalize bundled markup and SVG data URIs for AppKit's image host. */
21
22
  export function appKitImageSource(src: string): string {
22
- if (src.trimStart().startsWith('<svg') || src.trimStart().startsWith('<?xml')) {
23
- return svgDataUri(src)
24
- }
23
+ if (src.trimStart().startsWith('<svg') || src.trimStart().startsWith('<?xml')) {
24
+ return svgDataUri(src)
25
+ }
25
26
 
26
- if (
27
- /^data:image\/svg\+xml[;,]/i.test(src) &&
28
- !src.slice(0, src.indexOf(',')).endsWith(';base64')
29
- ) {
30
- return svgDataUri(decodeURIComponent(src.slice(src.indexOf(',') + 1)))
31
- }
27
+ if (
28
+ /^data:image\/svg\+xml[;,]/i.test(src) &&
29
+ !src.slice(0, src.indexOf(',')).endsWith(';base64')
30
+ ) {
31
+ return svgDataUri(decodeURIComponent(src.slice(src.indexOf(',') + 1)))
32
+ }
32
33
 
33
- return src
34
+ return src
34
35
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "version": 1,
3
+ "files": [
4
+ "Chart.d.ts",
5
+ "core/axes.d.ts",
6
+ "core/hit.d.ts",
7
+ "core/marks.d.ts",
8
+ "core/scales.d.ts",
9
+ "core/scene.d.ts",
10
+ "core/svg.d.ts",
11
+ "index.d.ts",
12
+ "props.d.ts",
13
+ "style-merge.d.ts"
14
+ ]
15
+ }
@@ -0,0 +1,9 @@
1
+ import type { ChartProps } from './props.js';
2
+ /** Chart — NativeScript leaf. The core's Mark[] serialize to one svg markup
3
+ * string fed to `<svgview>` (vendored ui-svg → SVGKit/androidsvg — its
4
+ * registration arrives transitively through `@octane-xplat/ui`'s native
5
+ * entry). Axis labels, legend, tooltip, and crosshair are real views in an
6
+ * `absolutelayout` overlay — never `<text>` in the markup. Touch input on
7
+ * the overlay reports view-relative dips (`e.getX()/getY()`), matching the
8
+ * markup's coordinate space. */
9
+ export declare function Chart(props: ChartProps): unknown;
@@ -0,0 +1,26 @@
1
+ import type { AxisSpec } from '../props.js';
2
+ import type { Mark } from './marks.js';
3
+ import type { PlotBox, XScale, XScaleKind, YScale } from './scales.js';
4
+ /** A positioned text label — rendered as a real element in the overlay,
5
+ * never as svg `<text>` (androidsvg/SVGKit text is degraded). `x`/`y` is the
6
+ * box origin in chart space; `width` bounds it for alignment. */
7
+ export interface LabelSpec {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ align: 'start' | 'center' | 'end';
12
+ text: string;
13
+ axis: 'x' | 'y';
14
+ }
15
+ export interface AxisModel {
16
+ labels: LabelSpec[];
17
+ /** Spine and tick stubs — painted over marks. */
18
+ frame: Mark[];
19
+ /** Gridlines — painted under marks. */
20
+ grid: Mark[];
21
+ }
22
+ /** Default tick label formatting — SI suffixes for big magnitudes, plain
23
+ * significant digits otherwise, short month-day for dates. */
24
+ export declare function defaultFormat(value: number | string | Date): string;
25
+ export declare function xAxisModel(kind: XScaleKind, scale: XScale, spec: AxisSpec | undefined, plot: PlotBox): AxisModel;
26
+ export declare function yAxisModel(scale: YScale, spec: AxisSpec | undefined, plot: PlotBox): AxisModel;
@@ -0,0 +1,34 @@
1
+ import type { ChartHit } from '../props.js';
2
+ import type { ChartScene } from './scene.js';
3
+ export interface SceneHit extends ChartHit {
4
+ /** Datum anchor in chart space — tooltip/crosshair position. */
5
+ px: number;
6
+ py: number;
7
+ }
8
+ /** Touch slop — how far outside the plot a pointer may sit and still hit.
9
+ * Also the nearest-point distance gate for scatter. */
10
+ export declare const HIT_SLOP = 24;
11
+ /** Map a chart-space pointer position to the nearest datum. Cartesian charts
12
+ * snap to the nearest x group, then pick the closest point inside it —
13
+ * scatter gates on pointer distance instead of always snapping. Pie hits
14
+ * resolve by ring + angle. Coordinates outside the plot (+slop) miss. */
15
+ export declare function hitTest(scene: ChartScene, x: number, y: number, slop?: number): SceneHit | null;
16
+ export type ScrubPhase = 'down' | 'move' | 'up' | 'cancel' | 'hover' | 'leave' | 'tap';
17
+ export interface ScrubProps {
18
+ tooltip?: boolean;
19
+ crosshair?: boolean;
20
+ onPress?: (hit: ChartHit) => void;
21
+ onScrub?: (hit: ChartHit | null) => void;
22
+ }
23
+ /** Shared gesture → cursor state machine. Both leaves normalize their pointer
24
+ * source (DOM pointer/click events, NS `touch`+`tap`) to phases and call
25
+ * this; hit math stays identical across targets. `move` while pressed
26
+ * scrubs and fires `onScrub`; `hover` (web-only, unpressed move) moves the
27
+ * cursor without scrubbing; `up` ends the scrub and persists the cursor;
28
+ * `tap` is a completed press — fires `onPress` and updates the cursor;
29
+ * `cancel`/`leave` clear. `onPress` lives only on `tap` so NS's tap
30
+ * recognizer and the web click both reach it exactly once. */
31
+ export declare function createScrub(getScene: () => ChartScene | null, getProps: () => ScrubProps, setCursor: (hit: SceneHit | null) => void): (phase: ScrubPhase, x: number, y: number) => void;
32
+ /** Tooltip body for a hit — series name + formatted y for cartesian charts,
33
+ * slice label + value for pie. */
34
+ export declare function hitLabel(scene: ChartScene, hit: ChartHit): string;