impaktapps-design 0.2.993-alpha.230 → 0.2.993-alpha.231
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[
|
|
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 !==
|
|
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[
|
|
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[
|
|
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[
|
|
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();
|