circuit-to-svg 0.0.223 → 0.0.224
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 +49 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1788,7 +1788,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
1788
1788
|
var package_default = {
|
|
1789
1789
|
name: "circuit-to-svg",
|
|
1790
1790
|
type: "module",
|
|
1791
|
-
version: "0.0.
|
|
1791
|
+
version: "0.0.223",
|
|
1792
1792
|
description: "Convert Circuit JSON to SVG",
|
|
1793
1793
|
main: "dist/index.js",
|
|
1794
1794
|
files: [
|
|
@@ -8621,16 +8621,23 @@ function createLegend(graphs, width) {
|
|
|
8621
8621
|
return svgElement("g", { class: "legend" }, children);
|
|
8622
8622
|
}
|
|
8623
8623
|
function createDataGroup(graphs, clipPathId, scaleX, scaleY) {
|
|
8624
|
-
const
|
|
8625
|
-
|
|
8626
|
-
|
|
8624
|
+
const LINE_REPEAT_COUNT = 3;
|
|
8625
|
+
const DASH_PATTERN = [4, 8];
|
|
8626
|
+
const dashArrayString = DASH_PATTERN.map((value) => formatNumber(value)).join(
|
|
8627
|
+
" "
|
|
8628
|
+
);
|
|
8629
|
+
const dashCycleLength = DASH_PATTERN.reduce((sum, value) => sum + value, 0);
|
|
8630
|
+
const dashOffsetStep = dashCycleLength / LINE_REPEAT_COUNT;
|
|
8631
|
+
const processedGraphs = [];
|
|
8632
|
+
graphs.forEach((entry, graphIndex) => {
|
|
8633
|
+
if (entry.points.length === 0) return;
|
|
8627
8634
|
const commands = [];
|
|
8628
8635
|
entry.points.forEach((point, index) => {
|
|
8629
8636
|
const x = formatNumber(scaleX(point.timeMs));
|
|
8630
8637
|
const y = formatNumber(scaleY(point.voltage));
|
|
8631
8638
|
commands.push(`${index === 0 ? "M" : "L"} ${x} ${y}`);
|
|
8632
8639
|
});
|
|
8633
|
-
const
|
|
8640
|
+
const baseAttributes = {
|
|
8634
8641
|
class: "simulation-line",
|
|
8635
8642
|
d: commands.join(" "),
|
|
8636
8643
|
stroke: entry.color,
|
|
@@ -8638,29 +8645,52 @@ function createDataGroup(graphs, clipPathId, scaleX, scaleY) {
|
|
|
8638
8645
|
"data-simulation-transient-voltage-graph-id": entry.graph.simulation_transient_voltage_graph_id
|
|
8639
8646
|
};
|
|
8640
8647
|
if (entry.graph.schematic_voltage_probe_id) {
|
|
8641
|
-
|
|
8648
|
+
baseAttributes["data-schematic-voltage-probe-id"] = entry.graph.schematic_voltage_probe_id;
|
|
8642
8649
|
}
|
|
8643
8650
|
if (entry.graph.subcircuit_connecivity_map_key) {
|
|
8644
|
-
|
|
8651
|
+
baseAttributes["data-subcircuit-connectivity-map-key"] = entry.graph.subcircuit_connecivity_map_key;
|
|
8645
8652
|
}
|
|
8646
|
-
|
|
8647
|
-
entry.points.forEach((point) => {
|
|
8653
|
+
const pointElements2 = entry.points.map((point) => {
|
|
8648
8654
|
const cx = formatNumber(scaleX(point.timeMs));
|
|
8649
8655
|
const cy = formatNumber(scaleY(point.voltage));
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8656
|
+
return svgElement("circle", {
|
|
8657
|
+
class: "simulation-point",
|
|
8658
|
+
cx,
|
|
8659
|
+
cy,
|
|
8660
|
+
r: "3.5",
|
|
8661
|
+
stroke: entry.color,
|
|
8662
|
+
fill: "#ffffff",
|
|
8663
|
+
"clip-path": `url(#${clipPathId})`
|
|
8664
|
+
});
|
|
8665
|
+
});
|
|
8666
|
+
processedGraphs.push({
|
|
8667
|
+
entry,
|
|
8668
|
+
graphIndex,
|
|
8669
|
+
pathAttributes: baseAttributes,
|
|
8670
|
+
pointElements: pointElements2
|
|
8671
|
+
});
|
|
8672
|
+
});
|
|
8673
|
+
const lineElements = [];
|
|
8674
|
+
for (let cycle = 0; cycle < LINE_REPEAT_COUNT; cycle++) {
|
|
8675
|
+
processedGraphs.forEach((graphInfo) => {
|
|
8676
|
+
const offsetIndex = (graphInfo.graphIndex + cycle) % LINE_REPEAT_COUNT;
|
|
8677
|
+
const dashOffset = formatNumber(offsetIndex * dashOffsetStep);
|
|
8678
|
+
lineElements.push(
|
|
8679
|
+
svgElement("path", {
|
|
8680
|
+
...graphInfo.pathAttributes,
|
|
8681
|
+
"stroke-dasharray": dashArrayString,
|
|
8682
|
+
"stroke-dashoffset": dashOffset
|
|
8659
8683
|
})
|
|
8660
8684
|
);
|
|
8661
8685
|
});
|
|
8662
8686
|
}
|
|
8663
|
-
|
|
8687
|
+
const pointElements = processedGraphs.flatMap(
|
|
8688
|
+
(graphInfo) => graphInfo.pointElements
|
|
8689
|
+
);
|
|
8690
|
+
return svgElement("g", { class: "data-series" }, [
|
|
8691
|
+
...lineElements,
|
|
8692
|
+
...pointElements
|
|
8693
|
+
]);
|
|
8664
8694
|
}
|
|
8665
8695
|
function createTitleNode(experiment, width) {
|
|
8666
8696
|
if (!experiment?.name) return null;
|