@quantumwake/terminal-ux-dashboard-components 0.1.21 → 0.1.23
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 +26 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +26 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -652,7 +652,7 @@ function PieView({ records, groupColumn, data: presetData, style }) {
|
|
|
652
652
|
}
|
|
653
653
|
) });
|
|
654
654
|
}
|
|
655
|
-
function LineView({ records, xColumn, yColumn, data: presetData,
|
|
655
|
+
function LineView({ records, xColumn, yColumn, data: presetData, style }) {
|
|
656
656
|
const computed = react.useMemo(() => {
|
|
657
657
|
if (presetData || !records) return [];
|
|
658
658
|
const sorted = [...records].filter((r) => r[xColumn] != null && r[yColumn] != null).sort((a, b) => {
|
|
@@ -674,16 +674,23 @@ function LineView({ records, xColumn, yColumn, data: presetData, dashedIds, styl
|
|
|
674
674
|
]));
|
|
675
675
|
const longest = data.reduce((a, b) => b.data.length > a.data.length ? b : a, { id: "", data: [] });
|
|
676
676
|
const tickValues = thinTicks(longest.data.map((d) => d.x), s.maxXTicks);
|
|
677
|
-
const
|
|
677
|
+
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) => {
|
|
679
|
+
const pts = serie.data.filter((d) => d.data.lo != null && d.data.hi != null && d.position.x != null);
|
|
680
|
+
if (pts.length < 2) return null;
|
|
681
|
+
const upper = lineGenerator(pts.map((d) => ({ x: d.position.x, y: yScale(d.data.hi) })));
|
|
682
|
+
const lower = lineGenerator([...pts].reverse().map((d) => ({ x: d.position.x, y: yScale(d.data.lo) })));
|
|
683
|
+
if (!upper || !lower) return null;
|
|
684
|
+
return /* @__PURE__ */ jsxRuntime.jsx("path", { d: `${upper} L ${lower.slice(1)} Z`, fill: serie.color, opacity: 0.12 }, `band-${serie.id}`);
|
|
685
|
+
}) });
|
|
678
686
|
const linesLayer = ({ series, lineGenerator }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: series.map((serie) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
679
687
|
"path",
|
|
680
688
|
{
|
|
681
689
|
d: lineGenerator(serie.data.map((d) => d.position)),
|
|
682
690
|
fill: "none",
|
|
683
691
|
stroke: serie.color,
|
|
684
|
-
strokeWidth: 2,
|
|
685
|
-
strokeLinecap: "round"
|
|
686
|
-
strokeDasharray: dashed.has(String(serie.id)) ? "1 5" : void 0
|
|
692
|
+
strokeWidth: bandedIds.has(String(serie.id)) ? 2.5 : 1.5,
|
|
693
|
+
strokeLinecap: "round"
|
|
687
694
|
},
|
|
688
695
|
serie.id
|
|
689
696
|
)) });
|
|
@@ -706,12 +713,12 @@ function LineView({ records, xColumn, yColumn, data: presetData, dashedIds, styl
|
|
|
706
713
|
axisBottom: { ...makeAxis(style, "x", xColumn), ...tickValues ? { tickValues } : {} },
|
|
707
714
|
axisLeft: makeAxis(style, "y", yColumn, { numeric: true }),
|
|
708
715
|
useMesh: true,
|
|
709
|
-
layers: ["grid", "markers", "axes", "areas", linesLayer, "crosshair", "slices", "mesh", "legends"],
|
|
716
|
+
layers: ["grid", "markers", "axes", "areas", bandsLayer, linesLayer, "crosshair", "slices", "mesh", "legends"],
|
|
710
717
|
theme: buildNivoTheme(style)
|
|
711
718
|
}
|
|
712
719
|
) });
|
|
713
720
|
}
|
|
714
|
-
function SparklineView({ data, height = 56, color = "#3987e5" }) {
|
|
721
|
+
function SparklineView({ data, height = 56, color = "#3987e5", showValue = false, format }) {
|
|
715
722
|
const gradientId = react.useId();
|
|
716
723
|
const width = 260;
|
|
717
724
|
const pts = data && data.length ? data : [0];
|
|
@@ -720,13 +727,18 @@ function SparklineView({ data, height = 56, color = "#3987e5" }) {
|
|
|
720
727
|
const xy = (v, i) => [i * dx, height - v / max * (height - 4) - 2];
|
|
721
728
|
const line = pts.map((v, i) => `${i === 0 ? "M" : "L"} ${xy(v, i)[0].toFixed(1)} ${xy(v, i)[1].toFixed(1)}`).join(" ");
|
|
722
729
|
const area = `${line} L ${width} ${height} L 0 ${height} Z`;
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
+
const current = pts[pts.length - 1];
|
|
731
|
+
const readout = format ? format(current) : current.toLocaleString(void 0, { maximumFractionDigits: 1 });
|
|
732
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
733
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: `0 0 ${width} ${height}`, height, className: "w-full", preserveAspectRatio: "none", children: [
|
|
734
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
735
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "0%", stopColor: color, stopOpacity: "0.25" }),
|
|
736
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "100%", stopColor: color, stopOpacity: "0" })
|
|
737
|
+
] }) }),
|
|
738
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: area, fill: `url(#${gradientId})` }),
|
|
739
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: line, fill: "none", stroke: color, strokeWidth: "2", vectorEffect: "non-scaling-stroke" })
|
|
740
|
+
] }),
|
|
741
|
+
showValue && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-1 top-0 font-mono text-lg text-midnight-text-primary", children: readout })
|
|
730
742
|
] });
|
|
731
743
|
}
|
|
732
744
|
function ScatterView({ records, xColumn, yColumn, data: presetData, style }) {
|