@octane-xplat/charts 0.19.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/README.md +2 -102
- package/package.json +14 -14
- package/src/Chart.macos.tsrx +248 -246
- package/src/Chart.tsrx +249 -247
- package/src/Chart.web.tsrx +236 -226
- package/src/appkit-pointer.macos.ts +91 -76
- package/src/core/axes.ts +175 -168
- package/src/core/hit.ts +197 -177
- package/src/core/marks.ts +336 -319
- package/src/core/scales.ts +128 -115
- package/src/core/scene.ts +123 -120
- package/src/core/svg.ts +52 -50
- package/src/index.macos.ts +7 -7
- package/src/index.ts +7 -7
- package/src/index.web.ts +7 -7
- package/src/props.ts +83 -83
- package/src/style-merge.ts +40 -37
- package/src/svg-image.macos.ts +21 -20
- package/types/generated/.tsrx-typegen-manifest.json +1 -7
- package/types/generated/Chart.macos.d.ts +0 -7
- package/types/generated/Chart.web.d.ts +0 -10
- package/types/generated/appkit-pointer.macos.d.ts +0 -37
- package/types/generated/index.macos.d.ts +0 -2
- package/types/generated/index.web.d.ts +0 -2
- package/types/generated/svg-image.macos.d.ts +0 -3
package/README.md
CHANGED
|
@@ -1,105 +1,5 @@
|
|
|
1
1
|
# @octane-xplat/charts
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
provides shared chart data and interaction props with web, iOS/Android, and
|
|
5
|
-
experimental macOS AppKit implementations.
|
|
3
|
+
[Documentation](https://octane-xplat.goddardai.org/package-charts).
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Start with a [configured Xplat app](https://octane-xplat.goddardai.org/toolchain#create-and-run),
|
|
10
|
-
then install from its directory:
|
|
11
|
-
|
|
12
|
-
```sh
|
|
13
|
-
bun add @octane-xplat/charts
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Put this component in a `.tsx` or `.tsrx` screen. Each series has a name and
|
|
17
|
-
an array of `{ x, y }` values; bars use category names for `x`:
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
import { Chart } from '@octane-xplat/charts'
|
|
21
|
-
|
|
22
|
-
export function PackingChart() {
|
|
23
|
-
return (
|
|
24
|
-
<Chart
|
|
25
|
-
type="bar"
|
|
26
|
-
width={320}
|
|
27
|
-
height={220}
|
|
28
|
-
accessibilityLabel="Packed items by bag: carry-on 4, day bag 2"
|
|
29
|
-
data={[
|
|
30
|
-
{
|
|
31
|
-
name: 'Packed items',
|
|
32
|
-
values: [
|
|
33
|
-
{ x: 'Carry-on', y: 4 },
|
|
34
|
-
{ x: 'Day bag', y: 2 },
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
]}
|
|
38
|
-
/>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The screen should show two bars, with Carry-on twice the height of Day bag.
|
|
44
|
-
Keep a text summary available for readers who cannot use the chart. If the
|
|
45
|
-
chart is blank, check that its container has nonzero size and the dataset is
|
|
46
|
-
not empty.
|
|
47
|
-
|
|
48
|
-
## Choose the data shape
|
|
49
|
-
|
|
50
|
-
Bar and pie charts use category labels. Line, area, and scatter charts use
|
|
51
|
-
numbers or dates on the horizontal axis. Use the exported types to check data
|
|
52
|
-
before passing it to a chart:
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
import type { SeriesSpec } from '@octane-xplat/charts'
|
|
56
|
-
|
|
57
|
-
const progress: SeriesSpec[] = [
|
|
58
|
-
{
|
|
59
|
-
name: 'Items packed',
|
|
60
|
-
values: [
|
|
61
|
-
{ x: 1, y: 2 },
|
|
62
|
-
{ x: 2, y: 5 },
|
|
63
|
-
{ x: 3, y: 6 },
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
]
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Respond to pointing and tapping
|
|
70
|
-
|
|
71
|
-
Add `tooltip` or `crosshair` to show the value under the pointer, `onScrub` to
|
|
72
|
-
follow it, and `onPress` to react when someone picks a datum. On web and macOS
|
|
73
|
-
AppKit, hovering moves the cursor, dragging scrubs and clicking presses the
|
|
74
|
-
point under the pointer. On iOS and Android, touching and dragging scrubs and
|
|
75
|
-
tapping presses.
|
|
76
|
-
|
|
77
|
-
```tsx
|
|
78
|
-
import { useState } from 'octane'
|
|
79
|
-
import { Chart, type ChartHit } from '@octane-xplat/charts'
|
|
80
|
-
|
|
81
|
-
export function StepsChart() {
|
|
82
|
-
const [picked, setPicked] = useState<ChartHit | null>(null)
|
|
83
|
-
return (
|
|
84
|
-
<Chart
|
|
85
|
-
type="line"
|
|
86
|
-
width={320}
|
|
87
|
-
height={200}
|
|
88
|
-
tooltip
|
|
89
|
-
crosshair
|
|
90
|
-
onPress={setPicked}
|
|
91
|
-
accessibilityLabel={picked ? `Picked ${picked.y} steps` : 'Steps per day'}
|
|
92
|
-
data={[{ name: 'Steps', values: [{ x: 1, y: 4200 }, { x: 2, y: 6100 }, { x: 3, y: 5300 }] }]}
|
|
93
|
-
/>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
AppKit hover, drag and click coordinates come from source that has not yet
|
|
99
|
-
been checked on a running Mac.
|
|
100
|
-
|
|
101
|
-
The shared geometry uses D3 and SVG. This does not establish identical font
|
|
102
|
-
metrics, assistive-technology behavior, or OS input on every host. Check the
|
|
103
|
-
[target limits](https://octane-xplat.goddardai.org/known-limits) and run the
|
|
104
|
-
chart on the targets you ship. Exact options live in the
|
|
105
|
-
[public prop declarations](https://github.com/octane-xplat/octane-xplat/blob/main/packages/charts/src/props.ts).
|
|
5
|
+
[API reference](https://octane-xplat.goddardai.org/api-charts).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/charts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Cross-platform SVG charts for Octane xplat — a DOM-free d3 core with web, iOS/Android, and macOS AppKit leaves",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"android",
|
|
@@ -51,30 +51,30 @@
|
|
|
51
51
|
"pack:check": "tsrx-typegen --pack-check"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@octane-xplat/jsx": "0.
|
|
55
|
-
"d3-array": "3.2.
|
|
56
|
-
"d3-format": "3.1.
|
|
57
|
-
"d3-scale": "4.0.
|
|
58
|
-
"d3-shape": "3.2.
|
|
59
|
-
"d3-time-format": "4.1.
|
|
54
|
+
"@octane-xplat/jsx": "0.20.0",
|
|
55
|
+
"d3-array": "3.2.5",
|
|
56
|
+
"d3-format": "3.1.3",
|
|
57
|
+
"d3-scale": "4.0.3",
|
|
58
|
+
"d3-shape": "3.2.1",
|
|
59
|
+
"d3-time-format": "4.1.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@nativescript-community/octane": "0.2.5",
|
|
63
63
|
"@nativescript/core": "9.1.3",
|
|
64
|
-
"@octane-xplat/macos-
|
|
65
|
-
"@octane-xplat/ui": "0.
|
|
64
|
+
"@octane-xplat/macos-appkit": "0.20.0",
|
|
65
|
+
"@octane-xplat/ui": "0.20.0",
|
|
66
66
|
"@octanejs/vite-plugin": "0.5.0",
|
|
67
|
-
"@tsrx/typescript-plugin": "0.4.11",
|
|
68
67
|
"@types/d3-array": "3.2.2",
|
|
69
68
|
"@types/d3-format": "3.0.4",
|
|
70
69
|
"@types/d3-scale": "4.0.9",
|
|
71
70
|
"@types/d3-shape": "3.2.0",
|
|
72
71
|
"@types/d3-time-format": "4.0.3",
|
|
73
72
|
"octane": "0.16.3",
|
|
74
|
-
"tsrx-typegen": "0.
|
|
75
|
-
"typescript": "
|
|
76
|
-
"vite": "8.3.
|
|
77
|
-
"vitest": "4.1.11"
|
|
73
|
+
"tsrx-typegen": "0.6.1",
|
|
74
|
+
"typescript": "7.1.0-beta",
|
|
75
|
+
"vite": "8.3.6",
|
|
76
|
+
"vitest": "4.1.11",
|
|
77
|
+
"@tsrx/content-mapper": "0.1.2"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"@nativescript-community/octane": ">=0.2.1 <1",
|
package/src/Chart.macos.tsrx
CHANGED
|
@@ -19,261 +19,263 @@ const TIP_ESTIMATE_CHAR = 6.2
|
|
|
19
19
|
* unqualified. AppKit does not deliver onTouch, so touch scrubbing is
|
|
20
20
|
* unavailable. */
|
|
21
21
|
export function Chart(props: ChartProps): unknown @{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
propsRef.current = props
|
|
22
|
+
const measure = useMeasure()
|
|
23
|
+
const [cursor, setCursor] = useState<SceneHit | null>(null)
|
|
24
|
+
const sceneRef = useRef<ChartScene | null>(null)
|
|
25
|
+
const propsRef = useRef(props)
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
const w = props.width ?? bounds?.width ?? 0
|
|
30
|
-
const h =
|
|
31
|
-
props.height ??
|
|
32
|
-
(props.aspectRatio && w > 0
|
|
33
|
-
? w / props.aspectRatio
|
|
34
|
-
: bounds?.height && bounds.height > 0
|
|
35
|
-
? bounds.height
|
|
36
|
-
: w > 0
|
|
37
|
-
? w / 1.6
|
|
38
|
-
: 0)
|
|
27
|
+
propsRef.current = props
|
|
39
28
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
h,
|
|
52
|
-
],
|
|
53
|
-
)
|
|
29
|
+
const bounds = measure.bounds
|
|
30
|
+
const w = props.width ?? bounds?.width ?? 0
|
|
31
|
+
const h =
|
|
32
|
+
props.height ??
|
|
33
|
+
(props.aspectRatio && w > 0
|
|
34
|
+
? w / props.aspectRatio
|
|
35
|
+
: bounds?.height && bounds.height > 0
|
|
36
|
+
? bounds.height
|
|
37
|
+
: w > 0
|
|
38
|
+
? w / 1.6
|
|
39
|
+
: 0)
|
|
54
40
|
|
|
55
|
-
|
|
41
|
+
const scene = useMemo(
|
|
42
|
+
() => (w > 0 && h > 0 ? computeScene(propsRef.current, w, h) : null),
|
|
43
|
+
[
|
|
44
|
+
props.type,
|
|
45
|
+
props.data,
|
|
46
|
+
props.margin,
|
|
47
|
+
props.stacked,
|
|
48
|
+
props.innerRadiusRatio,
|
|
49
|
+
props.xAxis,
|
|
50
|
+
props.yAxis,
|
|
51
|
+
w,
|
|
52
|
+
h,
|
|
53
|
+
],
|
|
54
|
+
)
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
const pointer = useMemo(
|
|
59
|
-
() =>
|
|
60
|
-
createAppKitChartPointer(
|
|
61
|
-
createScrub(
|
|
62
|
-
() => sceneRef.current,
|
|
63
|
-
() => propsRef.current,
|
|
64
|
-
setCursor,
|
|
65
|
-
),
|
|
66
|
-
() => ({
|
|
67
|
-
width: sceneRef.current?.width ?? 0,
|
|
68
|
-
height: sceneRef.current?.height ?? 0,
|
|
69
|
-
}),
|
|
70
|
-
),
|
|
71
|
-
[],
|
|
72
|
-
)
|
|
56
|
+
sceneRef.current = scene
|
|
73
57
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
58
|
+
const interactive = !!(props.onPress || props.onScrub || props.tooltip || props.crosshair)
|
|
59
|
+
const pointer = useMemo(
|
|
60
|
+
() =>
|
|
61
|
+
createAppKitChartPointer(
|
|
62
|
+
createScrub(
|
|
63
|
+
() => sceneRef.current,
|
|
64
|
+
() => propsRef.current,
|
|
65
|
+
setCursor,
|
|
66
|
+
),
|
|
67
|
+
() => ({
|
|
68
|
+
width: sceneRef.current?.width ?? 0,
|
|
69
|
+
height: sceneRef.current?.height ?? 0,
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
[],
|
|
73
|
+
)
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
const [tapView, setTapView] = useState<any>(null)
|
|
76
|
+
const bindTapView = useCallback((view: any) => setTapView(view), [])
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!interactive || !tapView) {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const dotColor =
|
|
90
|
-
cursor && scene
|
|
91
|
-
? scene.pie
|
|
92
|
-
? scene.pie.slices.find((s) => s.series === cursor.series && s.index === cursor.index)
|
|
93
|
-
?.color
|
|
94
|
-
: scene.series[cursor.series]?.color
|
|
95
|
-
: undefined
|
|
83
|
+
return pointer.observe(tapView)
|
|
84
|
+
}, [interactive, tapView, pointer])
|
|
96
85
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const tipLeft =
|
|
100
|
-
cursor && scene
|
|
101
|
-
? Math.min(Math.max(0, cursor.px - tipWidth / 2), Math.max(0, scene.width - tipWidth))
|
|
102
|
-
: 0
|
|
86
|
+
const markup = scene?.markup ?? EMPTY_SVG
|
|
87
|
+
const imageSource = useMemo(() => appKitImageSource(markup), [markup])
|
|
103
88
|
|
|
104
|
-
|
|
89
|
+
const legend = props.legend === true ? 'bottom' : props.legend
|
|
90
|
+
const plot = scene?.plot
|
|
91
|
+
const dotColor =
|
|
92
|
+
cursor && scene
|
|
93
|
+
? scene.pie
|
|
94
|
+
? scene.pie.slices.find((s) => s.series === cursor.series && s.index === cursor.index)
|
|
95
|
+
?.color
|
|
96
|
+
: scene.series[cursor.series]?.color
|
|
97
|
+
: undefined
|
|
105
98
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
99
|
+
const tipText = cursor && scene ? hitLabel(scene, cursor) : null
|
|
100
|
+
const tipWidth = tipText ? tipText.length * TIP_ESTIMATE_CHAR + 14 : 0
|
|
101
|
+
const tipLeft =
|
|
102
|
+
cursor && scene
|
|
103
|
+
? Math.min(Math.max(0, cursor.px - tipWidth / 2), Math.max(0, scene.width - tipWidth))
|
|
104
|
+
: 0
|
|
105
|
+
|
|
106
|
+
const tipTop = cursor ? cursor.py - 30 : 0
|
|
107
|
+
|
|
108
|
+
<masonview
|
|
109
|
+
id={props.id}
|
|
110
|
+
className={props.className}
|
|
111
|
+
style={{
|
|
112
|
+
display: 'flex',
|
|
113
|
+
flexDirection: 'column',
|
|
114
|
+
...props.style,
|
|
115
|
+
}}
|
|
116
|
+
accessible={props.accessibilityLabel != null}
|
|
117
|
+
accessibilityRole={'image'}
|
|
118
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
119
|
+
>
|
|
120
|
+
@if (legend === 'top' && scene) {
|
|
121
|
+
<masonview
|
|
122
|
+
style={mergeStyle(
|
|
123
|
+
{ flexDirection: 'row', flexWrap: 'wrap' },
|
|
124
|
+
{
|
|
125
|
+
display: 'flex',
|
|
126
|
+
paddingBottom: 4,
|
|
127
|
+
},
|
|
128
|
+
)}
|
|
129
|
+
>
|
|
130
|
+
{scene.legend.map((item) => (
|
|
131
|
+
<masonview
|
|
132
|
+
style={mergeStyle(
|
|
133
|
+
{ flexDirection: 'row', alignItems: 'center' },
|
|
134
|
+
{
|
|
135
|
+
display: 'flex',
|
|
136
|
+
marginRight: 12,
|
|
137
|
+
},
|
|
138
|
+
)}
|
|
139
|
+
>
|
|
140
|
+
<masonview
|
|
141
|
+
style={{
|
|
142
|
+
display: 'flex',
|
|
143
|
+
width: 10,
|
|
144
|
+
height: 10,
|
|
145
|
+
borderRadius: 2,
|
|
146
|
+
backgroundColor: item.color,
|
|
147
|
+
marginRight: 4,
|
|
148
|
+
}}
|
|
149
|
+
/>
|
|
150
|
+
<label text={item.text} style={{ fontSize: 11 }} />
|
|
151
|
+
</masonview>
|
|
152
|
+
))}
|
|
153
|
+
</masonview>
|
|
154
|
+
}
|
|
155
|
+
<masonview
|
|
156
|
+
ref={measure.ref}
|
|
157
|
+
style={{
|
|
158
|
+
display: 'grid',
|
|
159
|
+
width: props.width,
|
|
160
|
+
height: props.height ?? (props.aspectRatio && w > 0 ? w / props.aspectRatio : undefined),
|
|
161
|
+
flexGrow: 1,
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
<image
|
|
165
|
+
id={props.id ? props.id + '-image' : undefined}
|
|
166
|
+
src={imageSource}
|
|
167
|
+
style={{ width: w, height: h }}
|
|
168
|
+
accessibilityLabel=""
|
|
169
|
+
/>
|
|
170
|
+
<masonview
|
|
171
|
+
id={props.id ? props.id + '-tap' : undefined}
|
|
172
|
+
ref={bindTapView}
|
|
173
|
+
style={{
|
|
174
|
+
display: 'flex',
|
|
175
|
+
width: w,
|
|
176
|
+
height: h,
|
|
177
|
+
}}
|
|
178
|
+
onPan={interactive ? pointer.pan : undefined}
|
|
179
|
+
onTap={interactive ? () => pointer.tap(tapView) : undefined}
|
|
180
|
+
>
|
|
181
|
+
<masonview
|
|
182
|
+
id={props.id ? props.id + '-overlay' : undefined}
|
|
183
|
+
style={{ width: w, height: h }}
|
|
184
|
+
>
|
|
185
|
+
{scene?.labels.map((l) => (
|
|
186
|
+
<label
|
|
187
|
+
text={l.text}
|
|
188
|
+
{...{ left: l.x, top: l.y }}
|
|
189
|
+
style={{
|
|
190
|
+
width: l.width,
|
|
191
|
+
fontSize: 10,
|
|
192
|
+
opacity: 0.7,
|
|
193
|
+
textAlign: l.align === 'center' ? 'center' : l.align === 'end' ? 'right' : 'left',
|
|
194
|
+
position: 'absolute',
|
|
195
|
+
}}
|
|
196
|
+
/>
|
|
197
|
+
))}
|
|
198
|
+
@if (cursor && props.crosshair && !scene?.pie && plot) {
|
|
199
|
+
<masonview
|
|
200
|
+
style={{
|
|
201
|
+
display: 'flex',
|
|
202
|
+
width: 1,
|
|
203
|
+
height: plot.height,
|
|
204
|
+
backgroundColor: '#8a8a8a',
|
|
205
|
+
position: 'absolute',
|
|
206
|
+
left: cursor.px - 0.5,
|
|
207
|
+
top: plot.y,
|
|
208
|
+
}}
|
|
209
|
+
/>
|
|
210
|
+
}
|
|
211
|
+
@if (cursor && (props.crosshair || props.tooltip)) {
|
|
212
|
+
<masonview
|
|
213
|
+
style={{
|
|
214
|
+
display: 'flex',
|
|
215
|
+
width: 8,
|
|
216
|
+
height: 8,
|
|
217
|
+
borderRadius: 4,
|
|
218
|
+
backgroundColor: dotColor ?? '#4e79a7',
|
|
219
|
+
position: 'absolute',
|
|
220
|
+
left: cursor.px - 4,
|
|
221
|
+
top: cursor.py - 4,
|
|
222
|
+
}}
|
|
223
|
+
/>
|
|
224
|
+
}
|
|
225
|
+
@if (cursor && props.tooltip && tipText) {
|
|
226
|
+
<label
|
|
227
|
+
id={props.id ? props.id + '-tooltip' : undefined}
|
|
228
|
+
text={tipText}
|
|
229
|
+
{...{ left: tipLeft, top: tipTop < 0 ? cursor.py + 12 : tipTop }}
|
|
230
|
+
style={{
|
|
231
|
+
width: tipWidth,
|
|
232
|
+
height: 24,
|
|
233
|
+
backgroundColor: 'rgba(20,20,20,0.88)',
|
|
234
|
+
borderRadius: 4,
|
|
235
|
+
color: '#ffffff',
|
|
236
|
+
fontSize: 11,
|
|
237
|
+
textAlign: 'center',
|
|
238
|
+
position: 'absolute',
|
|
239
|
+
}}
|
|
240
|
+
/>
|
|
241
|
+
}
|
|
242
|
+
</masonview>
|
|
243
|
+
</masonview>
|
|
244
|
+
</masonview>
|
|
245
|
+
@if (legend === 'bottom' && scene) {
|
|
246
|
+
<masonview
|
|
247
|
+
style={mergeStyle(
|
|
248
|
+
{ flexDirection: 'row', flexWrap: 'wrap' },
|
|
249
|
+
{
|
|
250
|
+
display: 'flex',
|
|
251
|
+
paddingTop: 4,
|
|
252
|
+
},
|
|
253
|
+
)}
|
|
254
|
+
>
|
|
255
|
+
{scene.legend.map((item) => (
|
|
256
|
+
<masonview
|
|
257
|
+
style={mergeStyle(
|
|
258
|
+
{ flexDirection: 'row', alignItems: 'center' },
|
|
259
|
+
{
|
|
260
|
+
display: 'flex',
|
|
261
|
+
marginRight: 12,
|
|
262
|
+
},
|
|
263
|
+
)}
|
|
264
|
+
>
|
|
265
|
+
<masonview
|
|
266
|
+
style={{
|
|
267
|
+
display: 'flex',
|
|
268
|
+
width: 10,
|
|
269
|
+
height: 10,
|
|
270
|
+
borderRadius: 2,
|
|
271
|
+
backgroundColor: item.color,
|
|
272
|
+
marginRight: 4,
|
|
273
|
+
}}
|
|
274
|
+
/>
|
|
275
|
+
<label text={item.text} style={{ fontSize: 11 }} />
|
|
276
|
+
</masonview>
|
|
277
|
+
))}
|
|
278
|
+
</masonview>
|
|
279
|
+
}
|
|
280
|
+
</masonview>
|
|
279
281
|
}
|