@zombie-mermaid/svg-renderer 4.1.0 → 4.2.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 +51 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +1071 -948
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/pie-layout.test.ts +215 -0
- package/src/__tests__/pie-svg.test.ts +194 -0
- package/src/index.ts +2 -0
- package/src/pie/layout.ts +234 -0
- package/src/pie/renderer.ts +161 -0
- package/src/registry.ts +30 -0
package/dist/index.d.cts
CHANGED
|
@@ -12,11 +12,13 @@ import { FlowchartRenderOptions } from '@zombie-mermaid/core';
|
|
|
12
12
|
import { LayoutCache } from '@zombie-mermaid/core';
|
|
13
13
|
import { LayoutOptions } from 'elkjs';
|
|
14
14
|
import { MermaidGraph } from '@zombie-mermaid/core';
|
|
15
|
+
import { PieChart } from '@zombie-mermaid/mermaid-parser';
|
|
15
16
|
import { Point } from '@zombie-mermaid/core';
|
|
16
17
|
import { PositionedClassDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
17
18
|
import { PositionedErDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
18
19
|
import { PositionedGraph } from '@zombie-mermaid/core';
|
|
19
20
|
import { PositionedNode } from '@zombie-mermaid/core';
|
|
21
|
+
import { PositionedPieChart } from '@zombie-mermaid/mermaid-parser';
|
|
20
22
|
import { PositionedSequenceDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
21
23
|
import { PositionedXYChart } from '@zombie-mermaid/mermaid-parser';
|
|
22
24
|
import { RenderOptions } from '@zombie-mermaid/core';
|
|
@@ -376,6 +378,9 @@ export declare function layoutFlowchartSync(rawGraph: MermaidGraph, options?: Fl
|
|
|
376
378
|
*/
|
|
377
379
|
export declare function layoutGraphSync(graph: MermaidGraph, options?: FlowchartRenderOptions): PositionedGraph;
|
|
378
380
|
|
|
381
|
+
/** Lay out a parsed pie chart. Options are accepted for registry parity; none apply. */
|
|
382
|
+
export declare function layoutPieChart(chart: PieChart, _options?: unknown): PositionedPieChart;
|
|
383
|
+
|
|
379
384
|
/**
|
|
380
385
|
* Lay out a parsed sequence diagram.
|
|
381
386
|
* Returns a fully positioned diagram ready for SVG rendering.
|
|
@@ -406,6 +411,33 @@ export declare const NODE_PADDING: {
|
|
|
406
411
|
readonly diamondExtra: 24;
|
|
407
412
|
};
|
|
408
413
|
|
|
414
|
+
/** Mermaid pieRenderer.ts constants (default config and default theme). */
|
|
415
|
+
export declare const PIE: {
|
|
416
|
+
/** Frame height; the pie's own width equals it. */
|
|
417
|
+
readonly height: 450;
|
|
418
|
+
readonly margin: 40;
|
|
419
|
+
readonly legendRectSize: 18;
|
|
420
|
+
readonly legendSpacing: 4;
|
|
421
|
+
/** `pie.textPosition` default: label distance as a fraction of the radius. */
|
|
422
|
+
readonly textPosition: 0.75;
|
|
423
|
+
/** `pieOuterStrokeWidth`; the outline circle sits half of it outside the pie. */
|
|
424
|
+
readonly outerStrokeWidth: 2;
|
|
425
|
+
/** `pieTitleTextSize` */
|
|
426
|
+
readonly titleFontSize: 25;
|
|
427
|
+
/** `pieSectionTextSize` */
|
|
428
|
+
readonly sectionFontSize: 17;
|
|
429
|
+
/** `pieLegendTextSize` */
|
|
430
|
+
readonly legendFontSize: 17;
|
|
431
|
+
readonly fontWeight: 400;
|
|
432
|
+
/** Mermaid's `pie1`..`pie12` scale wraps after this many colours. */
|
|
433
|
+
readonly paletteSize: 12;
|
|
434
|
+
/** Slices below this percentage of the total are not drawn. */
|
|
435
|
+
readonly minPercent: 1;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
/** CSS value for palette slot `index`: slot 0 follows `--accent` live. */
|
|
439
|
+
export declare function pieColorValue(index: number, accent: string | undefined, bg: string): string;
|
|
440
|
+
|
|
409
441
|
/**
|
|
410
442
|
* Build the `d` attribute for an edge's routed points under `curve`.
|
|
411
443
|
*
|
|
@@ -514,6 +546,16 @@ export declare function renderMermaidSVGAsync(text: string, options?: RenderOpti
|
|
|
514
546
|
/** @deprecated Use `renderMermaidSVG` */
|
|
515
547
|
export declare const renderMermaidSync: typeof renderMermaidSVG;
|
|
516
548
|
|
|
549
|
+
/**
|
|
550
|
+
* Render a positioned pie chart as an SVG string.
|
|
551
|
+
*
|
|
552
|
+
* The accessible name is `title` (from `options.title`) when given,
|
|
553
|
+
* otherwise the chart's own `accTitle`; `accDescr` becomes the root
|
|
554
|
+
* `<desc>`. Both are dropped when `decorative` is set — see svgOpenTag() in
|
|
555
|
+
* packages/core/src/theme.ts.
|
|
556
|
+
*/
|
|
557
|
+
export declare function renderPieSvg(chart: PositionedPieChart, colors: DiagramColors, font?: string, transparent?: boolean, embedSource?: string, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
558
|
+
|
|
517
559
|
/**
|
|
518
560
|
* Render a positioned sequence diagram as an SVG string.
|
|
519
561
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -12,11 +12,13 @@ import { FlowchartRenderOptions } from '@zombie-mermaid/core';
|
|
|
12
12
|
import { LayoutCache } from '@zombie-mermaid/core';
|
|
13
13
|
import { LayoutOptions } from 'elkjs';
|
|
14
14
|
import { MermaidGraph } from '@zombie-mermaid/core';
|
|
15
|
+
import { PieChart } from '@zombie-mermaid/mermaid-parser';
|
|
15
16
|
import { Point } from '@zombie-mermaid/core';
|
|
16
17
|
import { PositionedClassDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
17
18
|
import { PositionedErDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
18
19
|
import { PositionedGraph } from '@zombie-mermaid/core';
|
|
19
20
|
import { PositionedNode } from '@zombie-mermaid/core';
|
|
21
|
+
import { PositionedPieChart } from '@zombie-mermaid/mermaid-parser';
|
|
20
22
|
import { PositionedSequenceDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
21
23
|
import { PositionedXYChart } from '@zombie-mermaid/mermaid-parser';
|
|
22
24
|
import { RenderOptions } from '@zombie-mermaid/core';
|
|
@@ -376,6 +378,9 @@ export declare function layoutFlowchartSync(rawGraph: MermaidGraph, options?: Fl
|
|
|
376
378
|
*/
|
|
377
379
|
export declare function layoutGraphSync(graph: MermaidGraph, options?: FlowchartRenderOptions): PositionedGraph;
|
|
378
380
|
|
|
381
|
+
/** Lay out a parsed pie chart. Options are accepted for registry parity; none apply. */
|
|
382
|
+
export declare function layoutPieChart(chart: PieChart, _options?: unknown): PositionedPieChart;
|
|
383
|
+
|
|
379
384
|
/**
|
|
380
385
|
* Lay out a parsed sequence diagram.
|
|
381
386
|
* Returns a fully positioned diagram ready for SVG rendering.
|
|
@@ -406,6 +411,33 @@ export declare const NODE_PADDING: {
|
|
|
406
411
|
readonly diamondExtra: 24;
|
|
407
412
|
};
|
|
408
413
|
|
|
414
|
+
/** Mermaid pieRenderer.ts constants (default config and default theme). */
|
|
415
|
+
export declare const PIE: {
|
|
416
|
+
/** Frame height; the pie's own width equals it. */
|
|
417
|
+
readonly height: 450;
|
|
418
|
+
readonly margin: 40;
|
|
419
|
+
readonly legendRectSize: 18;
|
|
420
|
+
readonly legendSpacing: 4;
|
|
421
|
+
/** `pie.textPosition` default: label distance as a fraction of the radius. */
|
|
422
|
+
readonly textPosition: 0.75;
|
|
423
|
+
/** `pieOuterStrokeWidth`; the outline circle sits half of it outside the pie. */
|
|
424
|
+
readonly outerStrokeWidth: 2;
|
|
425
|
+
/** `pieTitleTextSize` */
|
|
426
|
+
readonly titleFontSize: 25;
|
|
427
|
+
/** `pieSectionTextSize` */
|
|
428
|
+
readonly sectionFontSize: 17;
|
|
429
|
+
/** `pieLegendTextSize` */
|
|
430
|
+
readonly legendFontSize: 17;
|
|
431
|
+
readonly fontWeight: 400;
|
|
432
|
+
/** Mermaid's `pie1`..`pie12` scale wraps after this many colours. */
|
|
433
|
+
readonly paletteSize: 12;
|
|
434
|
+
/** Slices below this percentage of the total are not drawn. */
|
|
435
|
+
readonly minPercent: 1;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
/** CSS value for palette slot `index`: slot 0 follows `--accent` live. */
|
|
439
|
+
export declare function pieColorValue(index: number, accent: string | undefined, bg: string): string;
|
|
440
|
+
|
|
409
441
|
/**
|
|
410
442
|
* Build the `d` attribute for an edge's routed points under `curve`.
|
|
411
443
|
*
|
|
@@ -514,6 +546,16 @@ export declare function renderMermaidSVGAsync(text: string, options?: RenderOpti
|
|
|
514
546
|
/** @deprecated Use `renderMermaidSVG` */
|
|
515
547
|
export declare const renderMermaidSync: typeof renderMermaidSVG;
|
|
516
548
|
|
|
549
|
+
/**
|
|
550
|
+
* Render a positioned pie chart as an SVG string.
|
|
551
|
+
*
|
|
552
|
+
* The accessible name is `title` (from `options.title`) when given,
|
|
553
|
+
* otherwise the chart's own `accTitle`; `accDescr` becomes the root
|
|
554
|
+
* `<desc>`. Both are dropped when `decorative` is set — see svgOpenTag() in
|
|
555
|
+
* packages/core/src/theme.ts.
|
|
556
|
+
*/
|
|
557
|
+
export declare function renderPieSvg(chart: PositionedPieChart, colors: DiagramColors, font?: string, transparent?: boolean, embedSource?: string, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
558
|
+
|
|
517
559
|
/**
|
|
518
560
|
* Render a positioned sequence diagram as an SVG string.
|
|
519
561
|
*
|