@zombie-mermaid/svg-renderer 5.3.0 → 5.5.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/dist/index.cjs +93 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +753 -0
- package/dist/index.d.ts +753 -0
- package/dist/index.js +5813 -0
- package/dist/index.js.map +1 -0
- package/package.json +5 -5
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,753 @@
|
|
|
1
|
+
import { ClassDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
2
|
+
import { ClassRenderOptions } from '@zombie-mermaid/core';
|
|
3
|
+
import { CurveStyle } from '@zombie-mermaid/core';
|
|
4
|
+
import { DiagramColors } from '@zombie-mermaid/core';
|
|
5
|
+
import { Direction } from '@zombie-mermaid/core';
|
|
6
|
+
import { ElkConstructor } from '@zombie-mermaid/core';
|
|
7
|
+
import { ElkExtendedEdge } from '@zombie-mermaid/core';
|
|
8
|
+
import { ElkLabel } from '@zombie-mermaid/core';
|
|
9
|
+
import { ElkNode } from '@zombie-mermaid/core';
|
|
10
|
+
import { ErDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
11
|
+
import { ErRenderOptions } from '@zombie-mermaid/core';
|
|
12
|
+
import { FlowchartRenderOptions } from '@zombie-mermaid/core';
|
|
13
|
+
import { LayoutCache } from '@zombie-mermaid/core';
|
|
14
|
+
import { LayoutOptions } from '@zombie-mermaid/core';
|
|
15
|
+
import { MermaidGraph } from '@zombie-mermaid/core';
|
|
16
|
+
import { niceTickValues } from '@zombie-mermaid/core';
|
|
17
|
+
import { PieChart } from '@zombie-mermaid/mermaid-parser';
|
|
18
|
+
import { Point } from '@zombie-mermaid/core';
|
|
19
|
+
import { PositionedClassDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
20
|
+
import { PositionedErDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
21
|
+
import { PositionedGraph } from '@zombie-mermaid/core';
|
|
22
|
+
import { PositionedNode } from '@zombie-mermaid/core';
|
|
23
|
+
import { PositionedPieChart } from '@zombie-mermaid/mermaid-parser';
|
|
24
|
+
import { PositionedSequenceDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
25
|
+
import { PositionedXYChart } from '@zombie-mermaid/mermaid-parser';
|
|
26
|
+
import { RenderOptions } from '@zombie-mermaid/core';
|
|
27
|
+
import { SequenceDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
28
|
+
import { SequenceRenderOptions } from '@zombie-mermaid/core';
|
|
29
|
+
import { SvgEmitOptions } from '@zombie-mermaid/core';
|
|
30
|
+
import { XYChart } from '@zombie-mermaid/mermaid-parser';
|
|
31
|
+
import { XyChartRenderOptions } from '@zombie-mermaid/core';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Distance from the bottom of a stick-figure (`actor`) icon to the vertical
|
|
35
|
+
* centre of its label. Shared with the renderer so the label lands where the
|
|
36
|
+
* layout reserved room for it.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ACTOR_LABEL_OFFSET = 14;
|
|
39
|
+
|
|
40
|
+
/** Arrow head dimensions — matches spec: 8px wide × ~5px tall */
|
|
41
|
+
export declare const ARROW_HEAD: {
|
|
42
|
+
readonly width: 8;
|
|
43
|
+
readonly height: 5;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The `elk.*` options every one of the three graph builders sets, with the
|
|
48
|
+
* values they all agree on. Callers spread the result and add their own
|
|
49
|
+
* diagram-specific options on top.
|
|
50
|
+
*/
|
|
51
|
+
export declare function baseElkLayoutOptions(spec: {
|
|
52
|
+
direction: ElkDirection;
|
|
53
|
+
nodeSpacing: number;
|
|
54
|
+
layerSpacing: number;
|
|
55
|
+
padding: number | ElkPaddingSides;
|
|
56
|
+
}): LayoutOptions;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Height of the label band at the top of a `box … end` group, in px — the
|
|
60
|
+
* label's font size plus vertical breathing room. Shared with the renderer
|
|
61
|
+
* so the label lands centred in the band the layout reserved for it.
|
|
62
|
+
*/
|
|
63
|
+
export declare function boxLabelHeight(labelFontSize: number): number;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Build a single-source/single-target ELK edge, with a measured label when
|
|
67
|
+
* `label` is non-empty. An absent or empty label leaves `labels` off the
|
|
68
|
+
* edge entirely (rather than setting it to an empty array or `undefined`),
|
|
69
|
+
* matching what all three builders did by hand.
|
|
70
|
+
*/
|
|
71
|
+
export declare function buildElkEdge(spec: {
|
|
72
|
+
id: string;
|
|
73
|
+
source: string;
|
|
74
|
+
target: string;
|
|
75
|
+
label?: string;
|
|
76
|
+
labelStyle: ElkEdgeLabelStyle;
|
|
77
|
+
}): ElkExtendedEdge;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Measure an edge label and build ELK's label box for it.
|
|
81
|
+
*
|
|
82
|
+
* The `+8` / `+6` are the horizontal/vertical breathing room all three
|
|
83
|
+
* builders have always added around the measured text so ELK reserves a
|
|
84
|
+
* slightly larger channel than the glyphs strictly need.
|
|
85
|
+
*/
|
|
86
|
+
export declare function buildElkEdgeLabel(text: string, style: ElkEdgeLabelStyle): ElkLabel;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Build a leaf ELK node.
|
|
90
|
+
*
|
|
91
|
+
* `label` is attached as an ELK label when supplied — the flowchart/state
|
|
92
|
+
* path does that (ELK reads it for nothing, but `from-elk.ts` reads it
|
|
93
|
+
* back); class and ER carry labels in their own side tables instead and
|
|
94
|
+
* omit it. An empty-string label is still a label, so the check is
|
|
95
|
+
* `undefined`, not truthiness.
|
|
96
|
+
*/
|
|
97
|
+
export declare function buildElkLeafNode(id: string, size: {
|
|
98
|
+
width: number;
|
|
99
|
+
height: number;
|
|
100
|
+
}, label?: string): ElkNode;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* SVG `<style>` block for a diagram: core's `buildStyleBlock` plus, when
|
|
104
|
+
* `hasMonoFont` is set, the self-hosted mono font subset for the `.mono`
|
|
105
|
+
* rule. The subset lives here rather than in `core` because only SVG output
|
|
106
|
+
* embeds it (#1319).
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildSvgStyleBlock(font: string, hasMonoFont: boolean, nonce?: string): string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Indices into `diagram.relationships` of the edges dagre's depth-first walk
|
|
112
|
+
* reverses to break cycles; see `findBackEdges`.
|
|
113
|
+
*/
|
|
114
|
+
export declare function classBackEdges(diagram: ClassDiagram): Set<number>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Layout id for the i-th note. A class id is a run of non-whitespace
|
|
118
|
+
* (`\S+` in the parser), so an id containing a space can never collide
|
|
119
|
+
* with one; ELK treats ids as opaque strings.
|
|
120
|
+
*/
|
|
121
|
+
export declare function classNoteId(index: number): string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Clip an edge endpoint to the actual shape boundary of a node.
|
|
125
|
+
*
|
|
126
|
+
* @param points - The edge points array
|
|
127
|
+
* @param node - The node to clip to
|
|
128
|
+
* @param isStart - True if clipping the start point (source), false for end (target)
|
|
129
|
+
* @returns New points array with clipped endpoint
|
|
130
|
+
*/
|
|
131
|
+
export declare function clipEdgeToShape(points: Point[], node: PositionedNode, isStart: boolean): Point[];
|
|
132
|
+
|
|
133
|
+
/** Layout constants for class diagrams */
|
|
134
|
+
export declare const CLS: {
|
|
135
|
+
readonly padding: 40;
|
|
136
|
+
readonly boxPadX: 8;
|
|
137
|
+
readonly headerBaseHeight: 32;
|
|
138
|
+
readonly annotationHeight: 16;
|
|
139
|
+
readonly memberRowHeight: 20;
|
|
140
|
+
readonly sectionPadY: 8;
|
|
141
|
+
readonly emptySectionHeight: 8;
|
|
142
|
+
readonly minWidth: 120;
|
|
143
|
+
readonly memberFontSize: 11;
|
|
144
|
+
readonly memberFontWeight: 400;
|
|
145
|
+
readonly nodeSpacing: 40;
|
|
146
|
+
readonly layerSpacing: 60;
|
|
147
|
+
/** Horizontal / vertical padding inside a note box, around its text */
|
|
148
|
+
readonly notePadX: 10;
|
|
149
|
+
readonly notePadY: 6;
|
|
150
|
+
/** Space reserved above a namespace's classes for its title */
|
|
151
|
+
readonly namespaceTitleHeight: 28;
|
|
152
|
+
/** Padding between a namespace frame and its classes (other three sides) */
|
|
153
|
+
readonly namespacePad: 16;
|
|
154
|
+
readonly namespaceTitleFontSize: 12;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Convert MermaidGraph to ELK format (for benchmarking conversion overhead).
|
|
159
|
+
*/
|
|
160
|
+
export declare function convertToElkFormat(graph: MermaidGraph, options?: FlowchartRenderOptions): ElkNode;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Create a new opt-in layout cache with a bounded size (default 20
|
|
164
|
+
* entries). Once full, the least-recently-used entry is evicted to make
|
|
165
|
+
* room for a new one.
|
|
166
|
+
*
|
|
167
|
+
* Pass the result to `elkLayoutSync()` directly, or via
|
|
168
|
+
* `RenderOptions.layoutCache` (threaded through by `layoutGraphSync()`,
|
|
169
|
+
* `layoutClassDiagramSync()`, and `layoutErDiagramSync()`) to memoize
|
|
170
|
+
* layout across repeated renders of the same diagram + options.
|
|
171
|
+
*/
|
|
172
|
+
export declare function createLayoutCache(maxSize?: number): LayoutCache;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Convert a Mermaid `direction` to ELK's `elk.direction` value.
|
|
176
|
+
*
|
|
177
|
+
* `fallback` covers the no-`direction`-statement case only — every member
|
|
178
|
+
* of `Direction` has an explicit mapping. Pass the diagram type's entry
|
|
179
|
+
* from `ELK_DIRECTION_FALLBACK` rather than a bare string literal, so the
|
|
180
|
+
* per-type defaults stay documented in one place.
|
|
181
|
+
*/
|
|
182
|
+
export declare function directionToElk(dir: Direction | undefined, fallback: ElkDirection): ElkDirection;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The `elk.direction` each diagram type falls back to when its source
|
|
186
|
+
* carries no `direction` statement.
|
|
187
|
+
*
|
|
188
|
+
* These genuinely differ per diagram type, and the difference is
|
|
189
|
+
* intentional rather than an accident of three separate implementations:
|
|
190
|
+
*
|
|
191
|
+
* - **flowchart / state** — `DOWN`. `MermaidGraph.direction` is a required
|
|
192
|
+
* field the parser always fills in (defaulting to `TD`), so the fallback
|
|
193
|
+
* is only a type-level backstop; the effective default is mermaid's own
|
|
194
|
+
* top-down flowchart default.
|
|
195
|
+
* - **class** — `DOWN`. `ClassDiagram` has no direction concept at all (see
|
|
196
|
+
* `ClassRenderOptions` in `packages/core/src/types.ts`: class diagrams
|
|
197
|
+
* "have no `direction` or `curve` concept"), so this is the renderer's
|
|
198
|
+
* single fixed orientation, matching Mermaid's own TB class rendering —
|
|
199
|
+
* which `../class/layout.ts` relies on to put a `note for X` above its
|
|
200
|
+
* class.
|
|
201
|
+
* - **C4** — `DOWN`. `C4Diagram.direction` is never set by the parser (C4
|
|
202
|
+
* sources have no direction statement), only by `RenderOptions.direction`,
|
|
203
|
+
* so an unset one is the top-down layout every C4 diagram is drawn in.
|
|
204
|
+
* - **ER** — `DOWN`. An ER diagram's `direction` is optional
|
|
205
|
+
* (`ErDiagram.direction?`), left `undefined` when the source has no
|
|
206
|
+
* `direction` statement, and official Mermaid lays those out top-to-bottom
|
|
207
|
+
* (#1250; this renderer used to lay them out left-to-right).
|
|
208
|
+
* `direction TB`/`LR`/`BT`/`RL` in the source (or
|
|
209
|
+
* `RenderOptions.direction`, applied via `withDirectionOverride`) still
|
|
210
|
+
* wins over it.
|
|
211
|
+
*
|
|
212
|
+
* The *mappings* were never in conflict — both hand-rolled
|
|
213
|
+
* `directionToElk()` implementations agreed on all five `Direction` values
|
|
214
|
+
* (`LR`→`RIGHT`, `RL`→`LEFT`, `BT`→`UP`, `TD`/`TB`→`DOWN`). Only the
|
|
215
|
+
* no-direction fallback differed, which is why it is a parameter here
|
|
216
|
+
* rather than something to reconcile away.
|
|
217
|
+
*/
|
|
218
|
+
export declare const ELK_DIRECTION_FALLBACK: {
|
|
219
|
+
readonly flowchart: "DOWN";
|
|
220
|
+
readonly state: "DOWN";
|
|
221
|
+
readonly class: "DOWN";
|
|
222
|
+
readonly er: "DOWN";
|
|
223
|
+
readonly c4: "DOWN";
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/** The four values ELK's `elk.direction` option accepts in this codebase. */
|
|
227
|
+
export declare type ElkDirection = 'DOWN' | 'UP' | 'LEFT' | 'RIGHT';
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* How a caller wants its edge labels measured and placed. `fontSize` is
|
|
231
|
+
* the resolved `fontSizes.edgeLabel`; `layoutOptions`, when given, is
|
|
232
|
+
* attached to the ELK label itself.
|
|
233
|
+
*/
|
|
234
|
+
export declare interface ElkEdgeLabelStyle {
|
|
235
|
+
fontSize: number;
|
|
236
|
+
layoutOptions?: LayoutOptions;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Run ELK layout synchronously.
|
|
241
|
+
*
|
|
242
|
+
* Bypasses BOTH of ELK's setTimeout(0) wrappers:
|
|
243
|
+
* - FakeWorker.postMessage wraps dispatch in setTimeout(0) — bypassed by
|
|
244
|
+
* calling dispatcher.saveDispatch() directly
|
|
245
|
+
* - PromisedWorker.onmessage wraps receive in setTimeout(0) — bypassed by
|
|
246
|
+
* replacing rawWorker.onmessage with a direct interceptor
|
|
247
|
+
*
|
|
248
|
+
* @param cache - Optional opt-in layout cache (see `createLayoutCache()`).
|
|
249
|
+
* When provided, a cache hit returns the previous result without running
|
|
250
|
+
* ELK layout again. Omitted/undefined preserves the original
|
|
251
|
+
* always-recompute behavior exactly.
|
|
252
|
+
*/
|
|
253
|
+
export declare function elkLayoutSync(graph: ElkNode, cache?: LayoutCache): ElkNode;
|
|
254
|
+
|
|
255
|
+
/** Thrown when a graph diagram renders and no `elkjs` constructor is available. */
|
|
256
|
+
export declare class ElkNotRegisteredError extends Error {
|
|
257
|
+
constructor();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Format ELK's `elk.padding` value. A single number applies to all four
|
|
262
|
+
* sides; an object sets them individually.
|
|
263
|
+
*/
|
|
264
|
+
export declare function elkPadding(padding: number | ElkPaddingSides): string;
|
|
265
|
+
|
|
266
|
+
/** Per-side padding, for the asymmetric case (a subgraph's header gap). */
|
|
267
|
+
export declare interface ElkPaddingSides {
|
|
268
|
+
top: number;
|
|
269
|
+
left: number;
|
|
270
|
+
bottom: number;
|
|
271
|
+
right: number;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Average character width in px for monospace fonts (uniform glyph width) */
|
|
275
|
+
export declare function estimateMonoTextWidth(text: string, fontSize: number): number;
|
|
276
|
+
|
|
277
|
+
/** Average character width in px at the given font size and weight (proportional font) */
|
|
278
|
+
export declare function estimateTextWidth(text: string, fontSize: number, fontWeight: number): number;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Evaluate one CSS value against a flat set of custom-property
|
|
282
|
+
* declarations — the expression engine behind `resolveCssColors`, exposed
|
|
283
|
+
* so it can be unit-tested (and reused) without building an SVG around it.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* evaluateCssColorValue('color-mix(in srgb, var(--fg) 50%, var(--bg))',
|
|
287
|
+
* { '--fg': '#000000', '--bg': '#ffffff' }) // → '#808080'
|
|
288
|
+
*/
|
|
289
|
+
export declare function evaluateCssColorValue(value: string, declarations: Record<string, string>): string;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Compute an edge label's center position from ELK's placed label box
|
|
293
|
+
* (`label.x/y` is the box's top-left corner).
|
|
294
|
+
*
|
|
295
|
+
* `offsetX`/`offsetY` translate into an ancestor's coordinate space, same
|
|
296
|
+
* as `extractEdgePoints`.
|
|
297
|
+
*
|
|
298
|
+
* Returns `undefined` if ELK didn't place a label (no label on the edge,
|
|
299
|
+
* or ELK left `x`/`y` unset).
|
|
300
|
+
*/
|
|
301
|
+
export declare function extractEdgeLabelPosition(elkEdge: ElkExtendedEdge, offsetX?: number, offsetY?: number): Point | undefined;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Walk an ELK edge's first routed section into a flat point path:
|
|
305
|
+
* `startPoint → bendPoints → endPoint`.
|
|
306
|
+
*
|
|
307
|
+
* ELK can theoretically produce multiple sections per edge (for edges
|
|
308
|
+
* split across hierarchy boundaries via ports), but all three call sites
|
|
309
|
+
* only ever read `sections[0]` — hierarchical decomposition in this
|
|
310
|
+
* codebase is handled by emitting separate ELK edges (see
|
|
311
|
+
* `to-elk.ts`/`parseHopEdgeId` in `from-elk.ts`), not multi-section edges.
|
|
312
|
+
*
|
|
313
|
+
* `offsetX`/`offsetY` translate the section's coordinates into an
|
|
314
|
+
* ancestor's coordinate space, for callers walking a nested ELK result
|
|
315
|
+
* (`from-elk.ts`). Callers with a flat (non-hierarchical) ELK graph
|
|
316
|
+
* (`class/layout.ts`, `er/layout.ts`) can omit them.
|
|
317
|
+
*
|
|
318
|
+
* Returns an empty array if the edge has no routed sections.
|
|
319
|
+
*/
|
|
320
|
+
export declare function extractEdgePoints(elkEdge: ElkExtendedEdge, offsetX?: number, offsetY?: number): Point[];
|
|
321
|
+
|
|
322
|
+
/** Default font sizes used in the renderer (in px). Overridable via `RenderOptions.fontSizes`. */
|
|
323
|
+
export declare const FONT_SIZES: {
|
|
324
|
+
/** Node label text */
|
|
325
|
+
readonly nodeLabel: 13;
|
|
326
|
+
/** Edge label text */
|
|
327
|
+
readonly edgeLabel: 11;
|
|
328
|
+
/** Subgraph header text */
|
|
329
|
+
readonly groupHeader: 12;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/** Font weights used per element type */
|
|
333
|
+
export declare const FONT_WEIGHTS: {
|
|
334
|
+
readonly nodeLabel: 500;
|
|
335
|
+
readonly edgeLabel: 400;
|
|
336
|
+
readonly groupHeader: 600;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
/** Partial font-size overrides, as accepted by `RenderOptions.fontSizes`. */
|
|
340
|
+
export declare type FontSizeOptions = Partial<FontSizes>;
|
|
341
|
+
|
|
342
|
+
/** Resolved font-size set — same shape as {@link FONT_SIZES} but mutable numbers. */
|
|
343
|
+
export declare type FontSizes = {
|
|
344
|
+
[K in keyof typeof FONT_SIZES]: number;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Format a set of evenly-spaced tick values with enough decimal places to
|
|
349
|
+
* keep every label distinct. Precision comes from the tick step, not the
|
|
350
|
+
* magnitude of the value: a 0.5 step around 100 needs one decimal, or
|
|
351
|
+
* 99.5 and 100.5 both collapse into neighbouring whole numbers.
|
|
352
|
+
*/
|
|
353
|
+
export declare function formatTickLabels(ticks: number[]): string[];
|
|
354
|
+
|
|
355
|
+
/** Vertical gap between a subgraph header band and the content area below it (px).
|
|
356
|
+
* Without this, nested subgraph headers sit flush against their parent's header band.
|
|
357
|
+
* Increased from 8 to 12 to provide more clearance for edges routing near headers. */
|
|
358
|
+
export declare const GROUP_HEADER_CONTENT_PAD = 12;
|
|
359
|
+
|
|
360
|
+
/** True when the label sits below the icon (stick-figure or typed icon). */
|
|
361
|
+
export declare function hasLabelBelowIcon(a: {
|
|
362
|
+
type: 'participant' | 'actor';
|
|
363
|
+
participantType?: string | undefined;
|
|
364
|
+
}): boolean;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Per-label layout options the flowchart/state path sets on every edge
|
|
368
|
+
* label. Class and ER instead set `elk.edgeLabels.placement` once on the
|
|
369
|
+
* root graph, so they pass no per-label options.
|
|
370
|
+
*/
|
|
371
|
+
export declare const INLINE_CENTERED_EDGE_LABEL: LayoutOptions;
|
|
372
|
+
|
|
373
|
+
export { LayoutCache }
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Lay out a parsed class diagram using ELK.js (synchronous).
|
|
377
|
+
*/
|
|
378
|
+
export declare function layoutClassDiagramSync(diagram: ClassDiagram, options?: ClassRenderOptions): PositionedClassDiagram;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Lay out a parsed ER diagram using ELK.js (synchronous).
|
|
382
|
+
*/
|
|
383
|
+
export declare function layoutErDiagramSync(diagram: ErDiagram, options?: ErRenderOptions): PositionedErDiagram;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Lay out a flowchart, with its subgraphs arranged the way mermaid.js arranges
|
|
387
|
+
* them (see `layout-engine/compound-flat.ts`). Anything that layout doesn't
|
|
388
|
+
* handle, or can't make fit, is laid out by `layoutGraphSync`, so this is a
|
|
389
|
+
* drop-in for it wherever the graph is a flowchart. Other diagram types that
|
|
390
|
+
* share the engine (state, architecture) keep using `layoutGraphSync`.
|
|
391
|
+
*/
|
|
392
|
+
export declare function layoutFlowchartSync(rawGraph: MermaidGraph, options?: FlowchartRenderOptions): PositionedGraph;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Lay out a parsed MermaidGraph using ELK.js (synchronous).
|
|
396
|
+
* Returns a fully positioned graph ready for rendering.
|
|
397
|
+
*/
|
|
398
|
+
export declare function layoutGraphSync(graph: MermaidGraph, options?: FlowchartRenderOptions): PositionedGraph;
|
|
399
|
+
|
|
400
|
+
/** Lay out a parsed pie chart. Options are accepted for registry parity; none apply. */
|
|
401
|
+
export declare function layoutPieChart(chart: PieChart, _options?: unknown): PositionedPieChart;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Lay out a parsed sequence diagram.
|
|
405
|
+
* Returns a fully positioned diagram ready for SVG rendering.
|
|
406
|
+
*/
|
|
407
|
+
export declare function layoutSequenceDiagram(diagram: SequenceDiagram, options?: SequenceRenderOptions): PositionedSequenceDiagram;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Lay out a parsed XY chart by computing pixel coordinates.
|
|
411
|
+
*/
|
|
412
|
+
export declare function layoutXYChart(chart: XYChart, _options?: XyChartRenderOptions): PositionedXYChart;
|
|
413
|
+
|
|
414
|
+
/** Monospace font family used for code-like text (class members, types) */
|
|
415
|
+
export declare const MONO_FONT: "'JetBrains Mono'";
|
|
416
|
+
|
|
417
|
+
/** Full CSS fallback chain for monospace text */
|
|
418
|
+
export declare const MONO_FONT_STACK: "'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace";
|
|
419
|
+
|
|
420
|
+
export { niceTickValues }
|
|
421
|
+
|
|
422
|
+
/** Padding inside node shapes */
|
|
423
|
+
export declare const NODE_PADDING: {
|
|
424
|
+
/** Horizontal padding inside rectangles/rounded/stadium (increased from 16 for better label fit) */
|
|
425
|
+
readonly horizontal: 20;
|
|
426
|
+
/** Vertical padding inside rectangles/rounded/stadium */
|
|
427
|
+
readonly vertical: 10;
|
|
428
|
+
/** Extra padding for diamond shapes (they need more space due to rotation) */
|
|
429
|
+
readonly diamondExtra: 24;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
/** Mermaid pieRenderer.ts constants (default config and default theme). */
|
|
433
|
+
export declare const PIE: {
|
|
434
|
+
/** Frame height; the pie's own width equals it. */
|
|
435
|
+
readonly height: 450;
|
|
436
|
+
readonly margin: 40;
|
|
437
|
+
readonly legendRectSize: 18;
|
|
438
|
+
readonly legendSpacing: 4;
|
|
439
|
+
/** `pie.textPosition` default: label distance as a fraction of the radius. */
|
|
440
|
+
readonly textPosition: 0.75;
|
|
441
|
+
/** `pieOuterStrokeWidth`; the outline circle sits half of it outside the pie. */
|
|
442
|
+
readonly outerStrokeWidth: 2;
|
|
443
|
+
/** `pieTitleTextSize` */
|
|
444
|
+
readonly titleFontSize: 25;
|
|
445
|
+
/** `pieSectionTextSize` */
|
|
446
|
+
readonly sectionFontSize: 17;
|
|
447
|
+
/** `pieLegendTextSize` */
|
|
448
|
+
readonly legendFontSize: 17;
|
|
449
|
+
readonly fontWeight: 400;
|
|
450
|
+
/** Mermaid's `pie1`..`pie12` scale wraps after this many colours. */
|
|
451
|
+
readonly paletteSize: 12;
|
|
452
|
+
/** `.highlighted { scale: 1.05 }` in Mermaid's pieStyles.ts. */
|
|
453
|
+
readonly highlightScale: 1.05;
|
|
454
|
+
/** Slices below this percentage of the total are not drawn. */
|
|
455
|
+
readonly minPercent: 1;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
/** CSS value for palette slot `index`: slot 0 follows `--accent` live. */
|
|
459
|
+
export declare function pieColorValue(index: number, accent: string | undefined, bg: string): string;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Build the `d` attribute for an edge's routed points under `curve`.
|
|
463
|
+
*
|
|
464
|
+
* A path with fewer than two points cannot be drawn; the caller already skips
|
|
465
|
+
* those, but this degrades to an empty string rather than emitting `M`
|
|
466
|
+
* followed by nothing.
|
|
467
|
+
*/
|
|
468
|
+
export declare function pointsToPath(points: Point[], curve?: CurveStyle): string;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Register the `elkjs` constructor used for flowchart, state, class, ER and
|
|
472
|
+
* architecture layout. Call once before rendering, in browsers and bundlers:
|
|
473
|
+
*
|
|
474
|
+
* import ELK from 'elkjs/lib/elk.bundled.js'
|
|
475
|
+
* registerElk(ELK)
|
|
476
|
+
*
|
|
477
|
+
* Under Node (and Bun) this is optional when `elkjs` is installed: it is
|
|
478
|
+
* auto-loaded on first use. Calling it again swaps the constructor and drops
|
|
479
|
+
* the cached instance.
|
|
480
|
+
*/
|
|
481
|
+
export declare function registerElk(ctor: ElkConstructor): void;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Render a positioned class diagram as an SVG string.
|
|
485
|
+
*
|
|
486
|
+
* @param colors - DiagramColors with bg/fg and optional enrichment variables.
|
|
487
|
+
* @param transparent - If true, renders with transparent background.
|
|
488
|
+
* @param embedSource - Original diagram source to stamp onto the root `<svg>`
|
|
489
|
+
* as `data-src` (from `options.embedSource`). Omitted
|
|
490
|
+
* when the option is off.
|
|
491
|
+
* @param title - Accessible name (from `options.title`). See svgOpenTag() in
|
|
492
|
+
* packages/core/src/theme.ts.
|
|
493
|
+
* @param decorative - Marks the SVG decorative (from `options.decorative`).
|
|
494
|
+
* @param linksEnabled - Whether `click`-based `<a href>` links and `<title>`
|
|
495
|
+
* tooltips render (from `options.interactivity !==
|
|
496
|
+
* 'none'`, see `resolveLinksEnabled` in
|
|
497
|
+
* src/diagram-registry.ts).
|
|
498
|
+
* Default true — matches the flowchart/state renderer.
|
|
499
|
+
* @param emit - Strict-CSP controls (from `options.nonce` /
|
|
500
|
+
* `options.styleAttribute`, see #216). Default: no nonce,
|
|
501
|
+
* root `style` attribute on.
|
|
502
|
+
*/
|
|
503
|
+
export declare function renderClassSvg(diagram: PositionedClassDiagram, colors: DiagramColors, font?: string, transparent?: boolean, fontSizes?: FontSizes, embedSource?: string, title?: string, decorative?: boolean, linksEnabled?: boolean, emit?: SvgEmitOptions): string;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Render a positioned ER diagram as an SVG string.
|
|
507
|
+
*
|
|
508
|
+
* @param colors - DiagramColors with bg/fg and optional enrichment variables.
|
|
509
|
+
* @param transparent - If true, renders with transparent background.
|
|
510
|
+
* @param embedSource - Original diagram source to stamp onto the root `<svg>`
|
|
511
|
+
* as `data-src` (from `options.embedSource`). Omitted
|
|
512
|
+
* when the option is off.
|
|
513
|
+
* @param title - Accessible name (from `options.title`). See svgOpenTag() in
|
|
514
|
+
* packages/core/src/theme.ts.
|
|
515
|
+
* @param decorative - Marks the SVG decorative (from `options.decorative`).
|
|
516
|
+
* @param emit - Strict-CSP controls (from `options.nonce` /
|
|
517
|
+
* `options.styleAttribute`, see #216). Default: no nonce,
|
|
518
|
+
* root `style` attribute on.
|
|
519
|
+
*/
|
|
520
|
+
export declare function renderErSvg(diagram: PositionedErDiagram, colors: DiagramColors, font?: string, transparent?: boolean, fontSizes?: FontSizes, embedSource?: string, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
521
|
+
|
|
522
|
+
/** @deprecated Use `renderMermaidSVGAsync` */
|
|
523
|
+
export declare const renderMermaid: typeof renderMermaidSVGAsync;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Render Mermaid diagram text to an SVG string — synchronously.
|
|
527
|
+
*
|
|
528
|
+
* Uses elk.bundled.js with a direct FakeWorker bypass (no setTimeout(0) delay).
|
|
529
|
+
* The ELK singleton is created lazily on first use and cached forever.
|
|
530
|
+
*
|
|
531
|
+
* Use this in React components with useMemo() to avoid flash:
|
|
532
|
+
* const svg = useMemo(() => renderMermaidSVG(code, opts), [code])
|
|
533
|
+
*
|
|
534
|
+
* @param text - Mermaid source text
|
|
535
|
+
* @param options - Rendering options (colors, font, spacing)
|
|
536
|
+
* @returns A self-contained SVG string
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* ```ts
|
|
540
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B')
|
|
541
|
+
*
|
|
542
|
+
* // With theme
|
|
543
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B', {
|
|
544
|
+
* bg: '#1a1b26', fg: '#a9b1d6'
|
|
545
|
+
* })
|
|
546
|
+
*
|
|
547
|
+
* // With CSS variables (for live theme switching)
|
|
548
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B', {
|
|
549
|
+
* bg: 'var(--background)', fg: 'var(--foreground)', transparent: true
|
|
550
|
+
* })
|
|
551
|
+
*
|
|
552
|
+
* // With the original source stamped onto the root <svg> as data-src —
|
|
553
|
+
* // handy for a "copy source" button or an "open in Mermaid Live" link
|
|
554
|
+
* // without re-attaching it via string surgery on the output.
|
|
555
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B', { embedSource: true })
|
|
556
|
+
*
|
|
557
|
+
* // With an accessible name — role="img" + aria-labelledby pointing at a
|
|
558
|
+
* // <title> child, so assistive tech announces the diagram instead of
|
|
559
|
+
* // reading every node label individually (see issue #215).
|
|
560
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B', {
|
|
561
|
+
* title: 'Flowchart: Build → Test → Ship'
|
|
562
|
+
* })
|
|
563
|
+
*
|
|
564
|
+
* // Decorative diagram — already described in surrounding prose, so it's
|
|
565
|
+
* // hidden from assistive tech (aria-hidden="true") instead of named.
|
|
566
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B', { decorative: true })
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
export declare function renderMermaidSVG(text: string, options?: RenderOptions): string;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Render Mermaid diagram text to an SVG string — async.
|
|
573
|
+
*
|
|
574
|
+
* Same result as renderMermaidSVG() but returns a Promise.
|
|
575
|
+
* Useful in async contexts (server handlers, data loaders, etc.)
|
|
576
|
+
*/
|
|
577
|
+
export declare function renderMermaidSVGAsync(text: string, options?: RenderOptions): Promise<string>;
|
|
578
|
+
|
|
579
|
+
/** @deprecated Use `renderMermaidSVG` */
|
|
580
|
+
export declare const renderMermaidSync: typeof renderMermaidSVG;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Render a positioned pie chart as an SVG string.
|
|
584
|
+
*
|
|
585
|
+
* The accessible name is `title` (from `options.title`) when given,
|
|
586
|
+
* otherwise the chart's own `accTitle`; `accDescr` becomes the root
|
|
587
|
+
* `<desc>`. Both are dropped when `decorative` is set — see svgOpenTag() in
|
|
588
|
+
* packages/core/src/theme.ts.
|
|
589
|
+
*/
|
|
590
|
+
export declare function renderPieSvg(chart: PositionedPieChart, colors: DiagramColors, font?: string, transparent?: boolean, embedSource?: string, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Render a positioned sequence diagram as an SVG string.
|
|
594
|
+
*
|
|
595
|
+
* @param colors - DiagramColors with bg/fg and optional enrichment variables.
|
|
596
|
+
* @param transparent - If true, renders with transparent background.
|
|
597
|
+
* @param embedSource - Original diagram source to stamp onto the root `<svg>`
|
|
598
|
+
* as `data-src` (from `options.embedSource`). Omitted
|
|
599
|
+
* when the option is off.
|
|
600
|
+
* @param title - Accessible name (from `options.title`). See svgOpenTag() in
|
|
601
|
+
* packages/core/src/theme.ts.
|
|
602
|
+
* @param decorative - Marks the SVG decorative (from `options.decorative`).
|
|
603
|
+
* @param emit - Strict-CSP controls (from `options.nonce` /
|
|
604
|
+
* `options.styleAttribute`, see #216). Default: no nonce,
|
|
605
|
+
* root `style` attribute on.
|
|
606
|
+
*/
|
|
607
|
+
export declare function renderSequenceSvg(diagram: PositionedSequenceDiagram, colors: DiagramColors, font?: string, transparent?: boolean, fontSizes?: FontSizes, embedSource?: string, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Render a positioned graph as an SVG string.
|
|
611
|
+
*
|
|
612
|
+
* @param colors - DiagramColors with bg/fg and optional enrichment variables.
|
|
613
|
+
* These are set as CSS custom properties on the <svg> tag.
|
|
614
|
+
* All element colors reference derived --_xxx variables.
|
|
615
|
+
* @param transparent - If true, renders with transparent background.
|
|
616
|
+
* @param embedSource - Original diagram source to stamp onto the root `<svg>`
|
|
617
|
+
* as `data-src` (from `options.embedSource`). Omitted
|
|
618
|
+
* when the option is off.
|
|
619
|
+
* @param animationEnabled - Whether `e1@{ animate: true }` edges actually
|
|
620
|
+
* animate (from `options.interactivity === 'full'`,
|
|
621
|
+
* see `resolveAnimationEnabled` in
|
|
622
|
+
* src/diagram-registry.ts).
|
|
623
|
+
* Default true — preserves the previously-ungated
|
|
624
|
+
* behavior for callers who don't pass it.
|
|
625
|
+
* @param linksEnabled - Whether `click`-based `<a href>` links and `<title>`
|
|
626
|
+
* tooltips render (from
|
|
627
|
+
* `options.interactivity !== 'none'`, see
|
|
628
|
+
* `resolveLinksEnabled` in src/diagram-registry.ts). Default true
|
|
629
|
+
* — preserves the previously-ungated behavior for
|
|
630
|
+
* callers who don't pass it.
|
|
631
|
+
* @param title - Accessible name (from `options.title`). See svgOpenTag() in
|
|
632
|
+
* packages/core/src/theme.ts.
|
|
633
|
+
* @param decorative - Marks the SVG decorative (from `options.decorative`).
|
|
634
|
+
* @param emit - Strict-CSP controls (from `options.nonce` /
|
|
635
|
+
* `options.styleAttribute`, see #216): a `nonce` for every
|
|
636
|
+
* `<style>` element, and whether the root `style="…"`
|
|
637
|
+
* attribute is emitted at all. Default: no nonce, attribute on.
|
|
638
|
+
*/
|
|
639
|
+
export declare function renderSvg(graph: PositionedGraph, colors: DiagramColors, font?: string, transparent?: boolean, fontSizes?: FontSizes, curve?: CurveStyle, embedSource?: string, animationEnabled?: boolean, linksEnabled?: boolean, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Render a positioned XY chart as an SVG string.
|
|
643
|
+
*
|
|
644
|
+
* @param embedSource - Original diagram source to stamp onto the root
|
|
645
|
+
* `<svg>` as `data-src` (from `options.embedSource`).
|
|
646
|
+
* Omitted when the option is off.
|
|
647
|
+
* @param title - Accessible name (from `options.title`). See svgOpenTag() in
|
|
648
|
+
* packages/core/src/theme.ts.
|
|
649
|
+
* @param decorative - Marks the SVG decorative (from `options.decorative`).
|
|
650
|
+
* @param emit - Strict-CSP controls (from `options.nonce` /
|
|
651
|
+
* `options.styleAttribute`, see #216). Default: no nonce,
|
|
652
|
+
* root `style` attribute on.
|
|
653
|
+
*/
|
|
654
|
+
export declare function renderXYChartSvg(chart: PositionedXYChart, colors: DiagramColors, font?: string, transparent?: boolean, interactive?: boolean, embedSource?: string, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Replace every `var(--…)` and `color-mix(…)` in an SVG produced by this
|
|
658
|
+
* library's renderer with its computed sRGB value (`#rrggbb`, or
|
|
659
|
+
* `rgba(r, g, b, a)` when translucent).
|
|
660
|
+
*
|
|
661
|
+
* `colors` seeds the variable scope with the caller's palette; the SVG's
|
|
662
|
+
* own declarations (the root `style` attribute and any `<style>` block)
|
|
663
|
+
* are then read on top, so the derived `--_*` variables resolve through
|
|
664
|
+
* exactly the `color-mix()` rules `buildStyleBlock` emitted. See the
|
|
665
|
+
* module comment for what is and isn't rewritten.
|
|
666
|
+
*/
|
|
667
|
+
export declare function resolveCssColors(svg: string, colors: DiagramColors): string;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Merge user-provided font-size overrides over the {@link FONT_SIZES} defaults.
|
|
671
|
+
* Any field left unspecified (or `undefined`) falls back to its default.
|
|
672
|
+
*/
|
|
673
|
+
export declare function resolveFontSizes(overrides?: FontSizeOptions): FontSizes;
|
|
674
|
+
|
|
675
|
+
export declare function smoothCurvePath(points: Array<{
|
|
676
|
+
x: number;
|
|
677
|
+
y: number;
|
|
678
|
+
}>): string;
|
|
679
|
+
|
|
680
|
+
/** Stroke widths per element type (in px) */
|
|
681
|
+
export declare const STROKE_WIDTHS: {
|
|
682
|
+
readonly outerBox: 1;
|
|
683
|
+
readonly innerBox: 0.75;
|
|
684
|
+
/** Edge connector stroke (increased from 0.75 for better visibility) */
|
|
685
|
+
readonly connector: 1;
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Vertical shift applied to all text elements for font-agnostic centering.
|
|
690
|
+
*
|
|
691
|
+
* Instead of relying on `dominant-baseline="central"` (which each font interprets
|
|
692
|
+
* differently based on its own ascent/descent metrics), we use the default alphabetic
|
|
693
|
+
* baseline and shift down by 0.35em. This places the optical center of text at the
|
|
694
|
+
* y coordinate, regardless of font family (Inter, JetBrains Mono, system fallbacks).
|
|
695
|
+
*
|
|
696
|
+
* The 0.35em value approximates the distance from alphabetic baseline to visual
|
|
697
|
+
* center of Latin text. Using `em` units ensures it scales with font size.
|
|
698
|
+
*/
|
|
699
|
+
export declare const TEXT_BASELINE_SHIFT: "0.35em";
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* The exact CSS declaration list the root `<svg style="…">` attribute would
|
|
703
|
+
* carry for these options — `--bg`, `--fg`, whichever enrichment colours
|
|
704
|
+
* were given, and (unless `transparent`) `background: var(--bg)`.
|
|
705
|
+
*
|
|
706
|
+
* For hosts with a strict `Content-Security-Policy`: a `style=` attribute
|
|
707
|
+
* can't be nonced, so a `style-src` without `'unsafe-inline'` drops it and
|
|
708
|
+
* the diagram loses its colours. Render with `styleAttribute: false` and
|
|
709
|
+
* put this string in your own stylesheet on the SVG (or any ancestor —
|
|
710
|
+
* custom properties inherit) instead. Pass the same options object to both
|
|
711
|
+
* calls so the declarations match what the render expects. See
|
|
712
|
+
* `RenderOptions.styleAttribute` / `RenderOptions.nonce` and issue #216.
|
|
713
|
+
*
|
|
714
|
+
* Built by the same function that fills the attribute in normal renders,
|
|
715
|
+
* so there is one variable list to keep in sync. The string is compact
|
|
716
|
+
* (`--bg:#fff;--fg:#000;background:var(--bg)`) — valid inside any rule
|
|
717
|
+
* block — and the colour values are yours, unescaped, exactly as the
|
|
718
|
+
* attribute has always carried them.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```ts
|
|
722
|
+
* const opts = { bg: '#1a1b26', fg: '#a9b1d6', nonce, styleAttribute: false }
|
|
723
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B', opts)
|
|
724
|
+
* const css = `.diagram svg { ${themeCssVariables(opts)} }`
|
|
725
|
+
* ```
|
|
726
|
+
*/
|
|
727
|
+
export declare function themeCssVariables(options?: RenderOptions): string;
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Parse `text` with the same detection and parser the renderer would use, but
|
|
731
|
+
* lay out and draw nothing. Throws the parser's error (usually `Line N: ...`);
|
|
732
|
+
* returns normally when the source parses.
|
|
733
|
+
*/
|
|
734
|
+
export declare function validateMermaid(text: string): void;
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Splice a `data-src` attribute (the original diagram source, escaped) onto
|
|
738
|
+
* an already-built root `<svg ...>` opening tag, e.g. from
|
|
739
|
+
* `embedSource: true`. Applied to the string `svgOpenTag()` returns rather
|
|
740
|
+
* than the diagram source's own markup, so it always lands on the root
|
|
741
|
+
* element regardless of diagram type. No-op when `source` is undefined.
|
|
742
|
+
*/
|
|
743
|
+
export declare function withDataSrc(svgTag: string, source: string | undefined): string;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Step between shown x-axis labels: 1 when every pair of neighbouring labels
|
|
747
|
+
* keeps `X_LABEL_MIN_GAP` of clear space, otherwise the smallest n for which
|
|
748
|
+
* every pair of shown (every n-th) labels does. Checked pairwise on the real
|
|
749
|
+
* widths so one long label doesn't thin out an otherwise roomy axis.
|
|
750
|
+
*/
|
|
751
|
+
export declare function xLabelStep(labels: string[], bandWidth: number): number;
|
|
752
|
+
|
|
753
|
+
export { }
|