@mstone6969/graph 0.1.0 → 0.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.
Files changed (238) hide show
  1. package/README.md +111 -14
  2. package/dist/ExcelWriter-3ZSYUH4T.cjs +154 -0
  3. package/dist/GraphType.js +24 -38
  4. package/dist/PdfWriter-6HJFYMCO.cjs +205 -0
  5. package/dist/catalog-YWX6FHRM.cjs +8 -0
  6. package/dist/catalog.js +5 -1
  7. package/dist/charts/bars/index.js +2 -12
  8. package/dist/charts/comparison/EffectForestPlot.js +1 -1
  9. package/dist/charts/comparison/index.js +1 -8
  10. package/dist/charts/demography/Nomogram.js +3 -3
  11. package/dist/charts/density/HexbinChart.js +6 -4
  12. package/dist/charts/diagrams/ArchitectureCanvas.js +68 -0
  13. package/dist/charts/diagrams/ArchitectureDiagram.js +331 -0
  14. package/dist/charts/diagrams/ArchitectureLayout.js +106 -0
  15. package/dist/charts/diagrams/ArchitectureLinkLabels.js +78 -0
  16. package/dist/charts/diagrams/ArchitectureModel.js +108 -0
  17. package/dist/charts/diagrams/ArchitectureRouter.js +348 -0
  18. package/dist/charts/diagrams/ArchitectureSamples.js +312 -0
  19. package/dist/charts/diagrams/ArchitectureShapes.js +130 -0
  20. package/dist/charts/diagrams/ArchitectureText.js +25 -0
  21. package/dist/charts/diagrams/DiagramText.js +38 -0
  22. package/dist/charts/diagrams/EntityRelationshipDiagram.js +465 -0
  23. package/dist/charts/diagrams/ErCrowsFoot.js +33 -0
  24. package/dist/charts/diagrams/ErSamples.js +205 -0
  25. package/dist/charts/diagrams/ErSchema.js +122 -0
  26. package/dist/charts/diagrams/LogicCircuit.js +154 -0
  27. package/dist/charts/diagrams/LogicCircuitLayout.js +600 -0
  28. package/dist/charts/diagrams/LogicCircuitSamples.js +66 -0
  29. package/dist/charts/diagrams/LogicGateDiagram.js +216 -0
  30. package/dist/charts/diagrams/LogicGateSymbol.js +113 -0
  31. package/dist/charts/diagrams/NetworkTopologyDiagram.js +247 -0
  32. package/dist/charts/diagrams/SequenceDiagram.js +351 -0
  33. package/dist/charts/diagrams/SequenceLayout.js +422 -0
  34. package/dist/charts/diagrams/SequenceModel.js +221 -0
  35. package/dist/charts/diagrams/TopologyLayout.js +143 -0
  36. package/dist/charts/diagrams/architectureEnums.js +50 -0
  37. package/dist/charts/diagrams/index.js +26 -0
  38. package/dist/charts/diagrams/logicEnums.js +42 -0
  39. package/dist/charts/diagrams/sequenceEnums.js +40 -0
  40. package/dist/charts/distribution/HistogramChart.js +25 -3
  41. package/dist/charts/distribution/index.js +1 -3
  42. package/dist/charts/earthscience/HovmollerDiagram.js +477 -0
  43. package/dist/charts/earthscience/HovmollerEnums.js +42 -0
  44. package/dist/charts/earthscience/HovmollerField.js +180 -0
  45. package/dist/charts/earthscience/HovmollerSample.js +40 -0
  46. package/dist/charts/earthscience/HovmollerSpeed.js +71 -0
  47. package/dist/charts/earthscience/index.js +10 -2
  48. package/dist/charts/engineering/ConstellationDiagram.js +26 -6
  49. package/dist/charts/engineering/EyeDiagram.js +2 -1
  50. package/dist/charts/engineering/PoleZeroPlot.js +32 -8
  51. package/dist/charts/financial/RelativeStrengthRotation.js +434 -0
  52. package/dist/charts/financial/RelativeStrengthRotationMath.js +71 -0
  53. package/dist/charts/financial/RelativeStrengthRotationSamples.js +27 -0
  54. package/dist/charts/financial/index.js +5 -3
  55. package/dist/charts/flow/index.js +1 -5
  56. package/dist/charts/frameworks/AnsoffMatrix.js +523 -0
  57. package/dist/charts/frameworks/FrameworkText.js +98 -0
  58. package/dist/charts/frameworks/NpsGauge.js +279 -0
  59. package/dist/charts/frameworks/NpsSurvey.js +58 -0
  60. package/dist/charts/frameworks/PerceptualMap.js +419 -0
  61. package/dist/charts/frameworks/PerceptualProjection.js +142 -0
  62. package/dist/charts/frameworks/PositioningSamples.js +191 -0
  63. package/dist/charts/frameworks/RaciMatrix.js +458 -0
  64. package/dist/charts/frameworks/RaciPlan.js +81 -0
  65. package/dist/charts/frameworks/RaciSamples.js +76 -0
  66. package/dist/charts/frameworks/SwotMatrix.js +358 -0
  67. package/dist/charts/frameworks/SwotSamples.js +85 -0
  68. package/dist/charts/frameworks/VanWestendorpChart.js +187 -0
  69. package/dist/charts/frameworks/VanWestendorpSurvey.js +197 -0
  70. package/dist/charts/frameworks/index.js +26 -0
  71. package/dist/charts/frameworks/raciEnums.js +30 -0
  72. package/dist/charts/frameworks/swotEnums.js +34 -0
  73. package/dist/charts/genomics/CircosPlot.js +1 -1
  74. package/dist/charts/geoflows/GeoFlowChart.js +2 -2
  75. package/dist/charts/geoflows/GeoFlowSample.js +2 -1
  76. package/dist/charts/geomaps/FloorPlanMap.js +324 -0
  77. package/dist/charts/geomaps/FloorPlanModel.js +179 -0
  78. package/dist/charts/geomaps/FloorPlanSamples.js +416 -0
  79. package/dist/charts/geomaps/GeoLand.js +2 -2
  80. package/dist/charts/geomaps/GeoSamples.js +2 -1
  81. package/dist/charts/geomaps/GraticuleMap.js +2 -2
  82. package/dist/charts/geomaps/RoomLabelFit.js +200 -0
  83. package/dist/charts/geomaps/TissotMap.js +2 -2
  84. package/dist/charts/geomaps/index.js +8 -4
  85. package/dist/charts/hierarchy/SunburstChart.js +17 -10
  86. package/dist/charts/hierarchy/index.js +2 -11
  87. package/dist/charts/indicators/BulletChart.js +8 -2
  88. package/dist/charts/indicators/SpeedometerChart.js +1 -1
  89. package/dist/charts/indicators/ThermometerChart.js +1 -1
  90. package/dist/charts/lifescience/LoessFit.js +113 -0
  91. package/dist/charts/lifescience/MaPlot.js +337 -0
  92. package/dist/charts/lifescience/MaPlotSamples.js +35 -0
  93. package/dist/charts/lifescience/OncoGlyph.js +137 -0
  94. package/dist/charts/lifescience/OncoPrint.js +373 -0
  95. package/dist/charts/lifescience/OncoPrintMatrix.js +107 -0
  96. package/dist/charts/lifescience/OncoPrintSamples.js +142 -0
  97. package/dist/charts/lifescience/PedigreeChart.js +306 -0
  98. package/dist/charts/lifescience/PedigreeLayout.js +261 -0
  99. package/dist/charts/lifescience/PedigreeRows.js +70 -0
  100. package/dist/charts/lifescience/PedigreeSamples.js +161 -0
  101. package/dist/charts/lifescience/PedigreeSymbol.js +47 -0
  102. package/dist/charts/lifescience/RamachandranPlot.js +364 -0
  103. package/dist/charts/lifescience/RamachandranRegions.js +2712 -0
  104. package/dist/charts/lifescience/RamachandranSamples.js +235 -0
  105. package/dist/charts/lifescience/index.js +25 -0
  106. package/dist/charts/lifescience/pedigreeEnums.js +21 -0
  107. package/dist/charts/lifescience/ramachandranEnums.js +34 -0
  108. package/dist/charts/linesareas/DualAxisChart.js +1 -1
  109. package/dist/charts/linesareas/LineEnums.js +1 -15
  110. package/dist/charts/linesareas/MultiLineChart.js +1 -1
  111. package/dist/charts/linesareas/TrendChart.js +15 -5
  112. package/dist/charts/linesareas/index.js +2 -6
  113. package/dist/charts/massive/MassiveChart.js +3 -2
  114. package/dist/charts/mathematical/FourierSeriesChart.js +7 -1
  115. package/dist/charts/mathematical/index.js +2 -6
  116. package/dist/charts/matrix/GridPlot.js +27 -2
  117. package/dist/charts/matrix/TilegramChart.js +2 -2
  118. package/dist/charts/mlcharts/AttentionGrid.js +79 -0
  119. package/dist/charts/mlcharts/AttentionHeatmap.js +329 -0
  120. package/dist/charts/mlcharts/AttentionModel.js +132 -0
  121. package/dist/charts/mlcharts/AttentionSamples.js +82 -0
  122. package/dist/charts/mlcharts/CellNumber.js +8 -0
  123. package/dist/charts/mlcharts/CurveDiagnosticSamples.js +95 -0
  124. package/dist/charts/mlcharts/CurvePickMark.js +31 -0
  125. package/dist/charts/mlcharts/DecisionBoundaryChart.js +316 -0
  126. package/dist/charts/mlcharts/DecisionSamples.js +60 -0
  127. package/dist/charts/mlcharts/DecisionSurface.js +130 -0
  128. package/dist/charts/mlcharts/DistinctTicks.js +13 -0
  129. package/dist/charts/mlcharts/ElbowMath.js +153 -0
  130. package/dist/charts/mlcharts/ElbowPlot.js +273 -0
  131. package/dist/charts/mlcharts/ExplainabilitySamples.js +70 -0
  132. package/dist/charts/mlcharts/FeatureImportanceChart.js +150 -0
  133. package/dist/charts/mlcharts/ImportanceRanking.js +98 -0
  134. package/dist/charts/mlcharts/LearningCurveChart.js +276 -0
  135. package/dist/charts/mlcharts/LearningCurveMath.js +92 -0
  136. package/dist/charts/mlcharts/PartialDependence.js +92 -0
  137. package/dist/charts/mlcharts/PartialDependencePlot.js +225 -0
  138. package/dist/charts/mlcharts/WideLabel.js +28 -0
  139. package/dist/charts/mlcharts/curveDiagnosticEnums.js +37 -0
  140. package/dist/charts/mlcharts/index.js +32 -0
  141. package/dist/charts/proportion/index.js +5 -9
  142. package/dist/charts/scatter/CategoryScatterBase.js +1 -4
  143. package/dist/charts/scatter/ConnectedScatter.js +7 -4
  144. package/dist/charts/scatter/MarginalScatter.js +13 -8
  145. package/dist/charts/scatter/index.js +4 -17
  146. package/dist/charts/scientific/SpectrogramChart.js +9 -3
  147. package/dist/charts/scientific/index.js +2 -2
  148. package/dist/charts/signals/index.js +3 -13
  149. package/dist/charts/statistics/LorenzCurve.js +7 -4
  150. package/dist/charts/threebars/Candlestick3DChart.js +18 -2
  151. package/dist/charts/threeglobe/GlobeChart.js +2 -2
  152. package/dist/charts/threeglobe/GlobeSamples.js +2 -1
  153. package/dist/charts/threeglobe/RingGlobe.js +1 -1
  154. package/dist/charts/threenetwork/ConeTreeChart.js +2 -1
  155. package/dist/charts/threenetwork/Gantt3DChart.js +3 -2
  156. package/dist/charts/threesurfaces/Ridgeline3DChart.js +22 -4
  157. package/dist/charts/threevolume/LorenzAttractor.js +19 -0
  158. package/dist/charts/threevolume/VolumeRaycastChart.js +4 -3
  159. package/dist/charts/threevolume/volumeEnums.js +1 -0
  160. package/dist/charts/timeline/index.js +2 -10
  161. package/dist/chunk-753UBLV2.cjs +33 -0
  162. package/dist/chunk-VX54A7KA.cjs +17 -0
  163. package/dist/{chunk-W5GAAAZY.cjs → chunk-WAODDPYX.cjs} +24874 -17620
  164. package/dist/chunk-Z3JPIJSC.cjs +338 -0
  165. package/dist/core/CartesianChart.js +87 -11
  166. package/dist/core/Chart.js +63 -15
  167. package/dist/core/Chart2D.js +54 -17
  168. package/dist/core/Chart3D.js +56 -20
  169. package/dist/core/ChartExportError.js +2 -0
  170. package/dist/core/ChartExporter.js +50 -8
  171. package/dist/core/ColumnCheck.js +53 -0
  172. package/dist/core/Context2D.js +29 -15
  173. package/dist/core/Context3D.js +7 -2
  174. package/dist/core/ExcelWriter.js +152 -0
  175. package/dist/core/ExportText.js +28 -0
  176. package/dist/core/MarkOrigin.js +88 -0
  177. package/dist/core/MarkStyle.js +294 -0
  178. package/dist/core/Palette.js +27 -7
  179. package/dist/core/PdfPage.js +13 -0
  180. package/dist/core/PdfWriter.js +245 -0
  181. package/dist/core/Scales.js +52 -2
  182. package/dist/core/SceneOverlay.js +4 -4
  183. package/dist/core/TextFit.js +37 -0
  184. package/dist/core/Theme.js +28 -1
  185. package/dist/core/enums.js +33 -1
  186. package/dist/core/pathMorph.js +15 -0
  187. package/dist/data/SampleData.js +1 -17
  188. package/dist/data/WorldSample.js +23 -0
  189. package/dist/index.cjs +810 -691
  190. package/dist/index.d.cts +8390 -2925
  191. package/dist/index.d.ts +8392 -2927
  192. package/dist/index.js +106 -56
  193. package/dist/react/ChartView.js +18 -8
  194. package/dist/react/GraphHandle.js +2 -0
  195. package/dist/react/components.js +74 -116
  196. package/package.json +13 -3
  197. package/dist/catalog-4UP2YFNR.cjs +0 -7
  198. package/dist/charts/bars/BulletBar.js +0 -184
  199. package/dist/charts/bars/ErrorBarColumn.js +0 -147
  200. package/dist/charts/bars/HistogramBar.js +0 -217
  201. package/dist/charts/bars/MarimekkoBar.js +0 -191
  202. package/dist/charts/bars/ParetoBar.js +0 -143
  203. package/dist/charts/comparison/PanelChart.js +0 -70
  204. package/dist/charts/comparison/SmallMultipleBars.js +0 -134
  205. package/dist/charts/comparison/SpanChart.js +0 -118
  206. package/dist/charts/comparison/TrellisChart.js +0 -158
  207. package/dist/charts/distribution/RidgeSlabs3DChart.js +0 -169
  208. package/dist/charts/financial/Candlestick3D.js +0 -157
  209. package/dist/charts/flow/BumpFlow.js +0 -212
  210. package/dist/charts/flow/StreamFlow.js +0 -174
  211. package/dist/charts/geomaps/ThiessenMap.js +0 -106
  212. package/dist/charts/hierarchy/ConeTree3D.js +0 -135
  213. package/dist/charts/hierarchy/Hierarchy3DChart.js +0 -27
  214. package/dist/charts/hierarchy/SpherePack3D.js +0 -81
  215. package/dist/charts/hierarchy/SunburstTower3D.js +0 -93
  216. package/dist/charts/hierarchy/TreemapSkyline3D.js +0 -98
  217. package/dist/charts/linesareas/ConnectedScatterTime.js +0 -206
  218. package/dist/charts/linesareas/SmallMultipleLines.js +0 -153
  219. package/dist/charts/mathematical/ParametricSurface3D.js +0 -234
  220. package/dist/charts/mathematical/StrangeAttractor3D.js +0 -251
  221. package/dist/charts/proportion/ConeFunnel.js +0 -126
  222. package/dist/charts/proportion/ExtrudedPieChart.js +0 -123
  223. package/dist/charts/scatter/BeeswarmScatter.js +0 -151
  224. package/dist/charts/scatter/BinnedScatterBase.js +0 -51
  225. package/dist/charts/scatter/ContourScatter.js +0 -116
  226. package/dist/charts/scatter/GridBinScatter.js +0 -98
  227. package/dist/charts/scatter/HexbinScatter.js +0 -74
  228. package/dist/charts/scatter/StripScatter.js +0 -107
  229. package/dist/charts/scatter/SunflowerScatter.js +0 -109
  230. package/dist/charts/signals/ConstellationChart.js +0 -153
  231. package/dist/charts/signals/CorrelogramChart.js +0 -171
  232. package/dist/charts/signals/EyeDiagramChart.js +0 -155
  233. package/dist/charts/signals/PoleZeroChart.js +0 -164
  234. package/dist/charts/signals/SpectrogramChart.js +0 -79
  235. package/dist/charts/timeline/CalendarSkylineChart.js +0 -128
  236. package/dist/charts/timeline/ScheduleBlocksChart.js +0 -119
  237. package/dist/charts/timeline/SpiralTimeline.js +0 -154
  238. package/dist/charts/timeline/StreamTimeline.js +0 -141
