@opendata-ai/openchart-vanilla 8.9.1 → 9.0.0-rc.1
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 +4 -4
- package/dist/{chunk-REH5UQCL.js → chunk-46E3QB6O.js} +6 -20
- package/dist/chunk-46E3QB6O.js.map +1 -0
- package/dist/{chunk-GX6BWMJD.js → chunk-5ZLSMZRM.js} +466 -330
- package/dist/chunk-5ZLSMZRM.js.map +1 -0
- package/dist/{chunk-Q7YEEF2X.js → chunk-6YPRYQKD.js} +16 -50
- package/dist/chunk-6YPRYQKD.js.map +1 -0
- package/dist/{chunk-SDJHUELU.js → chunk-A5C4VCUO.js} +26 -45
- package/dist/chunk-A5C4VCUO.js.map +1 -0
- package/dist/{chunk-MGFXAROR.js → chunk-CMIJA63X.js} +5 -3
- package/dist/chunk-CMIJA63X.js.map +1 -0
- package/dist/{chunk-APMUBW72.js → chunk-ERPYVYFW.js} +1565 -294
- package/dist/chunk-ERPYVYFW.js.map +1 -0
- package/dist/chunk-FFP5GXIP.js +45 -0
- package/dist/chunk-FFP5GXIP.js.map +1 -0
- package/dist/chunk-NLKQ5AOA.js +448 -0
- package/dist/chunk-NLKQ5AOA.js.map +1 -0
- package/dist/{chunk-R5TZHNTG.js → chunk-RBXIZJPE.js} +17 -5
- package/dist/chunk-RBXIZJPE.js.map +1 -0
- package/dist/{chunk-CCRFYGHU.js → chunk-T6IPHUN4.js} +2354 -2338
- package/dist/chunk-T6IPHUN4.js.map +1 -0
- package/dist/export-gif.d.ts +2 -2
- package/dist/export-gif.js +4 -3
- package/dist/graph-3d/index.d.ts +28 -1
- package/dist/graph-3d/index.js +26 -12
- package/dist/graph-3d/index.js.map +1 -1
- package/dist/index.d.ts +155 -29
- package/dist/index.js +1774 -186
- package/dist/index.js.map +1 -1
- package/dist/{mount-TEjIdF0m.d.ts → mount-types-DeUCa2hy.d.ts} +34 -21
- package/dist/{renderer-registry-Cng76n8F.d.ts → renderer-registry-Bu22Roek.d.ts} +5 -22
- package/dist/simulation-worker.js +1 -0
- package/dist/static.d.ts +4 -2
- package/dist/static.js +34 -10
- package/dist/static.js.map +1 -1
- package/dist/story/index.d.ts +8 -6
- package/dist/story/index.js +15 -12
- package/dist/story/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-APMUBW72.js.map +0 -1
- package/dist/chunk-CCRFYGHU.js.map +0 -1
- package/dist/chunk-GX6BWMJD.js.map +0 -1
- package/dist/chunk-MGFXAROR.js.map +0 -1
- package/dist/chunk-Q7YEEF2X.js.map +0 -1
- package/dist/chunk-R5TZHNTG.js.map +0 -1
- package/dist/chunk-REH5UQCL.js.map +0 -1
- package/dist/chunk-SDJHUELU.js.map +0 -1
- package/dist/chunk-UC4IHEUO.js +0 -73
- package/dist/chunk-UC4IHEUO.js.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/renderers/svg-dom.ts
|
|
2
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
3
|
+
var XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
4
|
+
function createSVGElement(tag) {
|
|
5
|
+
return document.createElementNS(SVG_NS, tag);
|
|
6
|
+
}
|
|
7
|
+
function setAttrs(el, attrs) {
|
|
8
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
9
|
+
el.setAttribute(key, String(value));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function applyKnockoutHalo(el, color, fontSize) {
|
|
13
|
+
setAttrs(el, {
|
|
14
|
+
stroke: color,
|
|
15
|
+
"stroke-width": Math.round(fontSize * 0.3),
|
|
16
|
+
"stroke-linejoin": "round",
|
|
17
|
+
"paint-order": "stroke"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function applyTextStyle(el, style) {
|
|
21
|
+
const inline = el.style;
|
|
22
|
+
inline.setProperty("fill", style.fill);
|
|
23
|
+
inline.setProperty("font-size", `${style.fontSize}px`);
|
|
24
|
+
inline.setProperty("font-weight", String(style.fontWeight));
|
|
25
|
+
inline.setProperty("font-family", style.fontFamily);
|
|
26
|
+
if (style.textAnchor) {
|
|
27
|
+
el.setAttribute("text-anchor", style.textAnchor);
|
|
28
|
+
}
|
|
29
|
+
if (style.dominantBaseline) {
|
|
30
|
+
el.setAttribute("dominant-baseline", style.dominantBaseline);
|
|
31
|
+
}
|
|
32
|
+
if (style.fontVariant) {
|
|
33
|
+
el.setAttribute("font-variant", style.fontVariant);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
SVG_NS,
|
|
39
|
+
XLINK_NS,
|
|
40
|
+
createSVGElement,
|
|
41
|
+
setAttrs,
|
|
42
|
+
applyKnockoutHalo,
|
|
43
|
+
applyTextStyle
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=chunk-FFP5GXIP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/renderers/svg-dom.ts"],"sourcesContent":["/**\n * Shared SVG DOM helpers used across the per-concern renderers.\n *\n * Pure, stateless utilities. No layout/theme knowledge.\n */\n\nimport type { TextStyle } from '@opendata-ai/openchart-core';\n\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\n\nexport function createSVGElement(tag: string): SVGElement {\n return document.createElementNS(SVG_NS, tag);\n}\n\nexport function setAttrs(el: SVGElement, attrs: Record<string, string | number>): void {\n for (const [key, value] of Object.entries(attrs)) {\n el.setAttribute(key, String(value));\n }\n}\n\n/**\n * Cut a knockout halo behind text so it stays legible where it crosses\n * gridlines, marks, or a neighbouring series: a surface-colored stroke painted\n * under the glyphs.\n *\n * Presentation attributes, not inline styles, so a stylesheet can still\n * override the halo. The width scales with the font size -- a fixed width rings\n * small glyphs and disappears behind large ones.\n */\nexport function applyKnockoutHalo(el: SVGElement, color: string, fontSize: number): void {\n setAttrs(el, {\n stroke: color,\n 'stroke-width': Math.round(fontSize * 0.3),\n 'stroke-linejoin': 'round',\n 'paint-order': 'stroke',\n });\n}\n\nexport function applyTextStyle(el: SVGElement, style: TextStyle): void {\n // Use inline styles so engine-computed values take priority over CSS class\n // defaults (e.g. .oc-title { font-size: var(--oc-title-size) } would otherwise\n // override the responsive scaling applied by the chrome layout).\n const inline = (el as SVGElement & ElementCSSInlineStyle).style;\n inline.setProperty('fill', style.fill);\n inline.setProperty('font-size', `${style.fontSize}px`);\n inline.setProperty('font-weight', String(style.fontWeight));\n inline.setProperty('font-family', style.fontFamily);\n if (style.textAnchor) {\n el.setAttribute('text-anchor', style.textAnchor);\n }\n if (style.dominantBaseline) {\n el.setAttribute('dominant-baseline', style.dominantBaseline);\n }\n if (style.fontVariant) {\n el.setAttribute('font-variant', style.fontVariant);\n }\n}\n"],"mappings":";AAQO,IAAM,SAAS;AACf,IAAM,WAAW;AAEjB,SAAS,iBAAiB,KAAyB;AACxD,SAAO,SAAS,gBAAgB,QAAQ,GAAG;AAC7C;AAEO,SAAS,SAAS,IAAgB,OAA8C;AACrF,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,OAAG,aAAa,KAAK,OAAO,KAAK,CAAC;AAAA,EACpC;AACF;AAWO,SAAS,kBAAkB,IAAgB,OAAe,UAAwB;AACvF,WAAS,IAAI;AAAA,IACX,QAAQ;AAAA,IACR,gBAAgB,KAAK,MAAM,WAAW,GAAG;AAAA,IACzC,mBAAmB;AAAA,IACnB,eAAe;AAAA,EACjB,CAAC;AACH;AAEO,SAAS,eAAe,IAAgB,OAAwB;AAIrE,QAAM,SAAU,GAA0C;AAC1D,SAAO,YAAY,QAAQ,MAAM,IAAI;AACrC,SAAO,YAAY,aAAa,GAAG,MAAM,QAAQ,IAAI;AACrD,SAAO,YAAY,eAAe,OAAO,MAAM,UAAU,CAAC;AAC1D,SAAO,YAAY,eAAe,MAAM,UAAU;AAClD,MAAI,MAAM,YAAY;AACpB,OAAG,aAAa,eAAe,MAAM,UAAU;AAAA,EACjD;AACA,MAAI,MAAM,kBAAkB;AAC1B,OAAG,aAAa,qBAAqB,MAAM,gBAAgB;AAAA,EAC7D;AACA,MAAI,MAAM,aAAa;AACrB,OAAG,aAAa,gBAAgB,MAAM,WAAW;AAAA,EACnD;AACF;","names":[]}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import {
|
|
2
|
+
XLINK_NS,
|
|
3
|
+
applyTextStyle,
|
|
4
|
+
createSVGElement,
|
|
5
|
+
setAttrs
|
|
6
|
+
} from "./chunk-FFP5GXIP.js";
|
|
7
|
+
|
|
8
|
+
// src/motion/easing.ts
|
|
9
|
+
function linear(t) {
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
function cubicOut(t) {
|
|
13
|
+
const f = 1 - t;
|
|
14
|
+
return 1 - f * f * f;
|
|
15
|
+
}
|
|
16
|
+
function cubicInOut(t) {
|
|
17
|
+
return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
|
|
18
|
+
}
|
|
19
|
+
var clamp01 = (t) => Math.min(1, Math.max(0, t));
|
|
20
|
+
var lerp = (a, b, t) => a + (b - a) * t;
|
|
21
|
+
|
|
22
|
+
// src/renderers/chrome.ts
|
|
23
|
+
import {
|
|
24
|
+
computeNoteBandHeight,
|
|
25
|
+
FOOTNOTE_LINE_HEIGHT,
|
|
26
|
+
textAscent,
|
|
27
|
+
truncateToWidth,
|
|
28
|
+
wrapText
|
|
29
|
+
} from "@opendata-ai/openchart-core";
|
|
30
|
+
function renderChromeElement(parent, element, className, chromeKey, measureText, uppercase = false) {
|
|
31
|
+
const text = createSVGElement("text");
|
|
32
|
+
setAttrs(text, { x: element.x, y: element.y + textAscent(element.style.fontSize) });
|
|
33
|
+
applyTextStyle(text, element.style);
|
|
34
|
+
text.setAttribute("class", className);
|
|
35
|
+
text.setAttribute("data-chrome-key", chromeKey);
|
|
36
|
+
const renderedText = uppercase ? element.text.toUpperCase() : element.text;
|
|
37
|
+
const lines = wrapText(
|
|
38
|
+
renderedText,
|
|
39
|
+
element.style.fontSize,
|
|
40
|
+
element.style.fontWeight,
|
|
41
|
+
element.maxWidth,
|
|
42
|
+
measureText
|
|
43
|
+
);
|
|
44
|
+
let truncated = false;
|
|
45
|
+
if (element.maxLines != null && lines.length > element.maxLines) {
|
|
46
|
+
truncated = true;
|
|
47
|
+
lines.length = element.maxLines;
|
|
48
|
+
const lastIndex = element.maxLines - 1;
|
|
49
|
+
const measure = measureText ? (text2, fontSize, fontWeight) => measureText(text2, fontSize, fontWeight).width : void 0;
|
|
50
|
+
const withEllipsis = `${lines[lastIndex]}\u2026`;
|
|
51
|
+
lines[lastIndex] = truncateToWidth(
|
|
52
|
+
withEllipsis,
|
|
53
|
+
element.maxWidth,
|
|
54
|
+
element.style.fontSize,
|
|
55
|
+
element.style.fontWeight,
|
|
56
|
+
measure
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
if (lines.length === 1 && !truncated) {
|
|
60
|
+
text.textContent = renderedText;
|
|
61
|
+
} else if (lines.length === 1) {
|
|
62
|
+
text.textContent = lines[0];
|
|
63
|
+
} else {
|
|
64
|
+
const lineHeight = element.style.fontSize * (element.style.lineHeight ?? 1.3);
|
|
65
|
+
for (let i = 0; i < lines.length; i++) {
|
|
66
|
+
const tspan = createSVGElement("tspan");
|
|
67
|
+
setAttrs(tspan, { x: element.x, dy: i === 0 ? 0 : lineHeight });
|
|
68
|
+
tspan.textContent = lines[i];
|
|
69
|
+
text.appendChild(tspan);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
parent.appendChild(text);
|
|
73
|
+
}
|
|
74
|
+
function renderChrome(parent, layout) {
|
|
75
|
+
const g = createSVGElement("g");
|
|
76
|
+
g.setAttribute("class", "oc-chrome");
|
|
77
|
+
const { chrome, measureText } = layout;
|
|
78
|
+
if (chrome.rule) {
|
|
79
|
+
const rule = createSVGElement("rect");
|
|
80
|
+
rule.setAttribute("class", "oc-chrome-rule");
|
|
81
|
+
setAttrs(rule, {
|
|
82
|
+
x: chrome.rule.x,
|
|
83
|
+
y: chrome.rule.y,
|
|
84
|
+
width: chrome.rule.width,
|
|
85
|
+
height: chrome.rule.thickness
|
|
86
|
+
});
|
|
87
|
+
rule.setAttribute("fill", chrome.rule.color);
|
|
88
|
+
rule.setAttribute("shape-rendering", "crispEdges");
|
|
89
|
+
g.appendChild(rule);
|
|
90
|
+
}
|
|
91
|
+
if (chrome.eyebrow && chrome.rule) {
|
|
92
|
+
renderChromeElement(g, chrome.eyebrow, "oc-eyebrow", "eyebrow", measureText, true);
|
|
93
|
+
} else if (chrome.eyebrow) {
|
|
94
|
+
const eyebrow = chrome.eyebrow;
|
|
95
|
+
const dotR = 3;
|
|
96
|
+
const dotGap = 8;
|
|
97
|
+
const dotX = eyebrow.x + dotR;
|
|
98
|
+
const dotY = eyebrow.y + eyebrow.style.fontSize * 0.42;
|
|
99
|
+
const dot = createSVGElement("circle");
|
|
100
|
+
dot.setAttribute("class", "oc-eyebrow-dot");
|
|
101
|
+
setAttrs(dot, { cx: dotX, cy: dotY, r: dotR });
|
|
102
|
+
dot.setAttribute("fill", eyebrow.style.fill ?? "currentColor");
|
|
103
|
+
g.appendChild(dot);
|
|
104
|
+
const shifted = {
|
|
105
|
+
...eyebrow,
|
|
106
|
+
x: eyebrow.x + dotR * 2 + dotGap
|
|
107
|
+
};
|
|
108
|
+
renderChromeElement(g, shifted, "oc-eyebrow", "eyebrow", measureText, true);
|
|
109
|
+
}
|
|
110
|
+
if (chrome.title) {
|
|
111
|
+
renderChromeElement(g, chrome.title, "oc-title", "title", measureText);
|
|
112
|
+
}
|
|
113
|
+
if (chrome.subtitle) {
|
|
114
|
+
renderChromeElement(g, chrome.subtitle, "oc-subtitle", "subtitle", measureText);
|
|
115
|
+
}
|
|
116
|
+
const bottomOffset = layout.chrome.bottomAnchorY ?? layout.area.y + layout.area.height;
|
|
117
|
+
const bandHeight = layout.chrome.noteBandHeight ?? computeNoteBandHeight(layout.chrome, layout.theme);
|
|
118
|
+
let noteLine = 0;
|
|
119
|
+
if (chrome.footnotes && chrome.footnotes.length > 0) {
|
|
120
|
+
const fontSize = layout.theme.fonts.sizes.small;
|
|
121
|
+
const pad = layout.theme.spacing.padding;
|
|
122
|
+
const lineHeight = fontSize * FOOTNOTE_LINE_HEIGHT;
|
|
123
|
+
const style = {
|
|
124
|
+
fontFamily: layout.theme.fonts.family,
|
|
125
|
+
fontSize,
|
|
126
|
+
fontWeight: layout.theme.fonts.weights.normal,
|
|
127
|
+
fill: layout.theme.chrome.source.color,
|
|
128
|
+
lineHeight: FOOTNOTE_LINE_HEIGHT,
|
|
129
|
+
textAnchor: "start"
|
|
130
|
+
};
|
|
131
|
+
const list = createSVGElement("g");
|
|
132
|
+
list.setAttribute("role", "list");
|
|
133
|
+
list.setAttribute("aria-label", "Annotation notes, in source order");
|
|
134
|
+
g.appendChild(list);
|
|
135
|
+
for (let i = 0; i < chrome.footnotes.length; i++) {
|
|
136
|
+
const f = chrome.footnotes[i];
|
|
137
|
+
const y = bottomOffset + layout.theme.spacing.chartToFooter + textAscent(fontSize) + noteLine * lineHeight;
|
|
138
|
+
const el = createSVGElement("text");
|
|
139
|
+
el.setAttribute("class", "oc-footnotes");
|
|
140
|
+
el.setAttribute("role", "listitem");
|
|
141
|
+
if (!layout.a11y.hidden) el.setAttribute("tabindex", "0");
|
|
142
|
+
el.setAttribute(
|
|
143
|
+
"aria-label",
|
|
144
|
+
`${f.index}. ${f.text.replaceAll("**", "")}${f.subtitle ? `. ${f.subtitle.replaceAll("**", "")}` : ""}`
|
|
145
|
+
);
|
|
146
|
+
if (f.specIndex !== void 0) el.setAttribute("data-note-spec-index", String(f.specIndex));
|
|
147
|
+
if (f.id !== void 0) el.setAttribute("data-note-id", f.id);
|
|
148
|
+
setAttrs(el, { x: pad, y });
|
|
149
|
+
applyTextStyle(el, style);
|
|
150
|
+
const lines = f.lines ?? [`${f.index}. ${f.text}`];
|
|
151
|
+
lines.forEach((line, index) => {
|
|
152
|
+
const span = createSVGElement("tspan");
|
|
153
|
+
setAttrs(span, { x: pad, dy: index === 0 ? 0 : lineHeight });
|
|
154
|
+
const runs = f.spans?.[index];
|
|
155
|
+
if (runs) {
|
|
156
|
+
for (const run of runs) {
|
|
157
|
+
const part = createSVGElement("tspan");
|
|
158
|
+
if (run.bold) part.setAttribute("font-weight", "700");
|
|
159
|
+
part.textContent = run.text;
|
|
160
|
+
span.appendChild(part);
|
|
161
|
+
}
|
|
162
|
+
} else span.textContent = line;
|
|
163
|
+
el.appendChild(span);
|
|
164
|
+
});
|
|
165
|
+
noteLine += f.lines?.length ?? 1;
|
|
166
|
+
list.appendChild(el);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
let summaryLine = noteLine;
|
|
170
|
+
for (const entry of chrome.seriesSummary ?? []) {
|
|
171
|
+
const size = layout.theme.fonts.sizes.small;
|
|
172
|
+
const el = createSVGElement("text");
|
|
173
|
+
el.setAttribute("class", "oc-series-summary");
|
|
174
|
+
el.setAttribute("data-series", entry.key);
|
|
175
|
+
setAttrs(el, {
|
|
176
|
+
x: layout.theme.spacing.padding,
|
|
177
|
+
y: bottomOffset + layout.theme.spacing.chartToFooter + textAscent(size) + summaryLine * size * FOOTNOTE_LINE_HEIGHT
|
|
178
|
+
});
|
|
179
|
+
applyTextStyle(el, {
|
|
180
|
+
fontFamily: layout.theme.fonts.family,
|
|
181
|
+
fontSize: size,
|
|
182
|
+
fontWeight: 500,
|
|
183
|
+
lineHeight: FOOTNOTE_LINE_HEIGHT,
|
|
184
|
+
fill: entry.color
|
|
185
|
+
});
|
|
186
|
+
entry.lines.forEach((line, index) => {
|
|
187
|
+
const span = createSVGElement("tspan");
|
|
188
|
+
setAttrs(span, {
|
|
189
|
+
x: layout.theme.spacing.padding,
|
|
190
|
+
dy: index === 0 ? 0 : size * FOOTNOTE_LINE_HEIGHT
|
|
191
|
+
});
|
|
192
|
+
span.textContent = line;
|
|
193
|
+
el.appendChild(span);
|
|
194
|
+
});
|
|
195
|
+
summaryLine += entry.lines.length;
|
|
196
|
+
g.appendChild(el);
|
|
197
|
+
}
|
|
198
|
+
if (chrome.source) {
|
|
199
|
+
renderChromeElement(
|
|
200
|
+
g,
|
|
201
|
+
{ ...chrome.source, y: bottomOffset + chrome.source.y + bandHeight },
|
|
202
|
+
"oc-source",
|
|
203
|
+
"source",
|
|
204
|
+
measureText
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
if (chrome.byline) {
|
|
208
|
+
renderChromeElement(
|
|
209
|
+
g,
|
|
210
|
+
{ ...chrome.byline, y: bottomOffset + chrome.byline.y + bandHeight },
|
|
211
|
+
"oc-byline",
|
|
212
|
+
"byline",
|
|
213
|
+
measureText
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
if (chrome.footer) {
|
|
217
|
+
renderChromeElement(
|
|
218
|
+
g,
|
|
219
|
+
{ ...chrome.footer, y: bottomOffset + chrome.footer.y + bandHeight },
|
|
220
|
+
"oc-footer",
|
|
221
|
+
"footer",
|
|
222
|
+
measureText
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
if (chrome.brand) {
|
|
226
|
+
const brandY = bottomOffset + chrome.brand.y + bandHeight;
|
|
227
|
+
renderChromeElement(g, { ...chrome.brand, y: brandY }, "oc-brand", "brand", measureText);
|
|
228
|
+
}
|
|
229
|
+
parent.appendChild(g);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/renderers/brand.ts
|
|
233
|
+
import { computeNoteBandHeight as computeNoteBandHeight2 } from "@opendata-ai/openchart-core";
|
|
234
|
+
var BRAND_URL = "https://tryopendata.ai";
|
|
235
|
+
function renderAttributionBrand(parent, chrome, bottomOffset, measureText, includeCustom = true) {
|
|
236
|
+
if (includeCustom && chrome.brand) {
|
|
237
|
+
renderChromeElement(
|
|
238
|
+
parent,
|
|
239
|
+
{ ...chrome.brand, y: bottomOffset + chrome.brand.y },
|
|
240
|
+
"oc-brand",
|
|
241
|
+
"brand",
|
|
242
|
+
measureText
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
const mark = chrome.watermark;
|
|
246
|
+
if (!mark) return;
|
|
247
|
+
const link = createSVGElement("a");
|
|
248
|
+
link.setAttribute("href", BRAND_URL);
|
|
249
|
+
link.setAttributeNS(XLINK_NS, "xlink:href", BRAND_URL);
|
|
250
|
+
link.setAttribute("target", "_blank");
|
|
251
|
+
link.setAttribute("rel", "noopener");
|
|
252
|
+
link.setAttribute("class", "oc-chrome-ref");
|
|
253
|
+
link.setAttribute("opacity", "0.55");
|
|
254
|
+
renderChromeElement(
|
|
255
|
+
link,
|
|
256
|
+
{ ...mark, y: bottomOffset + mark.y },
|
|
257
|
+
"oc-watermark",
|
|
258
|
+
"watermark",
|
|
259
|
+
measureText
|
|
260
|
+
);
|
|
261
|
+
parent.appendChild(link);
|
|
262
|
+
}
|
|
263
|
+
function renderBrand(parent, layout) {
|
|
264
|
+
const bandHeight = layout.chrome.noteBandHeight ?? computeNoteBandHeight2(layout.chrome, layout.theme);
|
|
265
|
+
const bottomOffset = (layout.chrome.bottomAnchorY ?? layout.area.y + layout.area.height) + bandHeight;
|
|
266
|
+
renderAttributionBrand(parent, layout.chrome, bottomOffset, layout.measureText, false);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/theme-tokens.ts
|
|
270
|
+
import { adaptForLightLineStroke, cssTokenDefault } from "@opendata-ai/openchart-core";
|
|
271
|
+
function resolvedSurface(theme) {
|
|
272
|
+
return theme.colors.neutral.surface;
|
|
273
|
+
}
|
|
274
|
+
var stamped = /* @__PURE__ */ new WeakMap();
|
|
275
|
+
function readWithoutThemeStamp(el, name, read) {
|
|
276
|
+
const entry = stamped.get(el)?.get(name);
|
|
277
|
+
const value = el.style.getPropertyValue(name);
|
|
278
|
+
if (!entry || value !== entry.value) return read();
|
|
279
|
+
const priority = el.style.getPropertyPriority(name);
|
|
280
|
+
try {
|
|
281
|
+
if (entry.previous) el.style.setProperty(name, entry.previous, entry.priority);
|
|
282
|
+
else el.style.removeProperty(name);
|
|
283
|
+
return read();
|
|
284
|
+
} finally {
|
|
285
|
+
el.style.setProperty(name, value, priority);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function stampThemeProperties(el, theme, kind) {
|
|
289
|
+
el.classList.toggle("oc-dark", theme.isDark);
|
|
290
|
+
const accent = theme.colors.categorical[0] ?? cssTokenDefault("--oc-accent", "light");
|
|
291
|
+
const bg = resolvedSurface(theme);
|
|
292
|
+
const n = theme.colors.neutral;
|
|
293
|
+
const props = [
|
|
294
|
+
["--oc-font-family", theme.fonts.family],
|
|
295
|
+
["--oc-font-mono", theme.fonts.mono],
|
|
296
|
+
["--oc-title-size", `${theme.chrome.title.fontSize}px`],
|
|
297
|
+
["--oc-title-weight", `${theme.chrome.title.fontWeight}`],
|
|
298
|
+
["--oc-subtitle-size", `${theme.chrome.subtitle.fontSize}px`],
|
|
299
|
+
["--oc-subtitle-weight", `${theme.chrome.subtitle.fontWeight}`],
|
|
300
|
+
["--oc-source-size", `${theme.chrome.source.fontSize}px`],
|
|
301
|
+
["--oc-source-weight", `${theme.chrome.source.fontWeight}`],
|
|
302
|
+
["--oc-body-size", `${theme.fonts.sizes.body}px`],
|
|
303
|
+
["--oc-endpoint-label-size", `${theme.fonts.sizes.endpointLabel}px`],
|
|
304
|
+
["--oc-endpoint-value-size", `${theme.fonts.sizes.endpointValue}px`],
|
|
305
|
+
["--oc-endpoint-entry-gap", `${theme.spacing.endpointEntryGap}px`],
|
|
306
|
+
["--oc-endpoint-value-gap", `${theme.spacing.endpointValueGap}px`],
|
|
307
|
+
["--oc-endpoint-column-gap", `${theme.spacing.endpointColumnGap}px`],
|
|
308
|
+
["--oc-eyebrow-size", `${theme.chrome.eyebrow.fontSize}px`],
|
|
309
|
+
["--oc-eyebrow-weight", `${theme.chrome.eyebrow.fontWeight}`],
|
|
310
|
+
["--oc-bg", bg],
|
|
311
|
+
["--oc-text", theme.colors.text],
|
|
312
|
+
["--oc-text-muted", theme.colors.axis],
|
|
313
|
+
// Secondary grays are derived from the theme's own text/background pair
|
|
314
|
+
// (ResolvedTheme.colors.neutral), so a warm or cool theme gets warm or
|
|
315
|
+
// cool grays instead of zinc. One direction only: theme -> CSS.
|
|
316
|
+
["--oc-text-secondary", n.secondary],
|
|
317
|
+
["--oc-text-faint", n.faint],
|
|
318
|
+
["--oc-border", n.border],
|
|
319
|
+
["--oc-gray-100", n[100]],
|
|
320
|
+
["--oc-gray-200", n[200]],
|
|
321
|
+
["--oc-gray-300", n[300]],
|
|
322
|
+
["--oc-gray-400", n[400]],
|
|
323
|
+
["--oc-gray-600", n[600]],
|
|
324
|
+
["--oc-gray-800", n[800]],
|
|
325
|
+
["--oc-gridline", theme.colors.gridline],
|
|
326
|
+
// --oc-axis is the hairline the axis line is drawn with, not the ink its
|
|
327
|
+
// tick labels take (that is --oc-text-muted, above).
|
|
328
|
+
["--oc-axis", theme.colors.hairline],
|
|
329
|
+
["--oc-border-radius", `${theme.borderRadius}px`],
|
|
330
|
+
["--oc-accent", accent],
|
|
331
|
+
["--oc-accent-strong", adaptForLightLineStroke(accent)],
|
|
332
|
+
["--oc-positive", theme.colors.positive],
|
|
333
|
+
["--oc-negative", theme.colors.negative],
|
|
334
|
+
["--oc-space-2", `${theme.spacing.chromeGap * 2}px`],
|
|
335
|
+
["--oc-space-4", `${theme.spacing.padding}px`]
|
|
336
|
+
];
|
|
337
|
+
const authored = theme._authored;
|
|
338
|
+
const colors = authored?.colors && !Array.isArray(authored.colors) ? authored.colors : {};
|
|
339
|
+
const neutralAuthored = colors.text !== void 0 || colors.background !== void 0;
|
|
340
|
+
const colorAuthored = (key) => colors[key] !== void 0;
|
|
341
|
+
const chromeAuthored = (element, field) => {
|
|
342
|
+
if (authored?.chrome?.[element]?.[field] !== void 0) return true;
|
|
343
|
+
if (field === "fontWeight" || element === "eyebrow") return false;
|
|
344
|
+
return authored?.fonts?.sizes?.[element === "source" ? "small" : element] !== void 0;
|
|
345
|
+
};
|
|
346
|
+
const paletteAuthored = Array.isArray(authored?.colors) || colors.categorical !== void 0;
|
|
347
|
+
const enabled = {
|
|
348
|
+
"--oc-font-family": authored?.fonts?.family !== void 0,
|
|
349
|
+
"--oc-font-mono": authored?.fonts?.mono !== void 0,
|
|
350
|
+
"--oc-title-size": chromeAuthored("title", "fontSize"),
|
|
351
|
+
"--oc-title-weight": chromeAuthored("title", "fontWeight"),
|
|
352
|
+
"--oc-subtitle-size": chromeAuthored("subtitle", "fontSize"),
|
|
353
|
+
"--oc-subtitle-weight": chromeAuthored("subtitle", "fontWeight"),
|
|
354
|
+
"--oc-source-size": chromeAuthored("source", "fontSize"),
|
|
355
|
+
"--oc-source-weight": chromeAuthored("source", "fontWeight"),
|
|
356
|
+
"--oc-body-size": authored?.fonts?.sizes?.body !== void 0,
|
|
357
|
+
"--oc-endpoint-label-size": authored?.fonts?.sizes?.endpointLabel !== void 0,
|
|
358
|
+
"--oc-endpoint-value-size": authored?.fonts?.sizes?.endpointValue !== void 0,
|
|
359
|
+
"--oc-endpoint-entry-gap": authored?.spacing?.endpointEntryGap !== void 0,
|
|
360
|
+
"--oc-endpoint-value-gap": authored?.spacing?.endpointValueGap !== void 0,
|
|
361
|
+
"--oc-endpoint-column-gap": authored?.spacing?.endpointColumnGap !== void 0,
|
|
362
|
+
"--oc-eyebrow-size": chromeAuthored("eyebrow", "fontSize"),
|
|
363
|
+
"--oc-eyebrow-weight": chromeAuthored("eyebrow", "fontWeight"),
|
|
364
|
+
"--oc-bg": colorAuthored("background"),
|
|
365
|
+
"--oc-text": colorAuthored("text"),
|
|
366
|
+
"--oc-text-muted": colorAuthored("axis") || kind === "table" && neutralAuthored,
|
|
367
|
+
"--oc-text-secondary": neutralAuthored,
|
|
368
|
+
"--oc-text-faint": neutralAuthored,
|
|
369
|
+
"--oc-border": neutralAuthored || kind === "table" && colorAuthored("gridline"),
|
|
370
|
+
"--oc-gridline": colorAuthored("gridline"),
|
|
371
|
+
"--oc-axis": colorAuthored("hairline"),
|
|
372
|
+
"--oc-border-radius": authored?.borderRadius !== void 0,
|
|
373
|
+
"--oc-accent": paletteAuthored,
|
|
374
|
+
"--oc-accent-strong": paletteAuthored,
|
|
375
|
+
"--oc-positive": colorAuthored("positive"),
|
|
376
|
+
"--oc-negative": colorAuthored("negative"),
|
|
377
|
+
"--oc-space-2": authored?.spacing?.chromeGap !== void 0,
|
|
378
|
+
"--oc-space-4": authored?.spacing?.padding !== void 0
|
|
379
|
+
};
|
|
380
|
+
for (const key of [
|
|
381
|
+
"annotationLabel",
|
|
382
|
+
"annotationMuted",
|
|
383
|
+
"annotationLeader",
|
|
384
|
+
"annotationRule",
|
|
385
|
+
"annotationRangeFill",
|
|
386
|
+
"annotationMarkerFill",
|
|
387
|
+
"annotationPlate"
|
|
388
|
+
]) {
|
|
389
|
+
const name = `--oc-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
|
|
390
|
+
props.push([name, theme.colors[key]]);
|
|
391
|
+
enabled[name] = colorAuthored(key) || (key === "annotationMarkerFill" || key === "annotationPlate") && neutralAuthored;
|
|
392
|
+
}
|
|
393
|
+
for (const key of [
|
|
394
|
+
"gridlineZero",
|
|
395
|
+
"mapNoDataFill",
|
|
396
|
+
"mapNoDataHatch",
|
|
397
|
+
"mapInteriorBorder",
|
|
398
|
+
"mapOutlineBorder"
|
|
399
|
+
]) {
|
|
400
|
+
const name = `--oc-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
|
|
401
|
+
if (theme.colors[key] !== void 0) props.push([name, theme.colors[key]]);
|
|
402
|
+
enabled[name] = colorAuthored(key);
|
|
403
|
+
}
|
|
404
|
+
for (const level of [100, 200, 300, 400, 600, 800])
|
|
405
|
+
enabled[`--oc-gray-${level}`] = neutralAuthored;
|
|
406
|
+
if (kind === "table") {
|
|
407
|
+
if (!colorAuthored("axis")) props.find(([name]) => name === "--oc-text-muted")[1] = n[600];
|
|
408
|
+
if (colorAuthored("gridline"))
|
|
409
|
+
props.find(([name]) => name === "--oc-border")[1] = theme.colors.gridline;
|
|
410
|
+
}
|
|
411
|
+
const previous = stamped.get(el) ?? /* @__PURE__ */ new Map();
|
|
412
|
+
for (const [name, entry] of previous) {
|
|
413
|
+
if (!enabled[name]) {
|
|
414
|
+
if (el.style.getPropertyValue(name) === entry.value) {
|
|
415
|
+
if (entry.previous) el.style.setProperty(name, entry.previous, entry.priority);
|
|
416
|
+
else el.style.removeProperty(name);
|
|
417
|
+
}
|
|
418
|
+
previous.delete(name);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
for (const [name, value] of props) {
|
|
422
|
+
if (!enabled[name]) continue;
|
|
423
|
+
const old = previous.get(name);
|
|
424
|
+
previous.set(name, {
|
|
425
|
+
previous: old?.previous ?? el.style.getPropertyValue(name),
|
|
426
|
+
priority: old?.priority ?? el.style.getPropertyPriority(name),
|
|
427
|
+
value
|
|
428
|
+
});
|
|
429
|
+
el.style.setProperty(name, value);
|
|
430
|
+
}
|
|
431
|
+
stamped.set(el, previous);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export {
|
|
435
|
+
renderChromeElement,
|
|
436
|
+
renderChrome,
|
|
437
|
+
renderAttributionBrand,
|
|
438
|
+
renderBrand,
|
|
439
|
+
resolvedSurface,
|
|
440
|
+
readWithoutThemeStamp,
|
|
441
|
+
stampThemeProperties,
|
|
442
|
+
linear,
|
|
443
|
+
cubicOut,
|
|
444
|
+
cubicInOut,
|
|
445
|
+
clamp01,
|
|
446
|
+
lerp
|
|
447
|
+
};
|
|
448
|
+
//# sourceMappingURL=chunk-NLKQ5AOA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/motion/easing.ts","../src/renderers/chrome.ts","../src/renderers/brand.ts","../src/theme-tokens.ts"],"sourcesContent":["/**\n * Shared easing and interpolation primitives.\n *\n * Single source of truth for the hand-rolled easings used by the canvas\n * scheduler (motion/tween.ts), the update-transition driver (transition.ts)\n * and the story tweens (story/tween.ts). No `d3-ease` dependency.\n */\n\n/** Linear (identity) easing. Required for stacked/segmented handoffs. */\nexport function linear(t: number): number {\n return t;\n}\n\n/** Cubic-out: decelerates into place. Maps to `'snappy'`. */\nexport function cubicOut(t: number): number {\n const f = 1 - t;\n return 1 - f * f * f;\n}\n\n/** Cubic-in-out: eases in and out. Maps to `'smooth'`. */\nexport function cubicInOut(t: number): number {\n return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;\n}\n\nexport const clamp01 = (t: number): number => Math.min(1, Math.max(0, t));\n\nexport const lerp = (a: number, b: number, t: number): number => a + (b - a) * t;\n","/**\n * Chrome rendering: title, subtitle, source, byline, footer.\n */\n\nimport type {\n ChartLayout,\n MeasureTextFn,\n ResolvedChromeElement,\n} from '@opendata-ai/openchart-core';\nimport {\n computeNoteBandHeight,\n FOOTNOTE_LINE_HEIGHT,\n textAscent,\n truncateToWidth,\n wrapText,\n} from '@opendata-ai/openchart-core';\nimport { applyTextStyle, createSVGElement, setAttrs } from './svg-dom';\n\nexport function renderChromeElement(\n parent: SVGElement,\n element: ResolvedChromeElement,\n className: string,\n chromeKey: string,\n measureText?: MeasureTextFn,\n uppercase = false,\n): void {\n const text = createSVGElement('text');\n // element.y is the TOP of the text box; convert to the alphabetic baseline\n // here instead of relying on dominant-baseline:hanging, which WebKit\n // positions from different font metrics and never inherits into tspans.\n setAttrs(text, { x: element.x, y: element.y + textAscent(element.style.fontSize) });\n applyTextStyle(text, element.style);\n text.setAttribute('class', className);\n text.setAttribute('data-chrome-key', chromeKey);\n\n // happy-dom doesn't apply CSS text-transform inside SVG measurement, so\n // pre-uppercase the rendered text for elements that style as uppercase.\n // Browsers honor the CSS rule too, so this is double-applied harmlessly.\n const renderedText = uppercase ? element.text.toUpperCase() : element.text;\n\n const lines = wrapText(\n renderedText,\n element.style.fontSize,\n element.style.fontWeight,\n element.maxWidth,\n measureText,\n );\n\n // Cap wrapped output to maxLines, truncating the last kept line with an\n // ellipsis so it fits maxWidth. Only when the natural wrap exceeds the cap.\n let truncated = false;\n if (element.maxLines != null && lines.length > element.maxLines) {\n truncated = true;\n lines.length = element.maxLines;\n const lastIndex = element.maxLines - 1;\n const measure = measureText\n ? (text: string, fontSize: number, fontWeight?: number) =>\n measureText(text, fontSize, fontWeight).width\n : undefined;\n // Content was dropped, so the last kept line always gets an ellipsis.\n // Append it first, then shrink to fit maxWidth if the combined string\n // overflows.\n const withEllipsis = `${lines[lastIndex]}…`;\n lines[lastIndex] = truncateToWidth(\n withEllipsis,\n element.maxWidth,\n element.style.fontSize,\n element.style.fontWeight,\n measure,\n );\n }\n\n if (lines.length === 1 && !truncated) {\n text.textContent = renderedText;\n } else if (lines.length === 1) {\n text.textContent = lines[0];\n } else {\n const lineHeight = element.style.fontSize * (element.style.lineHeight ?? 1.3);\n for (let i = 0; i < lines.length; i++) {\n const tspan = createSVGElement('tspan');\n setAttrs(tspan, { x: element.x, dy: i === 0 ? 0 : lineHeight });\n tspan.textContent = lines[i];\n text.appendChild(tspan);\n }\n }\n\n parent.appendChild(text);\n}\n\nexport function renderChrome(parent: SVGElement, layout: ChartLayout): void {\n const g = createSVGElement('g');\n g.setAttribute('class', 'oc-chrome');\n\n const { chrome, measureText } = layout;\n\n // Editorial rule: a short colored bar above the top chrome block.\n if (chrome.rule) {\n const rule = createSVGElement('rect');\n rule.setAttribute('class', 'oc-chrome-rule');\n setAttrs(rule, {\n x: chrome.rule.x,\n y: chrome.rule.y,\n width: chrome.rule.width,\n height: chrome.rule.thickness,\n });\n rule.setAttribute('fill', chrome.rule.color);\n rule.setAttribute('shape-rendering', 'crispEdges');\n g.appendChild(rule);\n }\n\n // Top chrome: render at their stored y positions (already absolute)\n if (chrome.eyebrow && chrome.rule) {\n // The rule already carries the accent above the block; a dot as well is\n // two pieces of furniture saying the same thing.\n renderChromeElement(g, chrome.eyebrow, 'oc-eyebrow', 'eyebrow', measureText, true);\n } else if (chrome.eyebrow) {\n // Leading accent dot — matches the editorial design system mock.\n // eyebrow.y is the top of the text box. Visual center is roughly\n // y + fontSize * 0.55 (cap height).\n const eyebrow = chrome.eyebrow;\n const dotR = 3;\n const dotGap = 8;\n const dotX = eyebrow.x + dotR;\n const dotY = eyebrow.y + eyebrow.style.fontSize * 0.42;\n const dot = createSVGElement('circle');\n dot.setAttribute('class', 'oc-eyebrow-dot');\n setAttrs(dot, { cx: dotX, cy: dotY, r: dotR });\n dot.setAttribute('fill', eyebrow.style.fill ?? 'currentColor');\n g.appendChild(dot);\n\n const shifted: ResolvedChromeElement = {\n ...eyebrow,\n x: eyebrow.x + dotR * 2 + dotGap,\n };\n renderChromeElement(g, shifted, 'oc-eyebrow', 'eyebrow', measureText, true);\n }\n if (chrome.title) {\n renderChromeElement(g, chrome.title, 'oc-title', 'title', measureText);\n }\n if (chrome.subtitle) {\n renderChromeElement(g, chrome.subtitle, 'oc-subtitle', 'subtitle', measureText);\n }\n\n const bottomOffset = layout.chrome.bottomAnchorY ?? layout.area.y + layout.area.height;\n\n // Footnotes from auto-thinned annotations, rendered above source/byline.\n // Each footnote gets its own line to avoid horizontal overflow.\n const bandHeight =\n layout.chrome.noteBandHeight ?? computeNoteBandHeight(layout.chrome, layout.theme);\n let noteLine = 0;\n if (chrome.footnotes && chrome.footnotes.length > 0) {\n const fontSize = layout.theme.fonts.sizes.small;\n const pad = layout.theme.spacing.padding;\n const lineHeight = fontSize * FOOTNOTE_LINE_HEIGHT;\n const style = {\n fontFamily: layout.theme.fonts.family,\n fontSize,\n fontWeight: layout.theme.fonts.weights.normal,\n fill: layout.theme.chrome.source.color,\n lineHeight: FOOTNOTE_LINE_HEIGHT,\n textAnchor: 'start' as const,\n };\n\n const list = createSVGElement('g');\n list.setAttribute('role', 'list');\n list.setAttribute('aria-label', 'Annotation notes, in source order');\n g.appendChild(list);\n for (let i = 0; i < chrome.footnotes.length; i++) {\n const f = chrome.footnotes[i];\n const y =\n bottomOffset +\n layout.theme.spacing.chartToFooter +\n textAscent(fontSize) +\n noteLine * lineHeight;\n const el = createSVGElement('text');\n el.setAttribute('class', 'oc-footnotes');\n el.setAttribute('role', 'listitem');\n if (!layout.a11y.hidden) el.setAttribute('tabindex', '0');\n el.setAttribute(\n 'aria-label',\n `${f.index}. ${f.text.replaceAll('**', '')}${f.subtitle ? `. ${f.subtitle.replaceAll('**', '')}` : ''}`,\n );\n if (f.specIndex !== undefined) el.setAttribute('data-note-spec-index', String(f.specIndex));\n if (f.id !== undefined) el.setAttribute('data-note-id', f.id);\n setAttrs(el, { x: pad, y });\n applyTextStyle(el, style);\n const lines = f.lines ?? [`${f.index}. ${f.text}`];\n lines.forEach((line, index) => {\n const span = createSVGElement('tspan');\n setAttrs(span, { x: pad, dy: index === 0 ? 0 : lineHeight });\n const runs = f.spans?.[index];\n if (runs) {\n for (const run of runs) {\n const part = createSVGElement('tspan');\n if (run.bold) part.setAttribute('font-weight', '700');\n part.textContent = run.text;\n span.appendChild(part);\n }\n } else span.textContent = line;\n el.appendChild(span);\n });\n noteLine += f.lines?.length ?? 1;\n list.appendChild(el);\n }\n }\n\n let summaryLine = noteLine;\n for (const entry of chrome.seriesSummary ?? []) {\n const size = layout.theme.fonts.sizes.small;\n const el = createSVGElement('text');\n el.setAttribute('class', 'oc-series-summary');\n el.setAttribute('data-series', entry.key);\n setAttrs(el, {\n x: layout.theme.spacing.padding,\n y:\n bottomOffset +\n layout.theme.spacing.chartToFooter +\n textAscent(size) +\n summaryLine * size * FOOTNOTE_LINE_HEIGHT,\n });\n applyTextStyle(el, {\n fontFamily: layout.theme.fonts.family,\n fontSize: size,\n fontWeight: 500,\n lineHeight: FOOTNOTE_LINE_HEIGHT,\n fill: entry.color,\n });\n entry.lines.forEach((line, index) => {\n const span = createSVGElement('tspan');\n setAttrs(span, {\n x: layout.theme.spacing.padding,\n dy: index === 0 ? 0 : size * FOOTNOTE_LINE_HEIGHT,\n });\n span.textContent = line;\n el.appendChild(span);\n });\n summaryLine += entry.lines.length;\n g.appendChild(el);\n }\n\n if (chrome.source) {\n renderChromeElement(\n g,\n { ...chrome.source, y: bottomOffset + chrome.source.y + bandHeight },\n 'oc-source',\n 'source',\n measureText,\n );\n }\n if (chrome.byline) {\n renderChromeElement(\n g,\n { ...chrome.byline, y: bottomOffset + chrome.byline.y + bandHeight },\n 'oc-byline',\n 'byline',\n measureText,\n );\n }\n if (chrome.footer) {\n renderChromeElement(\n g,\n { ...chrome.footer, y: bottomOffset + chrome.footer.y + bandHeight },\n 'oc-footer',\n 'footer',\n measureText,\n );\n }\n if (chrome.brand) {\n const brandY = bottomOffset + chrome.brand.y + bandHeight;\n renderChromeElement(g, { ...chrome.brand, y: brandY }, 'oc-brand', 'brand', measureText);\n }\n\n parent.appendChild(g);\n}\n","/** Shared measured attribution painting for SVG visualizations. */\nimport type { ChartLayout, MeasureTextFn, ResolvedChrome } from '@opendata-ai/openchart-core';\nimport { computeNoteBandHeight } from '@opendata-ai/openchart-core';\nimport { renderChromeElement } from './chrome';\nimport { createSVGElement, XLINK_NS } from './svg-dom';\n\nconst BRAND_URL = 'https://tryopendata.ai';\n\n/** Paint the exact portable footer mark resolved by computeChrome. */\nexport function renderAttributionBrand(\n parent: SVGElement,\n chrome: ResolvedChrome,\n bottomOffset: number,\n measureText?: MeasureTextFn,\n includeCustom = true,\n): void {\n if (includeCustom && chrome.brand) {\n renderChromeElement(\n parent,\n { ...chrome.brand, y: bottomOffset + chrome.brand.y },\n 'oc-brand',\n 'brand',\n measureText,\n );\n }\n const mark = chrome.watermark;\n if (!mark) return;\n const link = createSVGElement('a');\n link.setAttribute('href', BRAND_URL);\n link.setAttributeNS(XLINK_NS, 'xlink:href', BRAND_URL);\n link.setAttribute('target', '_blank');\n link.setAttribute('rel', 'noopener');\n link.setAttribute('class', 'oc-chrome-ref');\n link.setAttribute('opacity', '0.55');\n renderChromeElement(\n link,\n { ...mark, y: bottomOffset + mark.y },\n 'oc-watermark',\n 'watermark',\n measureText,\n );\n parent.appendChild(link);\n}\n\nexport function renderBrand(parent: SVGElement, layout: ChartLayout): void {\n const bandHeight =\n layout.chrome.noteBandHeight ?? computeNoteBandHeight(layout.chrome, layout.theme);\n const bottomOffset =\n (layout.chrome.bottomAnchorY ?? layout.area.y + layout.area.height) + bandHeight;\n renderAttributionBrand(parent, layout.chrome, bottomOffset, layout.measureText, false);\n}\n","/**\n * Project authored theme leaves to scoped CSS custom properties.\n *\n * Unauthored values remain in tokens.css / dark.css, leaving host CSS in\n * control. Derived neutral values follow authored text/background changes.\n */\n\nimport type { ResolvedTheme, ThemeConfig } from '@opendata-ai/openchart-core';\nimport { adaptForLightLineStroke, cssTokenDefault } from '@opendata-ai/openchart-core';\n\n/**\n * The opaque surface a theme paints on. A transparent theme background has no\n * color of its own, so it resolves to the static `--oc-bg` token for the mode --\n * the same value the engine's knockout strokes are cut in. Resolved once in\n * core, on `colors.neutral.surface`; this is a named read of it.\n */\nexport function resolvedSurface(theme: ResolvedTheme): string {\n return theme.colors.neutral.surface;\n}\n\ntype StyledElement = HTMLElement | SVGElement;\nconst stamped = new WeakMap<\n StyledElement,\n Map<string, { previous: string; priority: string; value: string }>\n>();\n\n/** Read the host cascade without an earlier authored token, then restore it synchronously. */\nexport function readWithoutThemeStamp<T>(el: StyledElement, name: string, read: () => T): T {\n const entry = stamped.get(el)?.get(name);\n const value = el.style.getPropertyValue(name);\n if (!entry || value !== entry.value) return read();\n const priority = el.style.getPropertyPriority(name);\n try {\n if (entry.previous) el.style.setProperty(name, entry.previous, entry.priority);\n else el.style.removeProperty(name);\n return read();\n } finally {\n el.style.setProperty(name, value, priority);\n }\n}\n\n/** Stamp only authored theme leaves. Defaults stay in CSS so host rules can override them. */\nexport function stampThemeProperties(\n el: StyledElement,\n theme: ResolvedTheme,\n kind?: 'table',\n): void {\n el.classList.toggle('oc-dark', theme.isDark);\n const accent = theme.colors.categorical[0] ?? cssTokenDefault('--oc-accent', 'light');\n const bg = resolvedSurface(theme);\n\n const n = theme.colors.neutral;\n\n const props: [string, string][] = [\n ['--oc-font-family', theme.fonts.family],\n ['--oc-font-mono', theme.fonts.mono],\n ['--oc-title-size', `${theme.chrome.title.fontSize}px`],\n ['--oc-title-weight', `${theme.chrome.title.fontWeight}`],\n ['--oc-subtitle-size', `${theme.chrome.subtitle.fontSize}px`],\n ['--oc-subtitle-weight', `${theme.chrome.subtitle.fontWeight}`],\n ['--oc-source-size', `${theme.chrome.source.fontSize}px`],\n ['--oc-source-weight', `${theme.chrome.source.fontWeight}`],\n ['--oc-body-size', `${theme.fonts.sizes.body}px`],\n ['--oc-endpoint-label-size', `${theme.fonts.sizes.endpointLabel}px`],\n ['--oc-endpoint-value-size', `${theme.fonts.sizes.endpointValue}px`],\n ['--oc-endpoint-entry-gap', `${theme.spacing.endpointEntryGap}px`],\n ['--oc-endpoint-value-gap', `${theme.spacing.endpointValueGap}px`],\n ['--oc-endpoint-column-gap', `${theme.spacing.endpointColumnGap}px`],\n ['--oc-eyebrow-size', `${theme.chrome.eyebrow.fontSize}px`],\n ['--oc-eyebrow-weight', `${theme.chrome.eyebrow.fontWeight}`],\n ['--oc-bg', bg],\n ['--oc-text', theme.colors.text],\n ['--oc-text-muted', theme.colors.axis],\n // Secondary grays are derived from the theme's own text/background pair\n // (ResolvedTheme.colors.neutral), so a warm or cool theme gets warm or\n // cool grays instead of zinc. One direction only: theme -> CSS.\n ['--oc-text-secondary', n.secondary],\n ['--oc-text-faint', n.faint],\n ['--oc-border', n.border],\n ['--oc-gray-100', n[100]],\n ['--oc-gray-200', n[200]],\n ['--oc-gray-300', n[300]],\n ['--oc-gray-400', n[400]],\n ['--oc-gray-600', n[600]],\n ['--oc-gray-800', n[800]],\n ['--oc-gridline', theme.colors.gridline],\n // --oc-axis is the hairline the axis line is drawn with, not the ink its\n // tick labels take (that is --oc-text-muted, above).\n ['--oc-axis', theme.colors.hairline],\n ['--oc-border-radius', `${theme.borderRadius}px`],\n ['--oc-accent', accent],\n ['--oc-accent-strong', adaptForLightLineStroke(accent)],\n ['--oc-positive', theme.colors.positive],\n ['--oc-negative', theme.colors.negative],\n ['--oc-space-2', `${theme.spacing.chromeGap * 2}px`],\n ['--oc-space-4', `${theme.spacing.padding}px`],\n ];\n\n const authored = theme._authored;\n const colors = authored?.colors && !Array.isArray(authored.colors) ? authored.colors : {};\n const neutralAuthored = colors.text !== undefined || colors.background !== undefined;\n const colorAuthored = (key: keyof Exclude<ThemeConfig['colors'], string[] | undefined>) =>\n colors[key] !== undefined;\n const chromeAuthored = (\n element: 'title' | 'subtitle' | 'source' | 'eyebrow',\n field: 'fontSize' | 'fontWeight',\n ) => {\n if (authored?.chrome?.[element]?.[field] !== undefined) return true;\n if (field === 'fontWeight' || element === 'eyebrow') return false;\n return authored?.fonts?.sizes?.[element === 'source' ? 'small' : element] !== undefined;\n };\n const paletteAuthored = Array.isArray(authored?.colors) || colors.categorical !== undefined;\n const enabled: Record<string, boolean> = {\n '--oc-font-family': authored?.fonts?.family !== undefined,\n '--oc-font-mono': authored?.fonts?.mono !== undefined,\n '--oc-title-size': chromeAuthored('title', 'fontSize'),\n '--oc-title-weight': chromeAuthored('title', 'fontWeight'),\n '--oc-subtitle-size': chromeAuthored('subtitle', 'fontSize'),\n '--oc-subtitle-weight': chromeAuthored('subtitle', 'fontWeight'),\n '--oc-source-size': chromeAuthored('source', 'fontSize'),\n '--oc-source-weight': chromeAuthored('source', 'fontWeight'),\n '--oc-body-size': authored?.fonts?.sizes?.body !== undefined,\n '--oc-endpoint-label-size': authored?.fonts?.sizes?.endpointLabel !== undefined,\n '--oc-endpoint-value-size': authored?.fonts?.sizes?.endpointValue !== undefined,\n '--oc-endpoint-entry-gap': authored?.spacing?.endpointEntryGap !== undefined,\n '--oc-endpoint-value-gap': authored?.spacing?.endpointValueGap !== undefined,\n '--oc-endpoint-column-gap': authored?.spacing?.endpointColumnGap !== undefined,\n '--oc-eyebrow-size': chromeAuthored('eyebrow', 'fontSize'),\n '--oc-eyebrow-weight': chromeAuthored('eyebrow', 'fontWeight'),\n '--oc-bg': colorAuthored('background'),\n '--oc-text': colorAuthored('text'),\n '--oc-text-muted': colorAuthored('axis') || (kind === 'table' && neutralAuthored),\n '--oc-text-secondary': neutralAuthored,\n '--oc-text-faint': neutralAuthored,\n '--oc-border': neutralAuthored || (kind === 'table' && colorAuthored('gridline')),\n '--oc-gridline': colorAuthored('gridline'),\n '--oc-axis': colorAuthored('hairline'),\n '--oc-border-radius': authored?.borderRadius !== undefined,\n '--oc-accent': paletteAuthored,\n '--oc-accent-strong': paletteAuthored,\n '--oc-positive': colorAuthored('positive'),\n '--oc-negative': colorAuthored('negative'),\n '--oc-space-2': authored?.spacing?.chromeGap !== undefined,\n '--oc-space-4': authored?.spacing?.padding !== undefined,\n };\n for (const key of [\n 'annotationLabel',\n 'annotationMuted',\n 'annotationLeader',\n 'annotationRule',\n 'annotationRangeFill',\n 'annotationMarkerFill',\n 'annotationPlate',\n ] as const) {\n const name = `--oc-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;\n props.push([name, theme.colors[key]]);\n enabled[name] =\n colorAuthored(key) ||\n ((key === 'annotationMarkerFill' || key === 'annotationPlate') && neutralAuthored);\n }\n for (const key of [\n 'gridlineZero',\n 'mapNoDataFill',\n 'mapNoDataHatch',\n 'mapInteriorBorder',\n 'mapOutlineBorder',\n ] as const) {\n const name = `--oc-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;\n if (theme.colors[key] !== undefined) props.push([name, theme.colors[key]]);\n enabled[name] = colorAuthored(key);\n }\n for (const level of [100, 200, 300, 400, 600, 800])\n enabled[`--oc-gray-${level}`] = neutralAuthored;\n if (kind === 'table') {\n if (!colorAuthored('axis')) props.find(([name]) => name === '--oc-text-muted')![1] = n[600];\n if (colorAuthored('gridline'))\n props.find(([name]) => name === '--oc-border')![1] = theme.colors.gridline;\n }\n const previous = stamped.get(el) ?? new Map();\n for (const [name, entry] of previous) {\n if (!enabled[name]) {\n // Do not erase a host change made since our last stamp.\n if (el.style.getPropertyValue(name) === entry.value) {\n if (entry.previous) el.style.setProperty(name, entry.previous, entry.priority);\n else el.style.removeProperty(name);\n }\n previous.delete(name);\n }\n }\n for (const [name, value] of props) {\n if (!enabled[name]) continue;\n const old = previous.get(name);\n previous.set(name, {\n previous: old?.previous ?? el.style.getPropertyValue(name),\n priority: old?.priority ?? el.style.getPropertyPriority(name),\n value,\n });\n el.style.setProperty(name, value);\n }\n stamped.set(el, previous);\n}\n"],"mappings":";;;;;;;;AASO,SAAS,OAAO,GAAmB;AACxC,SAAO;AACT;AAGO,SAAS,SAAS,GAAmB;AAC1C,QAAM,IAAI,IAAI;AACd,SAAO,IAAI,IAAI,IAAI;AACrB;AAGO,SAAS,WAAW,GAAmB;AAC5C,SAAO,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,IAAI,MAAM,IAAI;AAC3D;AAEO,IAAM,UAAU,CAAC,MAAsB,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AAEjE,IAAM,OAAO,CAAC,GAAW,GAAW,MAAsB,KAAK,IAAI,KAAK;;;ACjB/E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,oBACd,QACA,SACA,WACA,WACA,aACA,YAAY,OACN;AACN,QAAM,OAAO,iBAAiB,MAAM;AAIpC,WAAS,MAAM,EAAE,GAAG,QAAQ,GAAG,GAAG,QAAQ,IAAI,WAAW,QAAQ,MAAM,QAAQ,EAAE,CAAC;AAClF,iBAAe,MAAM,QAAQ,KAAK;AAClC,OAAK,aAAa,SAAS,SAAS;AACpC,OAAK,aAAa,mBAAmB,SAAS;AAK9C,QAAM,eAAe,YAAY,QAAQ,KAAK,YAAY,IAAI,QAAQ;AAEtE,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,QAAQ,MAAM;AAAA,IACd,QAAQ,MAAM;AAAA,IACd,QAAQ;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E,IAAG,MAAM,eAAe,IAAI;AAAA,MACnC;AACA,eAAS,OAAO,IAAI;AAAA,IACtB;AAAA,EACF;AACA,aAAW,CAAC,MAAM,KAAK,KAAK,OAAO;AACjC,QAAI,CAAC,QAAQ,IAAI,EAAG;AACpB,UAAM,MAAM,SAAS,IAAI,IAAI;AAC7B,aAAS,IAAI,MAAM;AAAA,MACjB,UAAU,KAAK,YAAY,GAAG,MAAM,iBAAiB,IAAI;AAAA,MACzD,UAAU,KAAK,YAAY,GAAG,MAAM,oBAAoB,IAAI;AAAA,MAC5D;AAAA,IACF,CAAC;AACD,OAAG,MAAM,YAAY,MAAM,KAAK;AAAA,EAClC;AACA,UAAQ,IAAI,IAAI,QAAQ;AAC1B;","names":["text","computeNoteBandHeight","computeNoteBandHeight"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
copyComputedThemeProperties,
|
|
2
3
|
injectThemeStyleBlock
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-A5C4VCUO.js";
|
|
4
5
|
|
|
5
6
|
// src/export.ts
|
|
6
7
|
function getSVGDimensions(svg) {
|
|
@@ -147,14 +148,24 @@ function getSVGBackgroundColor(svgElement, fallback) {
|
|
|
147
148
|
return fill;
|
|
148
149
|
}
|
|
149
150
|
function exportSVG(svgElement) {
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
const clone = svgElement.cloneNode(true);
|
|
152
|
+
for (const control of clone.querySelectorAll(
|
|
153
|
+
".oc-selection-overlay, .oc-anchor-handle, .oc-connector-handle"
|
|
154
|
+
))
|
|
155
|
+
control.remove();
|
|
156
|
+
clone.classList.remove("oc-note-active");
|
|
157
|
+
for (const element of clone.querySelectorAll(".oc-note-active")) {
|
|
158
|
+
element.classList.remove("oc-note-active");
|
|
159
|
+
}
|
|
160
|
+
if (!clone.getAttribute("xmlns")) {
|
|
161
|
+
clone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
152
162
|
}
|
|
153
163
|
const serializer = new XMLSerializer();
|
|
154
|
-
return serializer.serializeToString(
|
|
164
|
+
return serializer.serializeToString(clone);
|
|
155
165
|
}
|
|
156
166
|
async function exportSVGWithFonts(svgElement, options) {
|
|
157
167
|
const clone = svgElement.cloneNode(true);
|
|
168
|
+
copyComputedThemeProperties(svgElement, clone);
|
|
158
169
|
const shouldEmbed = options?.embedFonts ?? true;
|
|
159
170
|
injectThemeStyleBlock(clone, options?.theme);
|
|
160
171
|
if (shouldEmbed) {
|
|
@@ -214,6 +225,7 @@ function rasterizeSVGToCanvas(svgString, width, height, dpi, prepare) {
|
|
|
214
225
|
async function prepareRasterSVG(svgElement, shouldEmbed, theme) {
|
|
215
226
|
const { width, height } = getSVGDimensions(svgElement);
|
|
216
227
|
const clone = svgElement.cloneNode(true);
|
|
228
|
+
copyComputedThemeProperties(svgElement, clone);
|
|
217
229
|
injectThemeStyleBlock(clone, theme);
|
|
218
230
|
if (shouldEmbed) {
|
|
219
231
|
await embedFonts(clone);
|
|
@@ -297,4 +309,4 @@ export {
|
|
|
297
309
|
exportJPG,
|
|
298
310
|
exportCSV
|
|
299
311
|
};
|
|
300
|
-
//# sourceMappingURL=chunk-
|
|
312
|
+
//# sourceMappingURL=chunk-RBXIZJPE.js.map
|