@octane-xplat/charts 0.17.1 → 0.19.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 ADDED
@@ -0,0 +1,105 @@
1
+ # @octane-xplat/charts
2
+
3
+ Show a small dataset as a line, area, bar, pie, or scatter chart. The package
4
+ provides shared chart data and interaction props with web, iOS/Android, and
5
+ experimental macOS AppKit implementations.
6
+
7
+ ## Show a bar chart
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).
package/package.json CHANGED
@@ -1,94 +1,94 @@
1
1
  {
2
- "name": "@octane-xplat/charts",
3
- "version": "0.17.1",
4
- "description": "Cross-platform SVG charts for Octane xplat — a DOM-free d3 core with web, iOS/Android, and macOS AppKit leaves",
5
- "keywords": [
6
- "android",
7
- "charts",
8
- "cross-platform",
9
- "d3",
10
- "graph",
11
- "ios",
12
- "macos",
13
- "nativescript",
14
- "octane",
15
- "svg",
16
- "visualization",
17
- "xplat"
18
- ],
19
- "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/charts",
20
- "license": "MIT",
21
- "repository": {
22
- "type": "git",
23
- "url": "https://github.com/octane-xplat/octane-xplat",
24
- "directory": "packages/charts"
25
- },
26
- "files": [
27
- "types",
28
- "src",
29
- "!src/**/*.test.*",
30
- "!src/**/*.spec.*"
31
- ],
32
- "type": "module",
33
- "exports": {
34
- ".": {
35
- "macos": {
36
- "types": "./types/index.d.ts",
37
- "default": "./src/index.macos.ts"
38
- },
39
- "types": "./types/index.d.ts",
40
- "web": "./src/index.web.ts",
41
- "native": "./src/index.ts",
42
- "default": "./src/index.ts"
43
- }
44
- },
45
- "publishConfig": {
46
- "access": "public"
47
- },
48
- "dependencies": {
49
- "d3-array": "3.2.4",
50
- "d3-format": "3.1.2",
51
- "d3-scale": "4.0.2",
52
- "d3-shape": "3.2.0",
53
- "d3-time-format": "4.1.0"
54
- },
55
- "devDependencies": {
56
- "@nativescript-community/octane": "0.2.5",
57
- "@nativescript/core": "9.1.3",
58
- "@octane-xplat/macos-renderer": "0.17.1",
59
- "@octane-xplat/ui": "0.17.1",
60
- "@octanejs/vite-plugin": "0.1.61",
61
- "@tsrx/typescript-plugin": "0.4.11",
62
- "@types/d3-array": "3.2.2",
63
- "@types/d3-format": "3.0.4",
64
- "@types/d3-scale": "4.0.9",
65
- "@types/d3-shape": "3.2.0",
66
- "@types/d3-time-format": "4.0.3",
67
- "octane": "0.14.0",
68
- "tsrx-typegen": "0.4.0",
69
- "typescript": "5.9.3",
70
- "vite": "8.3.0",
71
- "vitest": "4.1.11"
72
- },
73
- "peerDependencies": {
74
- "@nativescript-community/octane": ">=0.2.1 <1",
75
- "@nativescript/core": ">=9.1.0 <10",
76
- "@octane-xplat/ui": ">=0.6.0 <1",
77
- "octane": ">=0.6.3 <1"
78
- },
79
- "peerDependenciesMeta": {
80
- "@nativescript-community/octane": {
81
- "optional": true
82
- },
83
- "@nativescript/core": {
84
- "optional": true
85
- }
86
- },
87
- "scripts": {
88
- "typegen": "tsc -p tsconfig.types.json",
89
- "typecheck": "node ../../scripts/typecheck.ts",
90
- "test": "vitest run",
91
- "test:packed": "node tests/packed-consumer.mjs",
92
- "pack:check": "tsrx-typegen --pack-check"
93
- }
94
- }
2
+ "name": "@octane-xplat/charts",
3
+ "version": "0.19.0",
4
+ "description": "Cross-platform SVG charts for Octane xplat — a DOM-free d3 core with web, iOS/Android, and macOS AppKit leaves",
5
+ "keywords": [
6
+ "android",
7
+ "charts",
8
+ "cross-platform",
9
+ "d3",
10
+ "graph",
11
+ "ios",
12
+ "macos",
13
+ "nativescript",
14
+ "octane",
15
+ "svg",
16
+ "visualization",
17
+ "xplat"
18
+ ],
19
+ "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/charts",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/octane-xplat/octane-xplat",
24
+ "directory": "packages/charts"
25
+ },
26
+ "files": [
27
+ "types/generated",
28
+ "src",
29
+ "!src/**/*.test.*",
30
+ "!src/**/*.spec.*"
31
+ ],
32
+ "type": "module",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./types/generated/index.d.ts",
36
+ "macos": "./src/index.macos.ts",
37
+ "web": "./src/index.web.ts",
38
+ "native": "./src/index.ts",
39
+ "default": "./src/index.ts"
40
+ }
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "typegen": "tsrx-typegen --target charts",
47
+ "typecheck": "node ../../scripts/typecheck.ts",
48
+ "test": "vitest run",
49
+ "prepack": "bun run typegen && tsrx-typegen --pack-check",
50
+ "test:packed": "node tests/packed-consumer.mjs",
51
+ "pack:check": "tsrx-typegen --pack-check"
52
+ },
53
+ "dependencies": {
54
+ "@octane-xplat/jsx": "0.19.0",
55
+ "d3-array": "3.2.4",
56
+ "d3-format": "3.1.2",
57
+ "d3-scale": "4.0.2",
58
+ "d3-shape": "3.2.0",
59
+ "d3-time-format": "4.1.0"
60
+ },
61
+ "devDependencies": {
62
+ "@nativescript-community/octane": "0.2.5",
63
+ "@nativescript/core": "9.1.3",
64
+ "@octane-xplat/macos-renderer": "0.19.0",
65
+ "@octane-xplat/ui": "0.19.0",
66
+ "@octanejs/vite-plugin": "0.5.0",
67
+ "@tsrx/typescript-plugin": "0.4.11",
68
+ "@types/d3-array": "3.2.2",
69
+ "@types/d3-format": "3.0.4",
70
+ "@types/d3-scale": "4.0.9",
71
+ "@types/d3-shape": "3.2.0",
72
+ "@types/d3-time-format": "4.0.3",
73
+ "octane": "0.16.3",
74
+ "tsrx-typegen": "0.5.0",
75
+ "typescript": "5.9.3",
76
+ "vite": "8.3.0",
77
+ "vitest": "4.1.11"
78
+ },
79
+ "peerDependencies": {
80
+ "@nativescript-community/octane": ">=0.2.1 <1",
81
+ "@nativescript/core": ">=9.1.0 <10",
82
+ "@octane-xplat/ui": ">=0.6.0 <1",
83
+ "octane": ">=0.6.3 <1"
84
+ },
85
+ "peerDependenciesMeta": {
86
+ "@nativescript-community/octane": {
87
+ "optional": true
88
+ },
89
+ "@nativescript/core": {
90
+ "optional": true
91
+ }
92
+ },
93
+ "types": "./types/generated/index.d.ts"
94
+ }
@@ -1,29 +1,32 @@
1
- /** @jsxImportSource @octane-xplat/macos-renderer */
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
2
  import { mergeStyle } from './style-merge'
