@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.cjs
CHANGED
|
@@ -283,6 +283,7 @@ var DEFAULT_CHART_STYLE = {
|
|
|
283
283
|
maxXTicks: 0,
|
|
284
284
|
maxYTicks: 0,
|
|
285
285
|
areaOpacity: 0.15,
|
|
286
|
+
yFromZero: false,
|
|
286
287
|
barLabels: true,
|
|
287
288
|
seriesColors: []
|
|
288
289
|
};
|
|
@@ -674,12 +675,17 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
|
|
|
674
675
|
]));
|
|
675
676
|
const longest = data.reduce((a, b) => b.data.length > a.data.length ? b : a, { id: "", data: [] });
|
|
676
677
|
const tickValues = thinTicks(longest.data.map((d) => d.x), s.maxXTicks);
|
|
678
|
+
let yScale = { type: "linear", min: "auto", max: "auto" };
|
|
679
|
+
if (s.yFromZero) {
|
|
680
|
+
const dataMax = Math.max(0, ...data.flatMap((serie) => serie.data.map((d) => Math.max(d.y, d.hi ?? d.y))));
|
|
681
|
+
yScale = { type: "linear", min: 0, max: niceCeil(dataMax) };
|
|
682
|
+
}
|
|
677
683
|
const bandedIds = new Set(data.filter((serie) => serie.data.some((d) => d.lo != null)).map((serie) => serie.id));
|
|
678
|
-
const bandsLayer = ({ series, yScale, lineGenerator }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: series.map((serie) => {
|
|
684
|
+
const bandsLayer = ({ series, yScale: yScale2, lineGenerator }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: series.map((serie) => {
|
|
679
685
|
const pts = serie.data.filter((d) => d.data.lo != null && d.data.hi != null && d.position.x != null);
|
|
680
686
|
if (pts.length < 2) return null;
|
|
681
|
-
const upper = lineGenerator(pts.map((d) => ({ x: d.position.x, y:
|
|
682
|
-
const lower = lineGenerator([...pts].reverse().map((d) => ({ x: d.position.x, y:
|
|
687
|
+
const upper = lineGenerator(pts.map((d) => ({ x: d.position.x, y: yScale2(d.data.hi) })));
|
|
688
|
+
const lower = lineGenerator([...pts].reverse().map((d) => ({ x: d.position.x, y: yScale2(d.data.lo) })));
|
|
683
689
|
if (!upper || !lower) return null;
|
|
684
690
|
return /* @__PURE__ */ jsxRuntime.jsx("path", { d: `${upper} L ${lower.slice(1)} Z`, fill: serie.color, opacity: 0.12 }, `band-${serie.id}`);
|
|
685
691
|
}) });
|
|
@@ -700,7 +706,7 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
|
|
|
700
706
|
data,
|
|
701
707
|
margin,
|
|
702
708
|
xScale: { type: "point" },
|
|
703
|
-
yScale
|
|
709
|
+
yScale,
|
|
704
710
|
curve: "monotoneX",
|
|
705
711
|
enableArea: s.areaOpacity > 0,
|
|
706
712
|
areaOpacity: s.areaOpacity,
|
|
@@ -718,6 +724,15 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
|
|
|
718
724
|
}
|
|
719
725
|
) });
|
|
720
726
|
}
|
|
727
|
+
function niceCeil(v) {
|
|
728
|
+
if (v <= 0) return 1;
|
|
729
|
+
const padded = v * 1.05;
|
|
730
|
+
const mag = Math.pow(10, Math.floor(Math.log10(padded)));
|
|
731
|
+
for (const step of [1, 2, 5, 10]) {
|
|
732
|
+
if (padded <= step * mag) return step * mag;
|
|
733
|
+
}
|
|
734
|
+
return 10 * mag;
|
|
735
|
+
}
|
|
721
736
|
function SparklineView({ data, height = 56, color = "#3987e5", showValue = false, format }) {
|
|
722
737
|
const gradientId = react.useId();
|
|
723
738
|
const width = 260;
|