@quantumwake/terminal-ux-dashboard-components 0.1.23 → 0.1.25

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
@@ -146,7 +146,9 @@ interface ChartStyle {
146
146
  maxXTicks: number;
147
147
  maxYTicks: number;
148
148
  areaOpacity: number;
149
+ yFromZero: boolean;
149
150
  barLabels: boolean;
151
+ animate: boolean;
150
152
  seriesColors: string[];
151
153
  }
152
154
  declare const DEFAULT_CHART_STYLE: ChartStyle;
package/dist/index.d.ts CHANGED
@@ -146,7 +146,9 @@ interface ChartStyle {
146
146
  maxXTicks: number;
147
147
  maxYTicks: number;
148
148
  areaOpacity: number;
149
+ yFromZero: boolean;
149
150
  barLabels: boolean;
151
+ animate: boolean;
150
152
  seriesColors: string[];
151
153
  }
152
154
  declare const DEFAULT_CHART_STYLE: ChartStyle;
package/dist/index.js CHANGED
@@ -275,7 +275,9 @@ var DEFAULT_CHART_STYLE = {
275
275
  maxXTicks: 0,
276
276
  maxYTicks: 0,
277
277
  areaOpacity: 0.15,
278
+ yFromZero: false,
278
279
  barLabels: true,
280
+ animate: false,
279
281
  seriesColors: []
280
282
  };
281
283
  var DEFAULT_SERIES_COLORS = [
@@ -602,6 +604,7 @@ function BarView({ records, groupColumn, valueColumn, aggFn = "count", data: pre
602
604
  labelSkipWidth: 12,
603
605
  labelSkipHeight: 12,
604
606
  labelTextColor: { from: "color", modifiers: [["darker", 3]] },
607
+ animate: s.animate,
605
608
  theme: buildNivoTheme(style)
606
609
  }
607
610
  ) });
@@ -640,6 +643,7 @@ function PieView({ records, groupColumn, data: presetData, style }) {
640
643
  arcLabelsSkipAngle: 10,
641
644
  arcLabelsTextColor: { from: "color", modifiers: [["darker", 3]] },
642
645
  legends: legend ? [legend] : [],
646
+ animate: s.animate,
643
647
  theme: buildNivoTheme(style)
644
648
  }
645
649
  ) });
@@ -666,12 +670,17 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
666
670
  ]));
667
671
  const longest = data.reduce((a, b) => b.data.length > a.data.length ? b : a, { id: "", data: [] });
668
672
  const tickValues = thinTicks(longest.data.map((d) => d.x), s.maxXTicks);
673
+ let yScale = { type: "linear", min: "auto", max: "auto" };
674
+ if (s.yFromZero) {
675
+ const dataMax = Math.max(0, ...data.flatMap((serie) => serie.data.map((d) => Math.max(d.y, d.hi ?? d.y))));
676
+ yScale = { type: "linear", min: 0, max: niceCeil(dataMax) };
677
+ }
669
678
  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) => {
679
+ const bandsLayer = ({ series, yScale: yScale2, lineGenerator }) => /* @__PURE__ */ jsx(Fragment, { children: series.map((serie) => {
671
680
  const pts = serie.data.filter((d) => d.data.lo != null && d.data.hi != null && d.position.x != null);
672
681
  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) })));
682
+ const upper = lineGenerator(pts.map((d) => ({ x: d.position.x, y: yScale2(d.data.hi) })));
683
+ const lower = lineGenerator([...pts].reverse().map((d) => ({ x: d.position.x, y: yScale2(d.data.lo) })));
675
684
  if (!upper || !lower) return null;
676
685
  return /* @__PURE__ */ jsx("path", { d: `${upper} L ${lower.slice(1)} Z`, fill: serie.color, opacity: 0.12 }, `band-${serie.id}`);
677
686
  }) });
@@ -692,7 +701,7 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
692
701
  data,
693
702
  margin,
694
703
  xScale: { type: "point" },
695
- yScale: { type: "linear", min: "auto", max: "auto" },
704
+ yScale,
696
705
  curve: "monotoneX",
697
706
  enableArea: s.areaOpacity > 0,
698
707
  areaOpacity: s.areaOpacity,
@@ -706,10 +715,20 @@ function LineView({ records, xColumn, yColumn, data: presetData, style }) {
706
715
  axisLeft: makeAxis(style, "y", yColumn, { numeric: true }),
707
716
  useMesh: true,
708
717
  layers: ["grid", "markers", "axes", "areas", bandsLayer, linesLayer, "crosshair", "slices", "mesh", "legends"],
718
+ animate: s.animate,
709
719
  theme: buildNivoTheme(style)
710
720
  }
711
721
  ) });
712
722
  }
723
+ function niceCeil(v) {
724
+ if (v <= 0) return 1;
725
+ const padded = v * 1.05;
726
+ const mag = Math.pow(10, Math.floor(Math.log10(padded)));
727
+ for (const step of [1, 2, 5, 10]) {
728
+ if (padded <= step * mag) return step * mag;
729
+ }
730
+ return 10 * mag;
731
+ }
713
732
  function SparklineView({ data, height = 56, color = "#3987e5", showValue = false, format }) {
714
733
  const gradientId = useId();
715
734
  const width = 260;
@@ -758,6 +777,7 @@ function ScatterView({ records, xColumn, yColumn, data: presetData, style }) {
758
777
  axisBottom: makeAxis(style, "x", xColumn, { numeric: true }),
759
778
  axisLeft: makeAxis(style, "y", yColumn, { numeric: true }),
760
779
  useMesh: true,
780
+ animate: s.animate,
761
781
  theme: buildNivoTheme(style)
762
782
  }
763
783
  ) });
@@ -865,6 +885,7 @@ function HeatmapView({
865
885
  borderColor: "#334155",
866
886
  labelTextColor: { from: "color", modifiers: [["darker", 3]] },
867
887
  hoverTarget: "cell",
888
+ animate: s.animate,
868
889
  theme: buildNivoTheme(style)
869
890
  }
870
891
  ) });
@@ -1019,6 +1040,7 @@ function HeatmapPlusView({
1019
1040
  borderColor: "#334155",
1020
1041
  labelTextColor: ((cell) => heatLabelColor(tAt(cell.serieId, cell.data.x))),
1021
1042
  hoverTarget: "cell",
1043
+ animate: s.animate,
1022
1044
  theme: buildNivoTheme(style)
1023
1045
  }
1024
1046
  ) });