3
- import { useMemo, useRef, useState } from 'octane';
4
- import { appKitImageSource } from './svg-image.macos';
5
- import { useMeasure } from '@octane-xplat/ui';
6
- import type { ChartProps } from './props';
7
- import { computeScene } from './core/scene';
8
- import type { ChartScene } from './core/scene';
9
- import { createScrub, hitLabel } from './core/hit';
10
- import type { SceneHit } from './core/hit';
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'octane'
4
+ import { appKitImageSource } from './svg-image.macos'
5
+ import { useMeasure } from '@octane-xplat/ui'
6
+ import type { ChartProps } from './props'
7
+ import { computeScene } from './core/scene'
8
+ import type { ChartScene } from './core/scene'
9
+ import { createScrub, hitLabel } from './core/hit'
10
+ import type { SceneHit } from './core/hit'
11
+ import { createAppKitChartPointer } from './appkit-pointer.macos'
11
12
 
12
- const EMPTY_SVG = '<svg xmlns="http://www.w3.org/2000/svg"/>';
13
- const TIP_ESTIMATE_CHAR = 6.2;
13
+ const EMPTY_SVG = '<svg xmlns="http://www.w3.org/2000/svg"/>'
14
+ const TIP_ESTIMATE_CHAR = 6.2
14
15
 
