@evergis/charts 2.0.64 → 2.0.66
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.
|
@@ -1987,7 +1987,7 @@ const barChartClassNames = /*#__PURE__*/_extends({
|
|
|
1987
1987
|
barChartGridLineY: 'barChartGridLineY',
|
|
1988
1988
|
barChartSelection: 'barChartSelection'
|
|
1989
1989
|
}, tooltipClassnames, labelClassnames, barChartLinesClassNames);
|
|
1990
|
-
const SvgWrapper$4 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$a || (_templateObject$a = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: ", ";\n user-select: ", ";\n
|
|
1990
|
+
const SvgWrapper$4 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$a || (_templateObject$a = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: ", ";\n user-select: ", ";\n width: ", ";\n\n line {\n stroke-width: 1px;\n shape-rendering: crispEdges;\n }\n\n .", ",\n .", " {\n stroke: rgba(48, 69, 79, 0.06);\n }\n\n .", " {\n }\n\n .", " {\n fill: none;\n pointer-events: all;\n }\n\n .", " {\n stroke-width: 1.5px;\n stroke-linejoin: round;\n stroke-linecap: round;\n }\n\n .", " {\n shape-rendering: auto;\n }\n\n .", " {\n fill-opacity: 0.24;\n }\n\n .", " {\n position: absolute;\n top: 0;\n width: 0;\n background: rgba(0, 170, 255, 0.06);\n box-shadow: 1px 0 0 #00AAFF, -1px 0 0 #00AAFF;\n pointer-events: none;\n }\n"])), _ref => {
|
|
1991
1991
|
let {
|
|
1992
1992
|
selectable
|
|
1993
1993
|
} = _ref;
|
|
@@ -2001,11 +2001,6 @@ const SvgWrapper$4 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$a ||
|
|
|
2001
2001
|
let {
|
|
2002
2002
|
selectable
|
|
2003
2003
|
} = _ref3;
|
|
2004
|
-
return selectable && "crosshair";
|
|
2005
|
-
}, _ref4 => {
|
|
2006
|
-
let {
|
|
2007
|
-
selectable
|
|
2008
|
-
} = _ref4;
|
|
2009
2004
|
return selectable && "auto";
|
|
2010
2005
|
}, barChartClassNames.barChartGridLineX, barChartClassNames.barChartGridLineY, barChartClassNames.barChartMouseRect, barChartClassNames.barChartMouseRect, barChartClassNames.barChartLinesGlobal, barChartClassNames.barChartLine, barChartClassNames.barChartArea, barChartClassNames.barChartSelection);
|
|
2011
2006
|
const TooltipStyles$1 = /*#__PURE__*/styled.createGlobalStyle(_templateObject2$4 || (_templateObject2$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", " {\n z-index: 1;\n transition: all linear 144ms;\n\n .", " {\n margin-bottom: 4px;\n :last-of-type {\n margin-bottom: 0;\n }\n }\n }\n"])), barChartClassNames.barChartMouseTooltip, barChartClassNames.barChartTooltipItem);
|
|
@@ -2013,26 +2008,30 @@ const TooltipStyles$1 = /*#__PURE__*/styled.createGlobalStyle(_templateObject2$4
|
|
|
2013
2008
|
const useSelection = (node, props) => {
|
|
2014
2009
|
const drawing = React.useRef(false);
|
|
2015
2010
|
const startX = React.useRef(0);
|
|
2016
|
-
const selection =
|
|
2011
|
+
const selection = React.useRef();
|
|
2017
2012
|
const onStartDrawing = React.useCallback(e => {
|
|
2018
2013
|
const isTouch = Boolean(e.touches);
|
|
2019
2014
|
e.stopPropagation();
|
|
2020
2015
|
|
|
2021
|
-
if (node) {
|
|
2022
|
-
var _e$touches$;
|
|
2016
|
+
if (node && e.which !== 3) {
|
|
2017
|
+
var _props$margin$bottom, _props$margin, _e$touches$;
|
|
2023
2018
|
|
|
2019
|
+
selection.current = document.createElement("div");
|
|
2020
|
+
selection.current.setAttribute("class", barChartClassNames.barChartSelection);
|
|
2021
|
+
selection.current.setAttribute("style", "height: calc(100% - " + ((_props$margin$bottom = (_props$margin = props.margin) == null ? void 0 : _props$margin.bottom) != null ? _props$margin$bottom : 0) + "px)");
|
|
2022
|
+
node.appendChild(selection.current);
|
|
2024
2023
|
drawing.current = true;
|
|
2025
2024
|
startX.current = isTouch ? ((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.pageX) - node.firstChild.getBoundingClientRect().left : e.offsetX;
|
|
2026
|
-
selection.style.display = "block";
|
|
2027
|
-
selection.style.width = "0px";
|
|
2028
|
-
selection.style.left = startX.current + "px";
|
|
2025
|
+
selection.current.style.display = "block";
|
|
2026
|
+
selection.current.style.width = "0px";
|
|
2027
|
+
selection.current.style.left = startX.current + "px";
|
|
2029
2028
|
}
|
|
2030
2029
|
}, [node]);
|
|
2031
2030
|
const onDraw = React.useCallback(e => {
|
|
2032
2031
|
const isTouch = Boolean(e.touches);
|
|
2033
2032
|
e.stopPropagation();
|
|
2034
2033
|
|
|
2035
|
-
if (node && drawing.current) {
|
|
2034
|
+
if (node && drawing.current && selection.current) {
|
|
2036
2035
|
var _e$touches$2;
|
|
2037
2036
|
|
|
2038
2037
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
@@ -2041,47 +2040,47 @@ const useSelection = (node, props) => {
|
|
|
2041
2040
|
|
|
2042
2041
|
if (offsetX >= 0) {
|
|
2043
2042
|
if (newWidth > 0) {
|
|
2044
|
-
selection.style.marginLeft = "0px";
|
|
2045
|
-
selection.style.width = offsetX <= nodeWidth ? newWidth + "px" : nodeWidth - startX.current + "px";
|
|
2043
|
+
selection.current.style.marginLeft = "0px";
|
|
2044
|
+
selection.current.style.width = offsetX <= nodeWidth ? newWidth + "px" : nodeWidth - startX.current + "px";
|
|
2046
2045
|
} else {
|
|
2047
|
-
selection.style.right = nodeWidth - startX.current + "px";
|
|
2048
|
-
selection.style.width = Math.abs(newWidth) + "px";
|
|
2049
|
-
selection.style.marginLeft = newWidth + "px";
|
|
2046
|
+
selection.current.style.right = nodeWidth - startX.current + "px";
|
|
2047
|
+
selection.current.style.width = Math.abs(newWidth) + "px";
|
|
2048
|
+
selection.current.style.marginLeft = newWidth + "px";
|
|
2050
2049
|
}
|
|
2051
2050
|
}
|
|
2052
2051
|
|
|
2053
2052
|
if (isTouch) {
|
|
2054
2053
|
if (node.offsetLeft > e.touches[0].pageX) {
|
|
2055
|
-
selection.style.right = nodeWidth - startX.current + "px";
|
|
2056
|
-
selection.style.width = startX.current + "px";
|
|
2057
|
-
selection.style.marginLeft = "-" + startX.current + "px";
|
|
2054
|
+
selection.current.style.right = nodeWidth - startX.current + "px";
|
|
2055
|
+
selection.current.style.width = startX.current + "px";
|
|
2056
|
+
selection.current.style.marginLeft = "-" + startX.current + "px";
|
|
2058
2057
|
}
|
|
2059
2058
|
}
|
|
2060
2059
|
}
|
|
2061
2060
|
}, [node]);
|
|
2062
2061
|
const onMouseLeave = React.useCallback(e => {
|
|
2063
|
-
if (drawing.current && node) {
|
|
2062
|
+
if (drawing.current && node && selection.current) {
|
|
2064
2063
|
if (node.offsetLeft > e.pageX) {
|
|
2065
2064
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2066
|
-
selection.style.right = nodeWidth - startX.current + "px";
|
|
2067
|
-
selection.style.width = startX.current + "px";
|
|
2068
|
-
selection.style.marginLeft = "-" + startX.current + "px";
|
|
2065
|
+
selection.current.style.right = nodeWidth - startX.current + "px";
|
|
2066
|
+
selection.current.style.width = startX.current + "px";
|
|
2067
|
+
selection.current.style.marginLeft = "-" + startX.current + "px";
|
|
2069
2068
|
}
|
|
2070
2069
|
|
|
2071
2070
|
if (node.offsetLeft + node.offsetWidth < e.pageX) {
|
|
2072
2071
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2073
|
-
selection.style.left = startX.current + "px";
|
|
2074
|
-
selection.style.width = nodeWidth - startX.current + "px";
|
|
2075
|
-
selection.style.marginLeft = "0px";
|
|
2072
|
+
selection.current.style.left = startX.current + "px";
|
|
2073
|
+
selection.current.style.width = nodeWidth - startX.current + "px";
|
|
2074
|
+
selection.current.style.marginLeft = "0px";
|
|
2076
2075
|
}
|
|
2077
2076
|
}
|
|
2078
2077
|
}, [node]);
|
|
2079
2078
|
const onStopDrawing = React.useCallback(() => {
|
|
2080
|
-
if (node) {
|
|
2079
|
+
if (node && selection.current) {
|
|
2081
2080
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2082
|
-
const selectionMinX = selection.offsetLeft >= 0 ? selection.offsetLeft <= nodeWidth ? selection.offsetLeft : nodeWidth : 0;
|
|
2083
|
-
const selectionWidth = selection.getBoundingClientRect().right - selection.getBoundingClientRect().left;
|
|
2084
|
-
const selectionMaxX = selection.offsetLeft + selectionWidth <= nodeWidth ? selection.offsetLeft + selectionWidth >= 0 ? selection.offsetLeft + selectionWidth : 0 : nodeWidth;
|
|
2081
|
+
const selectionMinX = selection.current.offsetLeft >= 0 ? selection.current.offsetLeft <= nodeWidth ? selection.current.offsetLeft : nodeWidth : 0;
|
|
2082
|
+
const selectionWidth = selection.current.getBoundingClientRect().right - selection.current.getBoundingClientRect().left;
|
|
2083
|
+
const selectionMaxX = selection.current.offsetLeft + selectionWidth <= nodeWidth ? selection.current.offsetLeft + selectionWidth >= 0 ? selection.current.offsetLeft + selectionWidth : 0 : nodeWidth;
|
|
2085
2084
|
const min = Math.round(selectionMinX);
|
|
2086
2085
|
const max = Math.round(selectionMaxX);
|
|
2087
2086
|
|
|
@@ -2090,20 +2089,15 @@ const useSelection = (node, props) => {
|
|
|
2090
2089
|
}
|
|
2091
2090
|
|
|
2092
2091
|
drawing.current = false;
|
|
2093
|
-
selection.
|
|
2092
|
+
node.removeChild(selection.current);
|
|
2093
|
+
selection.current = undefined;
|
|
2094
2094
|
}
|
|
2095
2095
|
}, [node]);
|
|
2096
2096
|
React.useEffect(() => {
|
|
2097
2097
|
if (node) {
|
|
2098
|
-
var _props$margin$bottom, _props$margin;
|
|
2099
|
-
|
|
2100
|
-
selection.setAttribute("class", barChartClassNames.barChartSelection);
|
|
2101
|
-
selection.setAttribute("style", "height: calc(100% - " + ((_props$margin$bottom = (_props$margin = props.margin) == null ? void 0 : _props$margin.bottom) != null ? _props$margin$bottom : 0) + "px)");
|
|
2102
|
-
selection.style.display = "none";
|
|
2103
2098
|
node.childNodes.forEach(child => {
|
|
2104
2099
|
child.style.userSelect = "none";
|
|
2105
2100
|
});
|
|
2106
|
-
node.appendChild(selection);
|
|
2107
2101
|
node.addEventListener("mousedown", onStartDrawing);
|
|
2108
2102
|
node.addEventListener("touchstart", onStartDrawing);
|
|
2109
2103
|
node.addEventListener("mousemove", onDraw);
|