@evergis/charts 2.0.63 → 2.0.65
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/charts.esm.js
CHANGED
|
@@ -1979,7 +1979,7 @@ const barChartClassNames = /*#__PURE__*/_extends({
|
|
|
1979
1979
|
barChartGridLineY: 'barChartGridLineY',
|
|
1980
1980
|
barChartSelection: 'barChartSelection'
|
|
1981
1981
|
}, tooltipClassnames, labelClassnames, barChartLinesClassNames);
|
|
1982
|
-
const SvgWrapper$4 = /*#__PURE__*/styled(Wrapper)(_templateObject$a || (_templateObject$a = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: ", ";\n user-select: ", ";\n cursor: ", ";\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 => {
|
|
1982
|
+
const SvgWrapper$4 = /*#__PURE__*/styled(Wrapper)(_templateObject$a || (_templateObject$a = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: ", ";\n user-select: ", ";\n cursor: ", ";\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 => {
|
|
1983
1983
|
let {
|
|
1984
1984
|
selectable
|
|
1985
1985
|
} = _ref;
|
|
@@ -1994,32 +1994,41 @@ const SvgWrapper$4 = /*#__PURE__*/styled(Wrapper)(_templateObject$a || (_templat
|
|
|
1994
1994
|
selectable
|
|
1995
1995
|
} = _ref3;
|
|
1996
1996
|
return selectable && "crosshair";
|
|
1997
|
+
}, _ref4 => {
|
|
1998
|
+
let {
|
|
1999
|
+
selectable
|
|
2000
|
+
} = _ref4;
|
|
2001
|
+
return selectable && "auto";
|
|
1997
2002
|
}, barChartClassNames.barChartGridLineX, barChartClassNames.barChartGridLineY, barChartClassNames.barChartMouseRect, barChartClassNames.barChartMouseRect, barChartClassNames.barChartLinesGlobal, barChartClassNames.barChartLine, barChartClassNames.barChartArea, barChartClassNames.barChartSelection);
|
|
1998
2003
|
const TooltipStyles$1 = /*#__PURE__*/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);
|
|
1999
2004
|
|
|
2000
2005
|
const useSelection = (node, props) => {
|
|
2001
2006
|
const drawing = useRef(false);
|
|
2002
2007
|
const startX = useRef(0);
|
|
2003
|
-
const selection =
|
|
2008
|
+
const selection = useRef();
|
|
2004
2009
|
const onStartDrawing = useCallback(e => {
|
|
2005
2010
|
const isTouch = Boolean(e.touches);
|
|
2006
2011
|
e.stopPropagation();
|
|
2007
2012
|
|
|
2008
|
-
if (node) {
|
|
2009
|
-
var _e$touches$;
|
|
2013
|
+
if (node && e.which !== 3) {
|
|
2014
|
+
var _props$margin$bottom, _props$margin, _e$touches$;
|
|
2010
2015
|
|
|
2016
|
+
selection.current = document.createElement("div");
|
|
2017
|
+
selection.current.setAttribute("class", barChartClassNames.barChartSelection);
|
|
2018
|
+
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)");
|
|
2019
|
+
node.appendChild(selection.current);
|
|
2011
2020
|
drawing.current = true;
|
|
2012
2021
|
startX.current = isTouch ? ((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.pageX) - node.firstChild.getBoundingClientRect().left : e.offsetX;
|
|
2013
|
-
selection.style.display = "block";
|
|
2014
|
-
selection.style.width = "0px";
|
|
2015
|
-
selection.style.left = startX.current + "px";
|
|
2022
|
+
selection.current.style.display = "block";
|
|
2023
|
+
selection.current.style.width = "0px";
|
|
2024
|
+
selection.current.style.left = startX.current + "px";
|
|
2016
2025
|
}
|
|
2017
2026
|
}, [node]);
|
|
2018
2027
|
const onDraw = useCallback(e => {
|
|
2019
2028
|
const isTouch = Boolean(e.touches);
|
|
2020
2029
|
e.stopPropagation();
|
|
2021
2030
|
|
|
2022
|
-
if (node && drawing.current) {
|
|
2031
|
+
if (node && drawing.current && selection.current) {
|
|
2023
2032
|
var _e$touches$2;
|
|
2024
2033
|
|
|
2025
2034
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
@@ -2028,42 +2037,47 @@ const useSelection = (node, props) => {
|
|
|
2028
2037
|
|
|
2029
2038
|
if (offsetX >= 0) {
|
|
2030
2039
|
if (newWidth > 0) {
|
|
2031
|
-
selection.style.marginLeft = "0px";
|
|
2032
|
-
selection.style.width = offsetX <= nodeWidth ? newWidth + "px" : nodeWidth - startX.current + "px";
|
|
2040
|
+
selection.current.style.marginLeft = "0px";
|
|
2041
|
+
selection.current.style.width = offsetX <= nodeWidth ? newWidth + "px" : nodeWidth - startX.current + "px";
|
|
2033
2042
|
} else {
|
|
2034
|
-
selection.style.right = nodeWidth - startX.current + "px";
|
|
2035
|
-
selection.style.width = Math.abs(newWidth) + "px";
|
|
2036
|
-
selection.style.marginLeft = newWidth + "px";
|
|
2043
|
+
selection.current.style.right = nodeWidth - startX.current + "px";
|
|
2044
|
+
selection.current.style.width = Math.abs(newWidth) + "px";
|
|
2045
|
+
selection.current.style.marginLeft = newWidth + "px";
|
|
2037
2046
|
}
|
|
2038
2047
|
}
|
|
2039
2048
|
|
|
2040
2049
|
if (isTouch) {
|
|
2041
2050
|
if (node.offsetLeft > e.touches[0].pageX) {
|
|
2042
|
-
selection.style.right = nodeWidth - startX.current + "px";
|
|
2043
|
-
selection.style.width = startX.current + "px";
|
|
2044
|
-
selection.style.marginLeft = "-" + startX.current + "px";
|
|
2051
|
+
selection.current.style.right = nodeWidth - startX.current + "px";
|
|
2052
|
+
selection.current.style.width = startX.current + "px";
|
|
2053
|
+
selection.current.style.marginLeft = "-" + startX.current + "px";
|
|
2045
2054
|
}
|
|
2046
2055
|
}
|
|
2047
2056
|
}
|
|
2048
2057
|
}, [node]);
|
|
2049
|
-
const
|
|
2050
|
-
if (drawing.current && node) {
|
|
2058
|
+
const onMouseLeave = useCallback(e => {
|
|
2059
|
+
if (drawing.current && node && selection.current) {
|
|
2051
2060
|
if (node.offsetLeft > e.pageX) {
|
|
2052
2061
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2053
|
-
selection.style.right = nodeWidth - startX.current + "px";
|
|
2054
|
-
selection.style.width = startX.current + "px";
|
|
2055
|
-
selection.style.marginLeft = "-" + startX.current + "px";
|
|
2062
|
+
selection.current.style.right = nodeWidth - startX.current + "px";
|
|
2063
|
+
selection.current.style.width = startX.current + "px";
|
|
2064
|
+
selection.current.style.marginLeft = "-" + startX.current + "px";
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
if (node.offsetLeft + node.offsetWidth < e.pageX) {
|
|
2068
|
+
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2069
|
+
selection.current.style.left = startX.current + "px";
|
|
2070
|
+
selection.current.style.width = nodeWidth - startX.current + "px";
|
|
2071
|
+
selection.current.style.marginLeft = "0px";
|
|
2056
2072
|
}
|
|
2057
2073
|
}
|
|
2058
2074
|
}, [node]);
|
|
2059
|
-
const onStopDrawing = useCallback(
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
if (node) {
|
|
2075
|
+
const onStopDrawing = useCallback(() => {
|
|
2076
|
+
if (node && selection.current) {
|
|
2063
2077
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2064
|
-
const selectionMinX = selection.offsetLeft >= 0 ? selection.offsetLeft <= nodeWidth ? selection.offsetLeft : nodeWidth : 0;
|
|
2065
|
-
const selectionWidth = selection.getBoundingClientRect().right - selection.getBoundingClientRect().left;
|
|
2066
|
-
const selectionMaxX = selection.offsetLeft + selectionWidth <= nodeWidth ? selection.offsetLeft + selectionWidth >= 0 ? selection.offsetLeft + selectionWidth : 0 : nodeWidth;
|
|
2078
|
+
const selectionMinX = selection.current.offsetLeft >= 0 ? selection.current.offsetLeft <= nodeWidth ? selection.current.offsetLeft : nodeWidth : 0;
|
|
2079
|
+
const selectionWidth = selection.current.getBoundingClientRect().right - selection.current.getBoundingClientRect().left;
|
|
2080
|
+
const selectionMaxX = selection.current.offsetLeft + selectionWidth <= nodeWidth ? selection.current.offsetLeft + selectionWidth >= 0 ? selection.current.offsetLeft + selectionWidth : 0 : nodeWidth;
|
|
2067
2081
|
const min = Math.round(selectionMinX);
|
|
2068
2082
|
const max = Math.round(selectionMaxX);
|
|
2069
2083
|
|
|
@@ -2072,27 +2086,23 @@ const useSelection = (node, props) => {
|
|
|
2072
2086
|
}
|
|
2073
2087
|
|
|
2074
2088
|
drawing.current = false;
|
|
2075
|
-
selection.
|
|
2089
|
+
node.removeChild(selection.current);
|
|
2090
|
+
selection.current = undefined;
|
|
2076
2091
|
}
|
|
2077
2092
|
}, [node]);
|
|
2078
2093
|
useEffect(() => {
|
|
2079
2094
|
if (node) {
|
|
2080
|
-
var _props$margin$bottom, _props$margin;
|
|
2081
|
-
|
|
2082
|
-
selection.setAttribute("class", barChartClassNames.barChartSelection);
|
|
2083
|
-
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)");
|
|
2084
|
-
selection.style.display = "none";
|
|
2085
2095
|
node.childNodes.forEach(child => {
|
|
2086
2096
|
child.style.userSelect = "none";
|
|
2087
2097
|
});
|
|
2088
|
-
node.appendChild(selection);
|
|
2089
2098
|
node.addEventListener("mousedown", onStartDrawing);
|
|
2090
2099
|
node.addEventListener("touchstart", onStartDrawing);
|
|
2091
2100
|
node.addEventListener("mousemove", onDraw);
|
|
2092
2101
|
node.addEventListener("touchmove", onDraw);
|
|
2093
|
-
|
|
2102
|
+
node.addEventListener("mouseleave", onMouseLeave);
|
|
2103
|
+
node.addEventListener("mouseup", onStopDrawing);
|
|
2104
|
+
node.addEventListener("touchend", onStopDrawing);
|
|
2094
2105
|
document.addEventListener("mouseup", onStopDrawing);
|
|
2095
|
-
document.addEventListener("touchend", onStopDrawing);
|
|
2096
2106
|
}
|
|
2097
2107
|
|
|
2098
2108
|
return () => {
|
|
@@ -2100,9 +2110,10 @@ const useSelection = (node, props) => {
|
|
|
2100
2110
|
node == null ? void 0 : node.removeEventListener("touchstart", onStartDrawing);
|
|
2101
2111
|
node == null ? void 0 : node.removeEventListener("mousemove", onDraw);
|
|
2102
2112
|
node == null ? void 0 : node.removeEventListener("touchmove", onDraw);
|
|
2103
|
-
|
|
2113
|
+
node == null ? void 0 : node.removeEventListener("mouseleave", onMouseLeave);
|
|
2114
|
+
node == null ? void 0 : node.removeEventListener("mouseup", onStopDrawing);
|
|
2115
|
+
node == null ? void 0 : node.removeEventListener("touchend", onStopDrawing);
|
|
2104
2116
|
document.removeEventListener("mouseup", onStopDrawing);
|
|
2105
|
-
document.removeEventListener("touchend", onStopDrawing);
|
|
2106
2117
|
};
|
|
2107
2118
|
}, [node]);
|
|
2108
2119
|
};
|