15
16
  /** AppKit leaf: one NSImage plus native label and cursor overlays.
16
- * Click recognizers currently supply no coordinates; taps use the scene center.
17
- * AppKit does not deliver onTouch, so touch scrubbing is unavailable. */
18
- export function Chart(props: ChartProps) @{
19
- const measure = useMeasure();
20
- const [cursor, setCursor] = useState<SceneHit | null>(null);
21
- const sceneRef = useRef<ChartScene | null>(null);
22
- const propsRef = useRef(props);
23
- propsRef.current = props;
17
+ * Hover/drag/click coordinates come from renderer tracking areas, pan
18
+ * recognizer location and the current mouse event; native delivery is
19
+ * unqualified. AppKit does not deliver onTouch, so touch scrubbing is
20
+ * unavailable. */
21
+ export function Chart(props: ChartProps): unknown @{
22
+ const measure = useMeasure()
23
+ const [cursor, setCursor] = useState<SceneHit | null>(null)
24
+ const sceneRef = useRef<ChartScene | null>(null)
25
+ const propsRef = useRef(props)
26
+ propsRef.current = props
24
27
 
25
- const bounds = measure.bounds;
26
- const w = props.width ?? bounds?.width ?? 0;
28
+ const bounds = measure.bounds
29
+ const w = props.width ?? bounds?.width ?? 0
27
30
  const h =
28
31
  props.height ??
29
32
  (props.aspectRatio && w > 0
@@ -32,7 +35,7 @@ export function Chart(props: ChartProps) @{
32
35
  ? bounds.height
33
36
  : w > 0
34
37
  ? w / 1.6
35
- : 0);
38
+ : 0)
36
39
 
37
40
  const scene = useMemo(
38
41
  () => (w > 0 && h > 0 ? computeScene(propsRef.current, w, h) : null),
@@ -47,69 +50,226 @@ export function Chart(props: ChartProps) @{
47
50
  w,
48
51
  h,
49
52
  ],
50
- );
53
+ )
51
54
 
52
- sceneRef.current = scene;
55
+ sceneRef.current = scene
53
56
 
54
- const interactive = !!(props.onPress || props.onScrub || props.tooltip || props.crosshair);
55
- const onTap = useMemo(() => {
56
- const scrub = createScrub(() => sceneRef.current, () => propsRef.current, setCursor);
57
- return (e?: any) => {
58
- const scene = sceneRef.current;
59
- scrub('tap', e?.getX?.() ?? (scene?.width ?? 0) / 2, e?.getY?.() ?? (scene?.height ?? 0) / 2);
60
- };
61
- }, []);
57
+ const interactive = !!(props.onPress || props.onScrub || props.tooltip || props.crosshair)
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
+ )
62
73
 
63
- const markup = scene?.markup ?? EMPTY_SVG;
64
- const imageSource = useMemo(() => appKitImageSource(markup), [markup]);
74
+ const [tapView, setTapView] = useState<any>(null)
75
+ const bindTapView = useCallback((view: any) => setTapView(view), [])
76
+ useEffect(() => {
77
+ if (!interactive || !tapView) {
78
+ return
79
+ }
80
+
81
+ return pointer.observe(tapView)
82
+ }, [interactive, tapView, pointer])
83
+
84
+ const markup = scene?.markup ?? EMPTY_SVG
85
+ const imageSource = useMemo(() => appKitImageSource(markup), [markup])
86
+
87
+ const legend = props.legend === true ? 'bottom' : props.legend
88
+ const plot = scene?.plot
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
96
+
97
+ const tipText = cursor && scene ? hitLabel(scene, cursor) : null
98
+ const tipWidth = tipText ? tipText.length * TIP_ESTIMATE_CHAR + 14 : 0
99
+ const tipLeft =
100
+ cursor && scene
101
+ ? Math.min(Math.max(0, cursor.px - tipWidth / 2), Math.max(0, scene.width - tipWidth))
102
+ : 0
65
103
 
66
- const legend = props.legend === true ? 'bottom' : props.legend;
67
- const plot = scene?.plot;
68
- const dotColor = cursor && scene ? (scene.pie ? scene.pie.slices.find((s) => s.series === cursor.series && s.index === cursor.index)?.color : scene.series[cursor.series]?.color) : undefined;
69
- const tipText = cursor && scene ? hitLabel(scene, cursor) : null;
70
- const tipWidth = tipText ? tipText.length * TIP_ESTIMATE_CHAR + 14 : 0;
71
- const tipLeft = cursor && scene ? Math.min(Math.max(0, cursor.px - tipWidth / 2), Math.max(0, scene.width - tipWidth)) : 0;
72
- const tipTop = cursor ? cursor.py - 30 : 0;
104
+ const tipTop = cursor ? cursor.py - 30 : 0
73
105
 
