@quantumwake/terminal-ux-dashboard-components 0.1.21 → 0.1.22
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 +13 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -348,8 +348,13 @@ interface SparklineViewProps {
|
|
|
348
348
|
height?: number;
|
|
349
349
|
/** Line + area hue. */
|
|
350
350
|
color?: string;
|
|
351
|
+
/** Show the CURRENT (last) value as a readout over the mark — a trend
|
|
352
|
+
* shape without its number answers "which way", never "how much". */
|
|
353
|
+
showValue?: boolean;
|
|
354
|
+
/** Formats the readout (e.g. v => `${v.toFixed(1)} ms`). Default: locale. */
|
|
355
|
+
format?: (v: number) => string;
|
|
351
356
|
}
|
|
352
|
-
declare function SparklineView({ data, height, color }: SparklineViewProps): react.JSX.Element;
|
|
357
|
+
declare function SparklineView({ data, height, color, showValue, format }: SparklineViewProps): react.JSX.Element;
|
|
353
358
|
|
|
354
359
|
interface ScatterSerie {
|
|
355
360
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -348,8 +348,13 @@ interface SparklineViewProps {
|
|
|
348
348
|
height?: number;
|
|
349
349
|
/** Line + area hue. */
|
|
350
350
|
color?: string;
|
|
351
|
+
/** Show the CURRENT (last) value as a readout over the mark — a trend
|
|
352
|
+
* shape without its number answers "which way", never "how much". */
|
|
353
|
+
showValue?: boolean;
|
|
354
|
+
/** Formats the readout (e.g. v => `${v.toFixed(1)} ms`). Default: locale. */
|
|
355
|
+
format?: (v: number) => string;
|
|
351
356
|
}
|
|
352
|
-
declare function SparklineView({ data, height, color }: SparklineViewProps): react.JSX.Element;
|
|
357
|
+
declare function SparklineView({ data, height, color, showValue, format }: SparklineViewProps): react.JSX.Element;
|
|
353
358
|
|
|
354
359
|
interface ScatterSerie {
|
|
355
360
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -703,7 +703,7 @@ function LineView({ records, xColumn, yColumn, data: presetData, dashedIds, styl
|
|
|
703
703
|
}
|
|
704
704
|
) });
|
|
705
705
|
}
|
|
706
|
-
function SparklineView({ data, height = 56, color = "#3987e5" }) {
|
|
706
|
+
function SparklineView({ data, height = 56, color = "#3987e5", showValue = false, format }) {
|
|
707
707
|
const gradientId = useId();
|
|
708
708
|
const width = 260;
|
|
709
709
|
const pts = data && data.length ? data : [0];
|
|
@@ -712,13 +712,18 @@ function SparklineView({ data, height = 56, color = "#3987e5" }) {
|
|
|
712
712
|
const xy = (v, i) => [i * dx, height - v / max * (height - 4) - 2];
|
|
713
713
|
const line = pts.map((v, i) => `${i === 0 ? "M" : "L"} ${xy(v, i)[0].toFixed(1)} ${xy(v, i)[1].toFixed(1)}`).join(" ");
|
|
714
714
|
const area = `${line} L ${width} ${height} L 0 ${height} Z`;
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
715
|
+
const current = pts[pts.length - 1];
|
|
716
|
+
const readout = format ? format(current) : current.toLocaleString(void 0, { maximumFractionDigits: 1 });
|
|
717
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
718
|
+
/* @__PURE__ */ jsxs("svg", { viewBox: `0 0 ${width} ${height}`, height, className: "w-full", preserveAspectRatio: "none", children: [
|
|
719
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
720
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: "0.25" }),
|
|
721
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: "0" })
|
|
722
|
+
] }) }),
|
|
723
|
+
/* @__PURE__ */ jsx("path", { d: area, fill: `url(#${gradientId})` }),
|
|
724
|
+
/* @__PURE__ */ jsx("path", { d: line, fill: "none", stroke: color, strokeWidth: "2", vectorEffect: "non-scaling-stroke" })
|
|
725
|
+
] }),
|
|
726
|
+
showValue && /* @__PURE__ */ jsx("span", { className: "absolute right-1 top-0 font-mono text-lg text-midnight-text-primary", children: readout })
|
|
722
727
|
] });
|
|
723
728
|
}
|
|
724
729
|
function ScatterView({ records, xColumn, yColumn, data: presetData, style }) {
|