@evergis/charts 2.0.12 → 2.0.17
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/HorizontalBarChart/hooks/useTooltip/index.d.ts +1 -1
- package/dist/charts/HorizontalBarChart/types.d.ts +1 -0
- package/dist/charts/LineChart/types.d.ts +3 -1
- package/dist/charts/PieChart/drawTooltips/index.d.ts +1 -1
- package/dist/charts/PieChart/drawTooltips/types.d.ts +2 -1
- package/dist/charts/PieChart/styled.d.ts +1 -0
- package/dist/charts.cjs.development.js +84 -60
- package/dist/charts.cjs.development.js.map +1 -1
- package/dist/charts.cjs.production.min.js +1 -1
- package/dist/charts.cjs.production.min.js.map +1 -1
- package/dist/charts.esm.js +83 -62
- package/dist/charts.esm.js.map +1 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useResize.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/package.json +2 -2
package/dist/charts.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css, createGlobalStyle } from 'styled-components';
|
|
2
|
-
import React, { useState, useCallback,
|
|
2
|
+
import React, { useState, useCallback, useMemo, useEffect, useRef, Fragment } from 'react';
|
|
3
3
|
import { select, pointer, min, max, scaleLinear, lineRadial, curveLinearClosed, range as range$1, format, arc, pie, create, quantize, interpolate, interpolateRound, quantile, axisBottom, group, utcFormat, scaleSequential, interpolateGreens, utcYear, utcMonths, utcMonth, utcSunday, utcMonday, axisLeft, line, curveLinear, area, scaleBand, sum } from 'd3';
|
|
4
4
|
import ReactDOMServer from 'react-dom/server';
|
|
5
5
|
import { unmountComponentAtNode, render } from 'react-dom';
|
|
@@ -57,6 +57,42 @@ function _templateObject() {
|
|
|
57
57
|
}
|
|
58
58
|
const Wrapper = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject());
|
|
59
59
|
|
|
60
|
+
function useNode() {
|
|
61
|
+
const [node, onSetNode] = useState(null);
|
|
62
|
+
const ref = useCallback(onSetNode, [onSetNode]);
|
|
63
|
+
return [ref, node];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function throttle(fn, wait) {
|
|
67
|
+
let isCalled = false;
|
|
68
|
+
return function () {
|
|
69
|
+
if (!isCalled) {
|
|
70
|
+
fn(...arguments);
|
|
71
|
+
isCalled = true;
|
|
72
|
+
setTimeout(function () {
|
|
73
|
+
isCalled = false;
|
|
74
|
+
}, wait);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const THROTTLE_DELAY = 44;
|
|
80
|
+
const useResize = (width, callback, delay) => {
|
|
81
|
+
const throttledCallback = useMemo(() => {
|
|
82
|
+
return callback ? throttle(callback, delay || THROTTLE_DELAY) : undefined;
|
|
83
|
+
}, [callback, delay]);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
throttledCallback && typeof width !== 'number' && window.addEventListener('resize', throttledCallback);
|
|
86
|
+
return () => throttledCallback && window.removeEventListener('resize', throttledCallback);
|
|
87
|
+
}, [width, throttledCallback]);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const appendSvg = (node, width, height) => {
|
|
91
|
+
select(node).select('svg').remove();
|
|
92
|
+
const svg = select(node).append('svg').attr('width', width).attr('height', height);
|
|
93
|
+
return svg;
|
|
94
|
+
};
|
|
95
|
+
|
|
60
96
|
function _templateObject$1() {
|
|
61
97
|
const data = _taggedTemplateLiteralLoose(["\n width: 100%;\n overflow: hidden;\n user-select: none;\n"]);
|
|
62
98
|
|
|
@@ -68,12 +104,6 @@ function _templateObject$1() {
|
|
|
68
104
|
}
|
|
69
105
|
const SwipeScrollContainer = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject$1());
|
|
70
106
|
|
|
71
|
-
function useNode() {
|
|
72
|
-
const [node, onSetNode] = useState(null);
|
|
73
|
-
const ref = useCallback(onSetNode, [onSetNode]);
|
|
74
|
-
return [ref, node];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
107
|
function animate(_ref) {
|
|
78
108
|
let {
|
|
79
109
|
duration,
|
|
@@ -240,36 +270,6 @@ SwipeScroll.defaultProps = {
|
|
|
240
270
|
duration: 1400
|
|
241
271
|
};
|
|
242
272
|
|
|
243
|
-
function throttle(fn, wait) {
|
|
244
|
-
let isCalled = false;
|
|
245
|
-
return function () {
|
|
246
|
-
if (!isCalled) {
|
|
247
|
-
fn(...arguments);
|
|
248
|
-
isCalled = true;
|
|
249
|
-
setTimeout(function () {
|
|
250
|
-
isCalled = false;
|
|
251
|
-
}, wait);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const THROTTLE_DELAY = 44;
|
|
257
|
-
const useResize = (width, callback) => {
|
|
258
|
-
const throttledCallback = useMemo(() => {
|
|
259
|
-
return callback ? throttle(callback, THROTTLE_DELAY) : undefined;
|
|
260
|
-
}, [callback]);
|
|
261
|
-
useEffect(() => {
|
|
262
|
-
throttledCallback && typeof width !== 'number' && window.addEventListener('resize', throttledCallback);
|
|
263
|
-
return () => throttledCallback && window.removeEventListener('resize', throttledCallback);
|
|
264
|
-
}, [width, throttledCallback]);
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
const appendSvg = (node, width, height) => {
|
|
268
|
-
select(node).select('svg').remove();
|
|
269
|
-
const svg = select(node).append('svg').attr('width', width).attr('height', height);
|
|
270
|
-
return svg;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
273
|
const degByIndex = (index, count) => {
|
|
274
274
|
const degs = 360;
|
|
275
275
|
const deg = degs / count * index;
|
|
@@ -718,7 +718,7 @@ function degreesToRadians(degrees) {
|
|
|
718
718
|
}
|
|
719
719
|
|
|
720
720
|
function _templateObject$5() {
|
|
721
|
-
const data = _taggedTemplateLiteralLoose(["\n .", " {\n fill: #4a4a4a;\n }\n .", " {\n position: absolute;\n max-width: 128px;\n }\n .", " {\n stroke: #000;\n }\n"]);
|
|
721
|
+
const data = _taggedTemplateLiteralLoose(["\n .", " {\n fill: #4a4a4a;\n }\n .", " {\n position: absolute;\n max-width: 128px;\n }\n .", " {\n stroke: #000;\n }\n .", " {\n fill: transparent;\n cursor: pointer;\n }\n"]);
|
|
722
722
|
|
|
723
723
|
_templateObject$5 = function _templateObject() {
|
|
724
724
|
return data;
|
|
@@ -740,9 +740,10 @@ const pieChartclassNames = {
|
|
|
740
740
|
pieTooltipItem: 'pieTooltipItem',
|
|
741
741
|
pieTooltipName: 'pieTooltipName',
|
|
742
742
|
pieTooltipValue: 'pieTooltipValue',
|
|
743
|
-
pieTooltipColorBox: 'pieTooltipColorBox'
|
|
743
|
+
pieTooltipColorBox: 'pieTooltipColorBox',
|
|
744
|
+
pieFullChartTooltipCircle: 'pieFullChartTooltipCircle'
|
|
744
745
|
};
|
|
745
|
-
const SvgWrapper$1 = /*#__PURE__*/styled(Wrapper)( /*#__PURE__*/_templateObject$5(), pieChartclassNames.pieSliceLabel, pieChartclassNames.pieRadialLabel, pieChartclassNames.pieRadialLink);
|
|
746
|
+
const SvgWrapper$1 = /*#__PURE__*/styled(Wrapper)( /*#__PURE__*/_templateObject$5(), pieChartclassNames.pieSliceLabel, pieChartclassNames.pieRadialLabel, pieChartclassNames.pieRadialLink, pieChartclassNames.pieFullChartTooltipCircle);
|
|
746
747
|
|
|
747
748
|
const getMidFactor = d => d.startAngle + (d.endAngle - d.startAngle) / 2 < Math.PI ? 1 : -1;
|
|
748
749
|
const getAlign = d => {
|
|
@@ -971,7 +972,10 @@ const drawTooltip = (_ref) => {
|
|
|
971
972
|
renderTooltip,
|
|
972
973
|
arc,
|
|
973
974
|
allSlices,
|
|
974
|
-
tooltipStyle
|
|
975
|
+
tooltipStyle,
|
|
976
|
+
width,
|
|
977
|
+
height,
|
|
978
|
+
radius
|
|
975
979
|
} = _ref;
|
|
976
980
|
const container = tooltipRoot || document.querySelector('body');
|
|
977
981
|
const format$1 = format(',');
|
|
@@ -1058,11 +1062,15 @@ const drawTooltip = (_ref) => {
|
|
|
1058
1062
|
|
|
1059
1063
|
if (fullChartTooltip) {
|
|
1060
1064
|
global.on('mouseover.fulltooltip', event => setTooltip(event));
|
|
1061
|
-
global.on('
|
|
1065
|
+
global.on('mouseout.fulltooltip', () => {
|
|
1062
1066
|
tooltipContainer.html('');
|
|
1063
1067
|
setVisible();
|
|
1064
1068
|
});
|
|
1065
1069
|
|
|
1070
|
+
if (width && height) {
|
|
1071
|
+
global.append('circle').attr('class', pieChartclassNames.pieFullChartTooltipCircle).attr('r', radius).attr('cx', 0).attr('cy', 0);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1066
1074
|
if (!tooltipBind) {
|
|
1067
1075
|
global.on('touchmove.tooltipBind mousemove.tooltipBind', event => setPosition(event));
|
|
1068
1076
|
}
|
|
@@ -1207,7 +1215,10 @@ const draw$1 = (node, props) => {
|
|
|
1207
1215
|
renderTooltip,
|
|
1208
1216
|
allSlices,
|
|
1209
1217
|
arc: arc$1,
|
|
1210
|
-
tooltipStyle
|
|
1218
|
+
tooltipStyle,
|
|
1219
|
+
width,
|
|
1220
|
+
height,
|
|
1221
|
+
radius
|
|
1211
1222
|
});
|
|
1212
1223
|
}
|
|
1213
1224
|
|
|
@@ -1702,16 +1713,21 @@ const drawTooltip$1 = (_ref) => {
|
|
|
1702
1713
|
const mouseRect = mouseGlobal.append('rect').attr('width', x2 - x1).attr('height', Math.abs(y1 - y2)).attr('class', lineChartClassNames.lineChartMouseRect).attr('transform', "translate(" + x1 + ", " + y2 + ")");
|
|
1703
1714
|
const mouseLine = mouseGlobal.append('path').attr('class', lineChartClassNames.lineChartMouseLine).style('opacity', '0');
|
|
1704
1715
|
const lines = svg.selectAll("." + lineChartClassNames.lineChartLine).nodes();
|
|
1705
|
-
const circles = mouseGlobal.selectAll('circle').data(chartData
|
|
1716
|
+
const circles = mouseGlobal.selectAll('circle').data(chartData.filter((_ref3) => {
|
|
1706
1717
|
let {
|
|
1707
|
-
|
|
1718
|
+
dynamicDotOff
|
|
1708
1719
|
} = _ref3;
|
|
1709
|
-
return
|
|
1710
|
-
}).attr('
|
|
1720
|
+
return !dynamicDotOff;
|
|
1721
|
+
})).join('circle').attr('class', lineChartClassNames.lineChartMouseCircle).attr('r', dynamicCircleRadius).attr('fill', (_ref4) => {
|
|
1711
1722
|
let {
|
|
1712
1723
|
stroke
|
|
1713
1724
|
} = _ref4;
|
|
1714
1725
|
return stroke || 'none';
|
|
1726
|
+
}).attr('stroke', (_ref5) => {
|
|
1727
|
+
let {
|
|
1728
|
+
stroke
|
|
1729
|
+
} = _ref5;
|
|
1730
|
+
return stroke || 'none';
|
|
1715
1731
|
}).style('opacity', '0');
|
|
1716
1732
|
let labelContainer = select("." + lineChartClassNames.lineChartMouseLabelContainer);
|
|
1717
1733
|
|
|
@@ -1772,27 +1788,27 @@ const drawTooltip$1 = (_ref) => {
|
|
|
1772
1788
|
circles.attr('transform', (lineChartData, index) => {
|
|
1773
1789
|
const value = getValue(lineChartData.values);
|
|
1774
1790
|
return positions[index] && value ? 'translate(' + x + ',' + positions[index].y + ')' : 'translate(-9999, -9999)';
|
|
1775
|
-
}).attr('style', (
|
|
1791
|
+
}).attr('style', (_ref6) => {
|
|
1776
1792
|
let {
|
|
1777
1793
|
dynamicDotStyle
|
|
1778
|
-
} =
|
|
1794
|
+
} = _ref6;
|
|
1779
1795
|
return dynamicDotStyle || '';
|
|
1780
1796
|
});
|
|
1781
|
-
const datas = chartData.map((
|
|
1797
|
+
const datas = chartData.map((_ref7, i) => {
|
|
1782
1798
|
let {
|
|
1783
1799
|
values
|
|
1784
|
-
} =
|
|
1785
|
-
rest = _objectWithoutPropertiesLoose(
|
|
1800
|
+
} = _ref7,
|
|
1801
|
+
rest = _objectWithoutPropertiesLoose(_ref7, ["values"]);
|
|
1786
1802
|
|
|
1787
1803
|
return _extends({}, rest, {
|
|
1788
1804
|
value: getValue(values),
|
|
1789
1805
|
invertValue: positions[i] ? yScale.invert(positions[i].y) : 0
|
|
1790
1806
|
});
|
|
1791
1807
|
});
|
|
1792
|
-
const noHasData = datas.every((
|
|
1808
|
+
const noHasData = datas.every((_ref8) => {
|
|
1793
1809
|
let {
|
|
1794
1810
|
value
|
|
1795
|
-
} =
|
|
1811
|
+
} = _ref8;
|
|
1796
1812
|
return isVoid(value);
|
|
1797
1813
|
});
|
|
1798
1814
|
|
|
@@ -1807,7 +1823,8 @@ const drawTooltip$1 = (_ref) => {
|
|
|
1807
1823
|
|
|
1808
1824
|
const prevValue = (_datas$Number = datas[Number(acc)]) == null ? void 0 : _datas$Number.value;
|
|
1809
1825
|
const value = (_datas$Number2 = datas[Number(key)]) == null ? void 0 : _datas$Number2.value;
|
|
1810
|
-
|
|
1826
|
+
const dynamicDotOff = argData == null ? void 0 : argData[index].dynamicDotOff;
|
|
1827
|
+
return index === 0 || isVoid(value) || dynamicDotOff ? acc : isVoid(prevValue) || positions[acc].y > positions[key].y ? key : acc;
|
|
1811
1828
|
}, '0');
|
|
1812
1829
|
const labelTexts = labels && labels.style('left', left + "px").style('top', (_, i) => {
|
|
1813
1830
|
const index = typeof stackedTooltipIndex === 'number' ? stackedTooltipIndex : stackedTooltip ? topIndex : i;
|
|
@@ -2053,7 +2070,7 @@ const draw$3 = (node, props) => {
|
|
|
2053
2070
|
filter
|
|
2054
2071
|
} = dot;
|
|
2055
2072
|
const dotsGroup = dotsGlobal.append('g').attr('class', lineChartClassNames.lineChartDotsGlobal);
|
|
2056
|
-
dotsGroup.selectAll('circle').data(values).join('circle').attr('cx', (_, index) => xScale(index)).attr('class', lineChartClassNames.lineChartDot).attr('cy', d => yScale(d)).attr('r', radius).attr('style', style || '');
|
|
2073
|
+
dotsGroup.selectAll('circle').data(values).join('circle').attr('cx', (_, index) => xScale(index)).attr('class', lineChartClassNames.lineChartDot).attr('cy', d => yScale(d)).attr('r', radius || 0).attr('style', style || '');
|
|
2057
2074
|
|
|
2058
2075
|
if (filter) {
|
|
2059
2076
|
dotsGroup.selectAll('circle').select((_, i, g) => filter(item, i, g) ? g[i] : null).remove();
|
|
@@ -3147,7 +3164,7 @@ const Tooltip = (_ref) => {
|
|
|
3147
3164
|
}
|
|
3148
3165
|
}), name && React.createElement(Name$1, {
|
|
3149
3166
|
className: horizontalBarChartClassNames.horizontalBarChartTooltipName
|
|
3150
|
-
},
|
|
3167
|
+
}, name), React.createElement(Value, {
|
|
3151
3168
|
className: horizontalBarChartClassNames.horizontalBarChartTooltipValue
|
|
3152
3169
|
}, format$1(value)));
|
|
3153
3170
|
})));
|
|
@@ -3160,7 +3177,8 @@ const useTooltip = (_ref) => {
|
|
|
3160
3177
|
tooltipBind,
|
|
3161
3178
|
tooltipStyle,
|
|
3162
3179
|
tooltipRoot,
|
|
3163
|
-
tooltipClassName
|
|
3180
|
+
tooltipClassName,
|
|
3181
|
+
hideTooltip
|
|
3164
3182
|
} = _ref;
|
|
3165
3183
|
useEffect(() => {
|
|
3166
3184
|
const container = tooltipRoot || document.querySelector('body');
|
|
@@ -3199,8 +3217,9 @@ const useTooltip = (_ref) => {
|
|
|
3199
3217
|
const onMouseLeave = useCallback(() => {
|
|
3200
3218
|
if (rootElement) {
|
|
3201
3219
|
rootElement.style.visibility = 'hidden';
|
|
3220
|
+
hideTooltip && hideTooltip();
|
|
3202
3221
|
}
|
|
3203
|
-
}, []);
|
|
3222
|
+
}, [hideTooltip]);
|
|
3204
3223
|
return [onMouseMove, onMouseLeave];
|
|
3205
3224
|
};
|
|
3206
3225
|
|
|
@@ -3380,7 +3399,8 @@ const HorizontalBarChart = (_ref) => {
|
|
|
3380
3399
|
thead,
|
|
3381
3400
|
withoutXScale,
|
|
3382
3401
|
stackedTooltip,
|
|
3383
|
-
fullChartTooltip
|
|
3402
|
+
fullChartTooltip,
|
|
3403
|
+
hideTooltip
|
|
3384
3404
|
} = _ref;
|
|
3385
3405
|
const {
|
|
3386
3406
|
fullMax,
|
|
@@ -3395,7 +3415,8 @@ const HorizontalBarChart = (_ref) => {
|
|
|
3395
3415
|
renderTooltip,
|
|
3396
3416
|
tooltipBind,
|
|
3397
3417
|
tooltipStyle,
|
|
3398
|
-
tooltipClassName
|
|
3418
|
+
tooltipClassName,
|
|
3419
|
+
hideTooltip
|
|
3399
3420
|
});
|
|
3400
3421
|
const Stack = useStackWrapper(stackedTooltip);
|
|
3401
3422
|
return React.createElement(Table, {
|
|
@@ -3812,5 +3833,5 @@ const bubbleChartDefaultProps = {
|
|
|
3812
3833
|
};
|
|
3813
3834
|
BubbleChart.defaultProps = bubbleChartDefaultProps;
|
|
3814
3835
|
|
|
3815
|
-
export { BarChart, BubbleChart, CalendarChart, Wrapper as ChartWrapper, HorizontalBarChart, LineChart, PieChart, RadarChart, SwipeScroll, barChartClassNames, bubbleChartClassNames, calendarChartClassNames, horizontalBarChartClassNames, lineChartClassNames, pieChartclassNames, radarChartclassNames };
|
|
3836
|
+
export { BarChart, BubbleChart, CalendarChart, Wrapper as ChartWrapper, HorizontalBarChart, LineChart, PieChart, RadarChart, SwipeScroll, appendSvg, barChartClassNames, bubbleChartClassNames, calendarChartClassNames, horizontalBarChartClassNames, lineChartClassNames, pieChartclassNames, radarChartclassNames, useNode, useResize };
|
|
3816
3837
|
//# sourceMappingURL=charts.esm.js.map
|