@joplo-app/plugin-viz 0.0.0-stage → 0.9.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 +97 -0
- package/dist/catalog.d.ts +8 -0
- package/dist/catalog.js +178 -0
- package/dist/components.d.ts +234 -0
- package/dist/components.js +55 -0
- package/dist/effects.d.ts +27 -0
- package/dist/effects.js +32 -0
- package/dist/guide.d.ts +3 -0
- package/dist/guide.js +79 -0
- package/dist/labels.json +12 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +312 -0
- package/dist/runtime/bar-chart.d.ts +4 -0
- package/dist/runtime/bar-chart.js +193 -0
- package/dist/runtime/delta-bar.d.ts +4 -0
- package/dist/runtime/delta-bar.js +165 -0
- package/dist/runtime/heatmap.d.ts +4 -0
- package/dist/runtime/heatmap.js +138 -0
- package/dist/runtime/hooks.d.ts +36 -0
- package/dist/runtime/hooks.js +54 -0
- package/dist/runtime/line-chart.d.ts +4 -0
- package/dist/runtime/line-chart.js +197 -0
- package/dist/runtime/radar.d.ts +4 -0
- package/dist/runtime/radar.js +101 -0
- package/dist/runtime/ratio-bar.d.ts +4 -0
- package/dist/runtime/ratio-bar.js +77 -0
- package/dist/runtime/sankey.d.ts +4 -0
- package/dist/runtime/sankey.js +171 -0
- package/dist/runtime/scatter-plot.d.ts +4 -0
- package/dist/runtime/scatter-plot.js +202 -0
- package/dist/runtime/time-lanes.d.ts +4 -0
- package/dist/runtime/time-lanes.js +179 -0
- package/dist/runtime/tokens.d.ts +11 -0
- package/dist/runtime/tokens.js +51 -0
- package/dist/runtime/waterfall.d.ts +4 -0
- package/dist/runtime/waterfall.js +119 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +26 -0
- package/dist/schema.d.ts +202 -0
- package/dist/schema.js +255 -0
- package/dist/version.json +3 -0
- package/package.json +67 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Required Notice: Copyright 2026 Joplo-app (https://joplo.app, support@joplo.app)
|
|
2
|
+
|
|
3
|
+
Licensor Line of Business: Joplo, a tool for authoring, previewing, reviewing, and publishing interactive product prototypes, demos, and presentations (https://joplo.app)
|
|
4
|
+
Licensor Line of Business: Joplo Cloud, a service for hosting, sharing, commenting on, reviewing, and measuring Joplo prototypes and presentations (https://joplo.app)
|
|
5
|
+
|
|
6
|
+
What counts as competing, and how to ask about other uses: see COMMERCIAL.md
|
|
7
|
+
https://github.com/Joplo-app/Joplo/blob/main/COMMERCIAL.md
|
|
8
|
+
|
|
9
|
+
# PolyForm Shield License 1.0.0
|
|
10
|
+
|
|
11
|
+
<https://polyformproject.org/licenses/shield/1.0.0>
|
|
12
|
+
|
|
13
|
+
## Acceptance
|
|
14
|
+
|
|
15
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
16
|
+
|
|
17
|
+
## Copyright License
|
|
18
|
+
|
|
19
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
20
|
+
|
|
21
|
+
## Distribution License
|
|
22
|
+
|
|
23
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
24
|
+
|
|
25
|
+
## Notices
|
|
26
|
+
|
|
27
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
28
|
+
|
|
29
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
30
|
+
|
|
31
|
+
## Changes and New Works License
|
|
32
|
+
|
|
33
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
34
|
+
|
|
35
|
+
## Patent License
|
|
36
|
+
|
|
37
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
38
|
+
|
|
39
|
+
## Noncompete
|
|
40
|
+
|
|
41
|
+
Any purpose is a permitted purpose, except for providing any product that competes with the software or any product the licensor or any of its affiliates provides using the software.
|
|
42
|
+
|
|
43
|
+
## Competition
|
|
44
|
+
|
|
45
|
+
Goods and services compete even when they provide functionality through different kinds of interfaces or for different technical platforms. Applications can compete with services, libraries with plugins, frameworks with development tools, and so on, even if they're written in different programming languages or for different computer architectures. Goods and services compete even when provided free of charge. If you market a product as a practical substitute for the software or another product, it definitely competes.
|
|
46
|
+
|
|
47
|
+
## New Products
|
|
48
|
+
|
|
49
|
+
If you are using the software to provide a product that does not compete, but the licensor or any of its affiliates brings your product into competition by providing a new version of the software or another product using the software, you may continue using versions of the software available under these terms beforehand to provide your competing product, but not any later versions.
|
|
50
|
+
|
|
51
|
+
## Discontinued Products
|
|
52
|
+
|
|
53
|
+
You may begin using the software to compete with a product or service that the licensor or any of its affiliates has stopped providing, unless the licensor includes a plain-text line beginning with `Licensor Line of Business:` with the software that mentions that line of business. For example:
|
|
54
|
+
|
|
55
|
+
> Licensor Line of Business: YoyodyneCMS Content Management System (http://example.com/cms)
|
|
56
|
+
|
|
57
|
+
## Sales of Business
|
|
58
|
+
|
|
59
|
+
If the licensor or any of its affiliates sells a line of business developing the software or using the software to provide a product, the buyer can also enforce [Noncompete](#noncompete) for that product.
|
|
60
|
+
|
|
61
|
+
## Fair Use
|
|
62
|
+
|
|
63
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
64
|
+
|
|
65
|
+
## No Other Rights
|
|
66
|
+
|
|
67
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
68
|
+
|
|
69
|
+
## Patent Defense
|
|
70
|
+
|
|
71
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
72
|
+
|
|
73
|
+
## Violations
|
|
74
|
+
|
|
75
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
76
|
+
|
|
77
|
+
## No Liability
|
|
78
|
+
|
|
79
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
80
|
+
|
|
81
|
+
## Definitions
|
|
82
|
+
|
|
83
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
84
|
+
|
|
85
|
+
A **product** can be a good or service, or a combination of them.
|
|
86
|
+
|
|
87
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
88
|
+
|
|
89
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all its affiliates.
|
|
90
|
+
|
|
91
|
+
**Affiliates** means the other organizations than an organization has control over, is under the control of, or is under common control with.
|
|
92
|
+
|
|
93
|
+
**Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
94
|
+
|
|
95
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
96
|
+
|
|
97
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PluginInspectField } from '@joplo-app/kit/plugin';
|
|
2
|
+
export declare const COMPONENT_TYPES: readonly ["DeltaBar", "BarChart", "RatioBar", "LineChart", "TimeLanes", "ScatterPlot", "Heatmap", "Sankey", "Waterfall", "Radar"];
|
|
3
|
+
export type VizComponentName = (typeof COMPONENT_TYPES)[number];
|
|
4
|
+
export declare const COMPONENT_DOCS: Record<VizComponentName, string>;
|
|
5
|
+
export declare const COMPONENT_EXAMPLES: Record<VizComponentName, string>;
|
|
6
|
+
export declare const TEXT_PROPS: Record<VizComponentName, string[]>;
|
|
7
|
+
export declare const TEXT_PATHS: Partial<Record<VizComponentName, string[][]>>;
|
|
8
|
+
export declare const INSPECT_FIELDS: Partial<Record<VizComponentName, PluginInspectField[]>>;
|
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
export const COMPONENT_TYPES = [
|
|
2
|
+
'DeltaBar',
|
|
3
|
+
'BarChart',
|
|
4
|
+
'RatioBar',
|
|
5
|
+
'LineChart',
|
|
6
|
+
'TimeLanes',
|
|
7
|
+
'ScatterPlot',
|
|
8
|
+
'Heatmap',
|
|
9
|
+
'Sankey',
|
|
10
|
+
'Waterfall',
|
|
11
|
+
'Radar',
|
|
12
|
+
];
|
|
13
|
+
export const COMPONENT_DOCS = {
|
|
14
|
+
DeltaBar: 'items: [{ id?, label, sub?, baseline?, value, deltaLabel?, note?, color?, lowerIsBetter? }], variant="ghost"|"paired", domain?, unit?="%", lowerIsBetter?, ticks?, title?, subtitle?. Before-vs-after metric comparison with ghost baseline outline, curtain-uncover retract animation, and direct delta pills. Supports pinBaseline() and focusDatum().',
|
|
15
|
+
BarChart: 'data: [{ id?, [dataKey], [series], locked?, lockedLabel?, deltaBadge?, note?, color? }], dataKey, series: [{ name, label?, color? }], orientation="vertical"|"horizontal", layout="grouped"|"stacked", scale="linear"|"log", unit?, referenceLine?, directLabels?=true, withLegend?, h?. Zero-stretch labels and invariant lock pins.',
|
|
16
|
+
RatioBar: 'total, left, optional right or segments: [{ id?, label?, value, color? }], threshold?, labels?, remainderLabel?, thresholdLabel?, colors?, unit?, height?, showDenominator?=false. Part-of-a-whole ratio and threshold bar; clean single-value formatting by default.',
|
|
17
|
+
LineChart: 'data: [{ id?, [dataKey], [series] }], dataKey, series: [{ name, label?, color?, area?, dashed? }], unit?, yDomain?, curve="linear"|"monotone", referenceLine?, referenceBand?, revealTo?, directLabels?=true, withLegend?, h?. Crisp SVG paths with zero-stretch HTML labels, progressive revealTo(), and addressable points.',
|
|
18
|
+
TimeLanes: 'domain: [min, max], spans: [{ id, lane, start, end, label?, shortLabel?, rangeLabel?, status?, color? }], unit?="ms", ticks?, cursor?, cursorLabel?, spanIds?, compact?. Full tick gridlines, animated playhead via setCursor(), focusDatum() lane dimming, and automatic external labels for narrow bars.',
|
|
19
|
+
ScatterPlot: 'points: [{ id?, label, x, y, r?, group?, tier?, color?, valueLabel? }], xLabel?, yLabel?, xUnit?, yUnit?, xDomain?, yDomain?, pareto?="top-left"|"top-right"|"bottom-left"|"bottom-right"|false, quadrant?, h?. 2D trade-off scatter plot with automatic Pareto frontier polyline and addressable points.',
|
|
20
|
+
Heatmap: 'rows: string[], cols: string[], values: number[][], domain?, colorScale="indigo"|"emerald"|"amber"|"crimson"|"diverging", format="fixed2"|"percent"|"int", cornerLabel?, showScale?=true, cellAnchors?. High-contrast matrix with automatic dark-cell white text and row/col/cell focusDatum().',
|
|
21
|
+
Sankey: 'nodes: [{ id, label, sub?, valueLabel?, color?, tone? }], links: [{ id?, source, target, value, label?, color? }], unit?, nodeWidth?, nodePadding?, h?. Proportional d3-sankey layout with cubic-Bezier curved ribbons and single-path focusDatum().',
|
|
22
|
+
Waterfall: 'steps: [{ id?, label, value, kind?="start"|"delta"|"subtotal"|"total", deltaLabel?, color? }], unit?, lowerIsBetter?, h?. Cumulative positive/negative attribution staircase with dashed connectors and revealTo().',
|
|
23
|
+
Radar: 'axes: [{ key, label, max?, deltaLabel? }], series: [{ id?, name, values, color?, dashed? }], levels?=3, max?=100, showTicks?=true, h?. Multi-axis polygonal spiderweb profile with direct axis/delta labels.',
|
|
24
|
+
};
|
|
25
|
+
export const COMPONENT_EXAMPLES = {
|
|
26
|
+
DeltaBar: `<DeltaBar
|
|
27
|
+
id="payoff"
|
|
28
|
+
title="单请求实测资源与延迟"
|
|
29
|
+
unit="%"
|
|
30
|
+
lowerIsBetter
|
|
31
|
+
items={[
|
|
32
|
+
{ id: 'delta_cpu', label: '单请求 CPU', baseline: 100, value: $.ui.cpuRust, deltaLabel: '−70%' },
|
|
33
|
+
{ id: 'delta_mem', label: '单请求内存', baseline: 100, value: $.ui.memRust, deltaLabel: '−80%+' },
|
|
34
|
+
{ id: 'delta_ttft', label: '中位 TTFT', baseline: 100, value: $.ui.ttftRust, deltaLabel: '−20%' },
|
|
35
|
+
]}
|
|
36
|
+
/>`,
|
|
37
|
+
BarChart: `<BarChart
|
|
38
|
+
id="kv_scale"
|
|
39
|
+
title="单词 KV 缓存维度"
|
|
40
|
+
dataKey="arch"
|
|
41
|
+
layout="stacked"
|
|
42
|
+
data={[
|
|
43
|
+
{ id: 'bar_mha', arch: '标准 MHA', semantic: 32768, pos: 0 },
|
|
44
|
+
{ id: 'bar_mla', arch: 'MLA', semantic: 512, pos: 64, deltaBadge: '−93.3%' },
|
|
45
|
+
]}
|
|
46
|
+
series={[
|
|
47
|
+
{ name: 'semantic', label: '语义核', color: 'indigo' },
|
|
48
|
+
{ name: 'pos', label: '位置签', color: 'orange' },
|
|
49
|
+
]}
|
|
50
|
+
/>`,
|
|
51
|
+
RatioBar: `<RatioBar
|
|
52
|
+
id="prod_match"
|
|
53
|
+
total={100}
|
|
54
|
+
left={$.ui.prodMatch}
|
|
55
|
+
threshold={99}
|
|
56
|
+
labels={['真实线上一致']}
|
|
57
|
+
remainderLabel="存在差异"
|
|
58
|
+
thresholdLabel="上线门槛"
|
|
59
|
+
unit="%"
|
|
60
|
+
colors={['indigo', 'red']}
|
|
61
|
+
/>`,
|
|
62
|
+
LineChart: `<LineChart
|
|
63
|
+
id="trend"
|
|
64
|
+
title="线上影子差异率收敛"
|
|
65
|
+
dataKey="month"
|
|
66
|
+
unit="%"
|
|
67
|
+
data={[
|
|
68
|
+
{ id: 'pt_apr', month: '4 月', diff: 75 },
|
|
69
|
+
{ id: 'pt_june', month: '6 月', diff: 12 },
|
|
70
|
+
{ id: 'pt_sep', month: '9 月', diff: 0.02 },
|
|
71
|
+
]}
|
|
72
|
+
series={[{ name: 'diff', label: '差异率', color: 'indigo', area: true }]}
|
|
73
|
+
referenceLine={{ value: 0.1, label: '上线门槛 < 0.1%', color: 'green' }}
|
|
74
|
+
/>`,
|
|
75
|
+
TimeLanes: `<TimeLanes
|
|
76
|
+
id="leverage"
|
|
77
|
+
title="工程师精力逐步外移"
|
|
78
|
+
domain={[4, 9]}
|
|
79
|
+
unit="月"
|
|
80
|
+
spans={[
|
|
81
|
+
{ id: 'sp_inner', lane: '内环排障', start: 4, end: 5.4, label: '亲自查差异', status: 'warn' },
|
|
82
|
+
{ id: 'sp_cutover', lane: '线上切流', start: 8.1, end: 9, label: '公开流量切入 Rust', shortLabel: '零停服切流', status: 'ok' },
|
|
83
|
+
]}
|
|
84
|
+
/>`,
|
|
85
|
+
ScatterPlot: `<ScatterPlot
|
|
86
|
+
id="pareto"
|
|
87
|
+
title="模型成本 vs 准确率"
|
|
88
|
+
xLabel="$/1M tok"
|
|
89
|
+
yLabel="准确率"
|
|
90
|
+
yUnit="%"
|
|
91
|
+
pareto="top-left"
|
|
92
|
+
points={[
|
|
93
|
+
{ id: 'sc_mini', label: 'Mini', x: 0.8, y: 68 },
|
|
94
|
+
{ id: 'sc_new', label: 'Loop×2', x: 4.4, y: 90.5, tier: 'highlight' },
|
|
95
|
+
{ id: 'sc_pro', label: 'Ultra', x: 18, y: 91 },
|
|
96
|
+
]}
|
|
97
|
+
/>`,
|
|
98
|
+
Heatmap: `<Heatmap
|
|
99
|
+
id="attn"
|
|
100
|
+
title="注意力权重矩阵"
|
|
101
|
+
rows={['系统', '代码', 'Rust']}
|
|
102
|
+
cols={['系统', '代码', 'Rust']}
|
|
103
|
+
values={[[0.64, 0.24, 0.12], [0.12, 0.56, 0.32], [0.08, 0.58, 0.34]]}
|
|
104
|
+
cellAnchors={{ '2:1': 'cell_rust_code' }}
|
|
105
|
+
/>`,
|
|
106
|
+
Sankey: `<Sankey
|
|
107
|
+
id="flow"
|
|
108
|
+
title="首周镜像流量去向"
|
|
109
|
+
unit="%"
|
|
110
|
+
nodes={[
|
|
111
|
+
{ id: 'all', label: '总流量', tone: 'accent' },
|
|
112
|
+
{ id: 'ok', label: '一致放行', tone: 'ok' },
|
|
113
|
+
{ id: 'diff', label: '差异指纹', tone: 'warn' },
|
|
114
|
+
]}
|
|
115
|
+
links={[
|
|
116
|
+
{ source: 'all', target: 'ok', value: 25 },
|
|
117
|
+
{ source: 'all', target: 'diff', value: 75 },
|
|
118
|
+
]}
|
|
119
|
+
/>`,
|
|
120
|
+
Waterfall: `<Waterfall
|
|
121
|
+
id="cpu_breakdown"
|
|
122
|
+
title="CPU 节省归因拆解"
|
|
123
|
+
unit="%"
|
|
124
|
+
lowerIsBetter
|
|
125
|
+
steps={[
|
|
126
|
+
{ id: 'wf_base', label: 'Python 基线', value: 100, kind: 'start' },
|
|
127
|
+
{ id: 'wf_gil', label: '去 GIL', value: -34 },
|
|
128
|
+
{ id: 'wf_json', label: '零拷贝 SSE', value: -22 },
|
|
129
|
+
{ id: 'wf_async', label: '异步调度', value: -14 },
|
|
130
|
+
{ id: 'wf_end', label: 'Rust 实测', value: 30, kind: 'total' },
|
|
131
|
+
]}
|
|
132
|
+
/>`,
|
|
133
|
+
Radar: `<Radar
|
|
134
|
+
id="profile"
|
|
135
|
+
title="五维能力轮廓对比"
|
|
136
|
+
axes={[
|
|
137
|
+
{ key: 'cpu', label: 'CPU 效率', deltaLabel: '34 → 94' },
|
|
138
|
+
{ key: 'mem', label: '内存效率', deltaLabel: '24 → 96' },
|
|
139
|
+
{ key: 'ttft', label: 'TTFT 延迟', deltaLabel: '68 → 88' },
|
|
140
|
+
]}
|
|
141
|
+
series={[
|
|
142
|
+
{ id: 's_py', name: 'Python', values: { cpu: 34, mem: 24, ttft: 68 }, color: 'gray' },
|
|
143
|
+
{ id: 's_rs', name: 'Rust', values: { cpu: 94, mem: 96, ttft: 88 }, color: 'indigo' },
|
|
144
|
+
]}
|
|
145
|
+
/>`,
|
|
146
|
+
};
|
|
147
|
+
export const TEXT_PROPS = {
|
|
148
|
+
DeltaBar: ['title', 'subtitle', 'unit', 'baselineLabel', 'afterLabel'],
|
|
149
|
+
BarChart: ['title', 'subtitle', 'unit'],
|
|
150
|
+
RatioBar: ['title', 'labels', 'remainderLabel', 'thresholdLabel', 'unit'],
|
|
151
|
+
LineChart: ['title', 'subtitle', 'unit'],
|
|
152
|
+
TimeLanes: ['title', 'subtitle', 'unit', 'cursorLabel'],
|
|
153
|
+
ScatterPlot: ['title', 'subtitle', 'xLabel', 'yLabel', 'xUnit', 'yUnit'],
|
|
154
|
+
Heatmap: ['title', 'subtitle', 'cornerLabel', 'rows', 'cols'],
|
|
155
|
+
Sankey: ['title', 'subtitle', 'unit'],
|
|
156
|
+
Waterfall: ['title', 'subtitle', 'unit'],
|
|
157
|
+
Radar: ['title', 'subtitle'],
|
|
158
|
+
};
|
|
159
|
+
export const TEXT_PATHS = {
|
|
160
|
+
DeltaBar: [['items', '*', 'label'], ['items', '*', 'sub'], ['items', '*', 'deltaLabel'], ['items', '*', 'note']],
|
|
161
|
+
BarChart: [['series', '*', 'label'], ['referenceLine', 'label']],
|
|
162
|
+
RatioBar: [['segments', '*', 'label']],
|
|
163
|
+
LineChart: [['series', '*', 'label'], ['referenceLine', 'label'], ['referenceBand', 'label']],
|
|
164
|
+
TimeLanes: [['spans', '*', 'lane'], ['spans', '*', 'label'], ['spans', '*', 'shortLabel'], ['spans', '*', 'rangeLabel']],
|
|
165
|
+
ScatterPlot: [['points', '*', 'label'], ['quadrant', 'label']],
|
|
166
|
+
Sankey: [['nodes', '*', 'label'], ['nodes', '*', 'sub'], ['links', '*', 'label']],
|
|
167
|
+
Waterfall: [['steps', '*', 'label'], ['steps', '*', 'deltaLabel']],
|
|
168
|
+
Radar: [['axes', '*', 'label'], ['axes', '*', 'deltaLabel'], ['series', '*', 'name']],
|
|
169
|
+
};
|
|
170
|
+
export const INSPECT_FIELDS = {
|
|
171
|
+
DeltaBar: [{ label: { en: 'Variant', 'zh-CN': '样式' }, props: ['variant'], fallback: 'ghost' }],
|
|
172
|
+
BarChart: [
|
|
173
|
+
{ label: { en: 'Layout', 'zh-CN': '排布' }, props: ['orientation', 'layout'], join: ' · ', fallback: 'vertical · grouped' },
|
|
174
|
+
],
|
|
175
|
+
TimeLanes: [{ label: { en: 'Unit', 'zh-CN': '单位' }, props: ['unit'], fallback: 'ms' }],
|
|
176
|
+
ScatterPlot: [{ label: { en: 'Pareto', 'zh-CN': '帕累托' }, props: ['pareto'], fallback: 'none' }],
|
|
177
|
+
Heatmap: [{ label: { en: 'Scale', 'zh-CN': '色阶' }, props: ['colorScale'], fallback: 'indigo' }],
|
|
178
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { type Bind, type JNode } from '@joplo-app/kit/node';
|
|
2
|
+
import type { JoploProps } from '@joplo-app/kit/plugin';
|
|
3
|
+
import type { ChartSeriesInput, DeltaBarItemInput, ParetoCorner, RatioSegment, TimeSpan, WaterfallStepInput } from './schema.js';
|
|
4
|
+
export type DeltaBarProps = JoploProps & {
|
|
5
|
+
title?: string | Bind;
|
|
6
|
+
subtitle?: string | Bind;
|
|
7
|
+
items: readonly DeltaBarItemInput[] | Bind;
|
|
8
|
+
itemIds?: readonly string[];
|
|
9
|
+
variant?: 'ghost' | 'paired' | Bind;
|
|
10
|
+
domain?: readonly [number, number] | Bind;
|
|
11
|
+
unit?: string;
|
|
12
|
+
lowerIsBetter?: boolean;
|
|
13
|
+
ticks?: readonly number[];
|
|
14
|
+
baselineLabel?: string;
|
|
15
|
+
afterLabel?: string;
|
|
16
|
+
showAxis?: boolean;
|
|
17
|
+
w?: number | string;
|
|
18
|
+
h?: number | string;
|
|
19
|
+
};
|
|
20
|
+
export declare function DeltaBar(props: DeltaBarProps): JNode;
|
|
21
|
+
export type BarChartRow = Record<string, unknown> & {
|
|
22
|
+
id?: string;
|
|
23
|
+
locked?: boolean;
|
|
24
|
+
lockedLabel?: string;
|
|
25
|
+
deltaBadge?: string;
|
|
26
|
+
note?: string;
|
|
27
|
+
color?: string;
|
|
28
|
+
};
|
|
29
|
+
export type BarChartProps = JoploProps & {
|
|
30
|
+
title?: string | Bind;
|
|
31
|
+
subtitle?: string | Bind;
|
|
32
|
+
data: readonly BarChartRow[] | Bind;
|
|
33
|
+
dataKey: string;
|
|
34
|
+
series: readonly ChartSeriesInput[];
|
|
35
|
+
orientation?: 'vertical' | 'horizontal';
|
|
36
|
+
layout?: 'grouped' | 'stacked';
|
|
37
|
+
scale?: 'linear' | 'log';
|
|
38
|
+
unit?: string;
|
|
39
|
+
referenceLine?: {
|
|
40
|
+
value: number;
|
|
41
|
+
label?: string;
|
|
42
|
+
color?: string;
|
|
43
|
+
};
|
|
44
|
+
directLabels?: boolean;
|
|
45
|
+
withLegend?: boolean;
|
|
46
|
+
itemIds?: readonly string[];
|
|
47
|
+
w?: number | string;
|
|
48
|
+
h?: number | string;
|
|
49
|
+
};
|
|
50
|
+
export declare function BarChart(props: BarChartProps): JNode;
|
|
51
|
+
export type RatioBarProps = JoploProps & {
|
|
52
|
+
title?: string | Bind;
|
|
53
|
+
total?: number | Bind;
|
|
54
|
+
left?: number | Bind;
|
|
55
|
+
right?: number | Bind;
|
|
56
|
+
segments?: readonly RatioSegment[] | Bind;
|
|
57
|
+
threshold?: number | Bind;
|
|
58
|
+
labels?: readonly string[];
|
|
59
|
+
remainderLabel?: string;
|
|
60
|
+
thresholdLabel?: string;
|
|
61
|
+
colors?: readonly string[];
|
|
62
|
+
unit?: string;
|
|
63
|
+
height?: number | string;
|
|
64
|
+
/** 单值占比默认不重复拼接 "/ 100%";显式传 true 展示 "count / total"。 */
|
|
65
|
+
showDenominator?: boolean;
|
|
66
|
+
segmentIds?: readonly string[];
|
|
67
|
+
};
|
|
68
|
+
export declare function RatioBar(props: RatioBarProps): JNode;
|
|
69
|
+
export type LineChartProps = JoploProps & {
|
|
70
|
+
title?: string | Bind;
|
|
71
|
+
subtitle?: string | Bind;
|
|
72
|
+
data: readonly (Record<string, unknown> & {
|
|
73
|
+
id?: string;
|
|
74
|
+
label?: string;
|
|
75
|
+
})[] | Bind;
|
|
76
|
+
dataKey: string;
|
|
77
|
+
series: readonly ChartSeriesInput[];
|
|
78
|
+
unit?: string;
|
|
79
|
+
yDomain?: readonly [number, number];
|
|
80
|
+
curve?: 'linear' | 'monotone';
|
|
81
|
+
referenceLine?: {
|
|
82
|
+
value: number;
|
|
83
|
+
label?: string;
|
|
84
|
+
color?: string;
|
|
85
|
+
};
|
|
86
|
+
referenceBand?: {
|
|
87
|
+
from: number;
|
|
88
|
+
to: number;
|
|
89
|
+
label?: string;
|
|
90
|
+
color?: string;
|
|
91
|
+
};
|
|
92
|
+
revealTo?: number | string | Bind;
|
|
93
|
+
directLabels?: boolean;
|
|
94
|
+
withLegend?: boolean;
|
|
95
|
+
pointIds?: readonly string[];
|
|
96
|
+
w?: number | string;
|
|
97
|
+
h?: number | string;
|
|
98
|
+
};
|
|
99
|
+
export declare function LineChart(props: LineChartProps): JNode;
|
|
100
|
+
export type { TimeSpan } from './schema.js';
|
|
101
|
+
export type TimeLanesProps = JoploProps & {
|
|
102
|
+
title?: string | Bind;
|
|
103
|
+
subtitle?: string | Bind;
|
|
104
|
+
domain: readonly [number, number] | Bind;
|
|
105
|
+
spans: readonly TimeSpan[] | Bind;
|
|
106
|
+
unit?: string;
|
|
107
|
+
ticks?: readonly number[];
|
|
108
|
+
cursor?: number | Bind;
|
|
109
|
+
cursorLabel?: string | Bind;
|
|
110
|
+
spanIds?: readonly string[];
|
|
111
|
+
compact?: boolean;
|
|
112
|
+
w?: number | string;
|
|
113
|
+
h?: number | string;
|
|
114
|
+
};
|
|
115
|
+
export declare function TimeLanes(props: TimeLanesProps): JNode;
|
|
116
|
+
export type ScatterPointInput = {
|
|
117
|
+
id?: string;
|
|
118
|
+
label: string;
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
r?: number;
|
|
122
|
+
group?: string;
|
|
123
|
+
tier?: 'frontier' | 'dominated' | 'highlight';
|
|
124
|
+
color?: string;
|
|
125
|
+
valueLabel?: string;
|
|
126
|
+
labelPos?: 'top' | 'bottom' | 'left' | 'right';
|
|
127
|
+
};
|
|
128
|
+
export type ScatterPlotProps = JoploProps & {
|
|
129
|
+
title?: string | Bind;
|
|
130
|
+
subtitle?: string | Bind;
|
|
131
|
+
points: readonly ScatterPointInput[] | Bind;
|
|
132
|
+
xLabel?: string;
|
|
133
|
+
yLabel?: string;
|
|
134
|
+
xUnit?: string;
|
|
135
|
+
yUnit?: string;
|
|
136
|
+
xDomain?: readonly [number, number];
|
|
137
|
+
yDomain?: readonly [number, number];
|
|
138
|
+
pareto?: ParetoCorner | false;
|
|
139
|
+
quadrant?: {
|
|
140
|
+
x: number;
|
|
141
|
+
y: number;
|
|
142
|
+
label?: string;
|
|
143
|
+
corner?: ParetoCorner;
|
|
144
|
+
};
|
|
145
|
+
pointIds?: readonly string[];
|
|
146
|
+
w?: number | string;
|
|
147
|
+
h?: number | string;
|
|
148
|
+
};
|
|
149
|
+
export declare function ScatterPlot(props: ScatterPlotProps): JNode;
|
|
150
|
+
export type HeatmapProps = JoploProps & {
|
|
151
|
+
title?: string | Bind;
|
|
152
|
+
subtitle?: string | Bind;
|
|
153
|
+
rows: readonly string[] | Bind;
|
|
154
|
+
cols: readonly string[] | Bind;
|
|
155
|
+
values: readonly (readonly number[])[] | Bind;
|
|
156
|
+
domain?: readonly [number, number];
|
|
157
|
+
colorScale?: 'indigo' | 'emerald' | 'amber' | 'crimson' | 'diverging';
|
|
158
|
+
format?: 'fixed2' | 'percent' | 'int';
|
|
159
|
+
cornerLabel?: string;
|
|
160
|
+
showScale?: boolean;
|
|
161
|
+
/** Optional map of "rowIndex:colIndex" -> element id for callout/highlight anchors. */
|
|
162
|
+
cellAnchors?: Record<string, string>;
|
|
163
|
+
cellIds?: readonly string[];
|
|
164
|
+
w?: number | string;
|
|
165
|
+
h?: number | string;
|
|
166
|
+
};
|
|
167
|
+
export declare function Heatmap(props: HeatmapProps): JNode;
|
|
168
|
+
export type SankeyNodeInput = {
|
|
169
|
+
id: string;
|
|
170
|
+
label: string;
|
|
171
|
+
sub?: string;
|
|
172
|
+
valueLabel?: string;
|
|
173
|
+
color?: string;
|
|
174
|
+
tone?: 'accent' | 'ok' | 'warn' | 'danger' | 'info' | 'muted';
|
|
175
|
+
};
|
|
176
|
+
export type SankeyLinkInput = {
|
|
177
|
+
id?: string;
|
|
178
|
+
source: string;
|
|
179
|
+
target: string;
|
|
180
|
+
value: number;
|
|
181
|
+
label?: string;
|
|
182
|
+
color?: string;
|
|
183
|
+
};
|
|
184
|
+
export type SankeyProps = JoploProps & {
|
|
185
|
+
title?: string | Bind;
|
|
186
|
+
subtitle?: string | Bind;
|
|
187
|
+
nodes: readonly SankeyNodeInput[] | Bind;
|
|
188
|
+
links: readonly SankeyLinkInput[] | Bind;
|
|
189
|
+
unit?: string;
|
|
190
|
+
nodeWidth?: number;
|
|
191
|
+
nodePadding?: number;
|
|
192
|
+
nodeIds?: readonly string[];
|
|
193
|
+
w?: number | string;
|
|
194
|
+
h?: number | string;
|
|
195
|
+
};
|
|
196
|
+
export declare function Sankey(props: SankeyProps): JNode;
|
|
197
|
+
export type { WaterfallStepInput } from './schema.js';
|
|
198
|
+
export type WaterfallProps = JoploProps & {
|
|
199
|
+
title?: string | Bind;
|
|
200
|
+
subtitle?: string | Bind;
|
|
201
|
+
steps: readonly WaterfallStepInput[] | Bind;
|
|
202
|
+
unit?: string;
|
|
203
|
+
lowerIsBetter?: boolean;
|
|
204
|
+
stepIds?: readonly string[];
|
|
205
|
+
w?: number | string;
|
|
206
|
+
h?: number | string;
|
|
207
|
+
};
|
|
208
|
+
export declare function Waterfall(props: WaterfallProps): JNode;
|
|
209
|
+
export type RadarAxisInput = {
|
|
210
|
+
key: string;
|
|
211
|
+
label: string;
|
|
212
|
+
max?: number;
|
|
213
|
+
deltaLabel?: string;
|
|
214
|
+
};
|
|
215
|
+
export type RadarSeriesInput = {
|
|
216
|
+
id?: string;
|
|
217
|
+
name: string;
|
|
218
|
+
values: Record<string, number> | readonly number[];
|
|
219
|
+
color?: string;
|
|
220
|
+
dashed?: boolean;
|
|
221
|
+
};
|
|
222
|
+
export type RadarProps = JoploProps & {
|
|
223
|
+
title?: string | Bind;
|
|
224
|
+
subtitle?: string | Bind;
|
|
225
|
+
axes: readonly RadarAxisInput[] | Bind;
|
|
226
|
+
series: readonly RadarSeriesInput[] | Bind;
|
|
227
|
+
levels?: number;
|
|
228
|
+
max?: number;
|
|
229
|
+
showTicks?: boolean;
|
|
230
|
+
seriesIds?: readonly string[];
|
|
231
|
+
w?: number | string;
|
|
232
|
+
h?: number | string;
|
|
233
|
+
};
|
|
234
|
+
export declare function Radar(props: RadarProps): JNode;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { component, createNode, Custom } from '@joplo-app/kit/node';
|
|
2
|
+
const c = (name) => component(`viz:${name}`, '@joplo-app/plugin-viz');
|
|
3
|
+
function withAnchors(marker, props, ids) {
|
|
4
|
+
const unique = [...new Set(ids)].filter((id) => typeof id === 'string' && !!id.trim());
|
|
5
|
+
if (!unique.length)
|
|
6
|
+
return createNode(marker, props);
|
|
7
|
+
return createNode(marker, { ...props, children: unique.map((id) => createNode(Custom, { id })) });
|
|
8
|
+
}
|
|
9
|
+
const idsOf = (arr, explicit) => {
|
|
10
|
+
const fromArray = Array.isArray(arr)
|
|
11
|
+
? arr.map((item) => (item && typeof item === 'object' ? item.id : undefined)).filter((x) => typeof x === 'string')
|
|
12
|
+
: [];
|
|
13
|
+
return [...fromArray, ...(explicit ?? [])];
|
|
14
|
+
};
|
|
15
|
+
const deltaBar = c('DeltaBar');
|
|
16
|
+
export function DeltaBar(props) {
|
|
17
|
+
return withAnchors(deltaBar, props, idsOf(props.items, props.itemIds));
|
|
18
|
+
}
|
|
19
|
+
const barChart = c('BarChart');
|
|
20
|
+
export function BarChart(props) {
|
|
21
|
+
return withAnchors(barChart, props, idsOf(props.data, props.itemIds));
|
|
22
|
+
}
|
|
23
|
+
const ratioBar = c('RatioBar');
|
|
24
|
+
export function RatioBar(props) {
|
|
25
|
+
return withAnchors(ratioBar, props, idsOf(props.segments, props.segmentIds));
|
|
26
|
+
}
|
|
27
|
+
const lineChart = c('LineChart');
|
|
28
|
+
export function LineChart(props) {
|
|
29
|
+
return withAnchors(lineChart, props, idsOf(props.data, props.pointIds));
|
|
30
|
+
}
|
|
31
|
+
const timeLanes = c('TimeLanes');
|
|
32
|
+
export function TimeLanes(props) {
|
|
33
|
+
return withAnchors(timeLanes, props, idsOf(props.spans, props.spanIds));
|
|
34
|
+
}
|
|
35
|
+
const scatterPlot = c('ScatterPlot');
|
|
36
|
+
export function ScatterPlot(props) {
|
|
37
|
+
return withAnchors(scatterPlot, props, idsOf(props.points, props.pointIds));
|
|
38
|
+
}
|
|
39
|
+
const heatmap = c('Heatmap');
|
|
40
|
+
export function Heatmap(props) {
|
|
41
|
+
const fromMap = props.cellAnchors ? Object.values(props.cellAnchors) : [];
|
|
42
|
+
return withAnchors(heatmap, props, [...fromMap, ...(props.cellIds ?? [])]);
|
|
43
|
+
}
|
|
44
|
+
const sankey = c('Sankey');
|
|
45
|
+
export function Sankey(props) {
|
|
46
|
+
return withAnchors(sankey, props, [...idsOf(props.nodes, props.nodeIds), ...idsOf(props.links)]);
|
|
47
|
+
}
|
|
48
|
+
const waterfall = c('Waterfall');
|
|
49
|
+
export function Waterfall(props) {
|
|
50
|
+
return withAnchors(waterfall, props, idsOf(props.steps, props.stepIds));
|
|
51
|
+
}
|
|
52
|
+
const radar = c('Radar');
|
|
53
|
+
export function Radar(props) {
|
|
54
|
+
return withAnchors(radar, props, idsOf(props.series, props.seriesIds));
|
|
55
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 聚焦图表里的一个或多个数据项(柱子、数据点、泳道、热力行/格、桑基节点),其余项自动退暗。
|
|
3
|
+
* 传 null 清除聚焦、恢复全览。
|
|
4
|
+
* focusDatum('payoff', 'delta_mem')
|
|
5
|
+
* focusDatum('heat', 'row:Rust')
|
|
6
|
+
* focusDatum('payoff', null)
|
|
7
|
+
*/
|
|
8
|
+
export declare const focusDatum: (chart: string, targets: string | readonly string[] | null) => import("@joplo-app/kit/plugin").PluginEffectDef;
|
|
9
|
+
/**
|
|
10
|
+
* 渐进揭示折线图、瀑布图或散点图到指定位置(x 轴标签、数值索引或节点 id)。传 null 显示全部。
|
|
11
|
+
* revealTo('trend', '5 月')
|
|
12
|
+
* revealTo('trend', '9 月')
|
|
13
|
+
*/
|
|
14
|
+
export declare const revealTo: (chart: string, cutoff: number | string | null) => import("@joplo-app/kit/plugin").PluginEffectDef;
|
|
15
|
+
/**
|
|
16
|
+
* 把当前步骤该图表的解析数值锁定为后续对比的基线(写入编译期 step.ext.viz.baselines)。
|
|
17
|
+
* pinBaseline('payoff')
|
|
18
|
+
*/
|
|
19
|
+
export declare const pinBaseline: (chart: string) => import("@joplo-app/kit/plugin").PluginEffectDef;
|
|
20
|
+
/**
|
|
21
|
+
* 移动时间泳道或趋势图上的时间游标(Playhead Cursor)。传 null 隐藏游标。
|
|
22
|
+
* setCursor('lanes', 6.9, { label: '6.9 月' })
|
|
23
|
+
* setCursor('lanes', 6.9, '6.9 月')
|
|
24
|
+
*/
|
|
25
|
+
export declare const setCursor: (chart: string, value: number | string | null, opts?: string | {
|
|
26
|
+
label?: string;
|
|
27
|
+
}) => import("@joplo-app/kit/plugin").PluginEffectDef;
|
package/dist/effects.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { pluginEffect } from '@joplo-app/kit/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* 聚焦图表里的一个或多个数据项(柱子、数据点、泳道、热力行/格、桑基节点),其余项自动退暗。
|
|
4
|
+
* 传 null 清除聚焦、恢复全览。
|
|
5
|
+
* focusDatum('payoff', 'delta_mem')
|
|
6
|
+
* focusDatum('heat', 'row:Rust')
|
|
7
|
+
* focusDatum('payoff', null)
|
|
8
|
+
*/
|
|
9
|
+
export const focusDatum = (chart, targets) => pluginEffect('viz', 'focus', {
|
|
10
|
+
chart,
|
|
11
|
+
targets: targets === null ? null : typeof targets === 'string' ? [targets] : [...targets],
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* 渐进揭示折线图、瀑布图或散点图到指定位置(x 轴标签、数值索引或节点 id)。传 null 显示全部。
|
|
15
|
+
* revealTo('trend', '5 月')
|
|
16
|
+
* revealTo('trend', '9 月')
|
|
17
|
+
*/
|
|
18
|
+
export const revealTo = (chart, cutoff) => pluginEffect('viz', 'reveal', { chart, cutoff });
|
|
19
|
+
/**
|
|
20
|
+
* 把当前步骤该图表的解析数值锁定为后续对比的基线(写入编译期 step.ext.viz.baselines)。
|
|
21
|
+
* pinBaseline('payoff')
|
|
22
|
+
*/
|
|
23
|
+
export const pinBaseline = (chart) => pluginEffect('viz', 'pinBaseline', { chart });
|
|
24
|
+
/**
|
|
25
|
+
* 移动时间泳道或趋势图上的时间游标(Playhead Cursor)。传 null 隐藏游标。
|
|
26
|
+
* setCursor('lanes', 6.9, { label: '6.9 月' })
|
|
27
|
+
* setCursor('lanes', 6.9, '6.9 月')
|
|
28
|
+
*/
|
|
29
|
+
export const setCursor = (chart, value, opts = {}) => {
|
|
30
|
+
const label = typeof opts === 'string' ? opts : opts.label;
|
|
31
|
+
return pluginEffect('viz', 'cursor', { chart, value, ...(label !== undefined ? { label } : {}) });
|
|
32
|
+
};
|
package/dist/guide.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const skill = "# Narrative Data Visualization: viz\n\nUse `@joplo-app/plugin-viz` for all quantitative comparisons, magnitudes, part-to-whole ratios, trends, timelines, Pareto trade-offs, matrices, flows, attributions, and multi-axis profiles. Install `@joplo-app/plugin-viz`, default-import `viz`, add `viz` to `config.plugins`, and run `npx joplo skill install`.\n\n## Choose the right chart (never abuse RatioBar or hand-roll div bars)\n- **Qualitative UI / prose A-vs-B switching** \u2192 stay in `@joplo-app/plugin-ui` (`<Compare>`).\n- **Before \u2192 After metric gain / reduction** (e.g., CPU \u221270%, Memory \u221280%, latency drop) \u2192 **`<DeltaBar>`** (default `variant=\"ghost\"` keeps a dashed ghost baseline in place and uncovers a tinted savings band as the bar retracts; `variant=\"paired\"` renders stacked old/new bars). Never abuse `<RatioBar>` for before/after comparisons.\n- **Category magnitude, stacked composition, or invariant locking** \u2192 **`<BarChart>`** (`orientation=\"vertical\"|\"horizontal\"`, `layout=\"grouped\"|\"stacked\"`, row `locked: true` pins an invariant bar while other bars scale).\n- **Part-of-a-whole split or pass threshold** (e.g., 98% test pass vs 25% prod match against a 99% bar) \u2192 **`<RatioBar>`** (clean single-value display by default; set `showDenominator` only when explicit `x / total` is needed).\n- **Trend over time / scaling curve / cliff inflection** \u2192 **`<LineChart>`** (zero-stretch HTML labels + crisp SVG curve + `revealTo()` progressive draw + `referenceLine` / `referenceBand`).\n- **Time intervals / Gantt / concurrent waterfall** \u2192 **`<TimeLanes>`** (full tick gridlines, animated `setCursor()` playhead, `focusDatum()` lane dimming, and automatic external labels so narrow bars never clip text).\n- **2D trade-off / cost-vs-accuracy Pareto frontier** \u2192 **`<ScatterPlot pareto=\"top-left\">`** (auto-computes and strokes the Pareto frontier polyline, optional quadrant tint).\n- **2D matrix density / attention weights / confusion matrix** \u2192 **`<Heatmap>`** (high-contrast auto-white text on dark cells, row/col/cell `focusDatum()`).\n- **Proportional multi-stage flow / funnel conservation** \u2192 **`<Sankey>`** (`d3-sankey` curved cubic-Bezier ribbons tapering from wide to narrow, single-path `focusDatum()`).\n- **Step-by-step positive/negative attribution** (how 100% dropped to 30%) \u2192 **`<Waterfall>`** (cumulative floating steps + dashed stair connectors + `revealTo()`).\n- **Multi-dimension profile comparison** (4\u20137 axes) \u2192 **`<Radar>`** (polygonal spiderweb rings + translucent series overlays + direct axis/delta scores).\n\n## Narrative step effects (deterministic compile-time snapshots)\nImport `focusDatum`, `revealTo`, `pinBaseline`, and `setCursor` from `@joplo-app/plugin-viz`:\n- `focusDatum(chartId, targetId | targetIds | null)`: dim unrelated bars/points/lanes/rows/nodes while spotlighting the active datum. For Heatmap, pass `'row:<name>'`, `'col:<name>'`, `'cell:<r>:<c>'`, or a `cellAnchors` id.\n- `revealTo(chartId, cutoff | null)`: reveal a `LineChart` up to an X label or index, or a `Waterfall` up to a step id or index.\n- `pinBaseline(chartId)`: lock the chart's current numeric values as the remembered baseline in `step.ext.viz.baselines`. (Step 0 values are also captured automatically when `baseline` is omitted.)\n- `setCursor(chartId, value | null, { label? })`: slide a vertical playhead across `TimeLanes` or `LineChart`.\n\n## Addressable anchors & silent observation windows\n- Give every important item/point/span/node/step an `id` (or pass `itemIds` / `spanIds` / `pointIds` / `cellAnchors` when data comes from state bindings). Every registered id receives a DOM `data-jid` anchor so `camera()`, `callout()`, `highlight()`, `spotlight()`, and Alt-click review inspection land directly on the bar, point, or cell.\n- Pair big quantitative transitions (e.g., `DeltaBar` retract, `LineChart` `revealTo`, `TimeLanes` `setCursor`) with a brief silent observation beat (`narrate(false)` + `hold(2.0)`) so viewers watch the motion without competing audio.\n\n## Verify & pitfalls\n- Run `npx joplo check`: fix `VIZ_DATA_INVALID`, `VIZ_CHART_UNKNOWN`, `RATIO_BAR_INVALID`, or `TIME_LANES_INVALID` before rendering.\n- Never wrap charts inside redundant bordered cards with duplicate titles when `title` / `subtitle` props already live on the chart.\n- Give narrow `TimeLanes` spans (`< 24%` of domain) a concise `shortLabel` so the bar carries the short pill while the full `label` floats cleanly beside the bar without clipping.\n- Read `npx joplo skill viz/components` for full prop tables and `npx joplo skill viz/recipes` for animation and framing patterns.\n\nRelated topics: components, authoring, focus, check, plugins\n";
|
|
2
|
+
export declare const recipes = "# Narrative DataViz recipes and pitfalls\n\n## 1. Before-vs-after payoff without spoiling the reveal (DeltaBar)\nStart at the baseline step with `value === baseline` (so no savings badge spoils the twist early), then update the bound state in a silent observation beat:\n```tsx\n<DeltaBar\n id=\"payoff\"\n title=\"\u5355\u8BF7\u6C42\u5B9E\u6D4B\u8D44\u6E90\u4E0E\u5EF6\u8FDF\"\n unit=\"%\"\n lowerIsBetter\n items={[\n { id: 'delta_cpu', label: '\u5355\u8BF7\u6C42 CPU', baseline: 100, value: $.ui.cpuRust, deltaLabel: '\u221270%' },\n { id: 'delta_mem', label: '\u5355\u8BF7\u6C42\u5185\u5B58', baseline: 100, value: $.ui.memRust, deltaLabel: '\u221280%+' },\n { id: 'delta_ttft', label: '\u4E2D\u4F4D TTFT', baseline: 100, value: $.ui.ttftRust, deltaLabel: '\u221220%' },\n ]}\n/>\n```\nIn the flow:\n1. Show Python baseline (`cpuRust: 100, memRust: 100, ttftRust: 100`) \u2014 clean solid bars, zero premature savings text.\n2. Drop values (`cpuRust: 30, memRust: 20, ttftRust: 80`) with `narrate(false)` + `hold(2.2)` \u2014 bars retract smoothly with row stagger, uncovering the dashed ghost baseline and emerald savings band.\n3. Add `focusDatum('payoff', 'delta_mem')` + `callout('delta_mem', '\u5185\u5B58\u76F4\u964D\u516B\u6210+')` to spotlight one metric.\n\n## 2. Invariant-locked comparison (BarChart)\nMark constant rows with `locked: true` (`lockedLabel: 'LOCKED \u00B7 \u4E0D\u53D8\u91CF'`). When toggling a knob (like loop depth 1\u00D7 \u2192 2\u00D7 \u2192 4\u00D7), viewers immediately see which bar stays frozen while other bars grow.\n\n## 3. Progressive trend & inflection callout (LineChart)\nUse `revealTo('trend', '5 \u6708')` to hold suspense on an early plateau, then `revealTo('trend', '9 \u6708')` in a silent observation step, followed by `callout('pt_june', '6 \u6708\u89C4\u5219\u6C89\u6DC0 \u2192 \u65AD\u5D16\u6536\u655B')` anchored directly on the point id.\n\n## 4. Narrow bars in TimeLanes\nIf a span occupies less than ~24% of `domain`, pass `shortLabel` (e.g., `shortLabel: '\u96F6\u505C\u670D\u5207\u6D41'`, `label: '\u516C\u5F00\u6D41\u91CF\u5206\u6279\u5207\u5165 Rust'`). `TimeLanes` centers `shortLabel` inside the bar and floats the full `label` into the adjacent open track so text is never truncated.\n\n## 5. Single-path storytelling in Sankey & Heatmap\n- `Sankey`: use `focusDatum('flow', ['diff', 'gate'])` to dim quiet baseline traffic while illuminating the anomalous cascade.\n- `Heatmap`: pass `cellAnchors={{ '4:2': 'cell_rust_code' }}` and use `focusDatum('attn', 'row:Rust')` + `callout('cell_rust_code', '\u6700\u9AD8\u6743\u91CD 0.46')` to walk viewers through one row at a time.\n";
|
|
3
|
+
export declare function componentGuide(): string;
|