@@ -0,0 +1,205 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+ var _chunkVX54A7KAcjs = require('./chunk-VX54A7KA.cjs');
4
+
5
+
6
+ var _chunk753UBLV2cjs = require('./chunk-753UBLV2.cjs');
7
+
8
+
9
+
10
+ var _chunkZ3JPIJSCcjs = require('./chunk-Z3JPIJSC.cjs');
11
+
12
+ // src/core/PdfWriter.ts
13
+ var _pdflib = require('pdf-lib');
14
+ var SIZES = { ["a4" /* A4 */]: _pdflib.PageSizes.A4, ["letter" /* Letter */]: _pdflib.PageSizes.Letter };
15
+ var MARGIN = 36;
16
+ var TITLE = 16;
17
+ var TEXT = 8;
18
+ var FOOTER = 7;
19
+ var ROW = 14;
20
+ var PADDING = 4;
21
+ var [MIN_COLUMN, MAX_COLUMN] = [44, 180];
22
+ var MEASURED = 500;
23
+ var MAX_ROWS = 25e3;
24
+ var SHARPNESS = 4;
25
+ var [ASCENT, DESCENT] = [1.05, 0.35];
26
+ var FALLBACK_FONT = 'Helvetica, Arial, "Noto Sans", sans-serif';
27
+ var INK = _pdflib.rgb.call(void 0, 0.1, 0.1, 0.1);
28
+ var QUIET = _pdflib.rgb.call(void 0, 0.4, 0.4, 0.4);
29
+ var RULE = _pdflib.rgb.call(void 0, 0.8, 0.8, 0.8);
30
+ var BAND = _pdflib.rgb.call(void 0, 0.94, 0.94, 0.94);
31
+ var PdfWriter = class _PdfWriter {
32
+ #doc;
33
+ #regular;
34
+ #bold;
35
+ #glyphs;
36
+ #pictures = /* @__PURE__ */ new Map();
37
+ #ruler = null;
38
+ #width;
39
+ #height;
40
+ constructor(doc, regular, bold, size) {
41
+ this.#doc = doc;
42
+ this.#regular = regular;
43
+ this.#bold = bold;
44
+ this.#glyphs = new Set(regular.getCharacterSet());
45
+ [this.#width, this.#height] = size;
46
+ }
47
+ static async write(chart, options = {}) {
48
+ const table = options.table ? _chunk753UBLV2cjs.ExportText.rows(chart, "A PDF data table") : null;
49
+ return _PdfWriter.file(await chart.toPNG({ scale: _nullishCoalesce(options.scale, () => ( 3)) }), table, options);
50
+ }
51
+ static async file(png, table, options) {
52
+ const { pageSize = "a4" /* A4 */, orientation = "auto" /* Auto */, title } = options;
53
+ const size = SIZES[pageSize];
54
+ if (!size) throw new RangeError(`Unknown PDF page size ${pageSize}.`);
55
+ if (!Object.values(_chunkVX54A7KAcjs.PdfOrientation).includes(orientation)) throw new RangeError(`Unknown PDF orientation ${orientation}.`);
56
+ if (table && table.rows.length > MAX_ROWS) throw new (0, _chunkZ3JPIJSCcjs.ChartExportError)("unsupported" /* Unsupported */, `A PDF table holds ${MAX_ROWS} rows and this one has ${table.rows.length}. Use Excel or CSV for the data.`);
57
+ const doc = await _pdflib.PDFDocument.create();
58
+ doc.setCreator("@mstone6969/graph");
59
+ doc.setProducer("pdf-lib");
60
+ if (title) doc.setTitle(title);
61
+ const chart = await doc.embedPng(await png.arrayBuffer());
62
+ const [narrow, wide] = size;
63
+ const landscape = orientation === "landscape" /* Landscape */ || orientation === "auto" /* Auto */ && chart.width >= chart.height;
64
+ const writer = new _PdfWriter(doc, await doc.embedFont(_pdflib.StandardFonts.Helvetica), await doc.embedFont(_pdflib.StandardFonts.HelveticaBold), landscape ? [wide, narrow] : [narrow, wide]);
65
+ await writer.#chartPage(chart, title);
66
+ if (table) await writer.#tablePages(table);
67
+ await writer.#numberPages();
68
+ return new Blob([await doc.save()], { type: "application/pdf" });
69
+ }
70
+ #page() {
71
+ return this.#doc.addPage([this.#width, this.#height]);
72
+ }
73
+ get #room() {
74
+ return this.#width - MARGIN * 2;
75
+ }
76
+ async #chartPage(chart, title) {
77
+ const page = this.#page();
78
+ let top = this.#height - MARGIN;
79
+ if (title) {
80
+ top -= TITLE;
81
+ await this.#text(page, title, MARGIN, top, this.#room, { size: TITLE, bold: true });
82
+ top -= TITLE;
83
+ }
84
+ const fit = Math.min(this.#room / chart.width, (top - MARGIN) / chart.height);
85
+ const [width, height] = [chart.width * fit, chart.height * fit];
86
+ page.drawImage(chart, { x: (this.#width - width) / 2, y: top - height, width, height });
87
+ }
88
+ async #tablePages({ columns, rows }) {
89
+ const texts = rows.map((row) => columns.map((_, c) => _chunk753UBLV2cjs.ExportText.of(row[c])));
90
+ const natural = columns.map((column, c) => {
91
+ const widest = texts.slice(0, MEASURED).reduce((most, row) => Math.max(most, this.#textWidth(_PdfWriter.#clean(row[c]), TEXT)), this.#textWidth(_PdfWriter.#clean(column), TEXT, true));
92
+ return Math.min(MAX_COLUMN, Math.max(MIN_COLUMN, widest + PADDING * 2));
93
+ });
94
+ for (const block of this.#blocks(natural)) {
95
+ const used = block.reduce((sum, c) => sum + natural[c], 0);
96
+ const widths = block.map((c) => natural[c] * this.#room / used);
97
+ let page = null, y = 0;
98
+ for (const [r, row] of texts.entries()) {
99
+ if (!page || y < MARGIN + ROW) {
100
+ page = this.#page();
101
+ y = this.#height - MARGIN - ROW;
102
+ page.drawRectangle({ x: MARGIN, y: y - PADDING, width: this.#room, height: ROW, color: BAND });
103
+ await this.#row(page, block.map((c) => columns[c]), block.map((c) => typeof rows[0][c] === "number"), widths, y, true);
104
+ y -= ROW;
105
+ }
106
+ await this.#row(page, block.map((c) => row[c]), block.map((c) => typeof rows[r][c] === "number"), widths, y, false);
107
+ page.drawLine({ start: { x: MARGIN, y: y - PADDING }, end: { x: MARGIN + this.#room, y: y - PADDING }, thickness: 0.25, color: RULE });
108
+ y -= ROW;
109
+ }
110
+ }
111
+ }
112
+ /** Greedy runs of columns that fit a page. Later runs repeat the first column, so their rows can still be told apart. */
113
+ #blocks(widths) {
114
+ const blocks = [];
115
+ let used = Infinity;
116
+ widths.forEach((width, c) => {
117
+ if (used + width > this.#room) {
118
+ blocks.push(c ? [0, c] : [c]);
119
+ used = (c ? widths[0] : 0) + width;
120
+ } else {
121
+ blocks.at(-1).push(c);
122
+ used += width;
123
+ }
124
+ });
125
+ return blocks;
126
+ }
127
+ async #row(page, cells, right, widths, y, bold) {
128
+ let x = MARGIN;
129
+ for (const [c, cell] of cells.entries()) {
130
+ const room = widths[c] - PADDING * 2;
131
+ await this.#text(page, cell, right[c] ? x + PADDING + room : x + PADDING, y, room, { size: TEXT, bold, right: right[c] });
132
+ x += widths[c];
133
+ }
134
+ }
135
+ async #numberPages() {
136
+ const pages = this.#doc.getPages();
137
+ if (pages.length < 2) return;
138
+ for (const [i, page] of pages.entries()) {
139
+ await this.#text(page, `Page ${i + 1} of ${pages.length}`, this.#width - MARGIN, MARGIN / 2, this.#room, { size: FOOTER, color: QUIET, right: true });
140
+ }
141
+ }
142
+ static #clean(text) {
143
+ return text.replace(/\s+/g, " ").trim();
144
+ }
145
+ #encodable(text) {
146
+ for (const char of text) if (!this.#glyphs.has(char.codePointAt(0))) return false;
147
+ return true;
148
+ }
149
+ #font(bold) {
150
+ return bold ? this.#bold : this.#regular;
151
+ }
152
+ #cssFont(px, bold) {
153
+ return `${bold ? "bold " : ""}${px}px ${FALLBACK_FONT}`;
154
+ }
155
+ #textWidth(text, size, bold) {
156
+ if (this.#encodable(text)) return this.#font(bold).widthOfTextAtSize(text, size);
157
+ this.#ruler ??= _chunkZ3JPIJSCcjs.ChartExporter.paint(_chunkZ3JPIJSCcjs.ChartExporter.canvas(1, 1));
158
+ this.#ruler.font = this.#cssFont(size * SHARPNESS, bold);
159
+ return this.#ruler.measureText(text).width / SHARPNESS;
160
+ }
161
+ /** Cuts by code point, so an ellipsis never lands inside a surrogate pair. */
162
+ #fit(text, room, size, bold) {
163
+ if (this.#textWidth(text, size, bold) <= room) return text;
164
+ const chars = [...text];
165
+ let [low, high] = [0, chars.length];
166
+ while (low < high) {
167
+ const middle = Math.ceil((low + high) / 2);
168
+ if (this.#textWidth(`${chars.slice(0, middle).join("")}\u2026`, size, bold) <= room) low = middle;
169
+ else high = middle - 1;
170
+ }
171
+ return `${chars.slice(0, low).join("").trimEnd()}\u2026`;
172
+ }
173
+ /** The 14 built-in fonts cover Western European text only. Anything else is drawn as a small picture, so it shows but cannot be selected. */
174
+ async #text(page, text, x, y, room, style) {
175
+ const { size, bold, color = INK, right } = style;
176
+ const clean = _PdfWriter.#clean(text);
177
+ if (!clean) return;
178
+ const shown = this.#fit(clean, room, size, bold);
179
+ const width = this.#textWidth(shown, size, bold);
180
+ const left = right ? x - width : x;
181
+ if (this.#encodable(shown)) {
182
+ page.drawText(shown, { x: left, y, size, font: this.#font(bold), color });
183
+ return;
184
+ }
185
+ const picture = await this.#picture(shown, width, size, bold);
186
+ page.drawImage(picture, { x: left, y: y - size * DESCENT, width: picture.width / SHARPNESS, height: picture.height / SHARPNESS });
187
+ }
188
+ async #picture(text, width, size, bold) {
189
+ const key = `${size}|${bold}|${text}`;
190
+ const known = this.#pictures.get(key);
191
+ if (known) return known;
192
+ const canvas = _chunkZ3JPIJSCcjs.ChartExporter.canvas(Math.ceil(width * SHARPNESS), Math.ceil(size * (ASCENT + DESCENT) * SHARPNESS));
193
+ const paint = _chunkZ3JPIJSCcjs.ChartExporter.paint(canvas);
194
+ paint.font = this.#cssFont(size * SHARPNESS, bold);
195
+ paint.fillStyle = "#1a1a1a";
196
+ paint.textBaseline = "alphabetic";
197
+ paint.fillText(text, 0, size * ASCENT * SHARPNESS);
198
+ const picture = await this.#doc.embedPng(await (await _chunkZ3JPIJSCcjs.ChartExporter.png(canvas)).arrayBuffer());
199
+ this.#pictures.set(key, picture);
200
+ return picture;
201
+ }
202
+ };
203
+
204
+
205
+ exports.PdfWriter = PdfWriter;
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkWAODDPYXcjs = require('./chunk-WAODDPYX.cjs');
4
+ require('./chunk-Z3JPIJSC.cjs');
5
+ require('./chunk-KGSYGPLS.cjs');
6
+
7
+
8
+ exports.catalog = _chunkWAODDPYXcjs.catalog;
package/dist/catalog.js CHANGED
@@ -28,6 +28,10 @@ import { genomicsCatalog } from "./charts/genomics/index.js";
28
28
  import { earthscienceCatalog } from "./charts/earthscience/index.js";
29
29
  import { demographyCatalog } from "./charts/demography/index.js";
30
30
  import { structureCatalog } from "./charts/structure/index.js";
31
+ import { diagramsCatalog } from "./charts/diagrams/index.js";
32
+ import { mlchartsCatalog } from "./charts/mlcharts/index.js";
33
+ import { frameworksCatalog } from "./charts/frameworks/index.js";
34
+ import { lifescienceCatalog } from "./charts/lifescience/index.js";
31
35
  import { threebarsCatalog } from "./charts/threebars/index.js";
32
36
  import { threesurfacesCatalog } from "./charts/threesurfaces/index.js";
33
37
  import { threevolumeCatalog } from "./charts/threevolume/index.js";
@@ -36,5 +40,5 @@ import { threeglobeCatalog } from "./charts/threeglobe/index.js";
36
40
  import { ChartRegistry } from "./core/ChartRegistry.js";
37
41
  // src/catalog.ts
38
42
  /** Every chart class in the library, and every chart type they expand to. */
39
- var catalog = new ChartRegistry().register(...barsCatalog, ...linesareasCatalog, ...scatterCatalog, ...distributionCatalog, ...financialCatalog, ...comparisonCatalog, ...proportionCatalog, ...radialCatalog, ...hierarchyCatalog, ...indicatorsCatalog, ...timelineCatalog, ...pictorialCatalog, ...networkCatalog, ...flowCatalog, ...matrixCatalog, ...densityCatalog, ...multivariateCatalog, ...statisticsCatalog, ...geomapsCatalog, ...geoflowsCatalog, ...scientificCatalog, ...engineeringCatalog, ...mathematicalCatalog, ...signalsCatalog, ...massiveCatalog, ...businessCatalog, ...genomicsCatalog, ...earthscienceCatalog, ...demographyCatalog, ...structureCatalog, ...threebarsCatalog, ...threesurfacesCatalog, ...threevolumeCatalog, ...threenetworkCatalog, ...threeglobeCatalog);
43
+ var catalog = new ChartRegistry().register(...barsCatalog, ...linesareasCatalog, ...scatterCatalog, ...distributionCatalog, ...financialCatalog, ...comparisonCatalog, ...proportionCatalog, ...radialCatalog, ...hierarchyCatalog, ...indicatorsCatalog, ...timelineCatalog, ...pictorialCatalog, ...networkCatalog, ...flowCatalog, ...matrixCatalog, ...densityCatalog, ...multivariateCatalog, ...statisticsCatalog, ...geomapsCatalog, ...geoflowsCatalog, ...scientificCatalog, ...engineeringCatalog, ...mathematicalCatalog, ...signalsCatalog, ...massiveCatalog, ...businessCatalog, ...genomicsCatalog, ...earthscienceCatalog, ...demographyCatalog, ...structureCatalog, ...diagramsCatalog, ...mlchartsCatalog, ...frameworksCatalog, ...lifescienceCatalog, ...threebarsCatalog, ...threesurfacesCatalog, ...threevolumeCatalog, ...threenetworkCatalog, ...threeglobeCatalog);
40
44
  export { catalog };
@@ -2,21 +2,16 @@ import { BarFrame } from "./BarFrame.js";
2
2
  import { BarAggregate, BarRows, BarSort } from "./BarRows.js";
3
3
  import { BandChart } from "./BandChart.js";
4
4
  import { BarChart } from "./BarChart.js";
5
- import { BulletBar, BulletBarMeasure, BulletBarScale, BulletBarTarget } from "./BulletBar.js";
6
5
  import { MirrorChart, MirrorMark } from "./MirrorChart.js";
7
6
  import { ButterflyChart, ButterflyChartScale, ButterflyChartSort } from "./ButterflyChart.js";
8
7
  import { DateBarChart, DateBarInterval } from "./DateBarChart.js";
9
8
  import { DivergingBarCenter, DivergingBarChart, DivergingBarLabels, DivergingBarLayout } from "./DivergingBarChart.js";
10
9
  import { DotPlot, DotPlotDomain, DotPlotGuide, DotPlotLayout } from "./DotPlot.js";
11
10
  import { DumbbellChart, DumbbellChartConnector, DumbbellChartSort } from "./DumbbellChart.js";
12
- import { ErrorBarColumn, ErrorBarInterval, ErrorBarMark } from "./ErrorBarColumn.js";
13
11
  import { FacetedBarChart, FacetedBarMark, FacetedBarScale, FacetedBarSort } from "./FacetedBarChart.js";
14
12
  import { GroupedStackedBar } from "./GroupedStackedBar.js";
15
- import { HistogramBar, HistogramBarBinning, HistogramBarLayout } from "./HistogramBar.js";
16
13
  import { IconlessRankAlign, IconlessRankBar, IconlessRankLayout } from "./IconlessRankBar.js";
17
14
  import { LollipopChart, LollipopChartBaseline } from "./LollipopChart.js";
18
- import { MarimekkoBar, MekkoMode } from "./MarimekkoBar.js";
19
- import { ParetoBar, ParetoBarLine } from "./ParetoBar.js";
20
15
  import { PercentChangeBar, PercentChangeMark, PercentChangeMeasure } from "./PercentChangeBar.js";
21
16
  import { PopulationPyramid } from "./PopulationPyramid.js";
22
17
  import { ProgressBars, ProgressBarsLabel, ProgressBarsTrack } from "./ProgressBars.js";
@@ -32,19 +27,14 @@ var barsCatalog = [
32
27
  DivergingBarChart,
33
28
  ButterflyChart,
34
29
  WaterfallChart,
35
- MarimekkoBar,
36
- HistogramBar,
37
30
  RangeBarChart,
38
31
  PopulationPyramid,
39
- BulletBar,
40
32
  ProgressBars,
41
33
  GroupedStackedBar,
42
34
  PercentChangeBar,
43
35
  TripleBarOverlay,
44
36
  IconlessRankBar,
45
- ParetoBar,
46
37
  DateBarChart,
47
- FacetedBarChart,
48
- ErrorBarColumn
38
+ FacetedBarChart
49
39
  ];
50
- export { BandChart, BarAggregate, BarChart, BarFrame, BarRows, BarSort, BulletBar, BulletBarMeasure, BulletBarScale, BulletBarTarget, ButterflyChart, ButterflyChartScale, ButterflyChartSort, DateBarChart, DateBarInterval, DivergingBarCenter, DivergingBarChart, DivergingBarLabels, DivergingBarLayout, DotPlot, DotPlotDomain, DotPlotGuide, DotPlotLayout, DumbbellChart, DumbbellChartConnector, DumbbellChartSort, ErrorBarColumn, ErrorBarInterval, ErrorBarMark, FacetedBarChart, FacetedBarMark, FacetedBarScale, FacetedBarSort, GroupedStackedBar, HistogramBar, HistogramBarBinning, HistogramBarLayout, IconlessRankAlign, IconlessRankBar, IconlessRankLayout, LollipopChart, LollipopChartBaseline, MarimekkoBar, MekkoMode, MirrorChart, MirrorMark, OverlayFront, OverlayNesting, ParetoBar, ParetoBarLine, PercentChangeBar, PercentChangeMark, PercentChangeMeasure, PopulationPyramid, ProgressBars, ProgressBarsLabel, ProgressBarsTrack, RangeBarChart, RangeBarMark, RangeBarSort, RangeBarSpread, TripleBarOverlay, WaterfallChart, WaterfallChartStep, WaterfallChartTotals, barsCatalog };
40
+ export { BandChart, BarAggregate, BarChart, BarFrame, BarRows, BarSort, ButterflyChart, ButterflyChartScale, ButterflyChartSort, DateBarChart, DateBarInterval, DivergingBarCenter, DivergingBarChart, DivergingBarLabels, DivergingBarLayout, DotPlot, DotPlotDomain, DotPlotGuide, DotPlotLayout, DumbbellChart, DumbbellChartConnector, DumbbellChartSort, FacetedBarChart, FacetedBarMark, FacetedBarScale, FacetedBarSort, GroupedStackedBar, IconlessRankAlign, IconlessRankBar, IconlessRankLayout, LollipopChart, LollipopChartBaseline, MirrorChart, MirrorMark, OverlayFront, OverlayNesting, PercentChangeBar, PercentChangeMark, PercentChangeMeasure, PopulationPyramid, ProgressBars, ProgressBarsLabel, ProgressBarsTrack, RangeBarChart, RangeBarMark, RangeBarSort, RangeBarSpread, TripleBarOverlay, WaterfallChart, WaterfallChartStep, WaterfallChartTotals, barsCatalog };
@@ -114,7 +114,7 @@ var EffectForestPlot = class extends BandValueChart {
114
114
  pooled: false
115
115
  }];
116
116
  });
117
- const items = sort === "effect" ? rows.sort((a, b) => b.effect - a.effect) : sort === "precision" ? rows.sort((a, b) => a.high / a.low - b.high / b.low) : rows;
117
+ const items = sort === "effect" ? rows.sort((a, b) => b.effect - a.effect) : sort === "precision" ? rows.sort((a, b) => on(a.high) - on(a.low) - (on(b.high) - on(b.low))) : rows;
118
118
  const summary = pooled ? this.pool(items, on) : null;
119
119
  if (summary) items.push(summary);
120
120
  const values = [...this.logged && noEffect <= 0 ? [] : [noEffect], ...items.flatMap((d) => [d.low, d.high])];
@@ -14,11 +14,7 @@ import { ProfileScale, RadarLikeProfileChart } from "./RadarLikeProfileChart.js"
14
14
  import { RangeDotChart, RangeDotLink } from "./RangeDotChart.js";
15
15
  import { RankedDotChart, RankedLeader } from "./RankedDotChart.js";
16
16
  import { RankedSlopeLabels, RankedSlopePosition, RankedSlopeSpan, SlopeGraphRanked } from "./SlopeGraphRanked.js";
17
- import { PanelChart, PanelFlow } from "./PanelChart.js";
18
- import { BarFacet, SmallMultipleBars } from "./SmallMultipleBars.js";
19
- import { SpanChart, SpanMarker } from "./SpanChart.js";
20
17
  import { LensBaseline, LensMark, LensScale, LensSort, TableLensChart } from "./TableLensChart.js";
21
- import { TrellisChart, TrellisMark } from "./TrellisChart.js";
22
18
  // src/charts/comparison/index.ts
23
19
  var comparisonCatalog = [
24
20
  RadarLikeProfileChart,
@@ -28,16 +24,13 @@ var comparisonCatalog = [
28
24
  ErrorBarChart,
29
25
  EffectForestPlot,
30
26
  GaugeBarsComparison,
31
- SpanChart,
32
27
  FloatingBarChart,
33
28
  DeviationChart,
34
29
  RangeDotChart,
35
30
  PairedBarChart,
36
- SmallMultipleBars,
37
31
  CycleChart,
38
- TrellisChart,
39
32
  MeanLineChart,
40
33
  IntervalChart,
41
34
  RankedDotChart
42
35
  ];
43
- export { BandValueChart, BarFacet, BarMeanChart, BarMeanRaw, ComparisonCenter, ComparisonSort, ComparisonSpread, CycleAggregate, CycleChart, CycleMark, CycleReference, CycleUnit, DeviationChart, DeviationMark, DeviationReference, DeviationUnit, EffectForestPlot, ErrorBarChart, ErrorBarLink, FloatReference, FloatShape, FloatingBarChart, ForestMarker, ForestSort, GaugeBarMarker, GaugeBarScale, GaugeBarTrack, GaugeBarsComparison, IntervalChart, IntervalStyle, LensBaseline, LensMark, LensScale, LensSort, MeanLineChart, MeanRibbon, PairedBarChart, PairedLayout, PairedSort, PairedUnit, PanelChart, PanelFlow, ProfileScale, RadarLikeProfileChart, RangeDotChart, RangeDotLink, RankedDotChart, RankedLeader, RankedSlopeLabels, RankedSlopePosition, RankedSlopeSpan, SlopeGraphRanked, SmallMultipleBars, SpanChart, SpanMarker, TableLensChart, Tally, TrellisChart, TrellisMark, comparisonCatalog };
36
+ export { BandValueChart, BarMeanChart, BarMeanRaw, ComparisonCenter, ComparisonSort, ComparisonSpread, CycleAggregate, CycleChart, CycleMark, CycleReference, CycleUnit, DeviationChart, DeviationMark, DeviationReference, DeviationUnit, EffectForestPlot, ErrorBarChart, ErrorBarLink, FloatReference, FloatShape, FloatingBarChart, ForestMarker, ForestSort, GaugeBarMarker, GaugeBarScale, GaugeBarTrack, GaugeBarsComparison, IntervalChart, IntervalStyle, LensBaseline, LensMark, LensScale, LensSort, MeanLineChart, MeanRibbon, PairedBarChart, PairedLayout, PairedSort, PairedUnit, ProfileScale, RadarLikeProfileChart, RangeDotChart, RangeDotLink, RankedDotChart, RankedLeader, RankedSlopeLabels, RankedSlopePosition, RankedSlopeSpan, SlopeGraphRanked, TableLensChart, Tally, comparisonCatalog };
@@ -229,14 +229,14 @@ var Nomogram = class extends Chart2D {
229
229
  }
230
230
  #drawRails(ctx, frame) {
231
231
  const { at, rails, tick } = frame;
232
- const lines = ctx.marks("rails", "path", rails, (d) => d.rail).attr("stroke", ctx.theme.inkSecondary).attr("stroke-width", 2).attr("stroke-linecap", "round").attr("fill", "none");
232
+ const lines = ctx.marks("axis-rails", "path", rails, (d) => d.rail).attr("stroke", ctx.theme.inkSecondary).attr("stroke-width", 2).attr("stroke-linecap", "round").attr("fill", "none");
233
233
  ctx.set(lines, { d: (d) => DemographyMarks.segment(at(d.across, 0), at(d.across, 1)) });
234
234
  const stroke = (name, pick, size) => {
235
235
  const ticks = ctx.marks(name, "path", rails, (d) => d.rail).attr("stroke", ctx.theme.inkSecondary).attr("stroke-width", 1).attr("fill", "none");
236
236
  ctx.set(ticks, { d: (d) => pick(d).map((value) => tick(d, value, size)).join("") });
237
237
  };
238
- stroke("ticks-major", (d) => d.marks.major, MAJOR);
239
- stroke("ticks-minor", (d) => d.marks.minor, MINOR);
238
+ stroke("axis-major", (d) => d.marks.major, MAJOR);
239
+ stroke("axis-minor", (d) => d.marks.minor, MINOR);
240
240
  const numbers = rails.flatMap((rail) => rail.marks.major.map((value) => {
241
241
  const [x, y] = at(rail.across, rail.scale.place(value));
242
242
  const out = 11;
@@ -1,4 +1,4 @@
1
- import { ChartFamily, DataShape, Dimension, Orientation } from "../../core/enums.js";
1
+ import { ChartFamily, DataShape, Dimension, Orientation, ScaleKind } from "../../core/enums.js";
2
2
  import { SampleData } from "../../data/SampleData.js";
3
3
  import { PlaneGeometry } from "./PlaneGeometry.js";
4
4
  import { PointDensityChart } from "./PointDensityChart.js";
@@ -65,7 +65,8 @@ var HexbinChart = class extends PointDensityChart {
65
65
  aggregate: "count",
66
66
  orientation: Orientation.Vertical,
67
67
  mesh: false,
68
- labels: false
68
+ labels: false,
69
+ toneScale: ScaleKind.Linear
69
70
  };
70
71
  }
71
72
  get sizeEncoded() {
@@ -76,7 +77,7 @@ var HexbinChart = class extends PointDensityChart {
76
77
  return aggregate === "count" ? points.length : aggregate === "sum" ? sum(points, (d) => d.w) : mean(points, (d) => d.w) ?? 0;
77
78
  }
78
79
  drawDensity(ctx, _axes, points) {
79
- const { radius, encoding, orientation, mesh, labels } = this.options;
80
+ const { radius, encoding, orientation, mesh, labels, toneScale } = this.options;
80
81
  const { width, height } = ctx.plot;
81
82
  const flat = orientation === Orientation.Horizontal;
82
83
  const lay = (a, b) => flat ? [b, a] : [a, b];
@@ -96,7 +97,8 @@ var HexbinChart = class extends PointDensityChart {
96
97
  const lattice = ctx.marks("mesh", "path", mesh ? [binner.centers().map(([a, b]) => lay(a, b)).filter(fits).map(([x, y]) => shape(x, y, radius - 1)).join("")] : []).attr("fill", "none").attr("stroke", ctx.theme.grid);
97
98
  ctx.set(lattice, { d: (d) => d });
98
99
  const scale = (value) => Math.sqrt(value / top);
99
- const tone = (d) => ctx.palette.sequential(encoding === "tone" ? .12 + .88 * d.value / top : .72);
100
+ const curve = (value) => toneScale === ScaleKind.Log ? Math.log1p(value) : toneScale === ScaleKind.Sqrt ? Math.sqrt(value) : value;
101
+ const tone = (d) => ctx.palette.sequential(encoding === "tone" ? .12 + .88 * curve(d.value) / curve(top) : .72);
100
102
  const gapped = radius - 1;
101
103
  const inner = (d) => encoding === "tone" ? gapped : Math.max(1.5, gapped * scale(d.value));
102
104
  const isDot = encoding === "dot";
@@ -0,0 +1,68 @@
1
+ import { Chart2D } from "../../core/Chart2D.js";
2
+ import { ArchitectureShapes } from "./ArchitectureShapes.js";
3
+ // src/charts/diagrams/ArchitectureCanvas.ts
4
+ var HEAD = 9;
5
+ var CORNER = 8;
6
+ var LINE = 12;
7
+ /** Connectors and link labels shared by both diagrams. `stage` is the context the diagram draws into. */
8
+ var ArchitectureCanvas = class extends Chart2D {
9
+ plotMargin() {
10
+ return {
11
+ top: 8,
12
+ right: 12,
13
+ bottom: 8,
14
+ left: 12
15
+ };
16
+ }
17
+ table() {
18
+ const links = this.options.data?.links ?? [], columns = [
19
+ "source",
20
+ "target",
21
+ ...this.linkFields
22
+ ];
23
+ return {
24
+ columns,
25
+ rows: links.map((link) => columns.map((column) => link[column]))
26
+ };
27
+ }
28
+ drawLinks(stage, views, ratio) {
29
+ const { theme } = stage;
30
+ const head = Math.min(18, HEAD / ratio);
31
+ const shorten = (view) => {
32
+ if (!view.arrow) return view.route;
33
+ const tip = view.route[view.route.length - 1], before = view.route[view.route.length - 2];
34
+ const length = Math.hypot(tip.x - before.x, tip.y - before.y) || 1, pull = Math.min(head * .8, length / 2);
35
+ return [...view.route.slice(0, -1), {
36
+ x: tip.x + (before.x - tip.x) * pull / length,
37
+ y: tip.y + (before.y - tip.y) * pull / length
38
+ }];
39
+ };
40
+ const lines = stage.marks("links", "path", views, (d) => d.key).attr("fill", "none").attr("stroke", theme.inkSecondary).attr("stroke-width", 2 / ratio).attr("stroke-linejoin", "round");
41
+ stage.set(lines, { d: (d) => ArchitectureShapes.route(shorten(d), CORNER) });
42
+ stage.drawOn(lines);
43
+ stage.hover(lines, (d) => d.tip);
44
+ const heads = stage.marks("heads", "path", views.filter((view) => view.arrow), (d) => d.key).attr("fill", theme.inkSecondary).style("pointer-events", "none");
45
+ stage.set(heads, { d: (d) => ArchitectureShapes.arrow(d.route[d.route.length - 2], d.route[d.route.length - 1], head) });
46
+ }
47
+ drawLinkLabels(stage, views, placed, size) {
48
+ const backs = stage.marks("link-backs", "rect", placed, (d) => views[d.index].key).attr("fill", stage.theme.surface).attr("rx", 2).style("pointer-events", "none");
49
+ stage.set(backs, {
50
+ x: (d) => d.rect.x,
51
+ y: (d) => d.rect.y,
52
+ width: (d) => d.rect.width,
53
+ height: (d) => d.rect.height
54
+ });
55
+ const lines = placed.flatMap((label) => label.lines.map((text, i) => ({
56
+ key: `${views[label.index].key}:${i}`,
57
+ text,
58
+ x: label.rect.x + label.rect.width / 2,
59
+ y: label.rect.y + (i + 1) * LINE * size / 10
60
+ })));
61
+ const words = stage.text(stage.marks("link-text", "text", lines, (d) => d.key), size, "secondary").attr("text-anchor", "middle").style("pointer-events", "none").text((d) => d.text);
62
+ stage.set(words, {
63
+ x: (d) => d.x,
64
+ y: (d) => d.y
65
+ });
66
+ }
67
+ };
68
+ export { ArchitectureCanvas };