@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/README.md +5 -0
- package/package.json +93 -93
- package/src/Chart.macos.tsrx +269 -107
- package/src/Chart.tsrx +274 -139
- package/src/Chart.web.tsrx +264 -206
- package/src/appkit-pointer.macos.ts +113 -0
- package/src/core/axes.ts +175 -168
- package/src/core/hit.ts +199 -174
- package/src/core/marks.ts +336 -319
- package/src/core/scales.ts +128 -115
- package/src/core/scene.ts +124 -121
- 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 +90 -63
- package/src/style-merge.ts +43 -45
- package/src/svg-image.macos.ts +21 -20
- package/types/generated/.tsrx-typegen-manifest.json +15 -0
- package/types/generated/Chart.d.ts +9 -0
- package/types/generated/core/axes.d.ts +26 -0
- package/types/generated/core/hit.d.ts +34 -0
- package/types/generated/core/marks.d.ts +88 -0
- package/types/generated/core/scales.d.ts +37 -0
- package/types/generated/core/scene.d.ts +30 -0
- package/types/generated/core/svg.d.ts +5 -0
- package/types/generated/index.d.ts +2 -0
- package/types/{props.d.ts → generated/props.d.ts} +27 -0
- package/types/generated/style-merge.d.ts +8 -0
- package/LICENSE +0 -21
- package/types/index.d.ts +0 -17
package/README.md
ADDED
package/package.json
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
2
|
+
"name": "@octane-xplat/charts",
|
|
3
|
+
"version": "0.20.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.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
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@nativescript-community/octane": "0.2.5",
|
|
63
|
+
"@nativescript/core": "9.1.3",
|
|
64
|
+
"@octane-xplat/macos-appkit": "0.20.0",
|
|
65
|
+
"@octane-xplat/ui": "0.20.0",
|
|
66
|
+
"@octanejs/vite-plugin": "0.5.0",
|
|
67
|
+
"@types/d3-array": "3.2.2",
|
|
68
|
+
"@types/d3-format": "3.0.4",
|
|
69
|
+
"@types/d3-scale": "4.0.9",
|
|
70
|
+
"@types/d3-shape": "3.2.0",
|
|
71
|
+
"@types/d3-time-format": "4.0.3",
|
|
72
|
+
"octane": "0.16.3",
|
|
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
|
+
},
|
|
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
|
+
}
|
package/src/Chart.macos.tsrx
CHANGED
|
@@ -1,119 +1,281 @@
|
|
|
1
|
-
/** @jsxImportSource @octane-xplat/
|
|
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
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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)
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
const w = props.width ?? bounds?.width ?? 0;
|
|
27
|
-
const h =
|
|
28
|
-
props.height ??
|
|
29
|
-
(props.aspectRatio && w > 0
|
|
30
|
-
? w / props.aspectRatio
|
|
31
|
-
: bounds?.height && bounds.height > 0
|
|
32
|
-
? bounds.height
|
|
33
|
-
: w > 0
|
|
34
|
-
? w / 1.6
|
|
35
|
-
: 0);
|
|
27
|
+
propsRef.current = props
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
h,
|
|
49
|
-
],
|
|
50
|
-
);
|
|
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)
|
|
51
40
|
|
|
52
|
-
|
|
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
|
+
)
|
|
53
55
|
|
|
54
|
-
|
|
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
|
-
}, []);
|
|
56
|
+
sceneRef.current = scene
|
|
62
57
|
|
|
63
|
-
|
|
64
|
-
|
|
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
|
+
)
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
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;
|
|
75
|
+
const [tapView, setTapView] = useState<any>(null)
|
|
76
|
+
const bindTapView = useCallback((view: any) => setTapView(view), [])
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!interactive || !tapView) {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return pointer.observe(tapView)
|
|
84
|
+
}, [interactive, tapView, pointer])
|
|
85
|
+
|
|
86
|
+
const markup = scene?.markup ?? EMPTY_SVG
|
|
87
|
+
const imageSource = useMemo(() => appKitImageSource(markup), [markup])
|
|
88
|
+
|
|
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
|
|
98
|
+
|
|
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>
|
|
119
281
|
}
|