impaktapps-design 0.2.993-alpha.233 → 0.2.993-alpha.235
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/impaktapps-design.es.js +55 -47
- package/dist/impaktapps-design.es.js.map +1 -1
- package/dist/impaktapps-design.umd.js +24 -24
- package/dist/impaktapps-design.umd.js.map +1 -1
- package/dist/src/utils/finalDataProvider.d.ts +0 -1
- package/package.json +1 -1
- package/src/component/AreaGraph/DrawAreaGraph.tsx +30 -19
- package/src/component/StackBarLineGraph/DrawStackBarLineGraph.tsx +37 -17
- package/src/utils/finalDataProvider.ts +1 -18
|
@@ -19146,7 +19146,7 @@ ParentSize$1.propTypes = {
|
|
|
19146
19146
|
children: _pt.func.isRequired
|
|
19147
19147
|
};
|
|
19148
19148
|
const finalDataProvider = (type2, value, theme) => {
|
|
19149
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t5, _u, _v, _w
|
|
19149
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t5, _u, _v, _w;
|
|
19150
19150
|
switch (type2) {
|
|
19151
19151
|
case "BarGraph":
|
|
19152
19152
|
case "StackBarGraph":
|
|
@@ -19281,24 +19281,12 @@ const finalDataProvider = (type2, value, theme) => {
|
|
|
19281
19281
|
...(_w = value.style) == null ? void 0 : _w.labelStyle
|
|
19282
19282
|
},
|
|
19283
19283
|
stackBarLineStyle: {
|
|
19284
|
-
...value.style
|
|
19285
|
-
colorMap: (_x = value.style) == null ? void 0 : _x.colorMap
|
|
19284
|
+
...value.style
|
|
19286
19285
|
}
|
|
19287
19286
|
}
|
|
19288
19287
|
};
|
|
19289
19288
|
}
|
|
19290
19289
|
};
|
|
19291
|
-
function getVisibleXAxisLabels(data, xAxisValue, innerWidth, minLabelWidth = 56) {
|
|
19292
|
-
const allXLabels = data.map((d2) => d2[xAxisValue]);
|
|
19293
|
-
const totalLabels = allXLabels.length;
|
|
19294
|
-
if (totalLabels === 0)
|
|
19295
|
-
return allXLabels;
|
|
19296
|
-
const maxVisibleLabels = Math.max(1, Math.floor(innerWidth / minLabelWidth));
|
|
19297
|
-
if (maxVisibleLabels >= totalLabels)
|
|
19298
|
-
return allXLabels;
|
|
19299
|
-
const skipInterval = Math.ceil(totalLabels / maxVisibleLabels);
|
|
19300
|
-
return allXLabels.filter((_2, i) => i % skipInterval === 0 || i === totalLabels - 1);
|
|
19301
|
-
}
|
|
19302
19290
|
const BarGraph = ({
|
|
19303
19291
|
value,
|
|
19304
19292
|
theme
|
|
@@ -22176,11 +22164,11 @@ LinearGradient.propTypes = {
|
|
|
22176
22164
|
const DrawAreaGraph = ({
|
|
22177
22165
|
width: width2,
|
|
22178
22166
|
height: height2,
|
|
22179
|
-
margin:
|
|
22167
|
+
margin: marginProp,
|
|
22180
22168
|
areaValue,
|
|
22181
22169
|
theme
|
|
22182
22170
|
}) => {
|
|
22183
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
22171
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
22184
22172
|
const {
|
|
22185
22173
|
tooltipData,
|
|
22186
22174
|
tooltipLeft,
|
|
@@ -22198,7 +22186,12 @@ const DrawAreaGraph = ({
|
|
|
22198
22186
|
const legendLabels = (_g = areaValue.main) == null ? void 0 : _g.legendLabels;
|
|
22199
22187
|
const colorMap = (_i = (_h = areaValue.style) == null ? void 0 : _h.areaStyle) == null ? void 0 : _i.colorMap;
|
|
22200
22188
|
const defaultColour = (_k = (_j = theme.myTheme.palette) == null ? void 0 : _j.primary) == null ? void 0 : _k.main;
|
|
22201
|
-
const
|
|
22189
|
+
const muiTheme = useTheme$1();
|
|
22190
|
+
const isSmallScreen = useMediaQuery(muiTheme.breakpoints.down("sm"));
|
|
22191
|
+
const margin2 = {
|
|
22192
|
+
...marginProp,
|
|
22193
|
+
bottom: isSmallScreen ? Math.max(marginProp.bottom, 90) : marginProp.bottom
|
|
22194
|
+
};
|
|
22202
22195
|
const labelsArray = useMemo(() => {
|
|
22203
22196
|
if (!chartData.length)
|
|
22204
22197
|
return [];
|
|
@@ -22290,7 +22283,18 @@ const DrawAreaGraph = ({
|
|
|
22290
22283
|
tooltipTop: yScale(tooltipPoint[labelsArray[0]] || 0)
|
|
22291
22284
|
});
|
|
22292
22285
|
};
|
|
22293
|
-
const
|
|
22286
|
+
const tickLabelProps = () => isSmallScreen ? {
|
|
22287
|
+
fill: "#6B7280",
|
|
22288
|
+
fontSize: 10,
|
|
22289
|
+
fontWeight: 600,
|
|
22290
|
+
textAnchor: "end",
|
|
22291
|
+
angle: -40
|
|
22292
|
+
} : {
|
|
22293
|
+
fill: "#6B7280",
|
|
22294
|
+
fontSize: 10,
|
|
22295
|
+
fontWeight: 600,
|
|
22296
|
+
textAnchor: "middle"
|
|
22297
|
+
};
|
|
22294
22298
|
return /* @__PURE__ */ jsxs("div", {
|
|
22295
22299
|
style: {
|
|
22296
22300
|
position: "relative"
|
|
@@ -22363,20 +22367,14 @@ const DrawAreaGraph = ({
|
|
|
22363
22367
|
}), /* @__PURE__ */ jsx$1(AxisBottom, {
|
|
22364
22368
|
top: innerHeight,
|
|
22365
22369
|
scale: xScale,
|
|
22366
|
-
label: (
|
|
22370
|
+
label: (_l = areaValue.main) == null ? void 0 : _l.bottomLabel,
|
|
22367
22371
|
tickFormat: formatXTick,
|
|
22368
22372
|
stroke: "#d1d5db",
|
|
22369
22373
|
tickStroke: "#d1d5db",
|
|
22370
|
-
|
|
22371
|
-
tickLabelProps: () => ({
|
|
22372
|
-
fill: "#6B7280",
|
|
22373
|
-
fontSize: 10,
|
|
22374
|
-
fontWeight: 600,
|
|
22375
|
-
textAnchor: "middle"
|
|
22376
|
-
})
|
|
22374
|
+
tickLabelProps
|
|
22377
22375
|
}), /* @__PURE__ */ jsx$1(AxisLeft, {
|
|
22378
22376
|
scale: yScale,
|
|
22379
|
-
label: !disableLeftLabel ? (
|
|
22377
|
+
label: !disableLeftLabel ? (_m = areaValue.main) == null ? void 0 : _m.leftLabel : void 0,
|
|
22380
22378
|
stroke: "#d1d5db",
|
|
22381
22379
|
tickStroke: "#d1d5db",
|
|
22382
22380
|
numTicks: yAxisTickCount || 6,
|
|
@@ -22504,15 +22502,15 @@ const AreaGraph = ({
|
|
|
22504
22502
|
}), GraphRender]
|
|
22505
22503
|
});
|
|
22506
22504
|
};
|
|
22507
|
-
const
|
|
22505
|
+
const GROWTH_RATE_KEY = "growthRate";
|
|
22508
22506
|
const DrawStackBarLineGraph = ({
|
|
22509
22507
|
width: width2,
|
|
22510
22508
|
height: height2,
|
|
22511
|
-
margin:
|
|
22509
|
+
margin: marginProp,
|
|
22512
22510
|
stackBarLineValue,
|
|
22513
22511
|
theme
|
|
22514
22512
|
}) => {
|
|
22515
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n
|
|
22513
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
22516
22514
|
const {
|
|
22517
22515
|
tooltipData,
|
|
22518
22516
|
tooltipLeft,
|
|
@@ -22529,14 +22527,19 @@ const DrawStackBarLineGraph = ({
|
|
|
22529
22527
|
const defaultColour = (_h = (_g = (_f = theme == null ? void 0 : theme.myTheme) == null ? void 0 : _f.palette) == null ? void 0 : _g.primary) == null ? void 0 : _h.main;
|
|
22530
22528
|
const yAxisTickCount = (_i = stackBarLineValue == null ? void 0 : stackBarLineValue.main) == null ? void 0 : _i.yAxisTickCount;
|
|
22531
22529
|
const disableLeftLabel = (_j = stackBarLineValue.main) == null ? void 0 : _j.disableLeftLabel;
|
|
22532
|
-
const
|
|
22533
|
-
const
|
|
22530
|
+
const trendColor = (_k = colorMap == null ? void 0 : colorMap[GROWTH_RATE_KEY]) != null ? _k : "#E24B4A";
|
|
22531
|
+
const muiTheme = useTheme$1();
|
|
22532
|
+
const isSmallScreen = useMediaQuery(muiTheme.breakpoints.down("sm"));
|
|
22533
|
+
const margin2 = {
|
|
22534
|
+
...marginProp,
|
|
22535
|
+
bottom: isSmallScreen ? Math.max(marginProp.bottom, 80) : marginProp.bottom
|
|
22536
|
+
};
|
|
22534
22537
|
const labelsArray = useMemo(() => {
|
|
22535
22538
|
if (!chartData.length)
|
|
22536
22539
|
return [];
|
|
22537
22540
|
return Object.keys(chartData[0]).filter((k2) => k2 !== xAxisValue);
|
|
22538
22541
|
}, [chartData, xAxisValue]);
|
|
22539
|
-
const barKeys = useMemo(() => labelsArray.filter((k2) => k2 !==
|
|
22542
|
+
const barKeys = useMemo(() => labelsArray.filter((k2) => k2 !== GROWTH_RATE_KEY), [labelsArray]);
|
|
22540
22543
|
const barData = useMemo(() => chartData.map((row) => {
|
|
22541
22544
|
const stripped = {
|
|
22542
22545
|
[xAxisValue]: row[xAxisValue]
|
|
@@ -22560,7 +22563,7 @@ const DrawStackBarLineGraph = ({
|
|
|
22560
22563
|
nice: true
|
|
22561
22564
|
}), [innerHeight, maxStacked]);
|
|
22562
22565
|
const trendScale = useMemo(() => {
|
|
22563
|
-
const vals = chartData.map((d2) => Number(d2[
|
|
22566
|
+
const vals = chartData.map((d2) => Number(d2[GROWTH_RATE_KEY]) || 0);
|
|
22564
22567
|
return createLinearScale({
|
|
22565
22568
|
domain: [Math.min(...vals), Math.max(...vals)],
|
|
22566
22569
|
range: [innerHeight, 0],
|
|
@@ -22572,11 +22575,11 @@ const DrawStackBarLineGraph = ({
|
|
|
22572
22575
|
return ((_a2 = categoryScale(cat)) != null ? _a2 : 0) + categoryScale.bandwidth() / 2;
|
|
22573
22576
|
}, [categoryScale]);
|
|
22574
22577
|
const getLineX = useCallback((d2) => getBarCentreX(d2[xAxisValue]), [getBarCentreX, xAxisValue]);
|
|
22575
|
-
const getLineY = useCallback((d2) => trendScale(Number(d2[
|
|
22578
|
+
const getLineY = useCallback((d2) => trendScale(Number(d2[GROWTH_RATE_KEY]) || 0), [trendScale]);
|
|
22576
22579
|
const handleColumnEnter = useCallback((_e2, cat) => {
|
|
22577
22580
|
const full = chartData.find((d2) => d2[xAxisValue] === cat);
|
|
22578
22581
|
const dotX = getBarCentreX(cat) + margin2.left;
|
|
22579
|
-
const dotY = trendScale(Number(full[
|
|
22582
|
+
const dotY = trendScale(Number(full[GROWTH_RATE_KEY]) || 0) + margin2.top;
|
|
22580
22583
|
setHoveredCategory(cat);
|
|
22581
22584
|
showTooltip({
|
|
22582
22585
|
tooltipData: full,
|
|
@@ -22588,7 +22591,18 @@ const DrawStackBarLineGraph = ({
|
|
|
22588
22591
|
setHoveredCategory(null);
|
|
22589
22592
|
hideTooltip();
|
|
22590
22593
|
}, [hideTooltip]);
|
|
22591
|
-
const
|
|
22594
|
+
const tickLabelProps = useCallback(() => isSmallScreen ? {
|
|
22595
|
+
fill: "#6B7280",
|
|
22596
|
+
fontSize: 12,
|
|
22597
|
+
fontWeight: 500,
|
|
22598
|
+
textAnchor: "end",
|
|
22599
|
+
angle: -40
|
|
22600
|
+
} : {
|
|
22601
|
+
fill: "#6B7280",
|
|
22602
|
+
fontSize: 12,
|
|
22603
|
+
fontWeight: 500,
|
|
22604
|
+
textAnchor: "middle"
|
|
22605
|
+
}, [isSmallScreen]);
|
|
22592
22606
|
return /* @__PURE__ */ jsxs("div", {
|
|
22593
22607
|
style: {
|
|
22594
22608
|
position: "relative"
|
|
@@ -22702,7 +22716,7 @@ const DrawStackBarLineGraph = ({
|
|
|
22702
22716
|
textAnchor: "end",
|
|
22703
22717
|
dy: "0.33em"
|
|
22704
22718
|
}),
|
|
22705
|
-
label: !disableLeftLabel ? (
|
|
22719
|
+
label: !disableLeftLabel ? (_l = stackBarLineValue.main) == null ? void 0 : _l.leftLabel : void 0,
|
|
22706
22720
|
labelProps: {
|
|
22707
22721
|
fill: "#6B7280",
|
|
22708
22722
|
fontSize: 11,
|
|
@@ -22714,7 +22728,7 @@ const DrawStackBarLineGraph = ({
|
|
|
22714
22728
|
scale: trendScale,
|
|
22715
22729
|
numTicks: 5,
|
|
22716
22730
|
stroke: "#9CA3AF",
|
|
22717
|
-
label: (
|
|
22731
|
+
label: (_m = stackBarLineValue.main) == null ? void 0 : _m.rightLabel,
|
|
22718
22732
|
tickStroke: "transparent",
|
|
22719
22733
|
tickLabelProps: () => ({
|
|
22720
22734
|
fill: "#6B7280",
|
|
@@ -22731,16 +22745,10 @@ const DrawStackBarLineGraph = ({
|
|
|
22731
22745
|
}), /* @__PURE__ */ jsx$1(AxisBottom, {
|
|
22732
22746
|
top: innerHeight,
|
|
22733
22747
|
scale: categoryScale,
|
|
22734
|
-
tickValues: visibleXAxisLabels,
|
|
22735
22748
|
stroke: "#9CA3AF",
|
|
22736
|
-
label: (
|
|
22749
|
+
label: (_n = stackBarLineValue.main) == null ? void 0 : _n.bottomLabel,
|
|
22737
22750
|
tickStroke: "transparent",
|
|
22738
|
-
tickLabelProps
|
|
22739
|
-
fill: "#6B7280",
|
|
22740
|
-
fontSize: 12,
|
|
22741
|
-
fontWeight: 500,
|
|
22742
|
-
textAnchor: "middle"
|
|
22743
|
-
})
|
|
22751
|
+
tickLabelProps
|
|
22744
22752
|
})]
|
|
22745
22753
|
})
|
|
22746
22754
|
}), stackBarLineValue.main.legendAvailable && labelsArray.length > 0 && /* @__PURE__ */ jsx$1(Legend, {
|