74
- <masonview id={props.id} className={props.className} style={{display: "flex", ...({ flexDirection: 'column', ...props.style })}} accessible={props.accessibilityLabel != null} accessibilityRole={'image'} accessibilityLabel={props.accessibilityLabel}>
106
+ <masonview
107
+ id={props.id}
108
+ className={props.className}
109
+ style={{
110
+ display: 'flex',
111
+ flexDirection: 'column',
112
+ ...props.style,
113
+ }}
114
+ accessible={props.accessibilityLabel != null}
115
+ accessibilityRole={'image'}
116
+ accessibilityLabel={props.accessibilityLabel}
117
+ >
75
118
  @if (legend === 'top' && scene) {
76
- <masonview style={mergeStyle({flexDirection: "row", flexWrap: "wrap"}, {display: "flex", ...({ paddingBottom: 4 })})}>
119
+ <masonview
120
+ style={mergeStyle(
121
+ { flexDirection: 'row', flexWrap: 'wrap' },
122
+ {
123
+ display: 'flex',
124
+ paddingBottom: 4,
125
+ },
126
+ )}
127
+ >
77
128
  {scene.legend.map((item) => (
78
- <masonview style={mergeStyle({flexDirection: "row", alignItems: "center"}, {display: "flex", ...({ marginRight: 12 })})}>
79
- <masonview style={{display: "flex", ...({ width: 10, height: 10, borderRadius: 2, backgroundColor: item.color, marginRight: 4 })}}/>
129
+ <masonview
130
+ style={mergeStyle(
131
+ { flexDirection: 'row', alignItems: 'center' },
132
+ {
133
+ display: 'flex',
134
+ marginRight: 12,
135
+ },
136
+ )}
137
+ >
138
+ <masonview
139
+ style={{
140
+ display: 'flex',
141
+ width: 10,
142
+ height: 10,
143
+ borderRadius: 2,
144
+ backgroundColor: item.color,
145
+ marginRight: 4,
146
+ }}
147
+ />
80
148
  <label text={item.text} style={{ fontSize: 11 }} />
81
149
  </masonview>
82
150
  ))}
83
151
  </masonview>
84
152
  }
85
- <masonview ref={measure.ref} style={{display: "grid", ...({
153
+ <masonview
154
+ ref={measure.ref}
155
+ style={{
156
+ display: 'grid',
86
157
  width: props.width,
87
158
  height: props.height ?? (props.aspectRatio && w > 0 ? w / props.aspectRatio : undefined),
88
159
  flexGrow: 1,
89
- })}}>
90
- <image id={props.id ? props.id + '-image' : undefined} src={imageSource} style={{ width: w, height: h }} accessibilityLabel="" />
91
- <masonview id={props.id ? props.id + '-tap' : undefined} style={{display: "flex", ...({ width: w, height: h })}} onTap={interactive ? onTap : undefined}>
92
- <masonview id={props.id ? props.id + '-overlay' : undefined} style={{ width: w, height: h }}>
160
+ }}
161
+ >
162
+ <image
163
+ id={props.id ? props.id + '-image' : undefined}
164
+ src={imageSource}
165
+ style={{ width: w, height: h }}
166
+ accessibilityLabel=""
167
+ />
168
+ <masonview
169
+ id={props.id ? props.id + '-tap' : undefined}
170
+ ref={bindTapView}
171
+ style={{
172
+ display: 'flex',
173
+ width: w,
174
+ height: h,
175
+ }}
176
+ onPan={interactive ? pointer.pan : undefined}
177
+ onTap={interactive ? () => pointer.tap(tapView) : undefined}
178
+ >
179
+ <masonview
180
+ id={props.id ? props.id + '-overlay' : undefined}
181
+ style={{ width: w, height: h }}
182
+ >
93
183
  {scene?.labels.map((l) => (
94
- <label text={l.text} {...{ left: l.x, top: l.y }} style={{ width: l.width, fontSize: 10, opacity: 0.7, textAlign: l.align === 'center' ? 'center' : l.align === 'end' ? 'right' : 'left' , position: 'absolute'}} />
184
+ <label
185
+ text={l.text}
186
+ {...{ left: l.x, top: l.y }}
187
+ style={{
188
+ width: l.width,
189
+ fontSize: 10,
190
+ opacity: 0.7,
191
+ textAlign: l.align === 'center' ? 'center' : l.align === 'end' ? 'right' : 'left',
192
+ position: 'absolute',
193
+ }}
194
+ />
95
195
  ))}
