impaktapps-design 0.1.2 → 0.1.4
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.
|
@@ -10472,43 +10472,6 @@ const LeftAxis = ({
|
|
|
10472
10472
|
}
|
|
10473
10473
|
});
|
|
10474
10474
|
};
|
|
10475
|
-
const BottomAxis = ({
|
|
10476
|
-
data,
|
|
10477
|
-
yMax,
|
|
10478
|
-
value,
|
|
10479
|
-
xScale,
|
|
10480
|
-
parentWidth,
|
|
10481
|
-
left: left2
|
|
10482
|
-
}) => {
|
|
10483
|
-
var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p, _q, _r, _s;
|
|
10484
|
-
return /* @__PURE__ */ jsx(AxisBottom$2, {
|
|
10485
|
-
numTicks: data == null ? void 0 : data.length,
|
|
10486
|
-
top: yMax,
|
|
10487
|
-
left: left2,
|
|
10488
|
-
hideTicks: (_a2 = value.main) == null ? void 0 : _a2.hideTicks,
|
|
10489
|
-
hideAxisLine: (_b2 = value.main) == null ? void 0 : _b2.hideBottomAxisLine,
|
|
10490
|
-
strokeWidth: (_d = (_c2 = value.style) == null ? void 0 : _c2.labelStyle) == null ? void 0 : _d.bottomAxisWidth,
|
|
10491
|
-
scale: xScale,
|
|
10492
|
-
stroke: (_f = (_e2 = value.style) == null ? void 0 : _e2.labelStyle) == null ? void 0 : _f.tickColor,
|
|
10493
|
-
labelOffset: (_h = (_g = value.style) == null ? void 0 : _g.labelStyle) == null ? void 0 : _h.bottomLabelOffset,
|
|
10494
|
-
label: (_i = value.main) == null ? void 0 : _i.bottomLabel,
|
|
10495
|
-
labelProps: {
|
|
10496
|
-
fill: (_k = (_j = value.style) == null ? void 0 : _j.labelStyle) == null ? void 0 : _k.labelColor,
|
|
10497
|
-
fontSize: (_m = (_l = value.style) == null ? void 0 : _l.labelStyle) == null ? void 0 : _m.fontSize,
|
|
10498
|
-
fontWeight: (_o = (_n2 = value.style) == null ? void 0 : _n2.labelStyle) == null ? void 0 : _o.fontWeight,
|
|
10499
|
-
fontFamily: (_q = (_p = value.style) == null ? void 0 : _p.labelStyle) == null ? void 0 : _q.fontWeight
|
|
10500
|
-
},
|
|
10501
|
-
tickStroke: (_s = (_r = value.style) == null ? void 0 : _r.labelStyle) == null ? void 0 : _s.tickColor,
|
|
10502
|
-
tickLabelProps: () => {
|
|
10503
|
-
var _a3, _b3, _c3, _d2;
|
|
10504
|
-
return {
|
|
10505
|
-
fill: (_b3 = (_a3 = value.style) == null ? void 0 : _a3.labelStyle) == null ? void 0 : _b3.tickLabelColor,
|
|
10506
|
-
fontSize: ((_d2 = (_c3 = value.style) == null ? void 0 : _c3.labelStyle) == null ? void 0 : _d2.tickFontSize) || 11,
|
|
10507
|
-
textAnchor: "middle"
|
|
10508
|
-
};
|
|
10509
|
-
}
|
|
10510
|
-
});
|
|
10511
|
-
};
|
|
10512
10475
|
var _excluded$r = ["tooltipOpen"];
|
|
10513
10476
|
function _objectWithoutPropertiesLoose$r(source, excluded) {
|
|
10514
10477
|
if (source == null)
|
|
@@ -10907,7 +10870,6 @@ Tooltip$1.propTypes = {
|
|
|
10907
10870
|
unstyled: _pt.bool
|
|
10908
10871
|
};
|
|
10909
10872
|
Tooltip$1.displayName = "Tooltip";
|
|
10910
|
-
var Tooltip$2 = Tooltip$1;
|
|
10911
10873
|
function _extends$C() {
|
|
10912
10874
|
_extends$C = Object.assign ? Object.assign.bind() : function(target) {
|
|
10913
10875
|
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
@@ -11059,7 +11021,7 @@ function TooltipWithBounds(_ref) {
|
|
|
11059
11021
|
top2 = Math.round(top2);
|
|
11060
11022
|
transform2 = "translate(" + left2 + "px, " + top2 + "px)";
|
|
11061
11023
|
}
|
|
11062
|
-
return /* @__PURE__ */ React__default.createElement(Tooltip$
|
|
11024
|
+
return /* @__PURE__ */ React__default.createElement(Tooltip$1, _extends$B({
|
|
11063
11025
|
ref: nodeRef,
|
|
11064
11026
|
style: _extends$B({
|
|
11065
11027
|
left: 0,
|
|
@@ -11104,7 +11066,7 @@ function useTooltipInPortal(_temp) {
|
|
|
11104
11066
|
var _ref2$left = _ref2.left, containerLeft = _ref2$left === void 0 ? 0 : _ref2$left, _ref2$top = _ref2.top, containerTop = _ref2$top === void 0 ? 0 : _ref2$top, detectBoundsProp = _ref2.detectBounds, zIndexProp = _ref2.zIndex, tooltipProps = _objectWithoutPropertiesLoose$o(_ref2, _excluded2$1);
|
|
11105
11067
|
var detectBounds = detectBoundsProp == null ? detectBoundsOption : detectBoundsProp;
|
|
11106
11068
|
var zIndex = zIndexProp == null ? zIndexOption : zIndexProp;
|
|
11107
|
-
var TooltipComponent = detectBounds ? TooltipWithBounds$1 : Tooltip$
|
|
11069
|
+
var TooltipComponent = detectBounds ? TooltipWithBounds$1 : Tooltip$1;
|
|
11108
11070
|
var scrollX = isSsr ? 0 : window.scrollX;
|
|
11109
11071
|
var scrollY = isSsr ? 0 : window.scrollY;
|
|
11110
11072
|
var portalLeft = containerLeft + (containerBounds.left || 0) + scrollX;
|
|
@@ -11126,6 +11088,43 @@ function useTooltipInPortal(_temp) {
|
|
|
11126
11088
|
TooltipInPortal
|
|
11127
11089
|
};
|
|
11128
11090
|
}
|
|
11091
|
+
const BottomAxis = ({
|
|
11092
|
+
data,
|
|
11093
|
+
yMax,
|
|
11094
|
+
value,
|
|
11095
|
+
xScale,
|
|
11096
|
+
parentWidth,
|
|
11097
|
+
left: left2
|
|
11098
|
+
}) => {
|
|
11099
|
+
var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p, _q, _r, _s;
|
|
11100
|
+
return /* @__PURE__ */ jsx(AxisBottom$2, {
|
|
11101
|
+
numTicks: data == null ? void 0 : data.length,
|
|
11102
|
+
top: yMax,
|
|
11103
|
+
left: left2,
|
|
11104
|
+
hideTicks: (_a2 = value.main) == null ? void 0 : _a2.hideTicks,
|
|
11105
|
+
hideAxisLine: (_b2 = value.main) == null ? void 0 : _b2.hideBottomAxisLine,
|
|
11106
|
+
strokeWidth: (_d = (_c2 = value.style) == null ? void 0 : _c2.labelStyle) == null ? void 0 : _d.bottomAxisWidth,
|
|
11107
|
+
scale: xScale,
|
|
11108
|
+
stroke: (_f = (_e2 = value.style) == null ? void 0 : _e2.labelStyle) == null ? void 0 : _f.tickColor,
|
|
11109
|
+
labelOffset: (_h = (_g = value.style) == null ? void 0 : _g.labelStyle) == null ? void 0 : _h.bottomLabelOffset,
|
|
11110
|
+
label: (_i = value.main) == null ? void 0 : _i.bottomLabel,
|
|
11111
|
+
labelProps: {
|
|
11112
|
+
fill: (_k = (_j = value.style) == null ? void 0 : _j.labelStyle) == null ? void 0 : _k.labelColor,
|
|
11113
|
+
fontSize: (_m = (_l = value.style) == null ? void 0 : _l.labelStyle) == null ? void 0 : _m.fontSize,
|
|
11114
|
+
fontWeight: (_o = (_n2 = value.style) == null ? void 0 : _n2.labelStyle) == null ? void 0 : _o.fontWeight,
|
|
11115
|
+
fontFamily: (_q = (_p = value.style) == null ? void 0 : _p.labelStyle) == null ? void 0 : _q.fontWeight
|
|
11116
|
+
},
|
|
11117
|
+
tickStroke: (_s = (_r = value.style) == null ? void 0 : _r.labelStyle) == null ? void 0 : _s.tickColor,
|
|
11118
|
+
tickLabelProps: () => {
|
|
11119
|
+
var _a3, _b3, _c3, _d2;
|
|
11120
|
+
return {
|
|
11121
|
+
fill: (_b3 = (_a3 = value.style) == null ? void 0 : _a3.labelStyle) == null ? void 0 : _b3.tickLabelColor,
|
|
11122
|
+
fontSize: ((_d2 = (_c3 = value.style) == null ? void 0 : _c3.labelStyle) == null ? void 0 : _d2.tickFontSize) || 11,
|
|
11123
|
+
textAnchor: "middle"
|
|
11124
|
+
};
|
|
11125
|
+
}
|
|
11126
|
+
});
|
|
11127
|
+
};
|
|
11129
11128
|
const ToolTip = ({
|
|
11130
11129
|
style: style2,
|
|
11131
11130
|
top: top2,
|
|
@@ -11143,26 +11142,27 @@ const ToolTip = ({
|
|
|
11143
11142
|
left: left2,
|
|
11144
11143
|
children: /* @__PURE__ */ jsxs("div", {
|
|
11145
11144
|
style: {
|
|
11146
|
-
height: "50px",
|
|
11147
11145
|
textAlign: "center",
|
|
11148
11146
|
background: "black",
|
|
11149
11147
|
padding: "10px",
|
|
11150
11148
|
boxShadow: "2px 2px 5px black",
|
|
11151
11149
|
color: "#6c5efb",
|
|
11152
|
-
backgroundColor:
|
|
11150
|
+
backgroundColor: "black",
|
|
11153
11151
|
...style2 == null ? void 0 : style2.tooltipStyle,
|
|
11154
11152
|
margin: "-20px"
|
|
11155
11153
|
},
|
|
11156
11154
|
children: [/* @__PURE__ */ jsx("div", {
|
|
11157
11155
|
style: {
|
|
11158
11156
|
padding: "4px 10px",
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11157
|
+
color: (style2 == null ? void 0 : style2.tooltipbackground) || "white",
|
|
11158
|
+
borderRadius: "5px",
|
|
11159
|
+
fontWeight: 700
|
|
11162
11160
|
},
|
|
11163
11161
|
children: tooltipData[0]
|
|
11164
11162
|
}), /* @__PURE__ */ jsx("div", {
|
|
11165
11163
|
style: {
|
|
11164
|
+
padding: "4px 10px",
|
|
11165
|
+
borderRadius: "5px",
|
|
11166
11166
|
marginTop: "10px",
|
|
11167
11167
|
fontWeight: 700
|
|
11168
11168
|
},
|
|
@@ -11538,17 +11538,23 @@ function Ordinal(props) {
|
|
|
11538
11538
|
return /* @__PURE__ */ React__default.createElement(Legend$1, props);
|
|
11539
11539
|
}
|
|
11540
11540
|
function Legend({
|
|
11541
|
-
value
|
|
11541
|
+
value,
|
|
11542
|
+
colorRange,
|
|
11543
|
+
dataKeyArray
|
|
11542
11544
|
}) {
|
|
11543
11545
|
var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k;
|
|
11544
11546
|
const legendGlyphSize = ((_b2 = (_a2 = value == null ? void 0 : value.main) == null ? void 0 : _a2.legend) == null ? void 0 : _b2.colorRectWidth) || 15;
|
|
11545
11547
|
const ordinalColorScale = createOrdinalScale$1({
|
|
11546
|
-
domain: (_c2 = value == null ? void 0 : value.main) == null ? void 0 : _c2.tooltipDataKey,
|
|
11547
|
-
range: (_e2 = (_d = value == null ? void 0 : value.style) == null ? void 0 : _d.pieStyle) == null ? void 0 : _e2.colorRange
|
|
11548
|
+
domain: dataKeyArray || ((_c2 = value == null ? void 0 : value.main) == null ? void 0 : _c2.tooltipDataKey),
|
|
11549
|
+
range: colorRange || ((_e2 = (_d = value == null ? void 0 : value.style) == null ? void 0 : _d.pieStyle) == null ? void 0 : _e2.colorRange)
|
|
11548
11550
|
});
|
|
11549
11551
|
return /* @__PURE__ */ jsxs("div", {
|
|
11550
11552
|
className: "legend",
|
|
11551
|
-
style:
|
|
11553
|
+
style: {
|
|
11554
|
+
paddingLeft: "40px",
|
|
11555
|
+
paddingRight: "40px",
|
|
11556
|
+
...(_g = (_f = value == null ? void 0 : value.style) == null ? void 0 : _f.legendStyle) == null ? void 0 : _g.legend
|
|
11557
|
+
},
|
|
11552
11558
|
children: [/* @__PURE__ */ jsx("div", {
|
|
11553
11559
|
className: "title",
|
|
11554
11560
|
style: (_i = (_h = value == null ? void 0 : value.style) == null ? void 0 : _h.legendStyle) == null ? void 0 : _i.legendTitle,
|
|
@@ -11591,6 +11597,12 @@ function Legend({
|
|
|
11591
11597
|
})]
|
|
11592
11598
|
});
|
|
11593
11599
|
}
|
|
11600
|
+
const tooltipStyles = {
|
|
11601
|
+
...defaultStyles,
|
|
11602
|
+
minWidth: 60,
|
|
11603
|
+
backgroundColor: "rgba(0,0,0,0.9)",
|
|
11604
|
+
color: "white"
|
|
11605
|
+
};
|
|
11594
11606
|
const defaultMargin = {
|
|
11595
11607
|
top: 20,
|
|
11596
11608
|
right: 0,
|
|
@@ -11604,10 +11616,18 @@ function DrawBarGraph({
|
|
|
11604
11616
|
margin = defaultMargin,
|
|
11605
11617
|
value
|
|
11606
11618
|
}) {
|
|
11607
|
-
var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k;
|
|
11619
|
+
var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p, _q, _r, _s, _t2, _u, _v, _w;
|
|
11608
11620
|
const data = (_a2 = value.main) == null ? void 0 : _a2.data;
|
|
11609
11621
|
const keys2 = Object.keys(data[0]).filter((d2) => d2 !== "label");
|
|
11610
11622
|
const getDate = (d2) => d2.label;
|
|
11623
|
+
const temperatureTotals = data.reduce((allTotals, currentDate) => {
|
|
11624
|
+
const totalTemperature = keys2.reduce((dailyTotal, k2) => {
|
|
11625
|
+
dailyTotal += Number(currentDate[k2]);
|
|
11626
|
+
return dailyTotal;
|
|
11627
|
+
}, 0);
|
|
11628
|
+
allTotals.push(totalTemperature);
|
|
11629
|
+
return allTotals;
|
|
11630
|
+
}, []);
|
|
11611
11631
|
const dateScale = createBandScale({
|
|
11612
11632
|
domain: data.map(getDate),
|
|
11613
11633
|
padding: 0.2
|
|
@@ -11617,14 +11637,15 @@ function DrawBarGraph({
|
|
|
11617
11637
|
padding: 0.1
|
|
11618
11638
|
});
|
|
11619
11639
|
const tempScale = createLinearScale({
|
|
11620
|
-
domain: [0, Math.max(...data.map((d2) => Math.max(...keys2.map((key) => Number(d2[key])))))]
|
|
11640
|
+
domain: ((_b2 = value == null ? void 0 : value.main) == null ? void 0 : _b2.type) === "StackBarGraph" ? [0, Math.max(...temperatureTotals)] : [0, Math.max(...data.map((d2) => Math.max(...keys2.map((key) => Number(d2[key])))))],
|
|
11641
|
+
nice: true
|
|
11621
11642
|
});
|
|
11622
11643
|
const colorScale = createOrdinalScale$1({
|
|
11623
11644
|
domain: keys2,
|
|
11624
|
-
range: [((
|
|
11645
|
+
range: [((_e2 = (_d = (_c2 = value.style) == null ? void 0 : _c2.barStyle) == null ? void 0 : _d.color) == null ? void 0 : _e2.firstBarColor) || "#aeeef8", ((_h = (_g = (_f = value.style) == null ? void 0 : _f.barStyle) == null ? void 0 : _g.color) == null ? void 0 : _h.secondBarColor) || "#e5fd3d", ((_k = (_j = (_i = value.style) == null ? void 0 : _i.barStyle) == null ? void 0 : _j.color) == null ? void 0 : _k.thirdBarColor) || "#9caff6"]
|
|
11625
11646
|
});
|
|
11626
11647
|
const xMax = width - margin.left - margin.right;
|
|
11627
|
-
const yMax = height - margin.top - margin.bottom;
|
|
11648
|
+
const yMax = height - margin.top - margin.bottom - 0;
|
|
11628
11649
|
dateScale.rangeRound([0, xMax]);
|
|
11629
11650
|
cityScale.rangeRound([0, dateScale.bandwidth()]);
|
|
11630
11651
|
tempScale.range([yMax, 0]);
|
|
@@ -11637,17 +11658,47 @@ function DrawBarGraph({
|
|
|
11637
11658
|
hideTooltip
|
|
11638
11659
|
} = useTooltip();
|
|
11639
11660
|
const handleMouse = (event, datum2) => {
|
|
11661
|
+
var _a3;
|
|
11640
11662
|
console.log(datum2);
|
|
11641
11663
|
showTooltip({
|
|
11642
11664
|
tooltipLeft: event.clientX,
|
|
11643
11665
|
tooltipTop: event.clientY,
|
|
11644
|
-
tooltipData:
|
|
11666
|
+
tooltipData: ((_a3 = value == null ? void 0 : value.main) == null ? void 0 : _a3.type) === "StackBarGraph" ? {
|
|
11667
|
+
label: datum2.bar.data.label,
|
|
11668
|
+
key: datum2.key,
|
|
11669
|
+
value: datum2.bar.data[datum2.key],
|
|
11670
|
+
color: datum2.color
|
|
11671
|
+
} : [datum2.key, datum2.value, datum2.color]
|
|
11672
|
+
});
|
|
11673
|
+
};
|
|
11674
|
+
const {
|
|
11675
|
+
TooltipInPortal,
|
|
11676
|
+
containerRef
|
|
11677
|
+
} = useTooltipInPortal({
|
|
11678
|
+
detectBounds: true,
|
|
11679
|
+
scroll: true
|
|
11680
|
+
});
|
|
11681
|
+
const stachHandleMouse = (event, datum2) => {
|
|
11682
|
+
console.log(datum2);
|
|
11683
|
+
showTooltip({
|
|
11684
|
+
tooltipLeft: event.clientX,
|
|
11685
|
+
tooltipTop: event.clientY,
|
|
11686
|
+
tooltipData: {
|
|
11687
|
+
label: datum2.bar.data.label,
|
|
11688
|
+
key: datum2.key,
|
|
11689
|
+
value: datum2.bar.data[datum2.key],
|
|
11690
|
+
color: datum2.color
|
|
11691
|
+
}
|
|
11645
11692
|
});
|
|
11646
11693
|
};
|
|
11647
11694
|
return width < 10 ? null : /* @__PURE__ */ jsxs("div", {
|
|
11648
|
-
|
|
11695
|
+
style: {},
|
|
11696
|
+
children: [((_l = value == null ? void 0 : value.main) == null ? void 0 : _l.legendAvailable) && /* @__PURE__ */ jsx(Legend, {
|
|
11697
|
+
dataKeyArray: keys2,
|
|
11698
|
+
colorRange: [((_o = (_n2 = (_m = value.style) == null ? void 0 : _m.barStyle) == null ? void 0 : _n2.color) == null ? void 0 : _o.firstBarColor) || "#aeeef8", ((_r = (_q = (_p = value.style) == null ? void 0 : _p.barStyle) == null ? void 0 : _q.color) == null ? void 0 : _r.secondBarColor) || "#e5fd3d", ((_u = (_t2 = (_s = value.style) == null ? void 0 : _s.barStyle) == null ? void 0 : _t2.color) == null ? void 0 : _u.thirdBarColor) || "#9caff6"],
|
|
11649
11699
|
value
|
|
11650
11700
|
}), /* @__PURE__ */ jsxs("svg", {
|
|
11701
|
+
ref: containerRef,
|
|
11651
11702
|
width,
|
|
11652
11703
|
height,
|
|
11653
11704
|
children: [/* @__PURE__ */ jsx("rect", {
|
|
@@ -11664,7 +11715,27 @@ function DrawBarGraph({
|
|
|
11664
11715
|
value,
|
|
11665
11716
|
yScale: tempScale,
|
|
11666
11717
|
parentWidth: width
|
|
11667
|
-
}), /* @__PURE__ */ jsx(
|
|
11718
|
+
}), ((_v = value == null ? void 0 : value.main) == null ? void 0 : _v.type) === "StackBarGraph" ? /* @__PURE__ */ jsx(BarStack, {
|
|
11719
|
+
data,
|
|
11720
|
+
keys: keys2,
|
|
11721
|
+
x: getDate,
|
|
11722
|
+
xScale: dateScale,
|
|
11723
|
+
yScale: tempScale,
|
|
11724
|
+
color: colorScale,
|
|
11725
|
+
children: (barStacks) => barStacks.map((barStack) => barStack.bars.map((bar) => /* @__PURE__ */ jsx("rect", {
|
|
11726
|
+
x: bar.x,
|
|
11727
|
+
y: bar.y,
|
|
11728
|
+
height: bar.height,
|
|
11729
|
+
width: bar.width,
|
|
11730
|
+
fill: bar.color,
|
|
11731
|
+
onClick: () => {
|
|
11732
|
+
if (events)
|
|
11733
|
+
alert(`clicked: ${JSON.stringify(bar)}`);
|
|
11734
|
+
},
|
|
11735
|
+
onMouseOver: (e3) => stachHandleMouse(e3, bar),
|
|
11736
|
+
onMouseOut: hideTooltip
|
|
11737
|
+
}, `bar-stack-${barStack.index}-${bar.index}`)))
|
|
11738
|
+
}) : /* @__PURE__ */ jsx(BarGroup, {
|
|
11668
11739
|
data,
|
|
11669
11740
|
keys: keys2,
|
|
11670
11741
|
height: yMax,
|
|
@@ -11706,7 +11777,25 @@ function DrawBarGraph({
|
|
|
11706
11777
|
xScale: dateScale,
|
|
11707
11778
|
parentWidth: width
|
|
11708
11779
|
})]
|
|
11709
|
-
}), tooltipOpen && /* @__PURE__ */
|
|
11780
|
+
}), ((_w = value == null ? void 0 : value.main) == null ? void 0 : _w.type) === "StackBarGraph" ? tooltipOpen && tooltipData && /* @__PURE__ */ jsxs(TooltipInPortal, {
|
|
11781
|
+
top: tooltipTop,
|
|
11782
|
+
left: tooltipLeft,
|
|
11783
|
+
style: tooltipStyles,
|
|
11784
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
11785
|
+
style: {
|
|
11786
|
+
color: tooltipData.color
|
|
11787
|
+
},
|
|
11788
|
+
children: /* @__PURE__ */ jsx("strong", {
|
|
11789
|
+
children: tooltipData.label
|
|
11790
|
+
})
|
|
11791
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
11792
|
+
children: tooltipData.key
|
|
11793
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
11794
|
+
children: /* @__PURE__ */ jsx("small", {
|
|
11795
|
+
children: tooltipData.value
|
|
11796
|
+
})
|
|
11797
|
+
})]
|
|
11798
|
+
}) : tooltipOpen && /* @__PURE__ */ jsx(ToolTip, {
|
|
11710
11799
|
style: {
|
|
11711
11800
|
...value == null ? void 0 : value.style,
|
|
11712
11801
|
tooltipbackground: tooltipData[2]
|
|
@@ -11969,7 +12058,7 @@ const Product1 = [
|
|
|
11969
12058
|
{ x: "g", y: 50 }
|
|
11970
12059
|
];
|
|
11971
12060
|
const finalDataProvider = (type2, value) => {
|
|
11972
|
-
var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p, _q, _r, _s, _t2, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
|
|
12061
|
+
var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p, _q, _r, _s, _t2, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
11973
12062
|
switch (type2) {
|
|
11974
12063
|
case "BarGraph":
|
|
11975
12064
|
return {
|
|
@@ -11979,6 +12068,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
11979
12068
|
header: "Bar Graph",
|
|
11980
12069
|
bottomLabel: "Name of Employe",
|
|
11981
12070
|
numTicks: 6,
|
|
12071
|
+
legendAvailable: true,
|
|
11982
12072
|
leftLabel: "Value",
|
|
11983
12073
|
axisLeft: true,
|
|
11984
12074
|
axisBottom: true,
|
|
@@ -11986,7 +12076,14 @@ const finalDataProvider = (type2, value) => {
|
|
|
11986
12076
|
hideLeftAxisLine: false,
|
|
11987
12077
|
hideBottomAxisLine: false,
|
|
11988
12078
|
bottomAxisWidth: "10px",
|
|
11989
|
-
...value.main
|
|
12079
|
+
...value.main,
|
|
12080
|
+
legend: {
|
|
12081
|
+
labelColor: "green",
|
|
12082
|
+
legendTitle: "Our Assests",
|
|
12083
|
+
direction: "row",
|
|
12084
|
+
align: "right",
|
|
12085
|
+
...(_b2 = value == null ? void 0 : value.main) == null ? void 0 : _b2.legend
|
|
12086
|
+
}
|
|
11990
12087
|
},
|
|
11991
12088
|
style: {
|
|
11992
12089
|
containerStyle: {
|
|
@@ -11995,7 +12092,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
11995
12092
|
height: "300",
|
|
11996
12093
|
borderRadius: "20px",
|
|
11997
12094
|
padding: "10px 0 2px 0",
|
|
11998
|
-
...(
|
|
12095
|
+
...(_c2 = value == null ? void 0 : value.style) == null ? void 0 : _c2.containerStyle
|
|
11999
12096
|
},
|
|
12000
12097
|
headerStyle: {
|
|
12001
12098
|
fontWeight: 500,
|
|
@@ -12005,12 +12102,12 @@ const finalDataProvider = (type2, value) => {
|
|
|
12005
12102
|
padding: "15px 0 1px 20px",
|
|
12006
12103
|
width: "100%",
|
|
12007
12104
|
fontSize: "18px",
|
|
12008
|
-
...(
|
|
12105
|
+
...(_d = value == null ? void 0 : value.style) == null ? void 0 : _d.headerStyle
|
|
12009
12106
|
},
|
|
12010
12107
|
tooltipStyle: {
|
|
12011
12108
|
padding: "6px",
|
|
12012
12109
|
borderRadius: "2px",
|
|
12013
|
-
...(
|
|
12110
|
+
...(_e2 = value == null ? void 0 : value.style) == null ? void 0 : _e2.tooltipStyle
|
|
12014
12111
|
},
|
|
12015
12112
|
labelStyle: {
|
|
12016
12113
|
leftLabelMargin: "75",
|
|
@@ -12023,20 +12120,20 @@ const finalDataProvider = (type2, value) => {
|
|
|
12023
12120
|
tickColor: "black",
|
|
12024
12121
|
rightAxisWidth: "0.3px",
|
|
12025
12122
|
fontSize: "10px",
|
|
12026
|
-
...(
|
|
12123
|
+
...(_f = value == null ? void 0 : value.style) == null ? void 0 : _f.labelStyle
|
|
12027
12124
|
},
|
|
12028
12125
|
barStyle: {
|
|
12029
12126
|
mediumValueColor: "rgba(63, 81, 181, 0.85)",
|
|
12030
12127
|
highValueColor: "rgba(63, 81, 181, 0.85)",
|
|
12031
12128
|
lowValueColor: "rgba(63, 81, 181, 0.85)",
|
|
12032
|
-
...(
|
|
12129
|
+
...(_g = value == null ? void 0 : value.style) == null ? void 0 : _g.barStyle
|
|
12033
12130
|
}
|
|
12034
12131
|
}
|
|
12035
12132
|
};
|
|
12036
12133
|
case "PieGraph":
|
|
12037
12134
|
return {
|
|
12038
12135
|
main: {
|
|
12039
|
-
data: ((
|
|
12136
|
+
data: ((_h = value == null ? void 0 : value.main) == null ? void 0 : _h.data) || [{ branch: "Kotak", value: 500 }, { branch: "SBI", value: 700 }, { branch: "HDFC", value: 900 }],
|
|
12040
12137
|
header: "Pie Graph",
|
|
12041
12138
|
bottomLabel: "Name of Employe",
|
|
12042
12139
|
leftLabel: "Value",
|
|
@@ -12050,7 +12147,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12050
12147
|
legendTitle: "Our Assests",
|
|
12051
12148
|
direction: "row",
|
|
12052
12149
|
align: "right",
|
|
12053
|
-
...(
|
|
12150
|
+
...(_i = value == null ? void 0 : value.main) == null ? void 0 : _i.legend
|
|
12054
12151
|
}
|
|
12055
12152
|
},
|
|
12056
12153
|
style: {
|
|
@@ -12060,7 +12157,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12060
12157
|
height: "310",
|
|
12061
12158
|
borderRadius: "20px",
|
|
12062
12159
|
padding: "10px 0 2px 0",
|
|
12063
|
-
...(
|
|
12160
|
+
...(_j = value == null ? void 0 : value.style) == null ? void 0 : _j.containerStyle
|
|
12064
12161
|
},
|
|
12065
12162
|
headerStyle: {
|
|
12066
12163
|
fontWeight: 500,
|
|
@@ -12070,17 +12167,17 @@ const finalDataProvider = (type2, value) => {
|
|
|
12070
12167
|
padding: "15px 0 1px 20px",
|
|
12071
12168
|
width: "100%",
|
|
12072
12169
|
fontSize: "18px",
|
|
12073
|
-
...(
|
|
12170
|
+
...(_k = value == null ? void 0 : value.style) == null ? void 0 : _k.headerStyle
|
|
12074
12171
|
},
|
|
12075
12172
|
tooltipStyle: {
|
|
12076
|
-
...(
|
|
12173
|
+
...(_l = value == null ? void 0 : value.style) == null ? void 0 : _l.tooltipStyle
|
|
12077
12174
|
},
|
|
12078
12175
|
labelStyle: {
|
|
12079
12176
|
labelColor: "black",
|
|
12080
12177
|
labelOffset: 45,
|
|
12081
12178
|
leftLabelMargin: "70",
|
|
12082
12179
|
topLabelMargin: "-40",
|
|
12083
|
-
...(
|
|
12180
|
+
...(_m = value == null ? void 0 : value.style) == null ? void 0 : _m.labelStyle
|
|
12084
12181
|
},
|
|
12085
12182
|
legendStyle: {
|
|
12086
12183
|
legend: {
|
|
@@ -12093,14 +12190,14 @@ const finalDataProvider = (type2, value) => {
|
|
|
12093
12190
|
border: "1px solid rgba(255, 255, 255, 0.3)",
|
|
12094
12191
|
borderRadius: " 8px",
|
|
12095
12192
|
margin: "5px 5px",
|
|
12096
|
-
...(
|
|
12193
|
+
...(_o = (_n2 = value == null ? void 0 : value.style) == null ? void 0 : _n2.legendStyle) == null ? void 0 : _o.legend
|
|
12097
12194
|
},
|
|
12098
12195
|
legendTitle: {
|
|
12099
12196
|
fontWeight: 500,
|
|
12100
12197
|
marginBottom: "5px",
|
|
12101
12198
|
fontFamily: "roboto",
|
|
12102
12199
|
fontSize: "10px",
|
|
12103
|
-
...(
|
|
12200
|
+
...(_q = (_p = value == null ? void 0 : value.style) == null ? void 0 : _p.legendStyle) == null ? void 0 : _q.legendTitle
|
|
12104
12201
|
}
|
|
12105
12202
|
},
|
|
12106
12203
|
pieStyle: {
|
|
@@ -12109,14 +12206,14 @@ const finalDataProvider = (type2, value) => {
|
|
|
12109
12206
|
innerRadius: 60,
|
|
12110
12207
|
cornerRadius: 2,
|
|
12111
12208
|
padAngle: 6e-3,
|
|
12112
|
-
...(
|
|
12209
|
+
...(_r = value == null ? void 0 : value.style) == null ? void 0 : _r.pieStyle
|
|
12113
12210
|
}
|
|
12114
12211
|
}
|
|
12115
12212
|
};
|
|
12116
12213
|
case "LineGraph":
|
|
12117
12214
|
return {
|
|
12118
12215
|
main: {
|
|
12119
|
-
data: ((
|
|
12216
|
+
data: ((_s = value == null ? void 0 : value.main) == null ? void 0 : _s.data) || [Product1],
|
|
12120
12217
|
header: "Line Graph Dynamic",
|
|
12121
12218
|
bottomLabel: "Name of Employe",
|
|
12122
12219
|
leftLabel: "Value",
|
|
@@ -12134,7 +12231,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12134
12231
|
direction: "row",
|
|
12135
12232
|
align: "right",
|
|
12136
12233
|
colorRectWidth: 20,
|
|
12137
|
-
...(
|
|
12234
|
+
...(_t2 = value == null ? void 0 : value.main) == null ? void 0 : _t2.legend
|
|
12138
12235
|
}
|
|
12139
12236
|
},
|
|
12140
12237
|
style: {
|
|
@@ -12144,7 +12241,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12144
12241
|
height: "300",
|
|
12145
12242
|
borderRadius: "20px",
|
|
12146
12243
|
padding: "10px 0 2px 0",
|
|
12147
|
-
...(
|
|
12244
|
+
...(_u = value == null ? void 0 : value.style) == null ? void 0 : _u.containerStyle
|
|
12148
12245
|
},
|
|
12149
12246
|
headerStyle: {
|
|
12150
12247
|
fontWeight: 500,
|
|
@@ -12154,35 +12251,35 @@ const finalDataProvider = (type2, value) => {
|
|
|
12154
12251
|
padding: "15px 0 1px 20px",
|
|
12155
12252
|
width: "100%",
|
|
12156
12253
|
fontSize: "18px",
|
|
12157
|
-
...(
|
|
12254
|
+
...(_v = value == null ? void 0 : value.style) == null ? void 0 : _v.headerStyle
|
|
12158
12255
|
},
|
|
12159
12256
|
labelStyle: {
|
|
12160
12257
|
labelColor: "black",
|
|
12161
12258
|
bottomLabelOffset: 20,
|
|
12162
12259
|
leftLabelOffset: 50,
|
|
12163
12260
|
leftLabelMargin: 80,
|
|
12164
|
-
...(
|
|
12261
|
+
...(_w = value == null ? void 0 : value.style) == null ? void 0 : _w.labelStyle
|
|
12165
12262
|
},
|
|
12166
12263
|
lineStyle: {
|
|
12167
12264
|
colorRange: ["#3f51b5", "rgba(200,0,31,0.9)", "rgba(25,200,205,0.6)"],
|
|
12168
12265
|
lineAreaColor: "none",
|
|
12169
12266
|
lineAreaOpacity: 0.2,
|
|
12170
|
-
...(
|
|
12267
|
+
...(_x = value == null ? void 0 : value.style) == null ? void 0 : _x.lineStyle
|
|
12171
12268
|
}
|
|
12172
12269
|
}
|
|
12173
12270
|
};
|
|
12174
12271
|
case "HorizontalBarGraph":
|
|
12175
12272
|
return {
|
|
12176
12273
|
main: {
|
|
12177
|
-
data: ((
|
|
12274
|
+
data: ((_y = value == null ? void 0 : value.main) == null ? void 0 : _y.data) || [{ y: "Anant Sharma", x: 60 }, { y: "Pankaj Chauhan", x: 60 }, { y: "satendra Raghav", x: 150 }, { y: "Vivek Pahadi", x: 80 }, { y: "Siddarth verma", x: 100 }],
|
|
12178
12275
|
header: " ",
|
|
12179
12276
|
bottomLabel: "Name of Employe",
|
|
12180
12277
|
leftLabel: "Value",
|
|
12181
12278
|
axisLeft: true,
|
|
12182
12279
|
axisBottom: true,
|
|
12183
12280
|
hideBottomTicks: false,
|
|
12184
|
-
hideLeftTicks: ((
|
|
12185
|
-
hideLeftAxisLine: ((
|
|
12281
|
+
hideLeftTicks: ((_z = value == null ? void 0 : value.main) == null ? void 0 : _z.data) ? true : false,
|
|
12282
|
+
hideLeftAxisLine: ((_A = value == null ? void 0 : value.main) == null ? void 0 : _A.data) ? true : false,
|
|
12186
12283
|
hideBottomAxisLine: false,
|
|
12187
12284
|
bottomAxisWidth: "10px",
|
|
12188
12285
|
...value.main
|
|
@@ -12194,7 +12291,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12194
12291
|
height: "300",
|
|
12195
12292
|
borderRadius: "20px",
|
|
12196
12293
|
padding: "10px 0 2px 0",
|
|
12197
|
-
...(
|
|
12294
|
+
...(_B = value == null ? void 0 : value.style) == null ? void 0 : _B.containerStyle
|
|
12198
12295
|
},
|
|
12199
12296
|
headerStyle: {
|
|
12200
12297
|
fontWeight: 500,
|
|
@@ -12204,12 +12301,12 @@ const finalDataProvider = (type2, value) => {
|
|
|
12204
12301
|
padding: "15px 0 1px 20px",
|
|
12205
12302
|
width: "100%",
|
|
12206
12303
|
fontSize: "18px",
|
|
12207
|
-
...(
|
|
12304
|
+
...(_C = value == null ? void 0 : value.style) == null ? void 0 : _C.headerStyle
|
|
12208
12305
|
},
|
|
12209
12306
|
tooltipStyle: {
|
|
12210
12307
|
padding: "6px",
|
|
12211
12308
|
borderRadius: "2px",
|
|
12212
|
-
...(
|
|
12309
|
+
...(_D = value == null ? void 0 : value.style) == null ? void 0 : _D.tooltipStyle
|
|
12213
12310
|
},
|
|
12214
12311
|
labelStyle: {
|
|
12215
12312
|
margin: { top: 10, left: 110, right: 40, bottom: 40 },
|
|
@@ -12220,11 +12317,11 @@ const finalDataProvider = (type2, value) => {
|
|
|
12220
12317
|
tickColor: "#6c5efb",
|
|
12221
12318
|
rightAxisWidth: "0.3px",
|
|
12222
12319
|
fontSize: "10px",
|
|
12223
|
-
...(
|
|
12320
|
+
...(_E = value == null ? void 0 : value.style) == null ? void 0 : _E.labelStyle
|
|
12224
12321
|
},
|
|
12225
12322
|
barStyle: {
|
|
12226
12323
|
color: "#6c5efb",
|
|
12227
|
-
...(
|
|
12324
|
+
...(_F = value == null ? void 0 : value.style) == null ? void 0 : _F.barStyle
|
|
12228
12325
|
}
|
|
12229
12326
|
}
|
|
12230
12327
|
};
|
|
@@ -18277,7 +18374,7 @@ var DrawHorizontalBarGraph = withTooltip(({
|
|
|
18277
18374
|
var _a2, _b2, _c2;
|
|
18278
18375
|
const xMax = width - margin.left - margin.right;
|
|
18279
18376
|
const yMax = height - margin.top - margin.bottom;
|
|
18280
|
-
const
|
|
18377
|
+
const tooltipStyles2 = {
|
|
18281
18378
|
...defaultStyles,
|
|
18282
18379
|
padding: "12px",
|
|
18283
18380
|
minWidth: 60,
|
|
@@ -18370,10 +18467,10 @@ var DrawHorizontalBarGraph = withTooltip(({
|
|
|
18370
18467
|
parentWidth: 500
|
|
18371
18468
|
})]
|
|
18372
18469
|
})]
|
|
18373
|
-
}), tooltipOpen && tooltipData && /* @__PURE__ */ jsxs(Tooltip$
|
|
18470
|
+
}), tooltipOpen && tooltipData && /* @__PURE__ */ jsxs(Tooltip$1, {
|
|
18374
18471
|
top: tooltipTop,
|
|
18375
18472
|
left: tooltipLeft,
|
|
18376
|
-
style:
|
|
18473
|
+
style: tooltipStyles2,
|
|
18377
18474
|
children: [/* @__PURE__ */ jsx("div", {
|
|
18378
18475
|
style: {
|
|
18379
18476
|
marginBottom: "5px"
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Group } from "@visx/group";
|
|
3
3
|
import { BarGroup } from "@visx/shape";
|
|
4
|
+
import { BarStack } from "@visx/shape";
|
|
4
5
|
import { scaleBand, scaleLinear, scaleOrdinal } from "@visx/scale";
|
|
5
6
|
import LeftAxis from "../LeftAxis";
|
|
7
|
+
import { useTooltipInPortal,defaultStyles } from "@visx/tooltip";
|
|
6
8
|
import BottomAxis from "../BottomAxis";
|
|
7
9
|
import { BarGroupProps } from "../../interface/interface";
|
|
8
10
|
import { useTooltip } from "@visx/tooltip";
|
|
@@ -10,6 +12,12 @@ import ToolTip from "../ToolTip";
|
|
|
10
12
|
import Legend from "../Legend";
|
|
11
13
|
|
|
12
14
|
type barValuesType = any;
|
|
15
|
+
const tooltipStyles = {
|
|
16
|
+
...defaultStyles,
|
|
17
|
+
minWidth: 60,
|
|
18
|
+
backgroundColor: "rgba(0,0,0,0.9)",
|
|
19
|
+
color: "white"
|
|
20
|
+
};
|
|
13
21
|
const defaultMargin = { top: 20, right: 0, bottom: 40, left:40 };
|
|
14
22
|
export default function DrawBarGraph({
|
|
15
23
|
width,
|
|
@@ -23,7 +31,14 @@ const keys = Object.keys(data[0]).filter((d) => d !== "label") as barValuesType[
|
|
|
23
31
|
|
|
24
32
|
// accessors
|
|
25
33
|
const getDate = (d: any) => d.label;
|
|
26
|
-
|
|
34
|
+
const temperatureTotals = data.reduce((allTotals, currentDate) => {
|
|
35
|
+
const totalTemperature = keys.reduce((dailyTotal, k) => {
|
|
36
|
+
dailyTotal += Number(currentDate[k]);
|
|
37
|
+
return dailyTotal;
|
|
38
|
+
}, 0);
|
|
39
|
+
allTotals.push(totalTemperature);
|
|
40
|
+
return allTotals;
|
|
41
|
+
}, [] as number[]);
|
|
27
42
|
// scales
|
|
28
43
|
const dateScale = scaleBand<string>({
|
|
29
44
|
domain: data.map(getDate),
|
|
@@ -34,20 +49,25 @@ const cityScale = scaleBand<string>({
|
|
|
34
49
|
padding: 0.1
|
|
35
50
|
});
|
|
36
51
|
const tempScale = scaleLinear<number>({
|
|
37
|
-
domain:
|
|
52
|
+
domain:value?.main?.type === "StackBarGraph"?
|
|
53
|
+
[0,Math.max(...temperatureTotals)]:
|
|
54
|
+
[
|
|
38
55
|
0,
|
|
39
56
|
Math.max(...data.map((d:any) => Math.max(...keys.map((key) => Number(d[key])))))
|
|
40
57
|
]
|
|
58
|
+
,
|
|
59
|
+
nice:true
|
|
60
|
+
|
|
41
61
|
});
|
|
42
62
|
const colorScale = scaleOrdinal<string, string>({
|
|
43
63
|
domain: keys,
|
|
44
64
|
range: [value.style?.barStyle?.color?.firstBarColor||"#aeeef8" ,
|
|
45
|
-
value.style?.barStyle?.color?.secondBarColor||"e5fd3d" ,
|
|
65
|
+
value.style?.barStyle?.color?.secondBarColor||"#e5fd3d" ,
|
|
46
66
|
value.style?.barStyle?.color?.thirdBarColor||"#9caff6" ]
|
|
47
67
|
});
|
|
48
68
|
// bounds
|
|
49
69
|
const xMax = width - margin.left - margin.right;
|
|
50
|
-
const yMax = height - margin.top - margin.bottom;
|
|
70
|
+
const yMax = height - margin.top - margin.bottom - 0;
|
|
51
71
|
|
|
52
72
|
// update scale output dimensions
|
|
53
73
|
dateScale.rangeRound([0, xMax]);
|
|
@@ -66,18 +86,38 @@ const colorScale = scaleOrdinal<string, string>({
|
|
|
66
86
|
showTooltip({
|
|
67
87
|
tooltipLeft: event.clientX,
|
|
68
88
|
tooltipTop: event.clientY,
|
|
69
|
-
tooltipData:
|
|
70
|
-
|
|
89
|
+
tooltipData: value?.main?.type === "StackBarGraph"?
|
|
90
|
+
{label:datum.bar.data.label,key:datum.key,value:datum.bar.data[datum.key],color:datum.color}
|
|
91
|
+
:
|
|
92
|
+
[datum.key,datum.value,datum.color],
|
|
93
|
+
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
const {TooltipInPortal, containerRef} = useTooltipInPortal({
|
|
97
|
+
detectBounds: true,
|
|
98
|
+
scroll: true,
|
|
99
|
+
});
|
|
100
|
+
const stachHandleMouse = (event: any, datum: any) => {
|
|
101
|
+
console.log(datum)
|
|
102
|
+
showTooltip({
|
|
103
|
+
tooltipLeft: event.clientX,
|
|
104
|
+
tooltipTop: event.clientY,
|
|
105
|
+
tooltipData:{label:datum.bar.data.label,key:datum.key,value:datum.bar.data[datum.key],color:datum.color}
|
|
106
|
+
|
|
71
107
|
});
|
|
72
108
|
};
|
|
73
109
|
return width < 10 ? null : (
|
|
74
|
-
<div>
|
|
75
|
-
{value?.main?.legendAvailable &&
|
|
110
|
+
<div style={{ }}>
|
|
111
|
+
{value?.main?.legendAvailable &&
|
|
76
112
|
<Legend
|
|
77
|
-
|
|
113
|
+
dataKeyArray={keys}
|
|
114
|
+
colorRange={[value.style?.barStyle?.color?.firstBarColor||"#aeeef8" ,
|
|
115
|
+
value.style?.barStyle?.color?.secondBarColor||"#e5fd3d" ,
|
|
116
|
+
value.style?.barStyle?.color?.thirdBarColor||"#9caff6" ]}
|
|
117
|
+
value={value}
|
|
78
118
|
/>
|
|
79
|
-
|
|
80
|
-
<svg width={width} height={height}>
|
|
119
|
+
}
|
|
120
|
+
<svg ref={containerRef} width={width} height={height}>
|
|
81
121
|
<rect
|
|
82
122
|
x={0}
|
|
83
123
|
y={0}
|
|
@@ -88,6 +128,37 @@ const colorScale = scaleOrdinal<string, string>({
|
|
|
88
128
|
/>
|
|
89
129
|
<Group top={margin.top} left={margin.left}>
|
|
90
130
|
<LeftAxis value={value} yScale={tempScale} parentWidth={width} />
|
|
131
|
+
{
|
|
132
|
+
value?.main?.type === "StackBarGraph"?
|
|
133
|
+
<BarStack<any, any>
|
|
134
|
+
data={data}
|
|
135
|
+
keys={keys}
|
|
136
|
+
x={getDate}
|
|
137
|
+
xScale={dateScale}
|
|
138
|
+
yScale={tempScale}
|
|
139
|
+
color={colorScale}
|
|
140
|
+
>
|
|
141
|
+
{(barStacks) =>
|
|
142
|
+
barStacks.map((barStack) =>
|
|
143
|
+
barStack.bars.map((bar) => (
|
|
144
|
+
<rect
|
|
145
|
+
key={`bar-stack-${barStack.index}-${bar.index}`}
|
|
146
|
+
x={bar.x}
|
|
147
|
+
y={bar.y}
|
|
148
|
+
height={bar.height}
|
|
149
|
+
width={bar.width}
|
|
150
|
+
fill={bar.color}
|
|
151
|
+
onClick={() => {
|
|
152
|
+
if (events) alert(`clicked: ${JSON.stringify(bar)}`);
|
|
153
|
+
}}
|
|
154
|
+
onMouseOver={(e) => stachHandleMouse(e, bar)}
|
|
155
|
+
onMouseOut={hideTooltip}
|
|
156
|
+
|
|
157
|
+
/>
|
|
158
|
+
)),
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
</BarStack> :
|
|
91
162
|
<BarGroup
|
|
92
163
|
data={data}
|
|
93
164
|
keys={keys}
|
|
@@ -126,6 +197,7 @@ const colorScale = scaleOrdinal<string, string>({
|
|
|
126
197
|
))
|
|
127
198
|
}
|
|
128
199
|
</BarGroup>
|
|
200
|
+
}
|
|
129
201
|
</Group>
|
|
130
202
|
<BottomAxis
|
|
131
203
|
yMax={yMax + margin.top}
|
|
@@ -136,7 +208,25 @@ const colorScale = scaleOrdinal<string, string>({
|
|
|
136
208
|
/>
|
|
137
209
|
|
|
138
210
|
</svg>
|
|
139
|
-
{
|
|
211
|
+
{
|
|
212
|
+
value?.main?.type === "StackBarGraph"?
|
|
213
|
+
tooltipOpen && tooltipData && (
|
|
214
|
+
|
|
215
|
+
<TooltipInPortal
|
|
216
|
+
top={tooltipTop}
|
|
217
|
+
left={tooltipLeft}
|
|
218
|
+
style={tooltipStyles}
|
|
219
|
+
>
|
|
220
|
+
<div style={{ color:tooltipData.color }}>
|
|
221
|
+
<strong>{tooltipData.label}</strong>
|
|
222
|
+
</div>
|
|
223
|
+
<div>{tooltipData.key}</div>
|
|
224
|
+
<div>
|
|
225
|
+
<small>{tooltipData.value}</small>
|
|
226
|
+
</div>
|
|
227
|
+
</TooltipInPortal>
|
|
228
|
+
):
|
|
229
|
+
tooltipOpen &&
|
|
140
230
|
<ToolTip
|
|
141
231
|
style={{...value?.style,tooltipbackground:tooltipData[2]}}
|
|
142
232
|
top={tooltipTop}
|
package/src/component/Legend.tsx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { LegendOrdinal, LegendItem, LegendLabel } from "@visx/legend";
|
|
3
3
|
import { scaleOrdinal } from "@visx/scale";
|
|
4
|
-
export function Legend({ value }: any) {
|
|
4
|
+
export function Legend({ value ,colorRange,dataKeyArray}: any) {
|
|
5
5
|
const legendGlyphSize = value?.main?.legend?.colorRectWidth || 15;
|
|
6
6
|
const ordinalColorScale = scaleOrdinal({
|
|
7
|
-
domain:
|
|
8
|
-
range: value?.style?.pieStyle?.colorRange,
|
|
7
|
+
domain:dataKeyArray||value?.main?.tooltipDataKey,
|
|
8
|
+
range:colorRange|| value?.style?.pieStyle?.colorRange,
|
|
9
9
|
});
|
|
10
10
|
return (
|
|
11
|
-
<div className="legend" style={value?.style?.legendStyle?.legend}>
|
|
11
|
+
<div className="legend" style={{paddingLeft:"40px",paddingRight:"40px",...value?.style?.legendStyle?.legend}}>
|
|
12
12
|
<div className="title" style={value?.style?.legendStyle?.legendTitle}>
|
|
13
13
|
{value?.main?.legend?.legendTitle}
|
|
14
14
|
</div>
|
|
@@ -13,24 +13,25 @@ const ToolTip = ({ style, top, left, tooltipData }: tooltipProps) => {
|
|
|
13
13
|
>
|
|
14
14
|
<div
|
|
15
15
|
style={{
|
|
16
|
-
height: "50px",
|
|
16
|
+
// height: "50px",
|
|
17
17
|
textAlign:"center",
|
|
18
18
|
background:"black",
|
|
19
19
|
padding:"10px",
|
|
20
20
|
boxShadow:"2px 2px 5px black",
|
|
21
21
|
color:"#6c5efb",
|
|
22
|
+
backgroundColor:"black",
|
|
22
23
|
// padding:"5px",
|
|
23
|
-
backgroundColor:style?.tooltipbackground||"black",
|
|
24
|
+
// backgroundColor:style?.tooltipbackground||"black",
|
|
24
25
|
...style?.tooltipStyle,
|
|
25
26
|
margin:"-20px",
|
|
26
27
|
}}
|
|
27
28
|
>
|
|
28
|
-
<div style={{padding:"4px 10px",
|
|
29
|
+
<div style={{padding:"4px 10px",color:style?.tooltipbackground||"white",borderRadius:"5px",fontWeight:700}}>
|
|
29
30
|
{tooltipData[0]}
|
|
30
31
|
</div>
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
<div style={{marginTop:"10px",fontWeight:700}}>
|
|
34
|
+
<div style={{padding:"4px 10px",borderRadius:"5px",marginTop:"10px",fontWeight:700}}>
|
|
34
35
|
{tooltipData[1]}
|
|
35
36
|
</div>
|
|
36
37
|
</div>
|
|
@@ -17,6 +17,7 @@ export const finalDataProvider = (type: string, value: any) => {
|
|
|
17
17
|
header: "Bar Graph",
|
|
18
18
|
bottomLabel: "Name of Employe",
|
|
19
19
|
numTicks: 6,
|
|
20
|
+
legendAvailable:true,
|
|
20
21
|
leftLabel: "Value",
|
|
21
22
|
axisLeft: true,
|
|
22
23
|
axisBottom: true,
|
|
@@ -25,7 +26,14 @@ export const finalDataProvider = (type: string, value: any) => {
|
|
|
25
26
|
hideLeftAxisLine: false,
|
|
26
27
|
hideBottomAxisLine: false,
|
|
27
28
|
bottomAxisWidth: "10px",
|
|
28
|
-
...value.main
|
|
29
|
+
...value.main,
|
|
30
|
+
legend: {
|
|
31
|
+
labelColor: "green",
|
|
32
|
+
legendTitle: "Our Assests",
|
|
33
|
+
direction: "row",
|
|
34
|
+
align: "right",
|
|
35
|
+
...value?.main?.legend,
|
|
36
|
+
},
|
|
29
37
|
},
|
|
30
38
|
style: {
|
|
31
39
|
containerStyle: {
|