@quantumwake/terminal-ux-dashboard-components 0.1.22 → 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.d.cts CHANGED
@@ -323,9 +323,14 @@ declare function PieView({ records, groupColumn, data: presetData, style }: PieV
323
323
 
324
324
  interface LineSerie {
325
325
  id: string;
326
+ /** lo/hi (optional, per point) draw a soft envelope band behind the
327
+ * line — the reading for "this line summarizes several": the band is
328
+ * the min–max spread of what it aggregates. */
326
329
  data: {
327
330
  x: string;
328
331
  y: number;
332
+ lo?: number;
333
+ hi?: number;
329
334
  }[];
330
335
  }
331
336
  interface LineViewProps {
@@ -334,12 +339,9 @@ interface LineViewProps {
334
339
  yColumn: string;
335
340
  /** Pre-shaped Nivo line series bypasses client-side processing. */
336
341
  data?: LineSerie[];
337
- /** Serie ids to draw dotted — the aggregate-vs-individual distinction
338
- * (an average line reads as derived, a member line as observed). */
339
- dashedIds?: string[];
340
342
  style?: Partial<ChartStyle>;
341
343
  }
342
- declare function LineView({ records, xColumn, yColumn, data: presetData, dashedIds, style }: LineViewProps): react.JSX.Element;
344
+ declare function LineView({ records, xColumn, yColumn, data: presetData, style }: LineViewProps): react.JSX.Element;
343
345
 
344
346
  interface SparklineViewProps {
345
347
  /** The series, oldest first. */
package/dist/index.d.ts CHANGED
@@ -323,9 +323,14 @@ declare function PieView({ records, groupColumn, data: presetData, style }: PieV
323
323
 
324
324
  interface LineSerie {
325
325
  id: string;
326
+ /** lo/hi (optional, per point) draw a soft envelope band behind the
327
+ * line — the reading for "this line summarizes several": the band is
328
+ * the min–max spread of what it aggregates. */
326
329
  data: {
327
330
  x: string;
328
331
  y: number;
332
+ lo?: number;
333
+ hi?: number;
329
334
  }[];
330
335
  }
331
336
  interface LineViewProps {
@@ -334,12 +339,9 @@ interface LineViewProps {
334
339
  yColumn: string;
335
340
  /** Pre-shaped Nivo line series bypasses client-side processing. */
336
341
  data?: LineSerie[];
337
- /** Serie ids to draw dotted — the aggregate-vs-individual distinction
338
- * (an average line reads as derived, a member line as observed). */
339
- dashedIds?: string[];
340
342
  style?: Partial<ChartStyle>;
341
343
  }
342
- declare function LineView({ records, xColumn, yColumn, data: presetData, dashedIds, style }: LineViewProps): react.JSX.Element;
344
+ declare function LineView({ records, xColumn, yColumn, data: presetData, style }: LineViewProps): react.JSX.Element;
343
345
 
344
346
  interface SparklineViewProps {
345
347
  /** The series, oldest first. */
package/dist/index.js CHANGED
@@ -644,7 +644,7 @@ function PieView({ records, groupColumn, data: presetData, style }) {
644
644
  }
645
645
  ) });
646
646
  }
647
- function LineView({ records, xColumn, yColumn, data: presetData, dashedIds, style }) {
647
+ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
648
648
  const computed = useMemo(() => {
649
649
  if (presetData || !records) return [];
650
650
  const sorted = [...records].filter((r) => r[xColumn] != null && r[yColumn] != null).sort((a, b) => {
@@ -666,16 +666,23 @@ function LineView({ records, xColumn, yColumn, data: presetData, dashedIds, styl
666
666
  ]));
667
667
  const longest = data.reduce((a, b) => b.data.length > a.data.length ? b : a, { id: "", data: [] });
668
668
  const tickValues = thinTicks(longest.data.map((d) => d.x), s.maxXTicks);
669
- const dashed = new Set(dashedIds || []);
669
+ 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) => {
671
+ const pts = serie.data.filter((d) => d.data.lo != null && d.data.hi != null && d.position.x != null);
672
+ if (pts.length < 2) return null;
673
+ const upper = lineGenerator(pts.map((d) => ({ x: d.position.x, y: yScale(d.data.hi) })));
674
+ const lower = lineGenerator([...pts].reverse().map((d) => ({ x: d.position.x, y: yScale(d.data.lo) })));
675
+ if (!upper || !lower) return null;
676
+ return /* @__PURE__ */ jsx("path", { d: `${upper} L ${lower.slice(1)} Z`, fill: serie.color, opacity: 0.12 }, `band-${serie.id}`);
677
+ }) });
670
678
  const linesLayer = ({ series, lineGenerator }) => /* @__PURE__ */ jsx(Fragment, { children: series.map((serie) => /* @__PURE__ */ jsx(
671
679
  "path",
672
680
  {
673
681
  d: lineGenerator(serie.data.map((d) => d.position)),
674
682
  fill: "none",
675
683
  stroke: serie.color,
676
- strokeWidth: 2,
677
- strokeLinecap: "round",
678
- strokeDasharray: dashed.has(String(serie.id)) ? "1 5" : void 0
684
+ strokeWidth: bandedIds.has(String(serie.id)) ? 2.5 : 1.5,
685
+ strokeLinecap: "round"
679
686
  },
680
687
  serie.id
681
688
  )) });
@@ -698,7 +705,7 @@ function LineView({ records, xColumn, yColumn, data: presetData, dashedIds, styl
698
705
  axisBottom: { ...makeAxis(style, "x", xColumn), ...tickValues ? { tickValues } : {} },
699
706
  axisLeft: makeAxis(style, "y", yColumn, { numeric: true }),
700
707
  useMesh: true,
701
- layers: ["grid", "markers", "axes", "areas", linesLayer, "crosshair", "slices", "mesh", "legends"],
708
+ layers: ["grid", "markers", "axes", "areas", bandsLayer, linesLayer, "crosshair", "slices", "mesh", "legends"],
702
709
  theme: buildNivoTheme(style)
703
710
  }
704
711
  ) });