96
196
  @if (cursor && props.crosshair && !scene?.pie && plot) {
97
- <masonview style={{display: "flex", ...({ width: 1, height: plot.height, backgroundColor: '#8a8a8a' , position: 'absolute', left: cursor.px - 0.5, top: plot.y})}}/>
197
+ <masonview
198
+ style={{
199
+ display: 'flex',
200
+ width: 1,
201
+ height: plot.height,
202
+ backgroundColor: '#8a8a8a',
203
+ position: 'absolute',
204
+ left: cursor.px - 0.5,
205
+ top: plot.y,
206
+ }}
207
+ />
98
208
  }
99
209
  @if (cursor && (props.crosshair || props.tooltip)) {
100
- <masonview style={{display: "flex", ...({ width: 8, height: 8, borderRadius: 4, backgroundColor: dotColor ?? '#4e79a7' , position: 'absolute', left: cursor.px - 4, top: cursor.py - 4})}}/>
210
+ <masonview
211
+ style={{
212
+ display: 'flex',
213
+ width: 8,
214
+ height: 8,
215
+ borderRadius: 4,
216
+ backgroundColor: dotColor ?? '#4e79a7',
217
+ position: 'absolute',
218
+ left: cursor.px - 4,
219
+ top: cursor.py - 4,
220
+ }}
221
+ />
101
222
  }
102
223
  @if (cursor && props.tooltip && tipText) {
103
- <label id={props.id ? props.id + '-tooltip' : undefined} text={tipText} {...{ left: tipLeft, top: tipTop < 0 ? cursor.py + 12 : tipTop }} style={{ width: tipWidth, height: 24, backgroundColor: 'rgba(20,20,20,0.88)', borderRadius: 4, color: '#ffffff', fontSize: 11, textAlign: 'center' , position: 'absolute'}} />
224
+ <label
225
+ id={props.id ? props.id + '-tooltip' : undefined}
226
+ text={tipText}
227
+ {...{ left: tipLeft, top: tipTop < 0 ? cursor.py + 12 : tipTop }}
228
+ style={{
229
+ width: tipWidth,
230
+ height: 24,
231
+ backgroundColor: 'rgba(20,20,20,0.88)',
232
+ borderRadius: 4,
233
+ color: '#ffffff',
234
+ fontSize: 11,
235
+ textAlign: 'center',
236
+ position: 'absolute',
237
+ }}
238
+ />
104
239
  }
105
240
  </masonview>
106
241
  </masonview>
107
242
  </masonview>
108
243
  @if (legend === 'bottom' && scene) {
109
- <masonview style={mergeStyle({flexDirection: "row", flexWrap: "wrap"}, {display: "flex", ...({ paddingTop: 4 })})}>
244
+ <masonview
245
+ style={mergeStyle(
246
+ { flexDirection: 'row', flexWrap: 'wrap' },
247
+ {
248
+ display: 'flex',
249
+ paddingTop: 4,
250
+ },
251
+ )}
252
+ >
110
253
  {scene.legend.map((item) => (
111
- <masonview style={mergeStyle({flexDirection: "row", alignItems: "center"}, {display: "flex", ...({ marginRight: 12 })})}>
112
- <masonview style={{display: "flex", ...({ width: 10, height: 10, borderRadius: 2, backgroundColor: item.color, marginRight: 4 })}}/>
254
+ <masonview
255
+ style={mergeStyle(
256
+ { flexDirection: 'row', alignItems: 'center' },
257
+ {
258
+ display: 'flex',
259
+ marginRight: 12,
260
+ },
261
+ )}
262
+ >
263
+ <masonview
264
+ style={{
265
+ display: 'flex',
266
+ width: 10,
267
+ height: 10,
268
+ borderRadius: 2,
269
+ backgroundColor: item.color,
270
+ marginRight: 4,
271
+ }}
272
+ />
113
273
  <label text={item.text} style={{ fontSize: 11 }} />
114
274
  </masonview>
115
275
  ))}