circuit-to-svg 0.0.458 → 0.0.459
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.js +33 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9115,7 +9115,7 @@ var package_default = {
|
|
|
9115
9115
|
engines: {
|
|
9116
9116
|
node: "24.x"
|
|
9117
9117
|
},
|
|
9118
|
-
version: "0.0.
|
|
9118
|
+
version: "0.0.458",
|
|
9119
9119
|
repository: {
|
|
9120
9120
|
type: "git",
|
|
9121
9121
|
url: "https://github.com/tscircuit/circuit-to-svg.git"
|
|
@@ -20442,8 +20442,35 @@ function wrapLegendText(label) {
|
|
|
20442
20442
|
return lines;
|
|
20443
20443
|
}
|
|
20444
20444
|
|
|
20445
|
-
// lib/sim/simulation-graph-svg/create-legend.ts
|
|
20445
|
+
// lib/sim/simulation-graph-svg/create-legend/get-legend-bounds.ts
|
|
20446
20446
|
var LEGEND_MIN_SPACING = 24;
|
|
20447
|
+
var LEGEND_FONT_SIZE = 11;
|
|
20448
|
+
var LEGEND_PADDING = 16;
|
|
20449
|
+
function getLegendBounds({
|
|
20450
|
+
graphs,
|
|
20451
|
+
width,
|
|
20452
|
+
height
|
|
20453
|
+
}) {
|
|
20454
|
+
let legendY = MARGIN.top;
|
|
20455
|
+
let rightEdge = width;
|
|
20456
|
+
let bottomEdge = height;
|
|
20457
|
+
for (const graph of graphs) {
|
|
20458
|
+
const lines = wrapLegendText(graph.label);
|
|
20459
|
+
const textWidth = Math.max(...lines.map((line) => estimateTextWidth(line))) * LEGEND_FONT_SIZE;
|
|
20460
|
+
rightEdge = Math.max(
|
|
20461
|
+
rightEdge,
|
|
20462
|
+
width - MARGIN.right + 30 + textWidth * 1.2 + LEGEND_PADDING
|
|
20463
|
+
);
|
|
20464
|
+
bottomEdge = Math.max(
|
|
20465
|
+
bottomEdge,
|
|
20466
|
+
legendY + (lines.length - 1) * LEGEND_LINE_HEIGHT + LEGEND_FONT_SIZE + LEGEND_PADDING
|
|
20467
|
+
);
|
|
20468
|
+
legendY += Math.max(lines.length * LEGEND_LINE_HEIGHT, LEGEND_MIN_SPACING);
|
|
20469
|
+
}
|
|
20470
|
+
return { width: Math.ceil(rightEdge), height: Math.ceil(bottomEdge) };
|
|
20471
|
+
}
|
|
20472
|
+
|
|
20473
|
+
// lib/sim/simulation-graph-svg/create-legend.ts
|
|
20447
20474
|
function createLegend(graphs, width) {
|
|
20448
20475
|
let currentY = MARGIN.top;
|
|
20449
20476
|
const children = graphs.map((entry) => {
|
|
@@ -20914,9 +20941,10 @@ function convertCircuitJsonToSimulationGraphSvg({
|
|
|
20914
20941
|
(entry) => entry.usesScopeTraceDisplay
|
|
20915
20942
|
);
|
|
20916
20943
|
const scopeAxisGutters = usesScopeTraceDisplay ? getScopeAxisGutters(preparedGraphs.length) : { left: 0, right: 0 };
|
|
20917
|
-
const
|
|
20944
|
+
const regularLegendBounds = usesScopeTraceDisplay ? null : getLegendBounds({ graphs: preparedGraphs, width, height });
|
|
20945
|
+
const outputWidth = regularLegendBounds?.width ?? width + scopeAxisGutters.left + scopeAxisGutters.right;
|
|
20918
20946
|
const scopeLegendLayout = usesScopeTraceDisplay ? getScopeLegendGridLayout(preparedGraphs.length, outputWidth) : null;
|
|
20919
|
-
const outputHeight = scopeLegendLayout ? height + SCOPE_LEGEND_GAP + scopeLegendLayout.height + SCOPE_LEGEND_GAP : height;
|
|
20947
|
+
const outputHeight = scopeLegendLayout ? height + SCOPE_LEGEND_GAP + scopeLegendLayout.height + SCOPE_LEGEND_GAP : regularLegendBounds.height;
|
|
20920
20948
|
const plotWidth = Math.max(1, width - MARGIN.left - MARGIN.right);
|
|
20921
20949
|
const plotHeight = Math.max(1, height - MARGIN.top - MARGIN.bottom);
|
|
20922
20950
|
const plotLeft = MARGIN.left + scopeAxisGutters.left;
|
|
@@ -20966,7 +20994,7 @@ function convertCircuitJsonToSimulationGraphSvg({
|
|
|
20966
20994
|
xAxisTitle: normalizedResults.xAxisTitle,
|
|
20967
20995
|
usesScopeTraceDisplay
|
|
20968
20996
|
}),
|
|
20969
|
-
usesScopeTraceDisplay ? createScopeLegend(preparedGraphs, outputWidth, height) : createLegend(preparedGraphs,
|
|
20997
|
+
usesScopeTraceDisplay ? createScopeLegend(preparedGraphs, outputWidth, height) : createLegend(preparedGraphs, width),
|
|
20970
20998
|
...titleNode ? [titleNode] : []
|
|
20971
20999
|
];
|
|
20972
21000
|
const svgObject = svgElement(
|