@octane-xplat/charts 0.0.1 → 0.10.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/LICENSE +21 -0
- package/dist/macos/Chart.macos.tsrx.js +351 -0
- package/dist/macos/core/axes.js +146 -0
- package/dist/macos/core/hit.js +131 -0
- package/dist/macos/core/marks.js +262 -0
- package/dist/macos/core/scales.js +99 -0
- package/dist/macos/core/scene.js +120 -0
- package/dist/macos/core/svg.js +40 -0
- package/dist/macos/index.js +2 -0
- package/dist/macos/octane-client-build.json +8 -0
- package/dist/macos/svg-image.macos.js +14 -0
- package/dist/native/Chart.tsrx.js +340 -0
- package/dist/native/core/axes.js +146 -0
- package/dist/native/core/hit.js +131 -0
- package/dist/native/core/marks.js +262 -0
- package/dist/native/core/scales.js +99 -0
- package/dist/native/core/scene.js +120 -0
- package/dist/native/core/svg.js +40 -0
- package/dist/native/index.js +2 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/web/Chart.web.tsrx.js +488 -0
- package/dist/web/core/axes.js +146 -0
- package/dist/web/core/hit.js +131 -0
- package/dist/web/core/marks.js +262 -0
- package/dist/web/core/scales.js +99 -0
- package/dist/web/core/scene.js +120 -0
- package/dist/web/core/svg.js +40 -0
- package/dist/web/index.js +2 -0
- package/dist/web/octane-client-build.json +8 -0
- package/package.json +86 -3
- package/src/Chart.macos.tsrx +134 -0
- package/src/Chart.tsrx +174 -0
- package/src/Chart.web.tsrx +215 -0
- package/src/core/axes.ts +211 -0
- package/src/core/hit.ts +201 -0
- package/src/core/marks.ts +380 -0
- package/src/core/scales.ts +168 -0
- package/src/core/scene.ts +145 -0
- package/src/core/svg.ts +84 -0
- package/src/index.macos.ts +12 -0
- package/src/index.ts +12 -0
- package/src/index.web.ts +12 -0
- package/src/props.ts +90 -0
- package/src/svg-image.macos.ts +34 -0
- package/types/index.d.ts +17 -0
- package/types/props.d.ts +83 -0
- package/README.md +0 -4
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import { computeScene } from "./core/scene.js";
|
|
2
|
+
import { createScrub, hitLabel } from "./core/hit.js";
|
|
3
|
+
import { __s, bag13, bag8, bag9, bagOf, child, clone, createElement, createScopedElement, createScopedValue, hookSlots, ifBlock, isHydratingStyle, positionalChildren, queueRefAttach, queueRefDetach, setAriaAttribute, setDangerouslySetInnerHTML, setStyle, setStyleProperties, setStyleProperty, sibling, template, useEffect, useRef, useState, withSlot } from "octane";
|
|
4
|
+
import { bindSignalAttribute, bindSignalChild, compilerMemoRegion, enableSignalBindings, hookMemoCreate, hookMemoEqual, hookMemoPublish, hookMemoPublish2, hookMemoPublishInvariant, replaceRef, setPlainAttribute } from "octane/internal/client";
|
|
5
|
+
import { useMeasure } from "@octane-xplat/ui";
|
|
6
|
+
//#region src/Chart.web.tsrx
|
|
7
|
+
enableSignalBindings(1, true);
|
|
8
|
+
var _t$0 = /* @__PURE__ */ template("<div style=\"position: absolute;\"></div>");
|
|
9
|
+
var _t$1 = /* @__PURE__ */ template("<div><!><div style=\"position: relative; flex-grow: 1; min-height: 0;\"><div></div><div style=\"position: absolute; inset: 0;\"><!><!><!><!></div></div><!></div>");
|
|
10
|
+
var _hs$ = /* @__PURE__ */ hookSlots(6);
|
|
11
|
+
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
12
|
+
function __then$2(__props, __s, __extra) {
|
|
13
|
+
const cursor = __extra[0];
|
|
14
|
+
const plot = __extra[1];
|
|
15
|
+
let _b = __s.slots[0];
|
|
16
|
+
if (_b === void 0) {
|
|
17
|
+
let _m7;
|
|
18
|
+
const _root = clone(_t$0, void 0, "||");
|
|
19
|
+
_m7 = _root;
|
|
20
|
+
_b = bag8(__s, _root, __s, void 0, void 0, void 0, void 0, void 0, void 0, _m7);
|
|
21
|
+
}
|
|
22
|
+
{
|
|
23
|
+
const _v0 = cursor.px - .5;
|
|
24
|
+
const _v1 = plot.y;
|
|
25
|
+
const _v2 = 1;
|
|
26
|
+
const _v3 = plot.height;
|
|
27
|
+
const _v4 = "#8a8a8a";
|
|
28
|
+
const _v5 = "none";
|
|
29
|
+
if (_b.a === __s || isHydratingStyle()) {
|
|
30
|
+
setStyleProperties(_b.h, [
|
|
31
|
+
"left",
|
|
32
|
+
_v0,
|
|
33
|
+
"top",
|
|
34
|
+
_v1,
|
|
35
|
+
"width",
|
|
36
|
+
_v2,
|
|
37
|
+
"height",
|
|
38
|
+
_v3,
|
|
39
|
+
"backgroundColor",
|
|
40
|
+
_v4,
|
|
41
|
+
"pointerEvents",
|
|
42
|
+
_v5
|
|
43
|
+
], "position: absolute;");
|
|
44
|
+
_b.a = null;
|
|
45
|
+
_b.b = _v0;
|
|
46
|
+
_b.c = _v1;
|
|
47
|
+
_b.d = _v2;
|
|
48
|
+
_b.e = _v3;
|
|
49
|
+
_b.f = _v4;
|
|
50
|
+
_b.g = _v5;
|
|
51
|
+
} else {
|
|
52
|
+
if (_b.b !== _v0) {
|
|
53
|
+
setStyleProperty(_b.h, "left", _v0, "", _b.b);
|
|
54
|
+
_b.b = _v0;
|
|
55
|
+
}
|
|
56
|
+
if (_b.c !== _v1) {
|
|
57
|
+
setStyleProperty(_b.h, "top", _v1, "", _b.c);
|
|
58
|
+
_b.c = _v1;
|
|
59
|
+
}
|
|
60
|
+
if (_b.d !== _v2) {
|
|
61
|
+
setStyleProperty(_b.h, "width", _v2, "", _b.d);
|
|
62
|
+
_b.d = _v2;
|
|
63
|
+
}
|
|
64
|
+
if (_b.e !== _v3) {
|
|
65
|
+
setStyleProperty(_b.h, "height", _v3, "", _b.e);
|
|
66
|
+
_b.e = _v3;
|
|
67
|
+
}
|
|
68
|
+
if (_b.f !== _v4) {
|
|
69
|
+
setStyleProperty(_b.h, "backgroundColor", _v4, "", _b.f);
|
|
70
|
+
_b.f = _v4;
|
|
71
|
+
}
|
|
72
|
+
if (_b.g !== _v5) {
|
|
73
|
+
setStyleProperty(_b.h, "pointerEvents", _v5, "", _b.g);
|
|
74
|
+
_b.g = _v5;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function __then$4(__props, __s, __extra) {
|
|
80
|
+
const cursor = __extra[0];
|
|
81
|
+
const dotColor = __extra[1];
|
|
82
|
+
let _b = __s.slots[0];
|
|
83
|
+
if (_b === void 0) {
|
|
84
|
+
let _m8;
|
|
85
|
+
const _root = clone(_t$0, void 0, "||");
|
|
86
|
+
_m8 = _root;
|
|
87
|
+
_b = bag9(__s, _root, __s, void 0, void 0, void 0, void 0, void 0, void 0, void 0, _m8);
|
|
88
|
+
}
|
|
89
|
+
{
|
|
90
|
+
const _v0 = cursor.px - 4;
|
|
91
|
+
const _v1 = cursor.py - 4;
|
|
92
|
+
const _v2 = 8;
|
|
93
|
+
const _v3 = 8;
|
|
94
|
+
const _v4 = 4;
|
|
95
|
+
const _v5 = dotColor ?? "#4e79a7";
|
|
96
|
+
const _v6 = "none";
|
|
97
|
+
if (_b.a === __s || isHydratingStyle()) {
|
|
98
|
+
setStyleProperties(_b.i, [
|
|
99
|
+
"left",
|
|
100
|
+
_v0,
|
|
101
|
+
"top",
|
|
102
|
+
_v1,
|
|
103
|
+
"width",
|
|
104
|
+
_v2,
|
|
105
|
+
"height",
|
|
106
|
+
_v3,
|
|
107
|
+
"borderRadius",
|
|
108
|
+
_v4,
|
|
109
|
+
"backgroundColor",
|
|
110
|
+
_v5,
|
|
111
|
+
"pointerEvents",
|
|
112
|
+
_v6
|
|
113
|
+
], "position: absolute;");
|
|
114
|
+
_b.a = null;
|
|
115
|
+
_b.b = _v0;
|
|
116
|
+
_b.c = _v1;
|
|
117
|
+
_b.d = _v2;
|
|
118
|
+
_b.e = _v3;
|
|
119
|
+
_b.f = _v4;
|
|
120
|
+
_b.g = _v5;
|
|
121
|
+
_b.h = _v6;
|
|
122
|
+
} else {
|
|
123
|
+
if (_b.b !== _v0) {
|
|
124
|
+
setStyleProperty(_b.i, "left", _v0, "", _b.b);
|
|
125
|
+
_b.b = _v0;
|
|
126
|
+
}
|
|
127
|
+
if (_b.c !== _v1) {
|
|
128
|
+
setStyleProperty(_b.i, "top", _v1, "", _b.c);
|
|
129
|
+
_b.c = _v1;
|
|
130
|
+
}
|
|
131
|
+
if (_b.d !== _v2) {
|
|
132
|
+
setStyleProperty(_b.i, "width", _v2, "", _b.d);
|
|
133
|
+
_b.d = _v2;
|
|
134
|
+
}
|
|
135
|
+
if (_b.e !== _v3) {
|
|
136
|
+
setStyleProperty(_b.i, "height", _v3, "", _b.e);
|
|
137
|
+
_b.e = _v3;
|
|
138
|
+
}
|
|
139
|
+
if (_b.f !== _v4) {
|
|
140
|
+
setStyleProperty(_b.i, "borderRadius", _v4, "", _b.f);
|
|
141
|
+
_b.f = _v4;
|
|
142
|
+
}
|
|
143
|
+
if (_b.g !== _v5) {
|
|
144
|
+
setStyleProperty(_b.i, "backgroundColor", _v5, "", _b.g);
|
|
145
|
+
_b.g = _v5;
|
|
146
|
+
}
|
|
147
|
+
if (_b.h !== _v6) {
|
|
148
|
+
setStyleProperty(_b.i, "pointerEvents", _v6, "", _b.h);
|
|
149
|
+
_b.h = _v6;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function __then$6(__props, __s, __extra) {
|
|
155
|
+
const cursor = __extra[0];
|
|
156
|
+
const tipLeft = __extra[1];
|
|
157
|
+
const tipText = __extra[2];
|
|
158
|
+
const tipTop = __extra[3];
|
|
159
|
+
let _b = __s.slots[0];
|
|
160
|
+
if (_b === void 0) {
|
|
161
|
+
let _m10;
|
|
162
|
+
const _root = clone(_t$0, void 0, "||");
|
|
163
|
+
_m10 = _root;
|
|
164
|
+
_b = bag13(__s, _root, __s, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, _m10, null, void 0);
|
|
165
|
+
}
|
|
166
|
+
{
|
|
167
|
+
const _v0 = tipLeft;
|
|
168
|
+
const _v1 = tipTop < 0 ? cursor.py + 12 : tipTop;
|
|
169
|
+
const _v2 = "rgba(20,20,20,0.88)";
|
|
170
|
+
const _v3 = "#fff";
|
|
171
|
+
const _v4 = 11;
|
|
172
|
+
const _v5 = "2px 6px";
|
|
173
|
+
const _v6 = 4;
|
|
174
|
+
const _v7 = "nowrap";
|
|
175
|
+
const _v8 = "none";
|
|
176
|
+
if (_b.a === __s || isHydratingStyle()) {
|
|
177
|
+
setStyleProperties(_b.k, [
|
|
178
|
+
"left",
|
|
179
|
+
_v0,
|
|
180
|
+
"top",
|
|
181
|
+
_v1,
|
|
182
|
+
"backgroundColor",
|
|
183
|
+
_v2,
|
|
184
|
+
"color",
|
|
185
|
+
_v3,
|
|
186
|
+
"fontSize",
|
|
187
|
+
_v4,
|
|
188
|
+
"padding",
|
|
189
|
+
_v5,
|
|
190
|
+
"borderRadius",
|
|
191
|
+
_v6,
|
|
192
|
+
"whiteSpace",
|
|
193
|
+
_v7,
|
|
194
|
+
"pointerEvents",
|
|
195
|
+
_v8
|
|
196
|
+
], "position: absolute;");
|
|
197
|
+
_b.a = null;
|
|
198
|
+
_b.b = _v0;
|
|
199
|
+
_b.c = _v1;
|
|
200
|
+
_b.d = _v2;
|
|
201
|
+
_b.e = _v3;
|
|
202
|
+
_b.f = _v4;
|
|
203
|
+
_b.g = _v5;
|
|
204
|
+
_b.h = _v6;
|
|
205
|
+
_b.i = _v7;
|
|
206
|
+
_b.j = _v8;
|
|
207
|
+
} else {
|
|
208
|
+
if (_b.b !== _v0) {
|
|
209
|
+
setStyleProperty(_b.k, "left", _v0, "", _b.b);
|
|
210
|
+
_b.b = _v0;
|
|
211
|
+
}
|
|
212
|
+
if (_b.c !== _v1) {
|
|
213
|
+
setStyleProperty(_b.k, "top", _v1, "", _b.c);
|
|
214
|
+
_b.c = _v1;
|
|
215
|
+
}
|
|
216
|
+
if (_b.d !== _v2) {
|
|
217
|
+
setStyleProperty(_b.k, "backgroundColor", _v2, "", _b.d);
|
|
218
|
+
_b.d = _v2;
|
|
219
|
+
}
|
|
220
|
+
if (_b.e !== _v3) {
|
|
221
|
+
setStyleProperty(_b.k, "color", _v3, "", _b.e);
|
|
222
|
+
_b.e = _v3;
|
|
223
|
+
}
|
|
224
|
+
if (_b.f !== _v4) {
|
|
225
|
+
setStyleProperty(_b.k, "fontSize", _v4, "", _b.f);
|
|
226
|
+
_b.f = _v4;
|
|
227
|
+
}
|
|
228
|
+
if (_b.g !== _v5) {
|
|
229
|
+
setStyleProperty(_b.k, "padding", _v5, "", _b.g);
|
|
230
|
+
_b.g = _v5;
|
|
231
|
+
}
|
|
232
|
+
if (_b.h !== _v6) {
|
|
233
|
+
setStyleProperty(_b.k, "borderRadius", _v6, "", _b.h);
|
|
234
|
+
_b.h = _v6;
|
|
235
|
+
}
|
|
236
|
+
if (_b.i !== _v7) {
|
|
237
|
+
setStyleProperty(_b.k, "whiteSpace", _v7, "", _b.i);
|
|
238
|
+
_b.i = _v7;
|
|
239
|
+
}
|
|
240
|
+
if (_b.j !== _v8) {
|
|
241
|
+
setStyleProperty(_b.k, "pointerEvents", _v8, "", _b.j);
|
|
242
|
+
_b.j = _v8;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
_b.n = bindSignalChild(__s, _b.n, 1, _b.k, tipText, "b:a58cdbae", null, void 0, void 0, void 0, true);
|
|
247
|
+
}
|
|
248
|
+
var _rm$10 = [
|
|
249
|
+
"r",
|
|
250
|
+
"i",
|
|
251
|
+
"h"
|
|
252
|
+
];
|
|
253
|
+
var TIP_ESTIMATE_CHAR = 6.2;
|
|
254
|
+
var Chart = /* @__PURE__ */ __s(function Chart(props, __s, __extra) {
|
|
255
|
+
const __memoRegion = compilerMemoRegion(__s, _hs$ + 0);
|
|
256
|
+
let __hk = __memoRegion.hooks;
|
|
257
|
+
if (__hk === void 0) __memoRegion.hooks = __hk = hookMemoCreate(16);
|
|
258
|
+
let __hkd0, __hkd1, __hkd2, __hkd3, __hkd4, __hkd5, __hkd6, __hkd7, __hkd8, __hkd0$, __hkd1$;
|
|
259
|
+
const measure = withSlot(_h$0, useMeasure);
|
|
260
|
+
const [cursor, setCursor] = useState(null, _hs$ + 1);
|
|
261
|
+
const sceneRef = useRef(null, _hs$ + 2);
|
|
262
|
+
const propsRef = useRef(props, _hs$ + 3);
|
|
263
|
+
propsRef.current = props;
|
|
264
|
+
const hostRef = useRef(null, _hs$ + 4);
|
|
265
|
+
const bounds = measure.bounds;
|
|
266
|
+
const w = props.width ?? bounds?.width ?? 0;
|
|
267
|
+
const h = props.height ?? (props.aspectRatio && w > 0 ? w / props.aspectRatio : bounds?.height && bounds.height > 0 ? bounds.height : w > 0 ? w / 1.6 : 0);
|
|
268
|
+
const scene = (__hkd0 = props.type, __hkd1 = props.data, __hkd2 = props.margin, __hkd3 = props.stacked, __hkd4 = props.innerRadiusRatio, __hkd5 = props.xAxis, __hkd6 = props.yAxis, __hkd7 = w, __hkd8 = h, __hk[0] !== true || !hookMemoEqual(__hk[1], __hkd0) || !hookMemoEqual(__hk[2], __hkd1) || !hookMemoEqual(__hk[3], __hkd2) || !hookMemoEqual(__hk[4], __hkd3) || !hookMemoEqual(__hk[5], __hkd4) || !hookMemoEqual(__hk[6], __hkd5) || !hookMemoEqual(__hk[7], __hkd6) || !hookMemoEqual(__hk[8], __hkd7) || !hookMemoEqual(__hk[9], __hkd8) ? hookMemoPublish(__hk, 0, w > 0 && h > 0 ? computeScene(propsRef.current, w, h) : null, __hkd0, __hkd1, __hkd2, __hkd3, __hkd4, __hkd5, __hkd6, __hkd7, __hkd8) : __hk[10]);
|
|
269
|
+
sceneRef.current = scene;
|
|
270
|
+
const interactive = !!(props.onPress || props.onScrub || props.tooltip || props.crosshair);
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
const el = hostRef.current;
|
|
273
|
+
if (!el || !interactive) return;
|
|
274
|
+
const scrub = createScrub(() => sceneRef.current, () => propsRef.current, setCursor);
|
|
275
|
+
const at = (e) => {
|
|
276
|
+
const rect = el.getBoundingClientRect();
|
|
277
|
+
return {
|
|
278
|
+
x: e.clientX - rect.left,
|
|
279
|
+
y: e.clientY - rect.top
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
const down = (e) => {
|
|
283
|
+
el.setPointerCapture?.(e.pointerId);
|
|
284
|
+
const p = at(e);
|
|
285
|
+
scrub("down", p.x, p.y);
|
|
286
|
+
};
|
|
287
|
+
const move = (e) => {
|
|
288
|
+
const p = at(e);
|
|
289
|
+
scrub(e.buttons !== 0 ? "move" : "hover", p.x, p.y);
|
|
290
|
+
};
|
|
291
|
+
const up = (e) => {
|
|
292
|
+
const p = at(e);
|
|
293
|
+
scrub("up", p.x, p.y);
|
|
294
|
+
};
|
|
295
|
+
const click = (e) => {
|
|
296
|
+
const p = e.clientX === 0 && e.clientY === 0 ? {
|
|
297
|
+
x: el.getBoundingClientRect().width / 2,
|
|
298
|
+
y: el.getBoundingClientRect().height / 2
|
|
299
|
+
} : at(e);
|
|
300
|
+
scrub("tap", p.x, p.y);
|
|
301
|
+
};
|
|
302
|
+
const end = () => scrub("cancel", 0, 0);
|
|
303
|
+
const leave = () => scrub("leave", 0, 0);
|
|
304
|
+
el.addEventListener("pointerdown", down);
|
|
305
|
+
el.addEventListener("pointermove", move);
|
|
306
|
+
el.addEventListener("pointerup", up);
|
|
307
|
+
el.addEventListener("pointercancel", end);
|
|
308
|
+
el.addEventListener("pointerleave", leave);
|
|
309
|
+
el.addEventListener("click", click);
|
|
310
|
+
return () => {
|
|
311
|
+
el.removeEventListener("pointerdown", down);
|
|
312
|
+
el.removeEventListener("pointermove", move);
|
|
313
|
+
el.removeEventListener("pointerup", up);
|
|
314
|
+
el.removeEventListener("pointercancel", end);
|
|
315
|
+
el.removeEventListener("pointerleave", leave);
|
|
316
|
+
el.removeEventListener("click", click);
|
|
317
|
+
};
|
|
318
|
+
}, [interactive], _hs$ + 5);
|
|
319
|
+
const legend = props.legend === true ? "bottom" : props.legend;
|
|
320
|
+
const plot = scene?.plot;
|
|
321
|
+
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 : void 0;
|
|
322
|
+
const tipText = (__hkd0$ = cursor, __hkd1$ = scene, __hk[11] !== true || !hookMemoEqual(__hk[12], __hkd0$) || !hookMemoEqual(__hk[13], __hkd1$) ? hookMemoPublish2(__hk, 11, cursor && scene ? hitLabel(scene, cursor) : null, __hkd0$, __hkd1$) : __hk[14]);
|
|
323
|
+
const tipWidth = tipText ? tipText.length * TIP_ESTIMATE_CHAR + 14 : 0;
|
|
324
|
+
const tipLeft = cursor && scene ? Math.min(Math.max(0, cursor.px - tipWidth / 2), Math.max(0, scene.width - tipWidth)) : 0;
|
|
325
|
+
const tipTop = cursor ? cursor.py - 30 : 0;
|
|
326
|
+
const legendRow = __hk[15] ?? hookMemoPublishInvariant(__hk, 15, (items, position) => createScopedValue(() => createScopedElement("div", { style: {
|
|
327
|
+
display: "flex",
|
|
328
|
+
flexWrap: "wrap",
|
|
329
|
+
gap: 12,
|
|
330
|
+
paddingTop: position === "bottom" ? 4 : 0,
|
|
331
|
+
paddingBottom: position === "top" ? 4 : 0
|
|
332
|
+
} }, () => items.map((item) => createScopedElement("span", { style: {
|
|
333
|
+
display: "inline-flex",
|
|
334
|
+
alignItems: "center",
|
|
335
|
+
gap: 4,
|
|
336
|
+
fontSize: 11
|
|
337
|
+
} }, () => positionalChildren([createScopedValue(() => createElement("span", { style: {
|
|
338
|
+
width: 10,
|
|
339
|
+
height: 10,
|
|
340
|
+
borderRadius: 2,
|
|
341
|
+
backgroundColor: item.color,
|
|
342
|
+
display: "inline-block"
|
|
343
|
+
} })), item.text]))))));
|
|
344
|
+
if (__s.block.pending && !__s.block.crossRenderUpdate) return;
|
|
345
|
+
let _b = __s.slots[0];
|
|
346
|
+
if (_b === void 0) {
|
|
347
|
+
let _m1, _m7, _m8, _m13, _m14, _m15, _m16, _m17, _m18, _m21, _m24;
|
|
348
|
+
const _root = clone(_t$1, void 0, "|1|");
|
|
349
|
+
_m1 = _root;
|
|
350
|
+
const _el0 = sibling(child(_root), 1);
|
|
351
|
+
_m7 = _el0;
|
|
352
|
+
queueRefAttach(__s, _m8 = (el) => {
|
|
353
|
+
hostRef.current = el;
|
|
354
|
+
measure.ref(el);
|
|
355
|
+
}, _m7);
|
|
356
|
+
(__s.cleanups ??= []).push(() => _b && queueRefDetach(_b.i, _b.h));
|
|
357
|
+
const _el1 = child(_el0);
|
|
358
|
+
_m13 = _el1;
|
|
359
|
+
const _el2 = sibling(_el1, 1);
|
|
360
|
+
_m14 = _el2;
|
|
361
|
+
const _el3 = sibling(child(_el2), 1);
|
|
362
|
+
_m15 = _el3;
|
|
363
|
+
const _el4 = sibling(_el3, 1);
|
|
364
|
+
_m16 = _el4;
|
|
365
|
+
_m17 = sibling(_el4, 1);
|
|
366
|
+
_m18 = child(_root);
|
|
367
|
+
_m21 = child(_el2);
|
|
368
|
+
_m24 = sibling(_el0, 1);
|
|
369
|
+
_b = bagOf(__s, _root, {
|
|
370
|
+
a: void 0,
|
|
371
|
+
b: _m1,
|
|
372
|
+
c: void 0,
|
|
373
|
+
d: void 0,
|
|
374
|
+
e: void 0,
|
|
375
|
+
f: void 0,
|
|
376
|
+
g: void 0,
|
|
377
|
+
h: _m7,
|
|
378
|
+
i: _m8,
|
|
379
|
+
j: __s,
|
|
380
|
+
k: void 0,
|
|
381
|
+
l: void 0,
|
|
382
|
+
m: void 0,
|
|
383
|
+
n: _m13,
|
|
384
|
+
o: _m14,
|
|
385
|
+
p: _m15,
|
|
386
|
+
q: _m16,
|
|
387
|
+
r: _m17,
|
|
388
|
+
s: _m18,
|
|
389
|
+
t: null,
|
|
390
|
+
u: void 0,
|
|
391
|
+
v: _m21,
|
|
392
|
+
w: null,
|
|
393
|
+
x: void 0,
|
|
394
|
+
y: _m24,
|
|
395
|
+
z: null,
|
|
396
|
+
A: void 0
|
|
397
|
+
});
|
|
398
|
+
__s.refFields = _rm$10;
|
|
399
|
+
} else {
|
|
400
|
+
const _r = (el) => {
|
|
401
|
+
hostRef.current = el;
|
|
402
|
+
measure.ref(el);
|
|
403
|
+
};
|
|
404
|
+
if (_r !== _b.i) _b.i = replaceRef(__s, _b.i, _r, _b.h);
|
|
405
|
+
}
|
|
406
|
+
_b.a = bindSignalAttribute(__s, _b.a, _b.b, "id", props.id, "b:c3863ebe", setPlainAttribute);
|
|
407
|
+
_b.c = bindSignalAttribute(__s, _b.c, _b.b, "class", props.className, "b:75b7746e", "class");
|
|
408
|
+
{
|
|
409
|
+
const _v = {
|
|
410
|
+
display: "flex",
|
|
411
|
+
flexDirection: "column",
|
|
412
|
+
width: props.width,
|
|
413
|
+
height: props.height,
|
|
414
|
+
...props.style
|
|
415
|
+
};
|
|
416
|
+
if (_b.d !== _v) {
|
|
417
|
+
setStyle(_b.b, _v, _b.d);
|
|
418
|
+
_b.d = _v;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
_b.e = bindSignalAttribute(__s, _b.e, _b.b, "role", props.accessibilityLabel ? "img" : void 0, "b:f6e63ca7", setPlainAttribute);
|
|
422
|
+
_b.f = bindSignalAttribute(__s, _b.f, _b.b, "aria-label", props.accessibilityLabel, "b:6f97c1ef", setAriaAttribute);
|
|
423
|
+
_b.g = bindSignalAttribute(__s, _b.g, _b.h, "id", props.id ? props.id + "-overlay" : void 0, "b:b2421ba0", setPlainAttribute);
|
|
424
|
+
{
|
|
425
|
+
const _v0 = props.width;
|
|
426
|
+
const _v1 = props.height ?? (props.aspectRatio && w > 0 ? w / props.aspectRatio : void 0);
|
|
427
|
+
if (_b.j === __s || isHydratingStyle()) {
|
|
428
|
+
setStyleProperties(_b.h, [
|
|
429
|
+
"width",
|
|
430
|
+
_v0,
|
|
431
|
+
"height",
|
|
432
|
+
_v1
|
|
433
|
+
], "position: relative; flex-grow: 1; min-height: 0;");
|
|
434
|
+
_b.j = null;
|
|
435
|
+
_b.k = _v0;
|
|
436
|
+
_b.l = _v1;
|
|
437
|
+
} else {
|
|
438
|
+
if (_b.k !== _v0) {
|
|
439
|
+
setStyleProperty(_b.h, "width", _v0, "", _b.k);
|
|
440
|
+
_b.k = _v0;
|
|
441
|
+
}
|
|
442
|
+
if (_b.l !== _v1) {
|
|
443
|
+
setStyleProperty(_b.h, "height", _v1, "", _b.l);
|
|
444
|
+
_b.l = _v1;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
{
|
|
449
|
+
const _v = scene ? { __html: scene.markup } : void 0;
|
|
450
|
+
if (_b.m !== _v) {
|
|
451
|
+
setDangerouslySetInnerHTML(_b.n, _v);
|
|
452
|
+
_b.m = _v;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
_b.B = bindSignalChild(__s, _b.B, 1, _b.b, legend === "top" && scene ? legendRow(scene.legend, "top") : null, "b:dbd2df85", _b.s, true, void 0, void 0, void 0);
|
|
456
|
+
_b.C = bindSignalChild(__s, _b.C, 2, _b.o, scene?.labels.map((l) => createScopedElement("div", { style: {
|
|
457
|
+
position: "absolute",
|
|
458
|
+
left: l.x,
|
|
459
|
+
top: l.y,
|
|
460
|
+
width: l.width,
|
|
461
|
+
fontSize: 10,
|
|
462
|
+
opacity: .7,
|
|
463
|
+
textAlign: l.align,
|
|
464
|
+
overflow: "hidden",
|
|
465
|
+
whiteSpace: "nowrap",
|
|
466
|
+
textOverflow: "ellipsis"
|
|
467
|
+
} }, () => l.text)), "b:fdc3332b", _b.v, true, void 0, void 0, void 0);
|
|
468
|
+
{
|
|
469
|
+
const __ifCondition = cursor && props.crosshair && !scene?.pie && plot;
|
|
470
|
+
ifBlock(__s, 3, _b.o, __ifCondition, __then$2, null, _b.p, __ifCondition ? [cursor, plot] : void 0);
|
|
471
|
+
}
|
|
472
|
+
{
|
|
473
|
+
const __ifCondition$ = cursor && (props.crosshair || props.tooltip);
|
|
474
|
+
ifBlock(__s, 4, _b.o, __ifCondition$, __then$4, null, _b.q, __ifCondition$ ? [cursor, dotColor] : void 0);
|
|
475
|
+
}
|
|
476
|
+
{
|
|
477
|
+
const __ifCondition$2 = cursor && props.tooltip && tipText;
|
|
478
|
+
ifBlock(__s, 5, _b.o, __ifCondition$2, __then$6, null, _b.r, __ifCondition$2 ? [
|
|
479
|
+
cursor,
|
|
480
|
+
tipLeft,
|
|
481
|
+
tipText,
|
|
482
|
+
tipTop
|
|
483
|
+
] : void 0);
|
|
484
|
+
}
|
|
485
|
+
_b.D = bindSignalChild(__s, _b.D, 6, _b.b, legend === "bottom" && scene ? legendRow(scene.legend, "bottom") : null, "b:30634c19", _b.y, true, void 0, void 0, void 0);
|
|
486
|
+
});
|
|
487
|
+
//#endregion
|
|
488
|
+
export { Chart };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { xCenter } from "./scales.js";
|
|
2
|
+
import { format } from "d3-format";
|
|
3
|
+
import { timeFormat } from "d3-time-format";
|
|
4
|
+
//#region src/core/axes.ts
|
|
5
|
+
var AXIS_COLOR = "#9aa3ad";
|
|
6
|
+
var GRID_COLOR = "#9aa3ad";
|
|
7
|
+
var GRID_OPACITY = .22;
|
|
8
|
+
var si = format("~s");
|
|
9
|
+
var plain = format("~g");
|
|
10
|
+
var day = timeFormat("%b %d");
|
|
11
|
+
/** Default tick label formatting — SI suffixes for big magnitudes, plain
|
|
12
|
+
* significant digits otherwise, short month-day for dates. */
|
|
13
|
+
function defaultFormat(value) {
|
|
14
|
+
if (value instanceof Date) return day(value);
|
|
15
|
+
if (typeof value === "number") return Math.abs(value) >= 1e3 ? si(value) : plain(value);
|
|
16
|
+
return String(value);
|
|
17
|
+
}
|
|
18
|
+
/** Cap categorical label count so boxes don't collide — keep every nth. */
|
|
19
|
+
function thinDomain(domain, plotWidth) {
|
|
20
|
+
const maxLabels = Math.max(2, Math.floor(plotWidth / 56));
|
|
21
|
+
if (domain.length <= maxLabels) return domain;
|
|
22
|
+
const step = Math.ceil(domain.length / maxLabels);
|
|
23
|
+
return domain.filter((_, i) => i % step === 0);
|
|
24
|
+
}
|
|
25
|
+
function xAxisModel(kind, scale, spec, plot) {
|
|
26
|
+
const labels = spec?.labels !== false;
|
|
27
|
+
const stubs = spec?.ticks !== false;
|
|
28
|
+
const grid = spec?.grid === true;
|
|
29
|
+
const fmt = spec?.format ?? defaultFormat;
|
|
30
|
+
const frame = [{
|
|
31
|
+
kind: "line",
|
|
32
|
+
x1: plot.x,
|
|
33
|
+
y1: plot.y + plot.height,
|
|
34
|
+
x2: plot.x + plot.width,
|
|
35
|
+
y2: plot.y + plot.height,
|
|
36
|
+
stroke: AXIS_COLOR,
|
|
37
|
+
strokeWidth: 1
|
|
38
|
+
}];
|
|
39
|
+
const gridMarks = [];
|
|
40
|
+
const out = [];
|
|
41
|
+
let values;
|
|
42
|
+
let format = fmt;
|
|
43
|
+
if (kind === "band" || kind === "point") values = thinDomain(scale.domain(), plot.width);
|
|
44
|
+
else {
|
|
45
|
+
const continuous = scale;
|
|
46
|
+
const count = spec?.tickCount ?? 6;
|
|
47
|
+
values = continuous.ticks(count);
|
|
48
|
+
if (!spec?.format && kind === "time") {
|
|
49
|
+
const tf = continuous.tickFormat(count);
|
|
50
|
+
format = (v) => tf(v);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
for (const v of values) {
|
|
54
|
+
const px = plot.x + xCenter(kind, scale, v);
|
|
55
|
+
if (stubs) frame.push({
|
|
56
|
+
kind: "line",
|
|
57
|
+
x1: px,
|
|
58
|
+
y1: plot.y + plot.height,
|
|
59
|
+
x2: px,
|
|
60
|
+
y2: plot.y + plot.height + 4,
|
|
61
|
+
stroke: AXIS_COLOR,
|
|
62
|
+
strokeWidth: 1
|
|
63
|
+
});
|
|
64
|
+
if (grid) gridMarks.push({
|
|
65
|
+
kind: "line",
|
|
66
|
+
x1: px,
|
|
67
|
+
y1: plot.y,
|
|
68
|
+
x2: px,
|
|
69
|
+
y2: plot.y + plot.height,
|
|
70
|
+
stroke: GRID_COLOR,
|
|
71
|
+
strokeOpacity: GRID_OPACITY,
|
|
72
|
+
strokeWidth: 1
|
|
73
|
+
});
|
|
74
|
+
if (labels) {
|
|
75
|
+
const width = Math.min(72, plot.width / Math.max(1, values.length));
|
|
76
|
+
const boxX = Math.min(Math.max(0, px - width / 2), Math.max(0, plot.x + plot.width + 8 - width));
|
|
77
|
+
out.push({
|
|
78
|
+
x: boxX,
|
|
79
|
+
y: plot.y + plot.height + 6,
|
|
80
|
+
width,
|
|
81
|
+
align: "center",
|
|
82
|
+
text: format(v),
|
|
83
|
+
axis: "x"
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
labels: out,
|
|
89
|
+
frame,
|
|
90
|
+
grid: gridMarks
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function yAxisModel(scale, spec, plot) {
|
|
94
|
+
const labels = spec?.labels !== false;
|
|
95
|
+
const stubs = spec?.ticks !== false;
|
|
96
|
+
const grid = spec?.grid === true;
|
|
97
|
+
const fmt = spec?.format ?? defaultFormat;
|
|
98
|
+
const frame = [{
|
|
99
|
+
kind: "line",
|
|
100
|
+
x1: plot.x,
|
|
101
|
+
y1: plot.y,
|
|
102
|
+
x2: plot.x,
|
|
103
|
+
y2: plot.y + plot.height,
|
|
104
|
+
stroke: AXIS_COLOR,
|
|
105
|
+
strokeWidth: 1
|
|
106
|
+
}];
|
|
107
|
+
const gridMarks = [];
|
|
108
|
+
const out = [];
|
|
109
|
+
for (const v of scale.ticks(spec?.tickCount ?? 5)) {
|
|
110
|
+
const py = plot.y + scale(v);
|
|
111
|
+
if (stubs) frame.push({
|
|
112
|
+
kind: "line",
|
|
113
|
+
x1: plot.x - 4,
|
|
114
|
+
y1: py,
|
|
115
|
+
x2: plot.x,
|
|
116
|
+
y2: py,
|
|
117
|
+
stroke: AXIS_COLOR,
|
|
118
|
+
strokeWidth: 1
|
|
119
|
+
});
|
|
120
|
+
if (grid) gridMarks.push({
|
|
121
|
+
kind: "line",
|
|
122
|
+
x1: plot.x,
|
|
123
|
+
y1: py,
|
|
124
|
+
x2: plot.x + plot.width,
|
|
125
|
+
y2: py,
|
|
126
|
+
stroke: GRID_COLOR,
|
|
127
|
+
strokeOpacity: GRID_OPACITY,
|
|
128
|
+
strokeWidth: 1
|
|
129
|
+
});
|
|
130
|
+
if (labels) out.push({
|
|
131
|
+
x: 0,
|
|
132
|
+
y: py - 6,
|
|
133
|
+
width: Math.max(0, plot.x - 8),
|
|
134
|
+
align: "end",
|
|
135
|
+
text: fmt(v),
|
|
136
|
+
axis: "y"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
labels: out,
|
|
141
|
+
frame,
|
|
142
|
+
grid: gridMarks
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { defaultFormat, xAxisModel, yAxisModel };
|