@quantumwake/terminal-ux-dashboard-components 0.1.23 → 0.1.24
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 +19 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -275,6 +275,7 @@ var DEFAULT_CHART_STYLE = {
|
|
|
275
275
|
maxXTicks: 0,
|
|
276
276
|
maxYTicks: 0,
|
|
277
277
|
areaOpacity: 0.15,
|
|
278
|
+
yFromZero: false,
|
|
278
279
|
barLabels: true,
|
|
279
280
|
seriesColors: []
|
|
280
281
|
};
|
|
@@ -666,12 +667,17 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
|
|
|
666
667
|
]));
|
|
667
668
|
const longest = data.reduce((a, b) => b.data.length > a.data.length ? b : a, { id: "", data: [] });
|
|
668
669
|
const tickValues = thinTicks(longest.data.map((d) => d.x), s.maxXTicks);
|
|
670
|
+
let yScale = { type: "linear", min: "auto", max: "auto" };
|
|
671
|
+
if (s.yFromZero) {
|
|
672
|
+
const dataMax = Math.max(0, ...data.flatMap((serie) => serie.data.map((d) => Math.max(d.y, d.hi ?? d.y))));
|
|
673
|
+
yScale = { type: "linear", min: 0, max: niceCeil(dataMax) };
|
|
674
|
+
}
|
|
669
675
|
const bandedIds = new Set(data.filter((serie) => serie.data.some((d) => d.lo != null)).map((serie) => serie.id));
|
|
670
|
-
const bandsLayer = ({ series, yScale, lineGenerator }) => /* @__PURE__ */ jsx(Fragment, { children: series.map((serie) => {
|
|
676
|
+
const bandsLayer = ({ series, yScale: yScale2, lineGenerator }) => /* @__PURE__ */ jsx(Fragment, { children: series.map((serie) => {
|
|
671
677
|
const pts = serie.data.filter((d) => d.data.lo != null && d.data.hi != null && d.position.x != null);
|
|
672
678
|
if (pts.length < 2) return null;
|
|
673
|
-
const upper = lineGenerator(pts.map((d) => ({ x: d.position.x, y:
|
|
674
|
-
const lower = lineGenerator([...pts].reverse().map((d) => ({ x: d.position.x, y:
|
|
679
|
+
const upper = lineGenerator(pts.map((d) => ({ x: d.position.x, y: yScale2(d.data.hi) })));
|
|
680
|
+
const lower = lineGenerator([...pts].reverse().map((d) => ({ x: d.position.x, y: yScale2(d.data.lo) })));
|
|
675
681
|
if (!upper || !lower) return null;
|
|
676
682
|
return /* @__PURE__ */ jsx("path", { d: `${upper} L ${lower.slice(1)} Z`, fill: serie.color, opacity: 0.12 }, `band-${serie.id}`);
|
|
677
683
|
}) });
|
|
@@ -692,7 +698,7 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
|
|
|
692
698
|
data,
|
|
693
699
|
margin,
|
|
694
700
|
xScale: { type: "point" },
|
|
695
|
-
yScale
|
|
701
|
+
yScale,
|
|
696
702
|
curve: "monotoneX",
|
|
697
703
|
enableArea: s.areaOpacity > 0,
|
|
698
704
|
areaOpacity: s.areaOpacity,
|
|
@@ -710,6 +716,15 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
|
|
|
710
716
|
}
|
|
711
717
|
) });
|
|
712
718
|
}
|
|
719
|
+
function niceCeil(v) {
|
|
720
|
+
if (v <= 0) return 1;
|
|
721
|
+
const padded = v * 1.05;
|
|
722
|
+
const mag = Math.pow(10, Math.floor(Math.log10(padded)));
|
|
723
|
+
for (const step of [1, 2, 5, 10]) {
|
|
724
|
+
if (padded <= step * mag) return step * mag;
|
|
725
|
+
}
|
|
726
|
+
return 10 * mag;
|
|
727
|
+
}
|
|
713
728
|
function SparklineView({ data, height = 56, color = "#3987e5", showValue = false, format }) {
|
|
714
729
|
const gradientId = useId();
|
|
715
730
|
const width = 260;
|