circuit-to-svg 0.0.276 → 0.0.277
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 +21 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4350,7 +4350,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
4350
4350
|
var package_default = {
|
|
4351
4351
|
name: "circuit-to-svg",
|
|
4352
4352
|
type: "module",
|
|
4353
|
-
version: "0.0.
|
|
4353
|
+
version: "0.0.276",
|
|
4354
4354
|
description: "Convert Circuit JSON to SVG",
|
|
4355
4355
|
main: "dist/index.js",
|
|
4356
4356
|
files: [
|
|
@@ -10871,7 +10871,10 @@ function convertCircuitJsonToSimulationGraphSvg({
|
|
|
10871
10871
|
);
|
|
10872
10872
|
}
|
|
10873
10873
|
const timeAxis = buildAxisInfo(allPoints.map((point) => point.timeMs));
|
|
10874
|
-
const voltageAxis = buildAxisInfo(
|
|
10874
|
+
const voltageAxis = buildAxisInfo(
|
|
10875
|
+
allPoints.map((point) => point.voltage),
|
|
10876
|
+
true
|
|
10877
|
+
);
|
|
10875
10878
|
const plotWidth = Math.max(1, width - MARGIN.left - MARGIN.right);
|
|
10876
10879
|
const plotHeight = Math.max(1, height - MARGIN.top - MARGIN.bottom);
|
|
10877
10880
|
const scaleX = createLinearScale(
|
|
@@ -10990,7 +10993,7 @@ function getTimestamps(graph) {
|
|
|
10990
10993
|
}
|
|
10991
10994
|
return timestamps;
|
|
10992
10995
|
}
|
|
10993
|
-
function buildAxisInfo(values) {
|
|
10996
|
+
function buildAxisInfo(values, applyPadding = false) {
|
|
10994
10997
|
if (values.length === 0) {
|
|
10995
10998
|
return {
|
|
10996
10999
|
domainMin: 0,
|
|
@@ -11009,9 +11012,21 @@ function buildAxisInfo(values) {
|
|
|
11009
11012
|
};
|
|
11010
11013
|
}
|
|
11011
11014
|
const ticks = generateTickValues(min, max);
|
|
11012
|
-
const safeTicks = ticks.length > 0 ? ticks : [min, max];
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
+
const safeTicks = ticks.length > 0 ? [...ticks] : [min, max];
|
|
11016
|
+
let domainMin = safeTicks[0];
|
|
11017
|
+
let domainMax = safeTicks[safeTicks.length - 1];
|
|
11018
|
+
if (applyPadding && safeTicks.length > 1) {
|
|
11019
|
+
const tickStep = Math.abs(safeTicks[1] - safeTicks[0]);
|
|
11020
|
+
const PADDING_TOLERANCE_RATIO = 0.1;
|
|
11021
|
+
if (min < domainMin + tickStep * PADDING_TOLERANCE_RATIO) {
|
|
11022
|
+
domainMin -= tickStep;
|
|
11023
|
+
safeTicks.unshift(domainMin);
|
|
11024
|
+
}
|
|
11025
|
+
if (max > domainMax - tickStep * PADDING_TOLERANCE_RATIO) {
|
|
11026
|
+
domainMax += tickStep;
|
|
11027
|
+
safeTicks.push(domainMax);
|
|
11028
|
+
}
|
|
11029
|
+
}
|
|
11015
11030
|
return { domainMin, domainMax, ticks: safeTicks };
|
|
11016
11031
|
}
|
|
11017
11032
|
function generateTickValues(min, max, desired = 6) {
|