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