@tensor_1/react 2.38.0 → 2.40.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 +65 -0
- package/dist/{chart-theme-Cl0IrkKQ.d.cts → ChartCore-BKK2HEfi.d.cts} +77 -50
- package/dist/chart-analytic-guide.d.ts +6 -0
- package/dist/chart-analytic-guide.js +10 -0
- package/dist/chart-analytic-model.d.ts +145 -0
- package/dist/chart-analytic-model.js +259 -0
- package/dist/chart-analytic.cjs +1379 -0
- package/dist/chart-analytic.d.cts +339 -0
- package/dist/chart-analytic.d.ts +19 -0
- package/dist/chart-analytic.js +95 -0
- package/dist/chart-panels-model.d.ts +92 -0
- package/dist/chart-panels-model.js +284 -0
- package/dist/chart-preset.cjs +41 -4
- package/dist/chart-preset.d.cts +2 -2
- package/dist/chart-preset.d.ts +1 -1
- package/dist/chart-stats-o4zDhpVm.d.cts +46 -0
- package/dist/chart-stats.d.ts +46 -0
- package/dist/chart-stats.js +89 -0
- package/dist/chart-theme.d.ts +3 -0
- package/dist/chart-theme.js +2 -0
- package/dist/chart.cjs +41 -4
- package/dist/chart.d.cts +2 -2
- package/dist/chart.d.ts +1 -1
- package/dist/components/Chart.d.ts +1 -1
- package/dist/components/ChartCore.d.ts +23 -3
- package/dist/components/ChartCore.js +40 -5
- package/dist/components/ChartPanels.d.ts +52 -0
- package/dist/components/ChartPanels.js +170 -0
- package/dist/components/Comments.d.ts +4 -1
- package/dist/components/Comments.js +3 -2
- package/dist/components/InsightCard.d.ts +86 -0
- package/dist/components/InsightCard.js +118 -0
- package/dist/components/Markdown.d.ts +9 -2
- package/dist/components/Markdown.js +16 -2
- package/dist/components/RichTextEditor.d.ts +17 -0
- package/dist/components/RichTextEditor.js +179 -11
- package/dist/components/ToggleRow.d.ts +8 -1
- package/dist/components/ToggleRow.js +17 -3
- package/dist/correlation-scatter-model.d.ts +68 -0
- package/dist/correlation-scatter-model.js +179 -0
- package/dist/icons/Icon.d.ts +17 -17
- package/dist/index.cjs +1663 -1427
- package/dist/index.d.cts +96 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -0
- package/dist/markdown-model-Cuwi6pIk.d.cts +110 -0
- package/dist/markdown-model.d.ts +38 -1
- package/dist/markdown-model.js +67 -0
- package/dist/markdown.cjs +90 -4
- package/dist/markdown.d.cts +11 -75
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js +16 -2
- package/dist/rich-text/mention.d.ts +14 -0
- package/dist/rich-text/mention.js +57 -0
- package/dist/rich-text/pipeline.js +4 -1
- package/dist/rich-text.cjs +1795 -1483
- package/dist/rich-text.d.cts +27 -1
- package/dist/rich-text.d.ts +3 -0
- package/dist/rich-text.js +6 -0
- package/package.json +6 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { linearFit, quantiles } from "./chart-stats.js";
|
|
2
|
+
import { combineMarks, thresholdMarks } from "./chart-analytic-model.js";
|
|
3
|
+
import { niceCeil } from "./chart-panels-model.js";
|
|
4
|
+
const defaultNumber = new Intl.NumberFormat("en", { maximumFractionDigits: 2 });
|
|
5
|
+
function formatCorrelation(r) {
|
|
6
|
+
const shown = Math.abs(r) < 1 ? Math.trunc(r * 100) / 100 : Math.sign(r);
|
|
7
|
+
return shown.toFixed(2);
|
|
8
|
+
}
|
|
9
|
+
const DEFAULT_CORRELATION_SCATTER_LABELS = {
|
|
10
|
+
stats: ({ r, n }) => `${r == null ? "" : `r = ${formatCorrelation(r)} \xB7 `}n = ${n} \xB7 association, not cause`,
|
|
11
|
+
notEnough: (n, min) => `Not enough data (n = ${n} of ${min})`,
|
|
12
|
+
percentile: (p) => `p${p}`,
|
|
13
|
+
trend: "Trend",
|
|
14
|
+
point: "Point",
|
|
15
|
+
formatX: (x) => defaultNumber.format(x),
|
|
16
|
+
formatY: (y) => defaultNumber.format(y)
|
|
17
|
+
};
|
|
18
|
+
const SCATTER_HIT_SIZE = 26;
|
|
19
|
+
const DOT_SIZE = 9;
|
|
20
|
+
const escapeHtml = (text) => text.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c] ?? c);
|
|
21
|
+
const niceRange = (values) => {
|
|
22
|
+
const lo = Math.min(...values);
|
|
23
|
+
const hi = Math.max(...values);
|
|
24
|
+
const max = niceCeil(hi > 0 ? hi * 1.08 : hi || 1);
|
|
25
|
+
const min = lo >= 0 ? 0 : -niceCeil(-lo * 1.08);
|
|
26
|
+
return [min, max];
|
|
27
|
+
};
|
|
28
|
+
function correlationScatterModel(spec, tokens, labelOverrides) {
|
|
29
|
+
const labels = { ...DEFAULT_CORRELATION_SCATTER_LABELS, ...labelOverrides };
|
|
30
|
+
const minPoints = Math.max(2, spec.minPoints ?? 8);
|
|
31
|
+
const points = spec.points.filter((p) => Number.isFinite(p.x) && Number.isFinite(p.y));
|
|
32
|
+
const n = points.length;
|
|
33
|
+
const enough = n >= minPoints;
|
|
34
|
+
const fit = enough && spec.trend !== "none" ? linearFit(points) : null;
|
|
35
|
+
const statsText = labels.stats({ r: fit?.r ?? null, n });
|
|
36
|
+
const xs = [...points.map((p) => p.x), ...(spec.thresholds?.x ?? []).map((t) => t.value), ...spec.breakpoint ? [spec.breakpoint.x] : []];
|
|
37
|
+
const ys = [...points.map((p) => p.y), ...(spec.thresholds?.y ?? []).map((t) => t.value)];
|
|
38
|
+
const [xMin, xMax] = xs.length ? niceRange(xs) : [0, 1];
|
|
39
|
+
const [yMin, yMax] = ys.length ? niceRange(ys) : [0, 1];
|
|
40
|
+
const dotData = points.map((p) => ({
|
|
41
|
+
value: [p.x, p.y],
|
|
42
|
+
symbol: p.emphasis === "danger" ? "diamond" : p.emphasis === "warning" ? "triangle" : "circle",
|
|
43
|
+
symbolSize: p.emphasis ? DOT_SIZE + 3 : DOT_SIZE,
|
|
44
|
+
itemStyle: {
|
|
45
|
+
color: p.emphasis === "danger" ? tokens.danger : p.emphasis === "warning" ? tokens.warning : tokens.palette[0],
|
|
46
|
+
borderColor: tokens.surface,
|
|
47
|
+
borderWidth: 2,
|
|
48
|
+
opacity: 1
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
const pcts = (spec.percentiles ?? []).filter((p) => p > 0 && p < 100);
|
|
52
|
+
const pctValues = quantiles(points.map((p) => p.y), pcts.map((p) => p / 100));
|
|
53
|
+
const percentileLines = enough && pcts.length ? {
|
|
54
|
+
markLine: {
|
|
55
|
+
silent: true,
|
|
56
|
+
symbol: "none",
|
|
57
|
+
animation: false,
|
|
58
|
+
data: pcts.flatMap((p, i) => {
|
|
59
|
+
const value = pctValues[i];
|
|
60
|
+
return value == null ? [] : [{
|
|
61
|
+
yAxis: value,
|
|
62
|
+
lineStyle: { color: tokens.reference, width: 1, type: "solid", opacity: 0.6 },
|
|
63
|
+
label: { show: true, position: "end", formatter: labels.percentile(p), color: tokens.textMuted, fontFamily: tokens.fontSans, fontSize: 11, distance: 6 }
|
|
64
|
+
}];
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
} : {};
|
|
68
|
+
const xLines = {
|
|
69
|
+
markLine: {
|
|
70
|
+
silent: true,
|
|
71
|
+
symbol: "none",
|
|
72
|
+
animation: false,
|
|
73
|
+
data: [
|
|
74
|
+
...(spec.thresholds?.x ?? []).map((t) => ({
|
|
75
|
+
xAxis: t.value,
|
|
76
|
+
lineStyle: { color: tokens.reference, width: 1, type: "solid" },
|
|
77
|
+
label: { show: true, position: "end", formatter: t.label, color: tokens.textMuted, fontFamily: tokens.fontSans, fontSize: 11 }
|
|
78
|
+
})),
|
|
79
|
+
...spec.breakpoint && enough ? [{
|
|
80
|
+
xAxis: spec.breakpoint.x,
|
|
81
|
+
lineStyle: { color: tokens.text, width: 1, type: "solid" },
|
|
82
|
+
label: { show: true, position: "end", formatter: spec.breakpoint.label, color: tokens.text, fontFamily: tokens.fontSans, fontSize: 11, fontWeight: 600 }
|
|
83
|
+
}] : []
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const marks = combineMarks(
|
|
88
|
+
spec.thresholds?.y?.length ? thresholdMarks(spec.thresholds.y, { tokens, extent: [yMin, yMax] }) : null,
|
|
89
|
+
percentileLines,
|
|
90
|
+
(xLines.markLine?.data).length ? xLines : null
|
|
91
|
+
);
|
|
92
|
+
const series = [
|
|
93
|
+
{
|
|
94
|
+
id: "points",
|
|
95
|
+
name: spec.yLabel,
|
|
96
|
+
type: "scatter",
|
|
97
|
+
data: dotData,
|
|
98
|
+
silent: true,
|
|
99
|
+
animation: false,
|
|
100
|
+
z: 3,
|
|
101
|
+
...marks
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
// the hit layer: transparent 24 px targets over the dots carry the tooltip and the click
|
|
105
|
+
id: "points-hit",
|
|
106
|
+
name: spec.yLabel,
|
|
107
|
+
type: "scatter",
|
|
108
|
+
data: points.map((p, index) => ({ value: [p.x, p.y, index] })),
|
|
109
|
+
symbol: "circle",
|
|
110
|
+
symbolSize: SCATTER_HIT_SIZE,
|
|
111
|
+
itemStyle: { color: "rgba(0,0,0,0)" },
|
|
112
|
+
emphasis: { itemStyle: { color: "rgba(0,0,0,0)", borderColor: tokens.text, borderWidth: 1 } },
|
|
113
|
+
cursor: "pointer",
|
|
114
|
+
animation: false,
|
|
115
|
+
z: 4
|
|
116
|
+
}
|
|
117
|
+
];
|
|
118
|
+
if (fit) {
|
|
119
|
+
series.push({
|
|
120
|
+
id: "trend",
|
|
121
|
+
name: labels.trend,
|
|
122
|
+
type: "line",
|
|
123
|
+
data: [[xMin, fit.intercept + fit.slope * xMin], [xMax, fit.intercept + fit.slope * xMax]],
|
|
124
|
+
symbol: "none",
|
|
125
|
+
silent: true,
|
|
126
|
+
lineStyle: { color: tokens.reference, width: 1.5, type: "solid" },
|
|
127
|
+
tooltip: { show: false },
|
|
128
|
+
animation: false,
|
|
129
|
+
clip: true,
|
|
130
|
+
z: 2
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const option = {
|
|
134
|
+
animation: false,
|
|
135
|
+
grid: { top: 28, right: spec.thresholds?.y?.length || pcts.length ? 100 : 20, bottom: 44, left: 52, containLabel: false },
|
|
136
|
+
xAxis: {
|
|
137
|
+
type: "value",
|
|
138
|
+
min: xMin,
|
|
139
|
+
max: xMax,
|
|
140
|
+
name: spec.xLabel,
|
|
141
|
+
nameLocation: "middle",
|
|
142
|
+
nameGap: 28,
|
|
143
|
+
nameTextStyle: { color: tokens.textMuted, fontFamily: tokens.fontSans, fontSize: 12 },
|
|
144
|
+
axisLabel: { formatter: (v) => labels.formatX(v) },
|
|
145
|
+
splitLine: { show: true }
|
|
146
|
+
},
|
|
147
|
+
yAxis: {
|
|
148
|
+
type: "value",
|
|
149
|
+
min: yMin,
|
|
150
|
+
max: yMax,
|
|
151
|
+
name: spec.yLabel,
|
|
152
|
+
nameLocation: "end",
|
|
153
|
+
nameGap: 10,
|
|
154
|
+
nameTextStyle: { align: "left", padding: [0, 0, 0, -48], color: tokens.textMuted, fontFamily: tokens.fontSans, fontSize: 12 },
|
|
155
|
+
axisLabel: { formatter: (v) => labels.formatY(v) }
|
|
156
|
+
},
|
|
157
|
+
tooltip: {
|
|
158
|
+
trigger: "item",
|
|
159
|
+
confine: true,
|
|
160
|
+
formatter: (params) => {
|
|
161
|
+
const p = params;
|
|
162
|
+
if (p.seriesId !== "points-hit" || !Array.isArray(p.value)) return "";
|
|
163
|
+
const point = points[Number(p.value[2])];
|
|
164
|
+
if (!point) return "";
|
|
165
|
+
return `<div style="font-weight:600;margin-bottom:4px">${escapeHtml(point.label)}</div><div>${escapeHtml(spec.xLabel)}: ${escapeHtml(labels.formatX(point.x))}</div><div>${escapeHtml(spec.yLabel)}: ${escapeHtml(labels.formatY(point.y))}</div>`;
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
series
|
|
169
|
+
};
|
|
170
|
+
const headers = [labels.point, spec.xLabel, spec.yLabel];
|
|
171
|
+
const rows = points.map((p) => ({ [labels.point]: p.label, [spec.xLabel]: labels.formatX(p.x), [spec.yLabel]: labels.formatY(p.y) }));
|
|
172
|
+
return { enough, n, minPoints, fit, option, statsText, table: { headers, rows }, hitSeriesId: "points-hit" };
|
|
173
|
+
}
|
|
174
|
+
export {
|
|
175
|
+
DEFAULT_CORRELATION_SCATTER_LABELS,
|
|
176
|
+
SCATTER_HIT_SIZE,
|
|
177
|
+
correlationScatterModel,
|
|
178
|
+
formatCorrelation
|
|
179
|
+
};
|
package/dist/icons/Icon.d.ts
CHANGED
|
@@ -19,14 +19,27 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
19
19
|
z?: number | string | undefined | undefined;
|
|
20
20
|
opacity?: number | string | undefined | undefined;
|
|
21
21
|
r?: number | string | undefined | undefined;
|
|
22
|
-
|
|
22
|
+
target?: string | undefined | undefined;
|
|
23
|
+
min?: number | string | undefined | undefined;
|
|
24
|
+
max?: number | string | undefined | undefined;
|
|
23
25
|
name?: string | undefined | undefined;
|
|
26
|
+
rotate?: number | string | undefined | undefined;
|
|
27
|
+
offset?: number | string | undefined | undefined;
|
|
28
|
+
overflow?: number | string | undefined | undefined;
|
|
29
|
+
end?: number | string | undefined | undefined;
|
|
30
|
+
scale?: number | string | undefined | undefined;
|
|
31
|
+
to?: number | string | undefined | undefined;
|
|
24
32
|
x?: number | string | undefined | undefined;
|
|
25
|
-
y?: number | string | undefined | undefined;
|
|
26
33
|
cursor?: number | string | undefined | undefined;
|
|
34
|
+
id?: string | undefined | undefined;
|
|
35
|
+
radius?: number | string | undefined | undefined;
|
|
36
|
+
from?: number | string | undefined | undefined;
|
|
37
|
+
y?: number | string | undefined | undefined;
|
|
38
|
+
slope?: number | string | undefined | undefined;
|
|
39
|
+
intercept?: number | string | undefined | undefined;
|
|
40
|
+
points?: string | undefined | undefined;
|
|
27
41
|
children?: react.ReactNode;
|
|
28
42
|
clipPath?: string | undefined | undefined;
|
|
29
|
-
radius?: number | string | undefined | undefined;
|
|
30
43
|
media?: string | undefined | undefined;
|
|
31
44
|
suppressHydrationWarning?: boolean | undefined | undefined;
|
|
32
45
|
lang?: string | undefined | undefined;
|
|
@@ -246,7 +259,6 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
246
259
|
onAnimationIterationCapture?: react.AnimationEventHandler<SVGSVGElement> | undefined;
|
|
247
260
|
onTransitionEnd?: react.TransitionEventHandler<SVGSVGElement> | undefined;
|
|
248
261
|
onTransitionEndCapture?: react.TransitionEventHandler<SVGSVGElement> | undefined;
|
|
249
|
-
end?: number | string | undefined | undefined;
|
|
250
262
|
alphabetic?: number | string | undefined | undefined;
|
|
251
263
|
ideographic?: number | string | undefined | undefined;
|
|
252
264
|
mathematical?: number | string | undefined | undefined;
|
|
@@ -256,17 +268,14 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
256
268
|
unicode?: number | string | undefined | undefined;
|
|
257
269
|
clip?: number | string | undefined | undefined;
|
|
258
270
|
stroke: string;
|
|
259
|
-
|
|
271
|
+
href?: string | undefined | undefined;
|
|
260
272
|
capHeight?: number | string | undefined | undefined;
|
|
261
273
|
dy?: number | string | undefined | undefined;
|
|
262
274
|
dx?: number | string | undefined | undefined;
|
|
263
275
|
transform?: string | undefined | undefined;
|
|
264
276
|
mask?: string | undefined | undefined;
|
|
265
277
|
path?: string | undefined | undefined;
|
|
266
|
-
max?: number | string | undefined | undefined;
|
|
267
278
|
method?: string | undefined | undefined;
|
|
268
|
-
min?: number | string | undefined | undefined;
|
|
269
|
-
target?: string | undefined | undefined;
|
|
270
279
|
crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
|
|
271
280
|
accentHeight?: number | string | undefined | undefined;
|
|
272
281
|
additive?: "replace" | "sum" | undefined | undefined;
|
|
@@ -323,7 +332,6 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
323
332
|
fontVariant?: number | string | undefined | undefined;
|
|
324
333
|
format?: number | string | undefined | undefined;
|
|
325
334
|
fr?: number | string | undefined | undefined;
|
|
326
|
-
from?: number | string | undefined | undefined;
|
|
327
335
|
fx?: number | string | undefined | undefined;
|
|
328
336
|
fy?: number | string | undefined | undefined;
|
|
329
337
|
g1?: number | string | undefined | undefined;
|
|
@@ -336,11 +344,9 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
336
344
|
gradientUnits?: string | undefined | undefined;
|
|
337
345
|
horizAdvX?: number | string | undefined | undefined;
|
|
338
346
|
horizOriginX?: number | string | undefined | undefined;
|
|
339
|
-
href?: string | undefined | undefined;
|
|
340
347
|
imageRendering?: number | string | undefined | undefined;
|
|
341
348
|
in2?: number | string | undefined | undefined;
|
|
342
349
|
in?: string | undefined | undefined;
|
|
343
|
-
intercept?: number | string | undefined | undefined;
|
|
344
350
|
k1?: number | string | undefined | undefined;
|
|
345
351
|
k2?: number | string | undefined | undefined;
|
|
346
352
|
k3?: number | string | undefined | undefined;
|
|
@@ -371,7 +377,6 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
371
377
|
orient?: number | string | undefined | undefined;
|
|
372
378
|
orientation?: number | string | undefined | undefined;
|
|
373
379
|
origin?: number | string | undefined | undefined;
|
|
374
|
-
overflow?: number | string | undefined | undefined;
|
|
375
380
|
overlinePosition?: number | string | undefined | undefined;
|
|
376
381
|
overlineThickness?: number | string | undefined | undefined;
|
|
377
382
|
paintOrder?: number | string | undefined | undefined;
|
|
@@ -381,7 +386,6 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
381
386
|
patternTransform?: number | string | undefined | undefined;
|
|
382
387
|
patternUnits?: string | undefined | undefined;
|
|
383
388
|
pointerEvents?: number | string | undefined | undefined;
|
|
384
|
-
points?: string | undefined | undefined;
|
|
385
389
|
pointsAtX?: number | string | undefined | undefined;
|
|
386
390
|
pointsAtY?: number | string | undefined | undefined;
|
|
387
391
|
pointsAtZ?: number | string | undefined | undefined;
|
|
@@ -397,13 +401,10 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
397
401
|
requiredFeatures?: number | string | undefined | undefined;
|
|
398
402
|
restart?: number | string | undefined | undefined;
|
|
399
403
|
result?: string | undefined | undefined;
|
|
400
|
-
rotate?: number | string | undefined | undefined;
|
|
401
404
|
rx?: number | string | undefined | undefined;
|
|
402
405
|
ry?: number | string | undefined | undefined;
|
|
403
|
-
scale?: number | string | undefined | undefined;
|
|
404
406
|
seed?: number | string | undefined | undefined;
|
|
405
407
|
shapeRendering?: number | string | undefined | undefined;
|
|
406
|
-
slope?: number | string | undefined | undefined;
|
|
407
408
|
spacing?: number | string | undefined | undefined;
|
|
408
409
|
specularConstant?: number | string | undefined | undefined;
|
|
409
410
|
specularExponent?: number | string | undefined | undefined;
|
|
@@ -433,7 +434,6 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
433
434
|
textDecoration?: number | string | undefined | undefined;
|
|
434
435
|
textLength?: number | string | undefined | undefined;
|
|
435
436
|
textRendering?: number | string | undefined | undefined;
|
|
436
|
-
to?: number | string | undefined | undefined;
|
|
437
437
|
transformOrigin?: string | undefined | undefined;
|
|
438
438
|
u1?: number | string | undefined | undefined;
|
|
439
439
|
u2?: number | string | undefined | undefined;
|