impaktapps-design 0.2.993-alpha.230 → 0.2.993-alpha.232

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.
@@ -22504,6 +22504,7 @@ const AreaGraph = ({
22504
22504
  }), GraphRender]
22505
22505
  });
22506
22506
  };
22507
+ const TREND_KEY = "growthRate";
22507
22508
  const DrawStackBarLineGraph = ({
22508
22509
  width: width2,
22509
22510
  height: height2,
@@ -22529,13 +22530,13 @@ const DrawStackBarLineGraph = ({
22529
22530
  const yAxisTickCount = (_i = stackBarLineValue == null ? void 0 : stackBarLineValue.main) == null ? void 0 : _i.yAxisTickCount;
22530
22531
  const disableLeftLabel = (_j = stackBarLineValue.main) == null ? void 0 : _j.disableLeftLabel;
22531
22532
  const xAxisLabelMinWidth = ((_k = stackBarLineValue == null ? void 0 : stackBarLineValue.main) == null ? void 0 : _k.xAxisLabelMinWidth) || 56;
22532
- const trendColor = (_l = colorMap == null ? void 0 : colorMap["growthRate"]) != null ? _l : "#E24B4A";
22533
+ const trendColor = (_l = colorMap == null ? void 0 : colorMap[TREND_KEY]) != null ? _l : "#E24B4A";
22533
22534
  const labelsArray = useMemo(() => {
22534
22535
  if (!chartData.length)
22535
22536
  return [];
22536
22537
  return Object.keys(chartData[0]).filter((k2) => k2 !== xAxisValue);
22537
22538
  }, [chartData, xAxisValue]);
22538
- const barKeys = useMemo(() => labelsArray.filter((k2) => k2 !== "growthRate"), [labelsArray]);
22539
+ const barKeys = useMemo(() => labelsArray.filter((k2) => k2 !== TREND_KEY), [labelsArray]);
22539
22540
  const barData = useMemo(() => chartData.map((row) => {
22540
22541
  const stripped = {
22541
22542
  [xAxisValue]: row[xAxisValue]
@@ -22559,30 +22560,30 @@ const DrawStackBarLineGraph = ({
22559
22560
  nice: true
22560
22561
  }), [innerHeight, maxStacked]);
22561
22562
  const trendScale = useMemo(() => {
22562
- const vals = chartData.map((d2) => Number(d2["growthRate"]) || 0);
22563
+ const vals = chartData.map((d2) => Number(d2[TREND_KEY]) || 0);
22563
22564
  return createLinearScale({
22564
22565
  domain: [Math.min(...vals), Math.max(...vals)],
22565
22566
  range: [innerHeight, 0],
22566
22567
  nice: true
22567
22568
  });
22568
22569
  }, [chartData, innerHeight]);
22569
- const getBarCentreX = (cat) => {
22570
+ const getBarCentreX = useCallback((cat) => {
22570
22571
  var _a2;
22571
22572
  return ((_a2 = categoryScale(cat)) != null ? _a2 : 0) + categoryScale.bandwidth() / 2;
22572
- };
22573
- const getLineX = (d2) => getBarCentreX(d2[xAxisValue]);
22574
- const getLineY = (d2) => trendScale(Number(d2["growthRate"]) || 0);
22573
+ }, [categoryScale]);
22574
+ const getLineX = useCallback((d2) => getBarCentreX(d2[xAxisValue]), [getBarCentreX, xAxisValue]);
22575
+ const getLineY = useCallback((d2) => trendScale(Number(d2[TREND_KEY]) || 0), [trendScale]);
22575
22576
  const handleColumnEnter = useCallback((_e2, cat) => {
22576
22577
  const full = chartData.find((d2) => d2[xAxisValue] === cat);
22577
22578
  const dotX = getBarCentreX(cat) + margin2.left;
22578
- const dotY = trendScale(Number(full["growthRate"]) || 0) + margin2.top;
22579
+ const dotY = trendScale(Number(full[TREND_KEY]) || 0) + margin2.top;
22579
22580
  setHoveredCategory(cat);
22580
22581
  showTooltip({
22581
22582
  tooltipData: full,
22582
22583
  tooltipLeft: dotX + 14,
22583
22584
  tooltipTop: dotY - 12
22584
22585
  });
22585
- }, [chartData, xAxisValue, trendScale, margin2, showTooltip]);
22586
+ }, [chartData, xAxisValue, trendScale, margin2, showTooltip, getBarCentreX]);
22586
22587
  const handleColumnLeave = useCallback(() => {
22587
22588
  setHoveredCategory(null);
22588
22589
  hideTooltip();
@@ -22609,16 +22610,34 @@ const DrawStackBarLineGraph = ({
22609
22610
  var _a2;
22610
22611
  return (_a2 = colorMap == null ? void 0 : colorMap[key]) != null ? _a2 : defaultColour;
22611
22612
  },
22612
- children: (barStacks) => barStacks.map((barStack) => barStack.bars.map((bar) => /* @__PURE__ */ jsx$1("rect", {
22613
- x: bar.x,
22614
- y: bar.y,
22615
- width: bar.width,
22616
- height: bar.height,
22617
- fill: bar.color,
22618
- opacity: 0.88,
22619
- rx: 6,
22620
- ry: 6
22621
- }, `bar-${barStack.index}-${bar.index}`)))
22613
+ children: (barStacks) => {
22614
+ const topStackIndex = barStacks.length - 1;
22615
+ return barStacks.map((barStack, stackIdx) => barStack.bars.map((bar) => {
22616
+ const isTop = stackIdx === topStackIndex;
22617
+ const r2 = 6;
22618
+ return isTop ? /* @__PURE__ */ jsx$1("path", {
22619
+ d: `
22620
+ M ${bar.x + r2},${bar.y}
22621
+ h ${bar.width - 2 * r2}
22622
+ q ${r2},0 ${r2},${r2}
22623
+ v ${bar.height - r2}
22624
+ h ${-bar.width}
22625
+ v ${-(bar.height - r2)}
22626
+ q 0,${-r2} ${r2},${-r2}
22627
+ z
22628
+ `,
22629
+ fill: bar.color,
22630
+ opacity: 0.88
22631
+ }, `bar-${barStack.index}-${bar.index}`) : /* @__PURE__ */ jsx$1("rect", {
22632
+ x: bar.x,
22633
+ y: bar.y,
22634
+ width: bar.width,
22635
+ height: bar.height,
22636
+ fill: bar.color,
22637
+ opacity: 0.88
22638
+ }, `bar-${barStack.index}-${bar.index}`);
22639
+ }));
22640
+ }
22622
22641
  }), /* @__PURE__ */ jsx$1(GridRows$1, {
22623
22642
  scale: barScale,
22624
22643
  width: innerWidth,
@@ -22742,7 +22761,7 @@ const DrawStackBarLineGraph = ({
22742
22761
  border: "none",
22743
22762
  borderRadius: 8,
22744
22763
  boxShadow: "0 4px 16px rgba(0,0,0,0.35)",
22745
- padding: "8px 12px",
22764
+ padding: "15px 12px",
22746
22765
  fontSize: 12,
22747
22766
  minWidth: 160
22748
22767
  },
@@ -22750,7 +22769,7 @@ const DrawStackBarLineGraph = ({
22750
22769
  style: {
22751
22770
  fontWeight: 600,
22752
22771
  color: "#454444",
22753
- margin: "0 0 6px",
22772
+ margin: "0 0 12px",
22754
22773
  fontSize: 13
22755
22774
  },
22756
22775
  children: tooltipData[xAxisValue]
@@ -22758,7 +22777,7 @@ const DrawStackBarLineGraph = ({
22758
22777
  style: {
22759
22778
  display: "flex",
22760
22779
  flexDirection: "column",
22761
- gap: 10
22780
+ gap: 11
22762
22781
  },
22763
22782
  children: labelsArray.map((key) => {
22764
22783
  var _a2, _b2;