impaktapps-design 0.1.3 → 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,27 +11142,27 @@ const ToolTip = ({
|
|
|
11143
11142
|
left: left2,
|
|
11144
11143
|
children: /* @__PURE__ */ jsxs("div", {
|
|
11145
11144
|
style: {
|
|
11146
|
-
height: "auto",
|
|
11147
|
-
width: "auto",
|
|
11148
11145
|
textAlign: "center",
|
|
11149
11146
|
background: "black",
|
|
11150
11147
|
padding: "10px",
|
|
11151
11148
|
boxShadow: "2px 2px 5px black",
|
|
11152
11149
|
color: "#6c5efb",
|
|
11153
|
-
backgroundColor:
|
|
11150
|
+
backgroundColor: "black",
|
|
11154
11151
|
...style2 == null ? void 0 : style2.tooltipStyle,
|
|
11155
11152
|
margin: "-20px"
|
|
11156
11153
|
},
|
|
11157
11154
|
children: [/* @__PURE__ */ jsx("div", {
|
|
11158
11155
|
style: {
|
|
11159
11156
|
padding: "4px 10px",
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11157
|
+
color: (style2 == null ? void 0 : style2.tooltipbackground) || "white",
|
|
11158
|
+
borderRadius: "5px",
|
|
11159
|
+
fontWeight: 700
|
|
11163
11160
|
},
|
|
11164
11161
|
children: tooltipData[0]
|
|
11165
11162
|
}), /* @__PURE__ */ jsx("div", {
|
|
11166
11163
|
style: {
|
|
11164
|
+
padding: "4px 10px",
|
|
11165
|
+
borderRadius: "5px",
|
|
11167
11166
|
marginTop: "10px",
|
|
11168
11167
|
fontWeight: 700
|
|
11169
11168
|
},
|
|
@@ -11539,17 +11538,23 @@ function Ordinal(props) {
|
|
|
11539
11538
|
return /* @__PURE__ */ React__default.createElement(Legend$1, props);
|
|
11540
11539
|
}
|
|
11541
11540
|
function Legend({
|
|
11542
|
-
value
|
|
11541
|
+
value,
|
|
11542
|
+
colorRange,
|
|
11543
|
+
dataKeyArray
|
|
11543
11544
|
}) {
|
|
11544
11545
|
var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k;
|
|
11545
11546
|
const legendGlyphSize = ((_b2 = (_a2 = value == null ? void 0 : value.main) == null ? void 0 : _a2.legend) == null ? void 0 : _b2.colorRectWidth) || 15;
|
|
11546
11547
|
const ordinalColorScale = createOrdinalScale$1({
|
|
11547
|
-
domain: (_c2 = value == null ? void 0 : value.main) == null ? void 0 : _c2.tooltipDataKey,
|
|
11548
|
-
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)
|
|
11549
11550
|
});
|
|
11550
11551
|
return /* @__PURE__ */ jsxs("div", {
|
|
11551
11552
|
className: "legend",
|
|
11552
|
-
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
|
+
},
|
|
11553
11558
|
children: [/* @__PURE__ */ jsx("div", {
|
|
11554
11559
|
className: "title",
|
|
11555
11560
|
style: (_i = (_h = value == null ? void 0 : value.style) == null ? void 0 : _h.legendStyle) == null ? void 0 : _i.legendTitle,
|
|
@@ -11592,6 +11597,12 @@ function Legend({
|
|
|
11592
11597
|
})]
|
|
11593
11598
|
});
|
|
11594
11599
|
}
|
|
11600
|
+
const tooltipStyles = {
|
|
11601
|
+
...defaultStyles,
|
|
11602
|
+
minWidth: 60,
|
|
11603
|
+
backgroundColor: "rgba(0,0,0,0.9)",
|
|
11604
|
+
color: "white"
|
|
11605
|
+
};
|
|
11595
11606
|
const defaultMargin = {
|
|
11596
11607
|
top: 20,
|
|
11597
11608
|
right: 0,
|
|
@@ -11605,10 +11616,18 @@ function DrawBarGraph({
|
|
|
11605
11616
|
margin = defaultMargin,
|
|
11606
11617
|
value
|
|
11607
11618
|
}) {
|
|
11608
|
-
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;
|
|
11609
11620
|
const data = (_a2 = value.main) == null ? void 0 : _a2.data;
|
|
11610
11621
|
const keys2 = Object.keys(data[0]).filter((d2) => d2 !== "label");
|
|
11611
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
|
+
}, []);
|
|
11612
11631
|
const dateScale = createBandScale({
|
|
11613
11632
|
domain: data.map(getDate),
|
|
11614
11633
|
padding: 0.2
|
|
@@ -11618,14 +11637,15 @@ function DrawBarGraph({
|
|
|
11618
11637
|
padding: 0.1
|
|
11619
11638
|
});
|
|
11620
11639
|
const tempScale = createLinearScale({
|
|
11621
|
-
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
|
|
11622
11642
|
});
|
|
11623
11643
|
const colorScale = createOrdinalScale$1({
|
|
11624
11644
|
domain: keys2,
|
|
11625
|
-
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"]
|
|
11626
11646
|
});
|
|
11627
11647
|
const xMax = width - margin.left - margin.right;
|
|
11628
|
-
const yMax = height - margin.top - margin.bottom;
|
|
11648
|
+
const yMax = height - margin.top - margin.bottom - 0;
|
|
11629
11649
|
dateScale.rangeRound([0, xMax]);
|
|
11630
11650
|
cityScale.rangeRound([0, dateScale.bandwidth()]);
|
|
11631
11651
|
tempScale.range([yMax, 0]);
|
|
@@ -11638,17 +11658,47 @@ function DrawBarGraph({
|
|
|
11638
11658
|
hideTooltip
|
|
11639
11659
|
} = useTooltip();
|
|
11640
11660
|
const handleMouse = (event, datum2) => {
|
|
11661
|
+
var _a3;
|
|
11641
11662
|
console.log(datum2);
|
|
11642
11663
|
showTooltip({
|
|
11643
11664
|
tooltipLeft: event.clientX,
|
|
11644
11665
|
tooltipTop: event.clientY,
|
|
11645
|
-
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
|
+
}
|
|
11646
11692
|
});
|
|
11647
11693
|
};
|
|
11648
11694
|
return width < 10 ? null : /* @__PURE__ */ jsxs("div", {
|
|
11649
|
-
|
|
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"],
|
|
11650
11699
|
value
|
|
11651
11700
|
}), /* @__PURE__ */ jsxs("svg", {
|
|
11701
|
+
ref: containerRef,
|
|
11652
11702
|
width,
|
|
11653
11703
|
height,
|
|
11654
11704
|
children: [/* @__PURE__ */ jsx("rect", {
|
|
@@ -11665,7 +11715,27 @@ function DrawBarGraph({
|
|
|
11665
11715
|
value,
|
|
11666
11716
|
yScale: tempScale,
|
|
11667
11717
|
parentWidth: width
|
|
11668
|
-
}), /* @__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, {
|
|
11669
11739
|
data,
|
|
11670
11740
|
keys: keys2,
|
|
11671
11741
|
height: yMax,
|
|
@@ -11707,7 +11777,25 @@ function DrawBarGraph({
|
|
|
11707
11777
|
xScale: dateScale,
|
|
11708
11778
|
parentWidth: width
|
|
11709
11779
|
})]
|
|
11710
|
-
}), 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, {
|
|
11711
11799
|
style: {
|
|
11712
11800
|
...value == null ? void 0 : value.style,
|
|
11713
11801
|
tooltipbackground: tooltipData[2]
|
|
@@ -11970,7 +12058,7 @@ const Product1 = [
|
|
|
11970
12058
|
{ x: "g", y: 50 }
|
|
11971
12059
|
];
|
|
11972
12060
|
const finalDataProvider = (type2, value) => {
|
|
11973
|
-
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;
|
|
11974
12062
|
switch (type2) {
|
|
11975
12063
|
case "BarGraph":
|
|
11976
12064
|
return {
|
|
@@ -11980,6 +12068,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
11980
12068
|
header: "Bar Graph",
|
|
11981
12069
|
bottomLabel: "Name of Employe",
|
|
11982
12070
|
numTicks: 6,
|
|
12071
|
+
legendAvailable: true,
|
|
11983
12072
|
leftLabel: "Value",
|
|
11984
12073
|
axisLeft: true,
|
|
11985
12074
|
axisBottom: true,
|
|
@@ -11987,7 +12076,14 @@ const finalDataProvider = (type2, value) => {
|
|
|
11987
12076
|
hideLeftAxisLine: false,
|
|
11988
12077
|
hideBottomAxisLine: false,
|
|
11989
12078
|
bottomAxisWidth: "10px",
|
|
11990
|
-
...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
|
+
}
|
|
11991
12087
|
},
|
|
11992
12088
|
style: {
|
|
11993
12089
|
containerStyle: {
|
|
@@ -11996,7 +12092,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
11996
12092
|
height: "300",
|
|
11997
12093
|
borderRadius: "20px",
|
|
11998
12094
|
padding: "10px 0 2px 0",
|
|
11999
|
-
...(
|
|
12095
|
+
...(_c2 = value == null ? void 0 : value.style) == null ? void 0 : _c2.containerStyle
|
|
12000
12096
|
},
|
|
12001
12097
|
headerStyle: {
|
|
12002
12098
|
fontWeight: 500,
|
|
@@ -12006,12 +12102,12 @@ const finalDataProvider = (type2, value) => {
|
|
|
12006
12102
|
padding: "15px 0 1px 20px",
|
|
12007
12103
|
width: "100%",
|
|
12008
12104
|
fontSize: "18px",
|
|
12009
|
-
...(
|
|
12105
|
+
...(_d = value == null ? void 0 : value.style) == null ? void 0 : _d.headerStyle
|
|
12010
12106
|
},
|
|
12011
12107
|
tooltipStyle: {
|
|
12012
12108
|
padding: "6px",
|
|
12013
12109
|
borderRadius: "2px",
|
|
12014
|
-
...(
|
|
12110
|
+
...(_e2 = value == null ? void 0 : value.style) == null ? void 0 : _e2.tooltipStyle
|
|
12015
12111
|
},
|
|
12016
12112
|
labelStyle: {
|
|
12017
12113
|
leftLabelMargin: "75",
|
|
@@ -12024,20 +12120,20 @@ const finalDataProvider = (type2, value) => {
|
|
|
12024
12120
|
tickColor: "black",
|
|
12025
12121
|
rightAxisWidth: "0.3px",
|
|
12026
12122
|
fontSize: "10px",
|
|
12027
|
-
...(
|
|
12123
|
+
...(_f = value == null ? void 0 : value.style) == null ? void 0 : _f.labelStyle
|
|
12028
12124
|
},
|
|
12029
12125
|
barStyle: {
|
|
12030
12126
|
mediumValueColor: "rgba(63, 81, 181, 0.85)",
|
|
12031
12127
|
highValueColor: "rgba(63, 81, 181, 0.85)",
|
|
12032
12128
|
lowValueColor: "rgba(63, 81, 181, 0.85)",
|
|
12033
|
-
...(
|
|
12129
|
+
...(_g = value == null ? void 0 : value.style) == null ? void 0 : _g.barStyle
|
|
12034
12130
|
}
|
|
12035
12131
|
}
|
|
12036
12132
|
};
|
|
12037
12133
|
case "PieGraph":
|
|
12038
12134
|
return {
|
|
12039
12135
|
main: {
|
|
12040
|
-
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 }],
|
|
12041
12137
|
header: "Pie Graph",
|
|
12042
12138
|
bottomLabel: "Name of Employe",
|
|
12043
12139
|
leftLabel: "Value",
|
|
@@ -12051,7 +12147,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12051
12147
|
legendTitle: "Our Assests",
|
|
12052
12148
|
direction: "row",
|
|
12053
12149
|
align: "right",
|
|
12054
|
-
...(
|
|
12150
|
+
...(_i = value == null ? void 0 : value.main) == null ? void 0 : _i.legend
|
|
12055
12151
|
}
|
|
12056
12152
|
},
|
|
12057
12153
|
style: {
|
|
@@ -12061,7 +12157,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12061
12157
|
height: "310",
|
|
12062
12158
|
borderRadius: "20px",
|
|
12063
12159
|
padding: "10px 0 2px 0",
|
|
12064
|
-
...(
|
|
12160
|
+
...(_j = value == null ? void 0 : value.style) == null ? void 0 : _j.containerStyle
|
|
12065
12161
|
},
|
|
12066
12162
|
headerStyle: {
|
|
12067
12163
|
fontWeight: 500,
|
|
@@ -12071,17 +12167,17 @@ const finalDataProvider = (type2, value) => {
|
|
|
12071
12167
|
padding: "15px 0 1px 20px",
|
|
12072
12168
|
width: "100%",
|
|
12073
12169
|
fontSize: "18px",
|
|
12074
|
-
...(
|
|
12170
|
+
...(_k = value == null ? void 0 : value.style) == null ? void 0 : _k.headerStyle
|
|
12075
12171
|
},
|
|
12076
12172
|
tooltipStyle: {
|
|
12077
|
-
...(
|
|
12173
|
+
...(_l = value == null ? void 0 : value.style) == null ? void 0 : _l.tooltipStyle
|
|
12078
12174
|
},
|
|
12079
12175
|
labelStyle: {
|
|
12080
12176
|
labelColor: "black",
|
|
12081
12177
|
labelOffset: 45,
|
|
12082
12178
|
leftLabelMargin: "70",
|
|
12083
12179
|
topLabelMargin: "-40",
|
|
12084
|
-
...(
|
|
12180
|
+
...(_m = value == null ? void 0 : value.style) == null ? void 0 : _m.labelStyle
|
|
12085
12181
|
},
|
|
12086
12182
|
legendStyle: {
|
|
12087
12183
|
legend: {
|
|
@@ -12094,14 +12190,14 @@ const finalDataProvider = (type2, value) => {
|
|
|
12094
12190
|
border: "1px solid rgba(255, 255, 255, 0.3)",
|
|
12095
12191
|
borderRadius: " 8px",
|
|
12096
12192
|
margin: "5px 5px",
|
|
12097
|
-
...(
|
|
12193
|
+
...(_o = (_n2 = value == null ? void 0 : value.style) == null ? void 0 : _n2.legendStyle) == null ? void 0 : _o.legend
|
|
12098
12194
|
},
|
|
12099
12195
|
legendTitle: {
|
|
12100
12196
|
fontWeight: 500,
|
|
12101
12197
|
marginBottom: "5px",
|
|
12102
12198
|
fontFamily: "roboto",
|
|
12103
12199
|
fontSize: "10px",
|
|
12104
|
-
...(
|
|
12200
|
+
...(_q = (_p = value == null ? void 0 : value.style) == null ? void 0 : _p.legendStyle) == null ? void 0 : _q.legendTitle
|
|
12105
12201
|
}
|
|
12106
12202
|
},
|
|
12107
12203
|
pieStyle: {
|
|
@@ -12110,14 +12206,14 @@ const finalDataProvider = (type2, value) => {
|
|
|
12110
12206
|
innerRadius: 60,
|
|
12111
12207
|
cornerRadius: 2,
|
|
12112
12208
|
padAngle: 6e-3,
|
|
12113
|
-
...(
|
|
12209
|
+
...(_r = value == null ? void 0 : value.style) == null ? void 0 : _r.pieStyle
|
|
12114
12210
|
}
|
|
12115
12211
|
}
|
|
12116
12212
|
};
|
|
12117
12213
|
case "LineGraph":
|
|
12118
12214
|
return {
|
|
12119
12215
|
main: {
|
|
12120
|
-
data: ((
|
|
12216
|
+
data: ((_s = value == null ? void 0 : value.main) == null ? void 0 : _s.data) || [Product1],
|
|
12121
12217
|
header: "Line Graph Dynamic",
|
|
12122
12218
|
bottomLabel: "Name of Employe",
|
|
12123
12219
|
leftLabel: "Value",
|
|
@@ -12135,7 +12231,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12135
12231
|
direction: "row",
|
|
12136
12232
|
align: "right",
|
|
12137
12233
|
colorRectWidth: 20,
|
|
12138
|
-
...(
|
|
12234
|
+
...(_t2 = value == null ? void 0 : value.main) == null ? void 0 : _t2.legend
|
|
12139
12235
|
}
|
|
12140
12236
|
},
|
|
12141
12237
|
style: {
|
|
@@ -12145,7 +12241,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12145
12241
|
height: "300",
|
|
12146
12242
|
borderRadius: "20px",
|
|
12147
12243
|
padding: "10px 0 2px 0",
|
|
12148
|
-
...(
|
|
12244
|
+
...(_u = value == null ? void 0 : value.style) == null ? void 0 : _u.containerStyle
|
|
12149
12245
|
},
|
|
12150
12246
|
headerStyle: {
|
|
12151
12247
|
fontWeight: 500,
|
|
@@ -12155,35 +12251,35 @@ const finalDataProvider = (type2, value) => {
|
|
|
12155
12251
|
padding: "15px 0 1px 20px",
|
|
12156
12252
|
width: "100%",
|
|
12157
12253
|
fontSize: "18px",
|
|
12158
|
-
...(
|
|
12254
|
+
...(_v = value == null ? void 0 : value.style) == null ? void 0 : _v.headerStyle
|
|
12159
12255
|
},
|
|
12160
12256
|
labelStyle: {
|
|
12161
12257
|
labelColor: "black",
|
|
12162
12258
|
bottomLabelOffset: 20,
|
|
12163
12259
|
leftLabelOffset: 50,
|
|
12164
12260
|
leftLabelMargin: 80,
|
|
12165
|
-
...(
|
|
12261
|
+
...(_w = value == null ? void 0 : value.style) == null ? void 0 : _w.labelStyle
|
|
12166
12262
|
},
|
|
12167
12263
|
lineStyle: {
|
|
12168
12264
|
colorRange: ["#3f51b5", "rgba(200,0,31,0.9)", "rgba(25,200,205,0.6)"],
|
|
12169
12265
|
lineAreaColor: "none",
|
|
12170
12266
|
lineAreaOpacity: 0.2,
|
|
12171
|
-
...(
|
|
12267
|
+
...(_x = value == null ? void 0 : value.style) == null ? void 0 : _x.lineStyle
|
|
12172
12268
|
}
|
|
12173
12269
|
}
|
|
12174
12270
|
};
|
|
12175
12271
|
case "HorizontalBarGraph":
|
|
12176
12272
|
return {
|
|
12177
12273
|
main: {
|
|
12178
|
-
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 }],
|
|
12179
12275
|
header: " ",
|
|
12180
12276
|
bottomLabel: "Name of Employe",
|
|
12181
12277
|
leftLabel: "Value",
|
|
12182
12278
|
axisLeft: true,
|
|
12183
12279
|
axisBottom: true,
|
|
12184
12280
|
hideBottomTicks: false,
|
|
12185
|
-
hideLeftTicks: ((
|
|
12186
|
-
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,
|
|
12187
12283
|
hideBottomAxisLine: false,
|
|
12188
12284
|
bottomAxisWidth: "10px",
|
|
12189
12285
|
...value.main
|
|
@@ -12195,7 +12291,7 @@ const finalDataProvider = (type2, value) => {
|
|
|
12195
12291
|
height: "300",
|
|
12196
12292
|
borderRadius: "20px",
|
|
12197
12293
|
padding: "10px 0 2px 0",
|
|
12198
|
-
...(
|
|
12294
|
+
...(_B = value == null ? void 0 : value.style) == null ? void 0 : _B.containerStyle
|
|
12199
12295
|
},
|
|
12200
12296
|
headerStyle: {
|
|
12201
12297
|
fontWeight: 500,
|
|
@@ -12205,12 +12301,12 @@ const finalDataProvider = (type2, value) => {
|
|
|
12205
12301
|
padding: "15px 0 1px 20px",
|
|
12206
12302
|
width: "100%",
|
|
12207
12303
|
fontSize: "18px",
|
|
12208
|
-
...(
|
|
12304
|
+
...(_C = value == null ? void 0 : value.style) == null ? void 0 : _C.headerStyle
|
|
12209
12305
|
},
|
|
12210
12306
|
tooltipStyle: {
|
|
12211
12307
|
padding: "6px",
|
|
12212
12308
|
borderRadius: "2px",
|
|
12213
|
-
...(
|
|
12309
|
+
...(_D = value == null ? void 0 : value.style) == null ? void 0 : _D.tooltipStyle
|
|
12214
12310
|
},
|
|
12215
12311
|
labelStyle: {
|
|
12216
12312
|
margin: { top: 10, left: 110, right: 40, bottom: 40 },
|
|
@@ -12221,11 +12317,11 @@ const finalDataProvider = (type2, value) => {
|
|
|
12221
12317
|
tickColor: "#6c5efb",
|
|
12222
12318
|
rightAxisWidth: "0.3px",
|
|
12223
12319
|
fontSize: "10px",
|
|
12224
|
-
...(
|
|
12320
|
+
...(_E = value == null ? void 0 : value.style) == null ? void 0 : _E.labelStyle
|
|
12225
12321
|
},
|
|
12226
12322
|
barStyle: {
|
|
12227
12323
|
color: "#6c5efb",
|
|
12228
|
-
...(
|
|
12324
|
+
...(_F = value == null ? void 0 : value.style) == null ? void 0 : _F.barStyle
|
|
12229
12325
|
}
|
|
12230
12326
|
}
|
|
12231
12327
|
};
|
|
@@ -18278,7 +18374,7 @@ var DrawHorizontalBarGraph = withTooltip(({
|
|
|
18278
18374
|
var _a2, _b2, _c2;
|
|
18279
18375
|
const xMax = width - margin.left - margin.right;
|
|
18280
18376
|
const yMax = height - margin.top - margin.bottom;
|
|
18281
|
-
const
|
|
18377
|
+
const tooltipStyles2 = {
|
|
18282
18378
|
...defaultStyles,
|
|
18283
18379
|
padding: "12px",
|
|
18284
18380
|
minWidth: 60,
|
|
@@ -18371,10 +18467,10 @@ var DrawHorizontalBarGraph = withTooltip(({
|
|
|
18371
18467
|
parentWidth: 500
|
|
18372
18468
|
})]
|
|
18373
18469
|
})]
|
|
18374
|
-
}), tooltipOpen && tooltipData && /* @__PURE__ */ jsxs(Tooltip$
|
|
18470
|
+
}), tooltipOpen && tooltipData && /* @__PURE__ */ jsxs(Tooltip$1, {
|
|
18375
18471
|
top: tooltipTop,
|
|
18376
18472
|
left: tooltipLeft,
|
|
18377
|
-
style:
|
|
18473
|
+
style: tooltipStyles2,
|
|
18378
18474
|
children: [/* @__PURE__ */ jsx("div", {
|
|
18379
18475
|
style: {
|
|
18380
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,25 +13,25 @@ const ToolTip = ({ style, top, left, tooltipData }: tooltipProps) => {
|
|
|
13
13
|
>
|
|
14
14
|
<div
|
|
15
15
|
style={{
|
|
16
|
-
height: "
|
|
17
|
-
width:"auto",
|
|
16
|
+
// height: "50px",
|
|
18
17
|
textAlign:"center",
|
|
19
18
|
background:"black",
|
|
20
19
|
padding:"10px",
|
|
21
20
|
boxShadow:"2px 2px 5px black",
|
|
22
21
|
color:"#6c5efb",
|
|
22
|
+
backgroundColor:"black",
|
|
23
23
|
// padding:"5px",
|
|
24
|
-
backgroundColor:style?.tooltipbackground||"black",
|
|
24
|
+
// backgroundColor:style?.tooltipbackground||"black",
|
|
25
25
|
...style?.tooltipStyle,
|
|
26
26
|
margin:"-20px",
|
|
27
27
|
}}
|
|
28
28
|
>
|
|
29
|
-
<div style={{padding:"4px 10px",
|
|
29
|
+
<div style={{padding:"4px 10px",color:style?.tooltipbackground||"white",borderRadius:"5px",fontWeight:700}}>
|
|
30
30
|
{tooltipData[0]}
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
<div style={{marginTop:"10px",fontWeight:700}}>
|
|
34
|
+
<div style={{padding:"4px 10px",borderRadius:"5px",marginTop:"10px",fontWeight:700}}>
|
|
35
35
|
{tooltipData[1]}
|
|
36
36
|
</div>
|
|
37
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: {
|