@evergis/charts 3.1.1 → 3.1.2
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/BarChart/drawLines/index.d.ts +3 -4
- package/dist/charts/BarChart/getBars/index.d.ts +1 -1
- package/dist/charts/BarChart/index.d.ts +2 -2
- package/dist/charts/BarChart/styled.d.ts +3 -2
- package/dist/charts/BarChart/types.d.ts +8 -8
- package/dist/charts/BubbleChart/index.d.ts +3 -3
- package/dist/charts/BubbleChart/styled.d.ts +2 -1
- package/dist/charts/BubbleChart/types.d.ts +5 -5
- package/dist/charts/BubbleChart/unmount.d.ts +1 -1
- package/dist/charts/CalendarChart/index.d.ts +3 -3
- package/dist/charts/CalendarChart/types.d.ts +5 -5
- package/dist/charts/HorizontalBarChart/hooks/useStackWrapper.d.ts +4 -4
- package/dist/charts/HorizontalBarChart/index.d.ts +3 -3
- package/dist/charts/HorizontalBarChart/types.d.ts +3 -3
- package/dist/charts/LineChart/index.d.ts +3 -3
- package/dist/charts/LineChart/styled.d.ts +2 -1
- package/dist/charts/LineChart/types.d.ts +3 -3
- package/dist/charts/PieChart/index.d.ts +3 -3
- package/dist/charts/PieChart/types.d.ts +4 -4
- package/dist/charts.cjs.development.js +241 -451
- 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 +241 -451
- package/dist/charts.esm.js.map +1 -1
- package/dist/common/components/SwipeScroll/index.d.ts +2 -2
- package/dist/common/components/SwipeScroll/types.d.ts +4 -3
- package/dist/common/components/labels/index.d.ts +1 -1
- package/dist/common/components/labels/types.d.ts +2 -2
- package/dist/hooks/useNode.d.ts +1 -1
- package/dist/hooks/useResize.d.ts +1 -1
- package/dist/index.d.ts +26 -26
- package/dist/jest.config.d.ts +14 -0
- package/dist/stories/Bar/Examples.stories.d.ts +23 -0
- package/dist/stories/Bar/HorizontalBar.stories.d.ts +25 -0
- package/dist/stories/Bar/Statistics.stories.d.ts +7 -0
- package/dist/stories/Bar/VerticalBar.stories.d.ts +41 -0
- package/dist/stories/Bubble/Bubble.stories.d.ts +23 -0
- package/dist/stories/Bubble/Examples.stories.d.ts +4 -0
- package/dist/stories/Bubble/examples/VEB/InvestBubble.d.ts +5 -0
- package/dist/stories/Bubble/examples/VEB/hooks/useCustomize.d.ts +3 -0
- package/dist/stories/Bubble/examples/VEB/hooks/useRenderTooltip/index.d.ts +4 -0
- package/dist/stories/Bubble/examples/VEB/hooks/useRenderTooltip/styled.d.ts +8 -0
- package/dist/stories/Bubble/examples/VEB/styled.d.ts +1 -0
- package/dist/stories/Calendar/Calendar.stories.d.ts +23 -0
- package/dist/stories/Calendar/ColorScheme.stories.d.ts +7 -0
- package/dist/stories/Calendar/Examples.stories.d.ts +11 -0
- package/dist/stories/Calendar/Legend.stories.d.ts +30 -0
- package/dist/stories/Common/SwipeScroll/SwipeScroll.stories.d.ts +13 -0
- package/dist/stories/Common/SwipeScroll/hooks/useSwipe.d.ts +1 -0
- package/dist/stories/Line/Examples.stories.d.ts +7 -0
- package/dist/stories/Line/Line.stories.d.ts +48 -0
- package/dist/stories/Line/examples/Beeline.d.ts +5 -0
- package/dist/stories/Line/examples/GeoVeb.d.ts +5 -0
- package/dist/stories/Line/examples/GeoVebInterval/data.d.ts +9 -0
- package/dist/stories/Line/examples/GeoVebInterval/index.d.ts +5 -0
- package/dist/stories/Line/examples/GeoVebInterval/styled.d.ts +4 -0
- package/dist/stories/Line/examples/Msp.d.ts +5 -0
- package/dist/stories/Pie/ColorScheme.stories.d.ts +7 -0
- package/dist/stories/Pie/Examples.stories.d.ts +7 -0
- package/dist/stories/Pie/Pie.stories.d.ts +47 -0
- package/dist/stories/Radar/Chart.stories.d.ts +38 -0
- package/dist/stories/Radar/Github.stories.d.ts +7 -0
- package/dist/stories/Radar/Gradient.stories.d.ts +7 -0
- package/dist/stories/Radar/Veb.stories.d.ts +7 -0
- package/dist/stories/Sankey/Examples.stories.d.ts +4 -0
- package/dist/stories/Sankey/examples/RelatedIndustries/data.d.ts +2 -0
- package/dist/stories/Sankey/examples/RelatedIndustries/index.d.ts +5 -0
- package/dist/stories/__internal__/colors.d.ts +40 -0
- package/dist/stories/__internal__/components/BeelineLineChart/hooks/useCustomize.d.ts +11 -0
- package/dist/stories/__internal__/components/BeelineLineChart/hooks/useLineRenderTooltip/index.d.ts +5 -0
- package/dist/stories/__internal__/components/BeelineLineChart/hooks/useLineRenderTooltip/styled.d.ts +5 -0
- package/dist/stories/__internal__/components/BeelineLineChart/index.d.ts +3 -0
- package/dist/stories/__internal__/components/BeelineLineChart/styled.d.ts +3 -0
- package/dist/stories/__internal__/components/BeelineRangeLineChart/Range/index.d.ts +7 -0
- package/dist/stories/__internal__/components/BeelineRangeLineChart/Range/styled.d.ts +3 -0
- package/dist/stories/__internal__/components/BeelineRangeLineChart/hooks/useChange.d.ts +8 -0
- package/dist/stories/__internal__/components/BeelineRangeLineChart/index.d.ts +2 -0
- package/dist/stories/__internal__/components/BeelineRangeLineChart/styled.d.ts +4 -0
- package/dist/stories/__internal__/components/BeelineTrafficHorizontalBarChart/data.d.ts +5 -0
- package/dist/stories/__internal__/components/BeelineTrafficHorizontalBarChart/hooks/useRenderDataTable.d.ts +2 -0
- package/dist/stories/__internal__/components/BeelineTrafficHorizontalBarChart/index.d.ts +2 -0
- package/dist/stories/__internal__/components/BeelineTrafficHorizontalBarChart/styled.d.ts +3 -0
- package/dist/stories/__internal__/components/Divider.d.ts +6 -0
- package/dist/stories/__internal__/components/GeoVebBarCharts.d.ts +2 -0
- package/dist/stories/__internal__/components/GeoVebHorizontalBarCharts/data.d.ts +47 -0
- package/dist/stories/__internal__/components/GeoVebHorizontalBarCharts/hooks/useRenderTooltip.d.ts +3 -0
- package/dist/stories/__internal__/components/GeoVebHorizontalBarCharts/hooks/useSimpleRenderTooltip.d.ts +3 -0
- package/dist/stories/__internal__/components/GeoVebHorizontalBarCharts/index.d.ts +4 -0
- package/dist/stories/__internal__/components/GeoVebHorizontalBarCharts/styled.d.ts +4 -0
- package/dist/stories/__internal__/components/GeoYearsBarChart/index.d.ts +2 -0
- package/dist/stories/__internal__/components/GeoYearsBarChart/styled.d.ts +4 -0
- package/dist/stories/__internal__/components/MixedTableChart/Chart/index.d.ts +3 -0
- package/dist/stories/__internal__/components/MixedTableChart/Chart/styled.d.ts +2 -0
- package/dist/stories/__internal__/components/MixedTableChart/index.d.ts +3 -0
- package/dist/stories/__internal__/components/MixedTableChart/styled.d.ts +5 -0
- package/dist/stories/__internal__/components/MixedTableChart/types.d.ts +21 -0
- package/dist/stories/__internal__/components/MspDashboardChart/hooks/useAnimation.d.ts +5 -0
- package/dist/stories/__internal__/components/MspDashboardChart/index.d.ts +3 -0
- package/dist/stories/__internal__/components/MspDashboardChart/styled.d.ts +5 -0
- package/dist/stories/__internal__/components/MspPromSupplyBarChart/hooks/useAnimationAreas.d.ts +6 -0
- package/dist/stories/__internal__/components/MspPromSupplyBarChart/hooks/useAnimationBars.d.ts +5 -0
- package/dist/stories/__internal__/components/MspPromSupplyBarChart/hooks/useCustomize.d.ts +4 -0
- package/dist/stories/__internal__/components/MspPromSupplyBarChart/hooks/useData.d.ts +8 -0
- package/dist/stories/__internal__/components/MspPromSupplyBarChart/hooks/useMarshalledMap.d.ts +1 -0
- package/dist/stories/__internal__/components/MspPromSupplyBarChart/hooks/useRenderTooltip.d.ts +2 -0
- package/dist/stories/__internal__/components/MspPromSupplyBarChart/index.d.ts +9 -0
- package/dist/stories/__internal__/components/MspPromSupplyBarChart/styled.d.ts +22 -0
- package/dist/stories/__internal__/components/SankeyTriChart/Groups/getCSSProperties.d.ts +4 -0
- package/dist/stories/__internal__/components/SankeyTriChart/Groups/helpers.d.ts +1 -0
- package/dist/stories/__internal__/components/SankeyTriChart/Groups/index.d.ts +5 -0
- package/dist/stories/__internal__/components/SankeyTriChart/Groups/styled.d.ts +1 -0
- package/dist/stories/__internal__/components/SankeyTriChart/ItemContent/getCSSProperties.d.ts +3 -0
- package/dist/stories/__internal__/components/SankeyTriChart/ItemContent/index.d.ts +5 -0
- package/dist/stories/__internal__/components/SankeyTriChart/ItemContent/styled.d.ts +8 -0
- package/dist/stories/__internal__/components/SankeyTriChart/draw.d.ts +2 -0
- package/dist/stories/__internal__/components/SankeyTriChart/helpers.d.ts +9 -0
- package/dist/stories/__internal__/components/SankeyTriChart/index.d.ts +10 -0
- package/dist/stories/__internal__/components/SankeyTriChart/marshaling.d.ts +6 -0
- package/dist/stories/__internal__/components/SankeyTriChart/styled.d.ts +1 -0
- package/dist/stories/__internal__/components/SankeyTriChart/types.d.ts +40 -0
- package/dist/stories/__internal__/components/SberBarMixChart/colors.d.ts +3 -0
- package/dist/stories/__internal__/components/SberBarMixChart/data.d.ts +8 -0
- package/dist/stories/__internal__/components/SberBarMixChart/hooks/styled.d.ts +3 -0
- package/dist/stories/__internal__/components/SberBarMixChart/hooks/useRenderTooltip.d.ts +2 -0
- package/dist/stories/__internal__/components/SberBarMixChart/index.d.ts +2 -0
- package/dist/stories/__internal__/components/SberBarMixChart/styled.d.ts +1 -0
- package/dist/stories/__internal__/components/StatisticsBarCharts/NumbersStatistics.d.ts +2 -0
- package/dist/stories/__internal__/components/StatisticsBarCharts/StringsStatistics.d.ts +2 -0
- package/dist/stories/__internal__/components/StatisticsBarCharts/index.d.ts +2 -0
- package/dist/stories/__internal__/components/StatisticsBarCharts/styled.d.ts +1 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/data.d.ts +38 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/hooks/useCustomize.d.ts +5 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/hooks/useDrawBars.d.ts +4 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/hooks/useRenderLabel/index.d.ts +9 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/hooks/useRenderLabel/styled.d.ts +1 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/hooks/useRenderTooltip/index.d.ts +8 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/hooks/useRenderTooltip/styled.d.ts +13 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/index.d.ts +3 -0
- package/dist/stories/__internal__/components/VebEstimationBarChart/styled.d.ts +2 -0
- package/dist/stories/__internal__/components/VebFilterBarChart/index.d.ts +2 -0
- package/dist/stories/__internal__/components/VebGroupHorizontalBarChart/hooks/useRenderSum/index.d.ts +3 -0
- package/dist/stories/__internal__/components/VebGroupHorizontalBarChart/hooks/useRenderSum/styled.d.ts +1 -0
- package/dist/stories/__internal__/components/VebGroupHorizontalBarChart/hooks/useRenderTooltip/index.d.ts +1 -0
- package/dist/stories/__internal__/components/VebGroupHorizontalBarChart/hooks/useRenderTooltip/styled.d.ts +5 -0
- package/dist/stories/__internal__/components/VebGroupHorizontalBarChart/index.d.ts +3 -0
- package/dist/stories/__internal__/components/VebGroupHorizontalBarChart/styled.d.ts +5 -0
- package/dist/stories/__internal__/components/VebGroupHorizontalBarChart/types.d.ts +11 -0
- package/dist/stories/__internal__/curves.d.ts +8 -0
- package/dist/stories/__internal__/data/msp.d.ts +14 -0
- package/dist/stories/__internal__/data/mspDashboard.d.ts +1 -0
- package/dist/stories/__internal__/data/mspPromSupply.d.ts +11 -0
- package/dist/stories/__internal__/data/population.d.ts +4 -0
- package/dist/stories/__internal__/data/veb.d.ts +31 -0
- package/dist/stories/__internal__/helpers/Path.d.ts +10 -0
- package/dist/stories/__internal__/helpers/Vector.d.ts +9 -0
- package/dist/stories/__internal__/helpers/animation.d.ts +15 -0
- package/dist/stories/__internal__/helpers/hexToRGB.d.ts +1 -0
- package/dist/stories/__internal__/helpers/random.d.ts +1 -0
- package/dist/stories/__internal__/helpers/randomData.d.ts +14 -0
- package/dist/stories/__internal__/helpers/randomHorizontalBarData.d.ts +5 -0
- package/dist/stories/__internal__/helpers/randomIntervalData.d.ts +11 -0
- package/dist/stories/__internal__/helpers/randomLineData.d.ts +8 -0
- package/dist/stories/__internal__/helpers/randomText.d.ts +1 -0
- package/dist/stories/__internal__/helpers/roundedRect.d.ts +10 -0
- package/dist/stories/__internal__/helpers/shuffleArray.d.ts +1 -0
- package/dist/stories/__internal__/hooks/useBarData.d.ts +10 -0
- package/dist/stories/__internal__/hooks/useLegend.d.ts +1 -0
- package/dist/stories/__internal__/hooks/useMinMaxValue.d.ts +4 -0
- package/dist/stories/__internal__/interpolates.d.ts +23 -0
- package/dist/storybook-static/1.05dfd83c.iframe.bundle.d.ts +0 -0
- package/dist/storybook-static/189.8c077122866758d3cf20.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/190.58050c9beb344d4cefd9.manager.bundle.d.ts +2 -0
- package/dist/storybook-static/191.b202c06c72968435b80b.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/192.83987c5b15f8a80893c5.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/193.8a12aa992b466e778018.manager.bundle.d.ts +2 -0
- package/dist/storybook-static/2.0231c7b6.iframe.bundle.d.ts +0 -0
- package/dist/storybook-static/6.6185fd0d.iframe.bundle.d.ts +0 -0
- package/dist/storybook-static/7.0ede09e9.iframe.bundle.d.ts +0 -0
- package/dist/storybook-static/8.6f0230ef.iframe.bundle.d.ts +2 -0
- package/dist/storybook-static/main.6b7543c14993fcfcab71.manager.bundle.d.ts +2 -0
- package/dist/storybook-static/main.724b5942.iframe.bundle.d.ts +9 -0
- package/dist/storybook-static/runtime~main.92273705.iframe.bundle.d.ts +1 -0
- package/dist/storybook-static/runtime~main.c89e55a461c11ef29193.manager.bundle.d.ts +1 -0
- package/package.json +12 -11
|
@@ -14,45 +14,25 @@ var lodash = require('lodash');
|
|
|
14
14
|
var reactDom = require('react-dom');
|
|
15
15
|
|
|
16
16
|
function _extends() {
|
|
17
|
-
_extends = Object.assign
|
|
18
|
-
for (var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
for (var key in source) {
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
23
|
-
target[key] = source[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
17
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
18
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
19
|
+
var t = arguments[e];
|
|
20
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
26
21
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return _extends.apply(this, arguments);
|
|
22
|
+
return n;
|
|
23
|
+
}, _extends.apply(null, arguments);
|
|
32
24
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
41
|
-
key = sourceKeys[i];
|
|
42
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
43
|
-
target[key] = source[key];
|
|
25
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
26
|
+
if (null == r) return {};
|
|
27
|
+
var t = {};
|
|
28
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
29
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
30
|
+
t[n] = r[n];
|
|
44
31
|
}
|
|
45
|
-
|
|
46
|
-
return target;
|
|
32
|
+
return t;
|
|
47
33
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (!raw) {
|
|
51
|
-
raw = strings.slice(0);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
strings.raw = raw;
|
|
55
|
-
return strings;
|
|
34
|
+
function _taggedTemplateLiteralLoose(e, t) {
|
|
35
|
+
return t || (t = e.slice(0)), e.raw = t, e;
|
|
56
36
|
}
|
|
57
37
|
|
|
58
38
|
var _templateObject;
|
|
@@ -83,8 +63,8 @@ const useResize = (width, callback, delay) => {
|
|
|
83
63
|
return callback ? throttle(callback, delay || THROTTLE_DELAY) : undefined;
|
|
84
64
|
}, [callback, delay]);
|
|
85
65
|
React.useEffect(() => {
|
|
86
|
-
throttledCallback && typeof width !==
|
|
87
|
-
return () => throttledCallback && window.removeEventListener(
|
|
66
|
+
throttledCallback && typeof width !== "number" && window.addEventListener("resize", throttledCallback);
|
|
67
|
+
return () => throttledCallback && window.removeEventListener("resize", throttledCallback);
|
|
88
68
|
}, [width, throttledCallback]);
|
|
89
69
|
};
|
|
90
70
|
|
|
@@ -107,11 +87,9 @@ function animate(_ref) {
|
|
|
107
87
|
let requestId;
|
|
108
88
|
requestAnimationFrame(function requestAnimate(time) {
|
|
109
89
|
let timeFraction = (time - start) / duration;
|
|
110
|
-
|
|
111
90
|
if (timeFraction < 1) {
|
|
112
91
|
requestId = requestAnimationFrame(requestAnimate);
|
|
113
92
|
}
|
|
114
|
-
|
|
115
93
|
if (timeFraction > 1) cancelAnimationFrame(requestId);
|
|
116
94
|
const progress = timing(timeFraction);
|
|
117
95
|
draw(progress, requestId);
|
|
@@ -120,7 +98,6 @@ function animate(_ref) {
|
|
|
120
98
|
const easeOutQuad = time => time * (2 - time);
|
|
121
99
|
|
|
122
100
|
const range = (num, min, max) => Math.min(Math.max(num, min), max);
|
|
123
|
-
|
|
124
101
|
const defaultRefs = {
|
|
125
102
|
animation: 0,
|
|
126
103
|
speed: 0,
|
|
@@ -156,7 +133,6 @@ const useSwipe = (node, _ref) => {
|
|
|
156
133
|
const maxX = width - nodeWidth;
|
|
157
134
|
const translateX = range(newX, -maxX, 0);
|
|
158
135
|
container.style('transform', "translateX(" + translateX + "px)");
|
|
159
|
-
|
|
160
136
|
if (refs.current.currentX) {
|
|
161
137
|
const hundred = 100;
|
|
162
138
|
const now = Date.now();
|
|
@@ -166,7 +142,6 @@ const useSwipe = (node, _ref) => {
|
|
|
166
142
|
refs.current.speed = speedX;
|
|
167
143
|
refs.current.timestamp = now;
|
|
168
144
|
}
|
|
169
|
-
|
|
170
145
|
refs.current.currentX = translateX;
|
|
171
146
|
onSwipe && onSwipe(translateX, container);
|
|
172
147
|
}, [onSwipe, width, node, container]);
|
|
@@ -178,16 +153,13 @@ const useSwipe = (node, _ref) => {
|
|
|
178
153
|
};
|
|
179
154
|
documentSelect.on('mousemove.swipe touchmove.swipe mouseup.swipe touchend.swipe', null);
|
|
180
155
|
body.style('cursor', null);
|
|
181
|
-
|
|
182
156
|
if (width > nodeWidth) {
|
|
183
157
|
container.style('cursor', 'grab');
|
|
184
158
|
} else {
|
|
185
159
|
container.style('cursor', null);
|
|
186
160
|
}
|
|
187
|
-
|
|
188
161
|
const dt = Date.now() - refs.current.timestamp;
|
|
189
162
|
const dtEnd = 44;
|
|
190
|
-
|
|
191
163
|
if (dt < dtEnd) {
|
|
192
164
|
animate({
|
|
193
165
|
duration: duration,
|
|
@@ -199,7 +171,6 @@ const useSwipe = (node, _ref) => {
|
|
|
199
171
|
const maxX = width - nodeWidth;
|
|
200
172
|
const translateX = range(currX, -maxX, 0);
|
|
201
173
|
const transX = Math.max(Math.min(currX, maxX), 0);
|
|
202
|
-
|
|
203
174
|
if (refs.current.currentX !== transX) {
|
|
204
175
|
container.style('transform', "translateX(" + translateX + "px)");
|
|
205
176
|
onSwipe && onSwipe(translateX, container);
|
|
@@ -218,12 +189,10 @@ const useSwipe = (node, _ref) => {
|
|
|
218
189
|
};
|
|
219
190
|
body.style('cursor', 'grabbing');
|
|
220
191
|
container.style('cursor', 'grabbing');
|
|
221
|
-
|
|
222
192
|
if (refs.current.animation) {
|
|
223
193
|
cancelAnimationFrame(refs.current.animation);
|
|
224
194
|
refs.current = defaultRefs;
|
|
225
195
|
}
|
|
226
|
-
|
|
227
196
|
refs.current.startX = Math.max(x + left, 0);
|
|
228
197
|
documentSelect.on('mousemove.swipe touchmove.swipe', onMove);
|
|
229
198
|
documentSelect.on('mouseup.swipe touchend.swipe', onEnd);
|
|
@@ -233,7 +202,6 @@ const useSwipe = (node, _ref) => {
|
|
|
233
202
|
const {
|
|
234
203
|
width: nodeWidth
|
|
235
204
|
} = node.getBoundingClientRect();
|
|
236
|
-
|
|
237
205
|
if (width > nodeWidth) {
|
|
238
206
|
container.style('cursor', 'grab');
|
|
239
207
|
container.on('mousedown.swipe touchstart.swipe', onStart);
|
|
@@ -245,12 +213,11 @@ const useSwipe = (node, _ref) => {
|
|
|
245
213
|
const _excluded = ["children", "width", "onSwipe"];
|
|
246
214
|
const SwipeScroll = _ref => {
|
|
247
215
|
let {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
216
|
+
children,
|
|
217
|
+
width,
|
|
218
|
+
onSwipe
|
|
219
|
+
} = _ref,
|
|
220
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
254
221
|
const [ref, draggingNode] = useNode();
|
|
255
222
|
useSwipe(draggingNode, _extends({
|
|
256
223
|
width,
|
|
@@ -269,24 +236,19 @@ const degByIndex = (index, count) => {
|
|
|
269
236
|
const deg = degs / count * index;
|
|
270
237
|
return deg;
|
|
271
238
|
};
|
|
272
|
-
|
|
273
239
|
const getTextAnchor = (index, length) => {
|
|
274
240
|
const deg = degByIndex(index, length);
|
|
275
241
|
const halfAngle = 180;
|
|
276
|
-
|
|
277
242
|
if ([0, halfAngle].includes(deg)) {
|
|
278
243
|
return 'middle';
|
|
279
244
|
}
|
|
280
|
-
|
|
281
245
|
if (deg < halfAngle) {
|
|
282
246
|
return 'start';
|
|
283
247
|
}
|
|
284
|
-
|
|
285
248
|
return 'end';
|
|
286
249
|
};
|
|
287
250
|
|
|
288
251
|
var _templateObject$2;
|
|
289
|
-
|
|
290
252
|
const getTranslate = _ref => {
|
|
291
253
|
let {
|
|
292
254
|
anchor,
|
|
@@ -294,7 +256,6 @@ const getTranslate = _ref => {
|
|
|
294
256
|
translateX,
|
|
295
257
|
translateY
|
|
296
258
|
} = _ref;
|
|
297
|
-
|
|
298
259
|
if (index === 0 && anchor === 'middle') {
|
|
299
260
|
return "translate(calc(-50% + " + translateX + "px), calc(-100% + " + translateY + "px))";
|
|
300
261
|
} else if (anchor === 'middle') {
|
|
@@ -304,10 +265,8 @@ const getTranslate = _ref => {
|
|
|
304
265
|
} else if (anchor === 'end') {
|
|
305
266
|
return "translate(calc(-100% + " + translateX + "px), calc(-50% + " + translateY + "px))";
|
|
306
267
|
}
|
|
307
|
-
|
|
308
268
|
return "translate(" + translateX + "px, " + translateY + "px)";
|
|
309
269
|
};
|
|
310
|
-
|
|
311
270
|
const LabelContainer = /*#__PURE__*/styled__default.div.attrs(props => ({
|
|
312
271
|
style: {
|
|
313
272
|
transform: getTranslate(props)
|
|
@@ -332,13 +291,9 @@ const drawRadialLabels = _ref => {
|
|
|
332
291
|
} = _ref;
|
|
333
292
|
const d3container = d3.select(node);
|
|
334
293
|
d3container.selectAll("." + labelClassName).remove();
|
|
335
|
-
|
|
336
294
|
const pxToValue = value => maxValue / radius * value;
|
|
337
|
-
|
|
338
295
|
const axisX = i => radiusScale(maxValue + pxToValue(xOffset || 0)) * Math.cos(angleSlice * i - Math.PI / 2);
|
|
339
|
-
|
|
340
296
|
const axisY = i => radiusScale((maxValue + pxToValue(yOffset || 0)) * Math.sin(angleSlice * i - Math.PI / 2));
|
|
341
|
-
|
|
342
297
|
const labels = Array.from({
|
|
343
298
|
length: dataLength
|
|
344
299
|
}, (_, index) => ({
|
|
@@ -374,17 +329,15 @@ const getTranslate$1 = _ref => {
|
|
|
374
329
|
translateX,
|
|
375
330
|
translateY
|
|
376
331
|
} = _ref;
|
|
377
|
-
|
|
378
|
-
if (index === 0 && anchor === 'middle') {
|
|
332
|
+
if (index === 0 && anchor === "middle") {
|
|
379
333
|
return "translate(calc(-50% + " + translateX + "px), calc(-100% + " + translateY + "px))";
|
|
380
|
-
} else if (anchor ===
|
|
334
|
+
} else if (anchor === "middle") {
|
|
381
335
|
return "translate(calc(-50% + " + translateX + "px), calc(" + translateY + "px))";
|
|
382
|
-
} else if (anchor ===
|
|
336
|
+
} else if (anchor === "start") {
|
|
383
337
|
return "translate(calc(" + translateX + "px), calc(-50% + " + translateY + "px))";
|
|
384
|
-
} else if (anchor ===
|
|
338
|
+
} else if (anchor === "end") {
|
|
385
339
|
return "translate(calc(-100% + " + translateX + "px), calc(-50% + " + translateY + "px))";
|
|
386
340
|
}
|
|
387
|
-
|
|
388
341
|
return "translate(" + translateX + "px, " + translateY + "px)";
|
|
389
342
|
};
|
|
390
343
|
const Label = /*#__PURE__*/styled__default.div(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n font-size: 12px;\n"])));
|
|
@@ -426,7 +379,6 @@ const draw = (node, props) => {
|
|
|
426
379
|
labelIndex,
|
|
427
380
|
selectLabel: _selectLabel
|
|
428
381
|
} = props;
|
|
429
|
-
|
|
430
382
|
if (node !== null && data.length) {
|
|
431
383
|
const defaultBleedLength = 10;
|
|
432
384
|
const bleedLength = typeof props.bleedLength === 'number' ? props.bleedLength : defaultBleedLength;
|
|
@@ -455,23 +407,23 @@ const draw = (node, props) => {
|
|
|
455
407
|
const ticks = d3.scaleLinear().domain([0, maxValue || 1]).range([]).ticks(props.levels || defaultLevels);
|
|
456
408
|
const lastTick = ticks[ticks.length - 1];
|
|
457
409
|
const newLastTick = lastTick + (ticks[1] - ticks[0]);
|
|
458
|
-
|
|
459
410
|
if (lastTick < maxValue) {
|
|
460
411
|
ticks.push(newLastTick);
|
|
461
412
|
}
|
|
462
|
-
|
|
463
413
|
const levels = props.levels || ticks.length - 1;
|
|
464
414
|
const newMaxValue = ticks[ticks.length - 1];
|
|
465
415
|
const angleSlice = Math.PI * 2 / data[0].length;
|
|
466
416
|
const radiusScale = d3.scaleLinear().range([0, radius]).domain([0, newMaxValue]);
|
|
467
|
-
const radarLine = d3.lineRadial().curve(d3.curveLinearClosed)
|
|
417
|
+
const radarLine = d3.lineRadial().curve(d3.curveLinearClosed)
|
|
418
|
+
// @ts-ignore
|
|
468
419
|
.radius(_ref3 => {
|
|
469
420
|
let {
|
|
470
421
|
value
|
|
471
422
|
} = _ref3;
|
|
472
423
|
return radiusScale(value);
|
|
473
424
|
}).angle((_, i) => i * angleSlice);
|
|
474
|
-
const radarValue = d3.lineRadial().curve(curve || d3.curveLinearClosed)
|
|
425
|
+
const radarValue = d3.lineRadial().curve(curve || d3.curveLinearClosed)
|
|
426
|
+
// @ts-ignore
|
|
475
427
|
.radius(_ref4 => {
|
|
476
428
|
let {
|
|
477
429
|
value
|
|
@@ -481,11 +433,8 @@ const draw = (node, props) => {
|
|
|
481
433
|
const svg = appendSvg(node, width, height);
|
|
482
434
|
const globalCenter = svg.append('g');
|
|
483
435
|
const levelsGrid = d3.range(1, levels + 1).reverse();
|
|
484
|
-
|
|
485
436
|
const axisGridY = value => -value * radius / levels;
|
|
486
|
-
|
|
487
437
|
const getAxisValue = value => newMaxValue * value / levels;
|
|
488
|
-
|
|
489
438
|
const gridGlobal = globalCenter.append('g').attr('class', radarChartclassNames.radarAxis).selectAll().data([data[0]]).enter();
|
|
490
439
|
const radarGlobal = globalCenter.append('g').attr('class', radarChartclassNames.radar);
|
|
491
440
|
const axis = gridGlobal.selectAll().data(data[0].map(_ref5 => {
|
|
@@ -495,7 +444,6 @@ const draw = (node, props) => {
|
|
|
495
444
|
return name;
|
|
496
445
|
})).enter();
|
|
497
446
|
let maxGridHeight = 0;
|
|
498
|
-
|
|
499
447
|
if (polar) {
|
|
500
448
|
levelsGrid.forEach(value => {
|
|
501
449
|
const path = gridGlobal.append('circle').attr('cx', 0).attr('cy', 0).attr('r', () => radius / levels * value);
|
|
@@ -505,7 +453,8 @@ const draw = (node, props) => {
|
|
|
505
453
|
});
|
|
506
454
|
} else {
|
|
507
455
|
levelsGrid.map(getAxisValue).forEach(value => {
|
|
508
|
-
const path = gridGlobal.append('path').attr('d', () =>
|
|
456
|
+
const path = gridGlobal.append('path').attr('d', () =>
|
|
457
|
+
// @ts-ignore
|
|
509
458
|
radarLine(Array.from({
|
|
510
459
|
length: data[0].length
|
|
511
460
|
}, () => ({
|
|
@@ -516,10 +465,10 @@ const draw = (node, props) => {
|
|
|
516
465
|
maxGridHeight = Math.max(maxGridHeight, pathHeight);
|
|
517
466
|
});
|
|
518
467
|
}
|
|
519
|
-
|
|
520
468
|
const radiusByMaxValue = radiusScale(newMaxValue) + bleedLength;
|
|
521
469
|
axis.append('line').attr('x1', 0).attr('y1', 0).attr('x2', (_, i) => Math.round(radiusByMaxValue * Math.cos(angleSlice * i - Math.PI / 2))).attr('y2', (_, i) => Math.round(radiusByMaxValue * Math.sin(angleSlice * i - Math.PI / 2)));
|
|
522
|
-
radarGlobal.selectAll('path').data(data).join('path').attr('class', radarChartclassNames.radarPolygon).attr('style', (_, index) => (radarStyles == null ? void 0 : radarStyles[index]) || '').attr('d', d => radarValue(
|
|
470
|
+
radarGlobal.selectAll('path').data(data).join('path').attr('class', radarChartclassNames.radarPolygon).attr('style', (_, index) => (radarStyles == null ? void 0 : radarStyles[index]) || '').attr('d', d => radarValue(
|
|
471
|
+
// @ts-ignore
|
|
523
472
|
d.map(dataItem => _extends({}, dataItem, {
|
|
524
473
|
value: dataItem.value - minValue
|
|
525
474
|
}))));
|
|
@@ -582,7 +531,6 @@ const draw = (node, props) => {
|
|
|
582
531
|
if (_selectLabel) {
|
|
583
532
|
const items = data.map(item => item[index]);
|
|
584
533
|
const item = data[labelIndex || 0][index];
|
|
585
|
-
|
|
586
534
|
_selectLabel(label, {
|
|
587
535
|
index,
|
|
588
536
|
item,
|
|
@@ -592,12 +540,10 @@ const draw = (node, props) => {
|
|
|
592
540
|
}
|
|
593
541
|
}
|
|
594
542
|
});
|
|
595
|
-
|
|
596
543
|
if (svgElements) {
|
|
597
544
|
const html = ReactDOMServer.renderToString(svgElements);
|
|
598
545
|
svg.append('g').html(html);
|
|
599
546
|
}
|
|
600
|
-
|
|
601
547
|
customize && customize(svg);
|
|
602
548
|
}
|
|
603
549
|
};
|
|
@@ -611,9 +557,7 @@ const RadarChart = props => {
|
|
|
611
557
|
React.useEffect(() => {
|
|
612
558
|
node && draw(node, props);
|
|
613
559
|
}, [node, props]);
|
|
614
|
-
|
|
615
560
|
const onDraw = () => draw(node, props);
|
|
616
|
-
|
|
617
561
|
useResize(props.width, onDraw);
|
|
618
562
|
return React__default.createElement("div", {
|
|
619
563
|
className: className,
|
|
@@ -681,7 +625,6 @@ const drawRadialLabels$1 = _ref => {
|
|
|
681
625
|
} = _ref;
|
|
682
626
|
const d3container = d3.select(node);
|
|
683
627
|
d3container.selectAll("." + pieChartclassNames.pieRadialLabel).remove();
|
|
684
|
-
|
|
685
628
|
if (enableRadialLabels) {
|
|
686
629
|
const defaultRadialLabelsLinkHorizontalLength = 4;
|
|
687
630
|
const outerArc = d3.arc().innerRadius(radius).outerRadius(radius);
|
|
@@ -693,47 +636,52 @@ const drawRadialLabels$1 = _ref => {
|
|
|
693
636
|
const posCPi = [(radius + (radialLabelsLinkHorizontalLength || defaultRadialLabelsLinkHorizontalLength)) * midFactor, posC[1]];
|
|
694
637
|
return [[posA[0], posA[1]], [posB[0] + (radialAngleXOffset || 0) * midFactor, posB[1] - (radialLabelYOffset || 0) * d.index], [posCPi[0], posCPi[1] - (radialLabelYOffset || 0) * d.index]];
|
|
695
638
|
});
|
|
696
|
-
|
|
697
639
|
const getPosition = d => {
|
|
698
640
|
const pos = outerArc.centroid(d);
|
|
699
641
|
return [(radius + (radialLabelsLinkHorizontalLength || defaultRadialLabelsLinkHorizontalLength)) * getMidFactor(d), pos[1]];
|
|
700
642
|
};
|
|
701
|
-
|
|
702
643
|
const defaultRadialLabelsTextXOffset = 4;
|
|
703
|
-
d3container.selectAll('allLabels').data(dataReady).enter().append('div')
|
|
644
|
+
d3container.selectAll('allLabels').data(dataReady).enter().append('div')
|
|
645
|
+
// @ts-ignore
|
|
704
646
|
.html(d => {
|
|
705
|
-
const html = ReactDOMServer.renderToString(
|
|
647
|
+
const html = ReactDOMServer.renderToString(
|
|
648
|
+
// @ts-ignore
|
|
706
649
|
formatRadialLabel ? formatRadialLabel(d) : d.data.name);
|
|
707
650
|
return html;
|
|
708
|
-
}).attr('class', pieChartclassNames.pieRadialLabel)
|
|
651
|
+
}).attr('class', pieChartclassNames.pieRadialLabel)
|
|
652
|
+
// @ts-ignore
|
|
709
653
|
.style('transform', d => getTranslate$1({
|
|
710
654
|
anchor: getAlign(d),
|
|
711
655
|
index: d.index,
|
|
712
656
|
translateX,
|
|
713
657
|
translateY: translateY - (radialLabelYOffset || 0) * d.index
|
|
714
|
-
}))
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
658
|
+
}))
|
|
659
|
+
// @ts-ignore
|
|
660
|
+
.style('left',
|
|
661
|
+
// @ts-ignore
|
|
662
|
+
d => getPosition(d)[0] - (getAlign(d) === 'start' ? -(radialLabelsTextXOffset || defaultRadialLabelsTextXOffset) : radialLabelsTextXOffset || defaultRadialLabelsTextXOffset) + "px")
|
|
663
|
+
// @ts-ignore
|
|
664
|
+
.style('top', d => getPosition(d)[1] + "px")
|
|
665
|
+
// @ts-ignore
|
|
718
666
|
.style('text-align', getAlign);
|
|
719
667
|
}
|
|
720
668
|
};
|
|
721
669
|
|
|
722
|
-
var _templateObject$6, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7, _templateObject8, _templateObject9,
|
|
670
|
+
var _templateObject$6, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7, _templateObject8, _templateObject9, _templateObject0, _templateObject1, _templateObject10, _templateObject11, _templateObject12;
|
|
723
671
|
const TooltipFlex = /*#__PURE__*/styled__default.div(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 0;\n height: 0;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n pointer-events: none;\n white-space: nowrap;\n"])));
|
|
724
672
|
const LabelFlex = /*#__PURE__*/styled__default(TooltipFlex)(_templateObject2$1 || (_templateObject2$1 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
|
|
725
673
|
const LabelFlexCenter = /*#__PURE__*/styled__default(LabelFlex)(_templateObject3$1 || (_templateObject3$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n align-items: center;\n"])));
|
|
726
|
-
const TooltipContainer = /*#__PURE__*/styled__default.div(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n font-size: 11px;\n color: #fff;\n margin-bottom: 8px;\n padding: 4px 6px;\n background-color: rgba(48, 69, 79, 1);\n border-radius: 4px;\n box-shadow: 0 0.1875rem 0.5rem rgba(48, 69, 79, 0.06);\n :before {\n content: '';\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translate(-50%, 100%);\n width: 0;\n height: 0;\n border-style: solid;\n border-width: 4px 3px 0 3px;\n border-color: rgba(48, 69, 79, 1) transparent transparent transparent;\n }\n"])));
|
|
674
|
+
const TooltipContainer = /*#__PURE__*/styled__default.div(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n font-size: 11px;\n color: #fff;\n margin-bottom: 8px;\n padding: 4px 6px;\n background-color: rgba(48, 69, 79, 1);\n border-radius: 4px;\n box-shadow: 0 0.1875rem 0.5rem rgba(48, 69, 79, 0.06);\n\n :before {\n content: '';\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translate(-50%, 100%);\n width: 0;\n height: 0;\n border-style: solid;\n border-width: 4px 3px 0 3px;\n border-color: rgba(48, 69, 79, 1) transparent transparent transparent;\n }\n"])));
|
|
727
675
|
const TooltipGroupName = /*#__PURE__*/styled__default.div(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 14px;\n margin-bottom: 6px;\n"])));
|
|
728
|
-
const TooltipItem = /*#__PURE__*/styled__default.div(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n margin-bottom: 0.25rem;\n &:last-of-type {\n margin-bottom: 0;\n }\n"])));
|
|
676
|
+
const TooltipItem = /*#__PURE__*/styled__default.div(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n margin-bottom: 0.25rem;\n\n &:last-of-type {\n margin-bottom: 0;\n }\n"])));
|
|
729
677
|
const ColFlex = /*#__PURE__*/styled__default.div(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n margin-right: 4px;\n"])));
|
|
730
678
|
const ColorBox = /*#__PURE__*/styled__default.div(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-right: 4px;\n width: 10px;\n height: 10px;\n border-radius: 2px;\n"])));
|
|
731
679
|
const ColorLine = /*#__PURE__*/styled__default(ColorBox)(_templateObject9 || (_templateObject9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 2px;\n border-radius: 0;\n"])));
|
|
732
|
-
const Name$1 = /*#__PURE__*/styled__default.div(
|
|
733
|
-
const Value = /*#__PURE__*/styled__default.div(
|
|
734
|
-
const Label$1 = /*#__PURE__*/styled__default.div(
|
|
735
|
-
const LabelTop = /*#__PURE__*/styled__default(Label$1)(
|
|
736
|
-
const LabelBottom = /*#__PURE__*/styled__default(Label$1)(
|
|
680
|
+
const Name$1 = /*#__PURE__*/styled__default.div(_templateObject0 || (_templateObject0 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-right: 4px;\n"])));
|
|
681
|
+
const Value = /*#__PURE__*/styled__default.div(_templateObject1 || (_templateObject1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n text-align: right;\n flex-shrink: 0;\n flex-grow: 1;\n"])));
|
|
682
|
+
const Label$1 = /*#__PURE__*/styled__default.div(_templateObject10 || (_templateObject10 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n font-size: 11px;\n color: #fff;\n font-weight: bold;\n letter-spacing: 0.52px;\n"])));
|
|
683
|
+
const LabelTop = /*#__PURE__*/styled__default(Label$1)(_templateObject11 || (_templateObject11 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n top: 6px;\n"])));
|
|
684
|
+
const LabelBottom = /*#__PURE__*/styled__default(Label$1)(_templateObject12 || (_templateObject12 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n bottom: 6px;\n"])));
|
|
737
685
|
|
|
738
686
|
const drawTooltip = _ref => {
|
|
739
687
|
let {
|
|
@@ -756,26 +704,21 @@ const drawTooltip = _ref => {
|
|
|
756
704
|
const pieTooltipContainer = d3.select(container).select("." + pieChartclassNames.pieTooltipContainer);
|
|
757
705
|
const isEmpty = pieTooltipContainer.empty();
|
|
758
706
|
const tooltipContainer = isEmpty ? d3.select(container).append('div').attr('class', pieChartclassNames.pieTooltipContainer + " " + (tooltipClassName || '')).style('position', 'absolute').style('opacity', '0').style('z-index', '103') : pieTooltipContainer;
|
|
759
|
-
|
|
760
707
|
if (tooltipStyle) {
|
|
761
708
|
Object.entries(tooltipStyle).forEach(_ref2 => {
|
|
762
709
|
let [prop, val] = _ref2;
|
|
763
710
|
return tooltipContainer.style(prop, val);
|
|
764
711
|
});
|
|
765
712
|
}
|
|
766
|
-
|
|
767
713
|
tooltipContainer.html('');
|
|
768
714
|
let isVisible = false;
|
|
769
|
-
|
|
770
715
|
const setVisible = visible => {
|
|
771
716
|
isVisible = Boolean(visible);
|
|
772
717
|
const opacity = isVisible ? '1' : '0';
|
|
773
718
|
tooltipContainer.style('opacity', opacity);
|
|
774
719
|
};
|
|
775
|
-
|
|
776
720
|
const setPosition = (event, pieChartDatum) => {
|
|
777
721
|
let [x, y] = d3.pointer(event, document);
|
|
778
|
-
|
|
779
722
|
if (!tooltipBind && fullChartTooltip) {
|
|
780
723
|
const [itemX, itemY] = d3.pointer(event, event.target);
|
|
781
724
|
x = x - itemX;
|
|
@@ -797,10 +740,8 @@ const drawTooltip = _ref => {
|
|
|
797
740
|
x = itemX + itemWidth / 2 + arcX;
|
|
798
741
|
y = itemY + itemHeight / 2 + arcY;
|
|
799
742
|
}
|
|
800
|
-
|
|
801
743
|
tooltipContainer.style('left', x + 'px').style('top', y + 'px');
|
|
802
744
|
};
|
|
803
|
-
|
|
804
745
|
const setTooltip = (event, pieChartDatum) => {
|
|
805
746
|
setVisible(true);
|
|
806
747
|
setPosition(event, pieChartDatum);
|
|
@@ -833,28 +774,23 @@ const drawTooltip = _ref => {
|
|
|
833
774
|
return html;
|
|
834
775
|
});
|
|
835
776
|
};
|
|
836
|
-
|
|
837
777
|
if (fullChartTooltip) {
|
|
838
778
|
global.on('mouseover.fulltooltip', event => setTooltip(event));
|
|
839
779
|
global.on('mouseout.fulltooltip', () => {
|
|
840
780
|
tooltipContainer.html('');
|
|
841
781
|
setVisible();
|
|
842
782
|
});
|
|
843
|
-
|
|
844
783
|
if (width && height) {
|
|
845
784
|
global.append('circle').attr('class', pieChartclassNames.pieFullChartTooltipCircle).attr('r', radius).attr('cx', 0).attr('cy', 0);
|
|
846
785
|
}
|
|
847
|
-
|
|
848
786
|
if (!tooltipBind) {
|
|
849
787
|
global.on('touchmove.tooltipBind mousemove.tooltipBind', event => setPosition(event));
|
|
850
788
|
}
|
|
851
789
|
} else {
|
|
852
790
|
allSlices.on('mouseover.slice', setTooltip);
|
|
853
|
-
|
|
854
791
|
if (!tooltipBind) {
|
|
855
792
|
allSlices.on('touchmove.slice mousemove.slice', setPosition);
|
|
856
793
|
}
|
|
857
|
-
|
|
858
794
|
allSlices.on('mouseout.slice', () => {
|
|
859
795
|
tooltipContainer.html('');
|
|
860
796
|
setVisible();
|
|
@@ -895,7 +831,6 @@ const draw$1 = (node, props) => {
|
|
|
895
831
|
renderTooltip,
|
|
896
832
|
tooltipStyle
|
|
897
833
|
} = props;
|
|
898
|
-
|
|
899
834
|
if (node !== null && data.length) {
|
|
900
835
|
const marginTop = margin ? margin.top : 0;
|
|
901
836
|
const marginRight = margin ? margin.right : 0;
|
|
@@ -913,56 +848,58 @@ const draw$1 = (node, props) => {
|
|
|
913
848
|
const maxPadAngle = 45;
|
|
914
849
|
const dividerPadAngle = 100;
|
|
915
850
|
const fullAngle = 360;
|
|
916
|
-
const pie = d3.pie().startAngle(-degreesToRadians(startAngle || 0)).endAngle(degreesToRadians(endAngle || fullAngle)).padAngle(padAngle ? Math.max(Math.min(padAngle / dividerPadAngle, maxPadAngle), 0) : 0).sort(null)
|
|
851
|
+
const pie = d3.pie().startAngle(-degreesToRadians(startAngle || 0)).endAngle(degreesToRadians(endAngle || fullAngle)).padAngle(padAngle ? Math.max(Math.min(padAngle / dividerPadAngle, maxPadAngle), 0) : 0).sort(null)
|
|
852
|
+
// @ts-ignore
|
|
917
853
|
.value(_ref => {
|
|
918
854
|
let {
|
|
919
855
|
value
|
|
920
856
|
} = _ref;
|
|
921
857
|
return value;
|
|
922
|
-
});
|
|
923
|
-
|
|
858
|
+
});
|
|
859
|
+
// @ts-ignore
|
|
924
860
|
const dataReady = pie(data);
|
|
925
861
|
const maxOuterRadius = 0.95;
|
|
926
862
|
const arc = d3.arc().cornerRadius(cornerRadius || 0).innerRadius(radius).outerRadius(radius * Math.min(Math.max(outerRadius || 0, 0), maxOuterRadius));
|
|
927
|
-
|
|
928
863
|
if (typeof backgroundColor === 'string') {
|
|
929
|
-
global.append('path').attr('fill', backgroundColor).attr('d', () =>
|
|
864
|
+
global.append('path').attr('fill', backgroundColor).attr('d', () =>
|
|
865
|
+
// @ts-ignore
|
|
930
866
|
arc({
|
|
931
867
|
startAngle: degreesToRadians(0),
|
|
932
868
|
endAngle: degreesToRadians(fullAngle)
|
|
933
869
|
}));
|
|
934
870
|
}
|
|
935
|
-
|
|
936
871
|
const format = d3.format(',');
|
|
937
|
-
const allSlices = global.selectAll('allSlices').data(dataReady).enter().append('path')
|
|
872
|
+
const allSlices = global.selectAll('allSlices').data(dataReady).enter().append('path')
|
|
873
|
+
// @ts-ignore
|
|
938
874
|
.attr('d', arc);
|
|
939
875
|
allSlices.attr('class', pieChartclassNames.pieSlice).attr('fill', _ref2 => {
|
|
940
876
|
let {
|
|
941
877
|
index
|
|
942
878
|
} = _ref2;
|
|
943
879
|
return data[index].color || '';
|
|
944
|
-
}).attr('stroke', borderColor || '').attr('stroke-width', borderWidth || 0).attr('style', onClick ? 'cursor: pointer' : '').on('click',
|
|
945
|
-
|
|
880
|
+
}).attr('stroke', borderColor || '').attr('stroke-width', borderWidth || 0).attr('style', onClick ? 'cursor: pointer' : '').on('click',
|
|
881
|
+
// @ts-ignore
|
|
882
|
+
(_, d) => onClick && onClick(data[d.index])).append('svg:title').text(d => formatSliceTitle ?
|
|
883
|
+
// @ts-ignore
|
|
946
884
|
formatSliceTitle(d) : fullChartTooltip || withTooltip ? '' : (data[d.index].name || '') + " (" + format(data[d.index].value) + ")");
|
|
947
|
-
|
|
948
885
|
if (enableSlicesLabels) {
|
|
949
|
-
const text = global.selectAll('allSlices').data(dataReady).enter().append('text').attr('class', pieChartclassNames.pieSliceLabel).attr('text-anchor', 'middle').attr('dominant-baseline', 'central').attr('transform',
|
|
886
|
+
const text = global.selectAll('allSlices').data(dataReady).enter().append('text').attr('class', pieChartclassNames.pieSliceLabel).attr('text-anchor', 'middle').attr('dominant-baseline', 'central').attr('transform',
|
|
887
|
+
// @ts-ignore
|
|
950
888
|
d => 'translate(' + arc.centroid(d) + ')');
|
|
951
|
-
text.append('tspan').attr('class', pieChartclassNames.pieSliceLabelValue)
|
|
889
|
+
text.append('tspan').attr('class', pieChartclassNames.pieSliceLabelValue)
|
|
890
|
+
// @ts-ignore
|
|
952
891
|
.text(d => {
|
|
953
892
|
const deg = radiansToDegrees(d.endAngle - d.startAngle);
|
|
954
|
-
|
|
955
893
|
if (!slicesLabelsSkipAngle || deg > slicesLabelsSkipAngle) {
|
|
956
894
|
return formatSliceLabel ? formatSliceLabel(d) : d.value;
|
|
957
895
|
}
|
|
958
896
|
});
|
|
959
|
-
|
|
960
897
|
if (enableSlicesLabelsName) {
|
|
961
|
-
text.append('tspan').attr('class', pieChartclassNames.pieSliceLabelName)
|
|
898
|
+
text.append('tspan').attr('class', pieChartclassNames.pieSliceLabelName)
|
|
899
|
+
// @ts-ignore
|
|
962
900
|
.text(d => formatSliceLabelName ? formatSliceLabelName(d) : d.data.name).attr('x', '0').attr('dy', '1.2em');
|
|
963
901
|
}
|
|
964
902
|
}
|
|
965
|
-
|
|
966
903
|
drawRadialLabels$1({
|
|
967
904
|
arc,
|
|
968
905
|
enableRadialLabels,
|
|
@@ -978,7 +915,6 @@ const draw$1 = (node, props) => {
|
|
|
978
915
|
radialLabelYOffset,
|
|
979
916
|
radialAngleXOffset
|
|
980
917
|
});
|
|
981
|
-
|
|
982
918
|
if (withTooltip || fullChartTooltip) {
|
|
983
919
|
drawTooltip({
|
|
984
920
|
fullChartTooltip,
|
|
@@ -995,7 +931,6 @@ const draw$1 = (node, props) => {
|
|
|
995
931
|
radius
|
|
996
932
|
});
|
|
997
933
|
}
|
|
998
|
-
|
|
999
934
|
if (svgElements) {
|
|
1000
935
|
const html = ReactDOMServer.renderToString(svgElements);
|
|
1001
936
|
svg.append('g').html(html);
|
|
@@ -1013,9 +948,7 @@ const PieChart = props => {
|
|
|
1013
948
|
React.useEffect(() => {
|
|
1014
949
|
node && draw$1(node, props);
|
|
1015
950
|
}, [node, props]);
|
|
1016
|
-
|
|
1017
951
|
const onDraw = () => draw$1(node, props);
|
|
1018
|
-
|
|
1019
952
|
useResize(props.width, onDraw);
|
|
1020
953
|
return React__default.createElement("div", {
|
|
1021
954
|
className: className,
|
|
@@ -1041,25 +974,20 @@ const legendClassNames = {
|
|
|
1041
974
|
legendTickLine: 'd3-legend-tick-line',
|
|
1042
975
|
legendTickText: 'd3-legend-tick-text'
|
|
1043
976
|
};
|
|
1044
|
-
|
|
1045
977
|
function ramp(color, n) {
|
|
1046
978
|
if (n === void 0) {
|
|
1047
979
|
n = defaultN;
|
|
1048
980
|
}
|
|
1049
|
-
|
|
1050
981
|
const canvas = document.createElement('canvas');
|
|
1051
982
|
canvas.width = n;
|
|
1052
983
|
canvas.height = 1;
|
|
1053
984
|
const context = canvas.getContext('2d');
|
|
1054
|
-
|
|
1055
985
|
for (let i = 0; i < n; ++i) {
|
|
1056
986
|
context.fillStyle = color(i / (n - 1));
|
|
1057
987
|
context.fillRect(i, 0, 1, 1);
|
|
1058
988
|
}
|
|
1059
|
-
|
|
1060
989
|
return canvas;
|
|
1061
990
|
}
|
|
1062
|
-
|
|
1063
991
|
const legendDefaultParams = {
|
|
1064
992
|
tickSize: 6,
|
|
1065
993
|
height: 44,
|
|
@@ -1085,9 +1013,9 @@ const getLegend = _ref => {
|
|
|
1085
1013
|
tickValues,
|
|
1086
1014
|
titleMarginBottom
|
|
1087
1015
|
} = _ref;
|
|
1088
|
-
const svg = d3.create('svg').attr('width', width).attr('height', height)
|
|
1016
|
+
const svg = d3.create('svg').attr('width', width).attr('height', height)
|
|
1017
|
+
// @ts-ignore
|
|
1089
1018
|
.attr('viewBox', [0, 0, width, height]).style('overflow', 'visible').style('display', 'block');
|
|
1090
|
-
|
|
1091
1019
|
let tickAdjust = g => {
|
|
1092
1020
|
const tick = g.selectAll('.tick');
|
|
1093
1021
|
tick.selectAll('.tick line').attr('y1', marginTop + marginBottom - height).attr('class', legendClassNames.legendTickLine);
|
|
@@ -1095,56 +1023,57 @@ const getLegend = _ref => {
|
|
|
1095
1023
|
tick.attr('class', legendClassNames.legendTick);
|
|
1096
1024
|
return tick;
|
|
1097
1025
|
};
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1026
|
+
let x;
|
|
1027
|
+
// Continuous
|
|
1101
1028
|
if (color.interpolate) {
|
|
1102
1029
|
const n = Math.min(color.domain().length, color.range().length);
|
|
1103
1030
|
x = color.copy().rangeRound(d3.quantize(d3.interpolate(marginLeft, width - marginRight), n));
|
|
1104
1031
|
svg.append('image').attr('x', marginLeft).attr('y', marginTop).attr('class', legendClassNames.legendContainer).attr('width', width - marginLeft - marginRight).attr('height', height - marginTop - marginBottom).attr('preserveAspectRatio', 'none').attr('xlink:href', ramp(color.copy().domain(d3.quantize(d3.interpolate(0, 1), n))).toDataURL());
|
|
1105
|
-
}
|
|
1032
|
+
}
|
|
1033
|
+
// Sequential
|
|
1106
1034
|
else if (color.interpolator) {
|
|
1107
1035
|
x = Object.assign(color.copy().interpolator(d3.interpolateRound(marginLeft, width - marginRight)), {
|
|
1108
1036
|
range() {
|
|
1109
1037
|
return [marginLeft, width - marginRight];
|
|
1110
1038
|
}
|
|
1111
|
-
|
|
1112
1039
|
});
|
|
1113
|
-
svg.append('image').attr('x', marginLeft).attr('y', marginTop).attr('width', width - marginLeft - marginRight).attr('height', height - marginTop - marginBottom).attr('preserveAspectRatio', 'none').attr('xlink:href', ramp(color.interpolator()).toDataURL());
|
|
1114
|
-
|
|
1040
|
+
svg.append('image').attr('x', marginLeft).attr('y', marginTop).attr('width', width - marginLeft - marginRight).attr('height', height - marginTop - marginBottom).attr('preserveAspectRatio', 'none').attr('xlink:href', ramp(color.interpolator()).toDataURL());
|
|
1041
|
+
// scaleSequentialQuantile doesn’t implement ticks or tickFormat.
|
|
1115
1042
|
if (!x.ticks) {
|
|
1116
1043
|
if (tickValues === undefined) {
|
|
1117
1044
|
const n = Math.round(ticks + 1);
|
|
1118
1045
|
tickValues = d3.range(n).map(i => d3.quantile(color.domain(), i / (n - 1)));
|
|
1119
1046
|
}
|
|
1120
|
-
|
|
1121
1047
|
if (typeof tickFormat !== 'function') {
|
|
1122
1048
|
tickFormat = d3.format(tickFormat === undefined ? ',f' : tickFormat);
|
|
1123
1049
|
}
|
|
1124
1050
|
}
|
|
1125
1051
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
.
|
|
1052
|
+
svg.append('g').attr('transform', "translate(0," + (height - marginBottom) + ")")
|
|
1053
|
+
// @ts-ignore
|
|
1054
|
+
.call(d3.axisBottom(x).ticks(ticks, typeof tickFormat === 'string' ? tickFormat : undefined)
|
|
1055
|
+
// @ts-ignore
|
|
1056
|
+
.tickFormat(typeof tickFormat === 'function' ? tickFormat : undefined).tickSize(tickSize)
|
|
1057
|
+
// @ts-ignore
|
|
1129
1058
|
.tickValues(tickValues)).call(tickAdjust).call(g => g.select('.domain').remove()).call(g => g.append('text').attr('x', marginLeft).attr('class', legendClassNames.legendTitle).attr('y', marginTop + marginBottom - height - (titleMarginBottom || legendDefaultParams.titleMarginBottom)).attr('fill', 'currentColor').attr('text-anchor', 'start').attr('font-weight', 'bold').text(title));
|
|
1130
1059
|
return svg;
|
|
1131
1060
|
};
|
|
1132
1061
|
|
|
1133
1062
|
var _templateObject$7;
|
|
1134
1063
|
const calendarChartClassNames = /*#__PURE__*/_extends({
|
|
1135
|
-
calendarChart:
|
|
1136
|
-
calendarYear:
|
|
1137
|
-
calendarAxis:
|
|
1138
|
-
calendarBody:
|
|
1139
|
-
calendarHeader:
|
|
1140
|
-
calendarYearTitle:
|
|
1141
|
-
calendarWeekDay:
|
|
1142
|
-
calendarMonth:
|
|
1143
|
-
calendarDays:
|
|
1144
|
-
calendarDay:
|
|
1064
|
+
calendarChart: "calendarChart",
|
|
1065
|
+
calendarYear: "calendarYear",
|
|
1066
|
+
calendarAxis: "calendarAxis",
|
|
1067
|
+
calendarBody: "calendarBody",
|
|
1068
|
+
calendarHeader: "calendarHeader",
|
|
1069
|
+
calendarYearTitle: "calendarYearTitle",
|
|
1070
|
+
calendarWeekDay: "calendarWeekDay",
|
|
1071
|
+
calendarMonth: "calendarMonth",
|
|
1072
|
+
calendarDays: "calendarDays",
|
|
1073
|
+
calendarDay: "calendarDay"
|
|
1145
1074
|
}, legendClassNames);
|
|
1146
|
-
const headerHeight =
|
|
1147
|
-
const SvgWrapper$2 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$7 || (_templateObject$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", " {\n display: flex;\n margin-bottom: 16px;\n }\n .", " {\n display: inline-flex;\n align-items: flex-end;\n height: ", ";\n margin-bottom: 4px;\n font-weight: bold;\n }\n .", " {\n height: ", ";\n margin-bottom: 4px;\n position: relative;\n display: flex;\n }\n .", " {\n font-size: 14px;\n bottom: 0;\n position: absolute;\n }\n .", " {\n display: flex;\n flex-direction: column;\n margin-right: 10px;\n }\n .", " {\n font-size: 12px;\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n }\n .", " {\n position: relative;\n }\n .", " {\n position: absolute;\n }\n"])), calendarChartClassNames.calendarYear, calendarChartClassNames.calendarYearTitle, headerHeight, calendarChartClassNames.calendarHeader, headerHeight, calendarChartClassNames.calendarMonth, calendarChartClassNames.calendarAxis, calendarChartClassNames.calendarWeekDay, calendarChartClassNames.calendarDays, calendarChartClassNames.calendarDay);
|
|
1075
|
+
const headerHeight = "20px";
|
|
1076
|
+
const SvgWrapper$2 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$7 || (_templateObject$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", " {\n display: flex;\n margin-bottom: 16px;\n }\n\n .", " {\n display: inline-flex;\n align-items: flex-end;\n height: ", ";\n margin-bottom: 4px;\n font-weight: bold;\n }\n\n .", " {\n height: ", ";\n margin-bottom: 4px;\n position: relative;\n display: flex;\n }\n\n .", " {\n font-size: 14px;\n bottom: 0;\n position: absolute;\n }\n\n .", " {\n display: flex;\n flex-direction: column;\n margin-right: 10px;\n }\n\n .", " {\n font-size: 12px;\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n }\n\n .", " {\n position: relative;\n }\n\n .", " {\n position: absolute;\n }\n"])), calendarChartClassNames.calendarYear, calendarChartClassNames.calendarYearTitle, headerHeight, calendarChartClassNames.calendarHeader, headerHeight, calendarChartClassNames.calendarMonth, calendarChartClassNames.calendarAxis, calendarChartClassNames.calendarWeekDay, calendarChartClassNames.calendarDays, calendarChartClassNames.calendarDay);
|
|
1148
1077
|
|
|
1149
1078
|
const draw$2 = (node, props) => {
|
|
1150
1079
|
const {
|
|
@@ -1157,28 +1086,20 @@ const draw$2 = (node, props) => {
|
|
|
1157
1086
|
colorRange,
|
|
1158
1087
|
legendProps
|
|
1159
1088
|
} = props;
|
|
1160
|
-
|
|
1161
1089
|
if (node !== null && data.length) {
|
|
1162
1090
|
const years = d3.group(data, d => d.date.getUTCFullYear());
|
|
1163
1091
|
const cellOffset = typeof props.cellOffset === 'number' ? props.cellOffset : 0;
|
|
1164
1092
|
const weekDays = 7;
|
|
1165
1093
|
const defaultCellSize = 18;
|
|
1166
1094
|
const cellSize = props.cellSize || defaultCellSize;
|
|
1167
|
-
|
|
1168
1095
|
const countDay = i => startSunday ? i : (i + (weekDays - 1)) % weekDays;
|
|
1169
|
-
|
|
1170
1096
|
const days = weekdays || ['вс', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'];
|
|
1171
1097
|
const sundayIndex = 6;
|
|
1172
|
-
|
|
1173
1098
|
const formatDay = i => startSunday ? days[i] : i === sundayIndex ? days[0] : days[i + 1];
|
|
1174
|
-
|
|
1175
1099
|
const formatDate = d3.utcFormat('%x');
|
|
1176
1100
|
const timeWeek = startSunday ? d3.utcSunday : d3.utcMonday;
|
|
1177
|
-
|
|
1178
1101
|
const getTimeWeekCount = (from, to) => timeWeek.count(d3.utcYear(from), to);
|
|
1179
|
-
|
|
1180
1102
|
const getMonthSpacing = date => date.getUTCMonth() * (monthSpacing || 0);
|
|
1181
|
-
|
|
1182
1103
|
const formatMonth = d3.utcFormat('%b');
|
|
1183
1104
|
const max = d3.max(data.map(_ref => {
|
|
1184
1105
|
let {
|
|
@@ -1192,7 +1113,8 @@ const draw$2 = (node, props) => {
|
|
|
1192
1113
|
} = _ref2;
|
|
1193
1114
|
return value;
|
|
1194
1115
|
}));
|
|
1195
|
-
const color = colorRange ? d3.scaleLinear().domain([min, max])
|
|
1116
|
+
const color = colorRange ? d3.scaleLinear().domain([min, max])
|
|
1117
|
+
// @ts-ignore
|
|
1196
1118
|
.range(colorRange) : d3.scaleSequential(interpolator || d3.interpolateGreens).domain([min, +max]);
|
|
1197
1119
|
let chartWidth = 0;
|
|
1198
1120
|
years.forEach((values, year) => {
|
|
@@ -1205,10 +1127,12 @@ const draw$2 = (node, props) => {
|
|
|
1205
1127
|
});
|
|
1206
1128
|
d3.select(node).select("." + calendarChartClassNames.calendarChart).remove();
|
|
1207
1129
|
const container = d3.select(node).append('div').attr('class', calendarChartClassNames.calendarChart);
|
|
1208
|
-
const year = container.selectAll('div')
|
|
1130
|
+
const year = container.selectAll('div')
|
|
1131
|
+
// @ts-ignore
|
|
1209
1132
|
.data(years).join('div').attr('class', calendarChartClassNames.calendarYear);
|
|
1210
1133
|
const calendarWeekdays = year.append('div').attr('class', calendarChartClassNames.calendarAxis);
|
|
1211
|
-
calendarWeekdays.append('div').attr('class', calendarChartClassNames.calendarYearTitle)
|
|
1134
|
+
calendarWeekdays.append('div').attr('class', calendarChartClassNames.calendarYearTitle)
|
|
1135
|
+
// @ts-ignore
|
|
1212
1136
|
.text(_ref3 => {
|
|
1213
1137
|
let [key] = _ref3;
|
|
1214
1138
|
return key;
|
|
@@ -1216,32 +1140,39 @@ const draw$2 = (node, props) => {
|
|
|
1216
1140
|
calendarWeekdays.selectAll('span').data(d3.range(weekDays)).join('div').attr('class', calendarChartClassNames.calendarWeekDay).style('height', cellSize + 'px').style('margin-bottom', cellOffset + 'px').text(formatDay);
|
|
1217
1141
|
const body = year.append('div').attr('class', calendarChartClassNames.calendarBody);
|
|
1218
1142
|
const header = body.append('div').attr('class', calendarChartClassNames.calendarHeader);
|
|
1219
|
-
header.selectAll('div')
|
|
1143
|
+
header.selectAll('div')
|
|
1144
|
+
// @ts-ignore
|
|
1220
1145
|
.data(_ref4 => {
|
|
1221
1146
|
let [_, values] = _ref4;
|
|
1222
1147
|
const fullYearlastMonth = 12;
|
|
1223
1148
|
const fullYearlastDate = 31;
|
|
1224
1149
|
return d3.utcMonths(d3.utcMonth(new Date(values[0].date.getUTCFullYear(), 1, 1)), d3.utcMonth(new Date(values[0].date.getUTCFullYear(), fullYearlastMonth, fullYearlastDate)));
|
|
1225
|
-
}).join('div').attr('class', calendarChartClassNames.calendarMonth).style('left', d => getTimeWeekCount(d, timeWeek.ceil(d)) * (cellSize + cellOffset) + getMonthSpacing(d) + 'px')
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1150
|
+
}).join('div').attr('class', calendarChartClassNames.calendarMonth).style('left', d => getTimeWeekCount(d, timeWeek.ceil(d)) * (cellSize + cellOffset) + getMonthSpacing(d) + 'px')
|
|
1151
|
+
// @ts-ignore
|
|
1152
|
+
.text(formatMonth);
|
|
1153
|
+
// @ts-ignore
|
|
1154
|
+
body.append('div').attr('class', calendarChartClassNames.calendarDays).style('height', (cellSize + cellOffset) * weekDays + 'px').style('width', chartWidth + 'px').selectAll('div')
|
|
1155
|
+
// @ts-ignore
|
|
1229
1156
|
.data(_ref5 => {
|
|
1230
1157
|
let [, values] = _ref5;
|
|
1231
1158
|
return values;
|
|
1232
|
-
}).join('div')
|
|
1159
|
+
}).join('div')
|
|
1160
|
+
// @ts-ignore
|
|
1233
1161
|
.each((data, index, elements) => {
|
|
1234
1162
|
if (onEachDay) {
|
|
1235
1163
|
const element = elements[index];
|
|
1236
1164
|
const currColor = color(data.value);
|
|
1237
1165
|
onEachDay(data, element, currColor);
|
|
1238
1166
|
}
|
|
1239
|
-
}).attr('class', calendarChartClassNames.calendarDay).style('width', cellSize + 'px').style('height', cellSize + 'px')
|
|
1240
|
-
|
|
1241
|
-
d =>
|
|
1242
|
-
|
|
1167
|
+
}).attr('class', calendarChartClassNames.calendarDay).style('width', cellSize + 'px').style('height', cellSize + 'px')
|
|
1168
|
+
// @ts-ignore
|
|
1169
|
+
.style('left', d => getTimeWeekCount(d.date, d.date) * (cellSize + cellOffset) + getMonthSpacing(d.date) + 'px').style('top',
|
|
1170
|
+
// @ts-ignore
|
|
1171
|
+
d => countDay(d.date.getUTCDay()) * (cellSize + cellOffset) + 'px')
|
|
1172
|
+
// @ts-ignore
|
|
1173
|
+
.style('background-color', d => color(d.value))
|
|
1174
|
+
// @ts-ignore
|
|
1243
1175
|
.attr('title', d => formatDate(d.date) + " - " + d.value);
|
|
1244
|
-
|
|
1245
1176
|
if (typeof legendProps === 'object') {
|
|
1246
1177
|
const legend = getLegend(_extends({
|
|
1247
1178
|
color: color
|
|
@@ -1270,7 +1201,8 @@ const CalendarChart = props => {
|
|
|
1270
1201
|
} = props;
|
|
1271
1202
|
const [ref, node] = useNode();
|
|
1272
1203
|
React.useEffect(() => {
|
|
1273
|
-
node && draw$2(node, props);
|
|
1204
|
+
node && draw$2(node, props);
|
|
1205
|
+
// eslint-disable-next-line
|
|
1274
1206
|
}, [node, data, startSunday, weekdays, cellOffset, cellSize, interpolator, monthSpacing, colorRange, legendProps]);
|
|
1275
1207
|
return React__default.createElement(SvgWrapper$2, {
|
|
1276
1208
|
ref: ref,
|
|
@@ -1285,7 +1217,6 @@ CalendarChart.defaultProps = {
|
|
|
1285
1217
|
function computeDimensions(selection) {
|
|
1286
1218
|
let dimensions;
|
|
1287
1219
|
const node = selection.node();
|
|
1288
|
-
|
|
1289
1220
|
if (node instanceof SVGGraphicsElement) {
|
|
1290
1221
|
// check if node is svg element
|
|
1291
1222
|
dimensions = node.getBBox();
|
|
@@ -1293,7 +1224,6 @@ function computeDimensions(selection) {
|
|
|
1293
1224
|
// else is html element
|
|
1294
1225
|
dimensions = node.getBoundingClientRect();
|
|
1295
1226
|
}
|
|
1296
|
-
|
|
1297
1227
|
return dimensions;
|
|
1298
1228
|
}
|
|
1299
1229
|
|
|
@@ -1308,7 +1238,6 @@ const stackedData = data => {
|
|
|
1308
1238
|
const stacks = {};
|
|
1309
1239
|
return data.map((item, index) => {
|
|
1310
1240
|
stacks[index] = {};
|
|
1311
|
-
|
|
1312
1241
|
if (index > 0) {
|
|
1313
1242
|
return _extends({}, item, {
|
|
1314
1243
|
values: item.values.map((value, valuesIndex) => {
|
|
@@ -1322,38 +1251,37 @@ const stackedData = data => {
|
|
|
1322
1251
|
stacks[index][valuesIndex] = Number(value);
|
|
1323
1252
|
});
|
|
1324
1253
|
}
|
|
1325
|
-
|
|
1326
1254
|
return item;
|
|
1327
1255
|
});
|
|
1328
1256
|
};
|
|
1329
1257
|
|
|
1330
1258
|
var _templateObject$8, _templateObject2$2;
|
|
1331
1259
|
const lineChartClassNames = {
|
|
1332
|
-
lineChartYScaleGlobal:
|
|
1333
|
-
lineChartYScaleRight:
|
|
1334
|
-
lineChartXScaleGlobal:
|
|
1335
|
-
lineChartLinesGlobal:
|
|
1336
|
-
lineChartLine:
|
|
1337
|
-
lineChartAreasGlobal:
|
|
1338
|
-
lineChartArea:
|
|
1339
|
-
lineChartDotsGlobalContainer:
|
|
1340
|
-
lineChartDotsGlobal:
|
|
1341
|
-
lineChartDot:
|
|
1342
|
-
lineChartGridGlobal:
|
|
1343
|
-
lineChartGridLineX:
|
|
1344
|
-
lineChartGridLineY:
|
|
1345
|
-
lineChartLabelContainer:
|
|
1346
|
-
lineChartLabelFlex:
|
|
1347
|
-
lineChartLabel:
|
|
1348
|
-
lineChartMouseGlobal:
|
|
1349
|
-
lineChartMouseLine:
|
|
1350
|
-
lineChartMouseRect:
|
|
1351
|
-
lineChartMouseCircle:
|
|
1352
|
-
lineChartMouseLabelContainer:
|
|
1353
|
-
lineChartMouseLabel:
|
|
1354
|
-
};
|
|
1355
|
-
const SvgWrapper$3 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$8 || (_templateObject$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", ",\n
|
|
1356
|
-
const TooltipStyles = /*#__PURE__*/styled.createGlobalStyle(_templateObject2$2 || (_templateObject2$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", " {\n transition: opacity linear 200ms;\n z-index: 100;\n .", " {\n justify-content: flex-start;\n align-items: center;\n pointer-events: none;\n }\n .", " {\n margin: 0 0 0 10px;\n }\n }\n"])), lineChartClassNames.lineChartMouseLabel, lineChartClassNames.lineChartLabelFlex, lineChartClassNames.lineChartLabel);
|
|
1260
|
+
lineChartYScaleGlobal: "lineChartYScaleGlobal",
|
|
1261
|
+
lineChartYScaleRight: "lineChartYScaleRight",
|
|
1262
|
+
lineChartXScaleGlobal: "lineChartXScaleGlobal",
|
|
1263
|
+
lineChartLinesGlobal: "lineChartLinesGlobal",
|
|
1264
|
+
lineChartLine: "lineChartLine",
|
|
1265
|
+
lineChartAreasGlobal: "lineChartAreasGlobal",
|
|
1266
|
+
lineChartArea: "lineChartArea",
|
|
1267
|
+
lineChartDotsGlobalContainer: "lineChartDotsGlobalContainer",
|
|
1268
|
+
lineChartDotsGlobal: "lineChartDotsGlobal",
|
|
1269
|
+
lineChartDot: "lineChartDot",
|
|
1270
|
+
lineChartGridGlobal: "lineChartGridGlobal",
|
|
1271
|
+
lineChartGridLineX: "lineChartGridLineX",
|
|
1272
|
+
lineChartGridLineY: "lineChartGridLineY",
|
|
1273
|
+
lineChartLabelContainer: "lineChartLabelContainer",
|
|
1274
|
+
lineChartLabelFlex: "lineChartLabelFlex",
|
|
1275
|
+
lineChartLabel: "lineChartLabel",
|
|
1276
|
+
lineChartMouseGlobal: "lineChartMouseGlobal",
|
|
1277
|
+
lineChartMouseLine: "lineChartMouseLine",
|
|
1278
|
+
lineChartMouseRect: "lineChartMouseRect",
|
|
1279
|
+
lineChartMouseCircle: "lineChartMouseCircle",
|
|
1280
|
+
lineChartMouseLabelContainer: "lineChartMouseLabelContainer",
|
|
1281
|
+
lineChartMouseLabel: "lineChartMouseLabel"
|
|
1282
|
+
};
|
|
1283
|
+
const SvgWrapper$3 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$8 || (_templateObject$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", ",\n .", ",\n .", " {\n shape-rendering: crispEdges;\n }\n\n .", " {\n fill: none;\n stroke: steelblue;\n stroke-width: 1.5px;\n stroke-linejoin: round;\n stroke-linecap: round;\n }\n\n .", " {\n fill-opacity: 0.24;\n }\n\n .", ",\n .", ",\n .", " {\n stroke: rgba(149, 149, 149, 0.24);\n }\n\n .", ",\n .", " {\n transition: opacity linear 200ms;\n pointer-events: none;\n stroke-width: 1px;\n }\n\n .", " {\n stroke: #fff;\n stroke-width: 2px;\n }\n\n .", " {\n shape-rendering: crispEdges;\n }\n\n .", " {\n fill: none;\n pointer-events: all;\n }\n"])), lineChartClassNames.lineChartYScaleGlobal, lineChartClassNames.lineChartXScaleGlobal, lineChartClassNames.lineChartGridGlobal, lineChartClassNames.lineChartLinesGlobal, lineChartClassNames.lineChartArea, lineChartClassNames.lineChartGridLineX, lineChartClassNames.lineChartGridLineY, lineChartClassNames.lineChartMouseLine, lineChartClassNames.lineChartMouseLine, lineChartClassNames.lineChartMouseCircle, lineChartClassNames.lineChartDot, lineChartClassNames.lineChartMouseLine, lineChartClassNames.lineChartMouseRect);
|
|
1284
|
+
const TooltipStyles = /*#__PURE__*/styled.createGlobalStyle(_templateObject2$2 || (_templateObject2$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", " {\n transition: opacity linear 200ms;\n z-index: 100;\n\n .", " {\n justify-content: flex-start;\n align-items: center;\n pointer-events: none;\n }\n\n .", " {\n margin: 0 0 0 10px;\n }\n }\n"])), lineChartClassNames.lineChartMouseLabel, lineChartClassNames.lineChartLabelFlex, lineChartClassNames.lineChartLabel);
|
|
1357
1285
|
|
|
1358
1286
|
const drawGrid = _ref => {
|
|
1359
1287
|
let {
|
|
@@ -1368,11 +1296,9 @@ const drawGrid = _ref => {
|
|
|
1368
1296
|
if (!drawGridY && !drawGridX) return;
|
|
1369
1297
|
const global = svg.append('g').attr('class', lineChartClassNames.lineChartGridGlobal);
|
|
1370
1298
|
const yTicks = yScale.ticks(yTicksCount);
|
|
1371
|
-
|
|
1372
1299
|
if (drawGridX) {
|
|
1373
1300
|
global.append('g').selectAll('line').data(yTicks).join('line').attr('class', lineChartClassNames.lineChartGridLineX).attr('x1', () => xScale(0)).attr('x2', () => xScale(lastIndex)).attr('y1', d => Math.round(yScale(d))).attr('y2', d => Math.round(yScale(d)));
|
|
1374
1301
|
}
|
|
1375
|
-
|
|
1376
1302
|
if (drawGridY) {
|
|
1377
1303
|
global.append('g').selectAll('line').data(Array.from({
|
|
1378
1304
|
length: lastIndex + 1
|
|
@@ -1395,8 +1321,8 @@ const drawLabel = _ref => {
|
|
|
1395
1321
|
eachLabel
|
|
1396
1322
|
} = _ref;
|
|
1397
1323
|
const labelsDiv = d3.select(node).append('div').attr('class', labelClassName$1);
|
|
1398
|
-
const format = d3.format(',');
|
|
1399
|
-
|
|
1324
|
+
const format = d3.format(',');
|
|
1325
|
+
// @ts-ignore
|
|
1400
1326
|
data.forEach(_ref2 => {
|
|
1401
1327
|
let {
|
|
1402
1328
|
values
|
|
@@ -1408,7 +1334,8 @@ const drawLabel = _ref => {
|
|
|
1408
1334
|
className: lineChartClassNames.lineChartLabel
|
|
1409
1335
|
}, formatLabel ? formatLabel(d, index, elements) : format(d))));
|
|
1410
1336
|
return html;
|
|
1411
|
-
})
|
|
1337
|
+
})
|
|
1338
|
+
// @ts-ignore
|
|
1412
1339
|
.each(eachLabel ? eachLabel : none);
|
|
1413
1340
|
});
|
|
1414
1341
|
};
|
|
@@ -1464,14 +1391,11 @@ const drawTooltip$1 = _ref => {
|
|
|
1464
1391
|
return stroke || 'none';
|
|
1465
1392
|
}).style('opacity', '0');
|
|
1466
1393
|
let labelContainer = d3.select("." + lineChartClassNames.lineChartMouseLabelContainer);
|
|
1467
|
-
|
|
1468
1394
|
if (labelContainer.size() === 0) {
|
|
1469
1395
|
labelContainer = d3.select(container).append('div').attr('class', lineChartClassNames.lineChartMouseLabelContainer);
|
|
1470
1396
|
}
|
|
1471
|
-
|
|
1472
1397
|
let labels = null;
|
|
1473
1398
|
let isVisible = false;
|
|
1474
|
-
|
|
1475
1399
|
const setVisible = visible => {
|
|
1476
1400
|
isVisible = Boolean(visible);
|
|
1477
1401
|
const opacity = isVisible ? '1' : '0';
|
|
@@ -1479,7 +1403,6 @@ const drawTooltip$1 = _ref => {
|
|
|
1479
1403
|
circles.style('opacity', opacity);
|
|
1480
1404
|
labels && labels.style('opacity', opacity);
|
|
1481
1405
|
};
|
|
1482
|
-
|
|
1483
1406
|
const mouseMove = event => {
|
|
1484
1407
|
const [docX, docY] = d3.pointer(event, document);
|
|
1485
1408
|
const [rectrX] = d3.pointer(event, mouseRect);
|
|
@@ -1488,41 +1411,33 @@ const drawTooltip$1 = _ref => {
|
|
|
1488
1411
|
const left = nodeX + (docX - nodeX);
|
|
1489
1412
|
const currIndex = Math.abs(xScale.invert(x));
|
|
1490
1413
|
const positions = {};
|
|
1491
|
-
|
|
1492
1414
|
const getValue = values => {
|
|
1493
1415
|
// The returning result is fixed for the task: https://jr.everpoint.ru/browse/PUB-5648
|
|
1494
1416
|
// Before the task it was like this (and I don't know why):
|
|
1495
|
-
|
|
1496
1417
|
/* return !isVoid(values[Math.floor(currIndex + 1)])
|
|
1497
1418
|
? values[Math.floor(currIndex)]
|
|
1498
1419
|
: null;*/
|
|
1499
1420
|
return values[Math.floor(currIndex)];
|
|
1500
1421
|
};
|
|
1501
|
-
|
|
1502
1422
|
lines.forEach((line, index) => {
|
|
1503
1423
|
let pos = {
|
|
1504
1424
|
x: 0,
|
|
1505
1425
|
y: 0
|
|
1506
1426
|
};
|
|
1507
|
-
|
|
1508
1427
|
if (!line.hasAttribute('d') || argData[index].tooltipOff) {
|
|
1509
1428
|
positions[index] = pos;
|
|
1510
1429
|
return;
|
|
1511
1430
|
}
|
|
1512
|
-
|
|
1513
1431
|
if (!dotSnapping) {
|
|
1514
1432
|
let beginning = 0;
|
|
1515
1433
|
let end = line.getTotalLength();
|
|
1516
1434
|
let target = null;
|
|
1517
|
-
|
|
1518
1435
|
while (true) {
|
|
1519
1436
|
target = Math.floor((beginning + end) / 2);
|
|
1520
1437
|
pos = line.getPointAtLength(target);
|
|
1521
|
-
|
|
1522
1438
|
if ((target === end || target === beginning) && pos.x !== x) {
|
|
1523
1439
|
break;
|
|
1524
1440
|
}
|
|
1525
|
-
|
|
1526
1441
|
if (pos.x > x) {
|
|
1527
1442
|
end = target;
|
|
1528
1443
|
} else if (pos.x < x) {
|
|
@@ -1531,7 +1446,6 @@ const drawTooltip$1 = _ref => {
|
|
|
1531
1446
|
break;
|
|
1532
1447
|
}
|
|
1533
1448
|
}
|
|
1534
|
-
|
|
1535
1449
|
positions[index] = pos;
|
|
1536
1450
|
} else {
|
|
1537
1451
|
const [x1, x2] = xScale.range();
|
|
@@ -1554,10 +1468,9 @@ const drawTooltip$1 = _ref => {
|
|
|
1554
1468
|
});
|
|
1555
1469
|
const datas = chartData.map((_ref7, i) => {
|
|
1556
1470
|
let {
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1471
|
+
values
|
|
1472
|
+
} = _ref7,
|
|
1473
|
+
rest = _objectWithoutPropertiesLoose(_ref7, _excluded$1);
|
|
1561
1474
|
return _extends({}, rest, {
|
|
1562
1475
|
value: getValue(values),
|
|
1563
1476
|
invertValue: positions[i] ? yScale.invert(positions[i].y) : 0
|
|
@@ -1569,16 +1482,13 @@ const drawTooltip$1 = _ref => {
|
|
|
1569
1482
|
} = _ref8;
|
|
1570
1483
|
return isVoid(value);
|
|
1571
1484
|
});
|
|
1572
|
-
|
|
1573
1485
|
if (noHasData && isVisible) {
|
|
1574
1486
|
setVisible();
|
|
1575
1487
|
} else if (!isVisible && !noHasData) {
|
|
1576
1488
|
setVisible(true);
|
|
1577
1489
|
}
|
|
1578
|
-
|
|
1579
1490
|
const topIndex = Object.keys(positions).reduce((acc, key, index) => {
|
|
1580
1491
|
var _datas$Number, _datas$Number2;
|
|
1581
|
-
|
|
1582
1492
|
const prevValue = (_datas$Number = datas[Number(acc)]) == null ? void 0 : _datas$Number.value;
|
|
1583
1493
|
const value = (_datas$Number2 = datas[Number(key)]) == null ? void 0 : _datas$Number2.value;
|
|
1584
1494
|
const dynamicDotOff = argData == null ? void 0 : argData[index].dynamicDotOff;
|
|
@@ -1586,15 +1496,12 @@ const drawTooltip$1 = _ref => {
|
|
|
1586
1496
|
}, '0');
|
|
1587
1497
|
const labelTexts = labels && labels.style('left', (_, i) => {
|
|
1588
1498
|
var _positions$i$x, _positions$i;
|
|
1589
|
-
|
|
1590
1499
|
return !dotSnapping ? left + "px" : ((_positions$i$x = (_positions$i = positions[i]) == null ? void 0 : _positions$i.x) != null ? _positions$i$x : 0) + "px";
|
|
1591
1500
|
}).style('top', (_, i) => {
|
|
1592
1501
|
var _positions$index$y, _positions$index;
|
|
1593
|
-
|
|
1594
1502
|
const index = typeof stackedTooltipIndex === 'number' ? stackedTooltipIndex : stackedTooltip ? topIndex : i;
|
|
1595
1503
|
return ((_positions$index$y = (_positions$index = positions[index]) == null ? void 0 : _positions$index.y) != null ? _positions$index$y : 0) + (docY - nodeY) + "px";
|
|
1596
1504
|
}).select("." + lineChartClassNames.lineChartLabel);
|
|
1597
|
-
|
|
1598
1505
|
if (renderTooltip && labels) {
|
|
1599
1506
|
labels.html((_, index) => {
|
|
1600
1507
|
return ReactDOMServer.renderToString(React__default.createElement(LabelContainer$1, {
|
|
@@ -1613,16 +1520,13 @@ const drawTooltip$1 = _ref => {
|
|
|
1613
1520
|
return formatDynamicTooltip ? formatDynamicTooltip(invertValue, value) : format(invertValue);
|
|
1614
1521
|
});
|
|
1615
1522
|
}
|
|
1616
|
-
|
|
1617
1523
|
mouseLine.attr('d', () => {
|
|
1618
1524
|
var _positions$topIndex;
|
|
1619
|
-
|
|
1620
1525
|
let d = 'M' + x + ',' + y1;
|
|
1621
1526
|
d += ' ' + x + ',' + (tooltipLineTop ? y2 : ((_positions$topIndex = positions[topIndex]) == null ? void 0 : _positions$topIndex.y) || 0);
|
|
1622
1527
|
return d;
|
|
1623
1528
|
});
|
|
1624
1529
|
};
|
|
1625
|
-
|
|
1626
1530
|
mouseRect.on('mouseover.tooltip', event => {
|
|
1627
1531
|
labels = labelContainer.selectAll('div').data(data).join('div').attr('class', lineChartClassNames.lineChartMouseLabel + " " + (tooltipClassName || '')).style('opacity', '0').style('position', 'absolute').html(() => {
|
|
1628
1532
|
const html = ReactDOMServer.renderToString(React__default.createElement(LabelContainer$1, {
|
|
@@ -1675,7 +1579,6 @@ const draw$3 = (node, props) => {
|
|
|
1675
1579
|
dotSnapping,
|
|
1676
1580
|
rightAxis
|
|
1677
1581
|
} = props;
|
|
1678
|
-
|
|
1679
1582
|
if (node !== null && chartData.length) {
|
|
1680
1583
|
const data = stacked ? stackedData(chartData) : chartData;
|
|
1681
1584
|
const marginTop = margin ? margin.top : 0;
|
|
@@ -1713,7 +1616,6 @@ const draw$3 = (node, props) => {
|
|
|
1713
1616
|
} = computeDimensions(yAxis);
|
|
1714
1617
|
yAxis.attr('transform', "translate(" + (marginLeft + yAxisWidth) + ", 0)");
|
|
1715
1618
|
let yAxisRightWidth = 0;
|
|
1716
|
-
|
|
1717
1619
|
if (rightAxis) {
|
|
1718
1620
|
const rightAxisMin = d3.min(rightAxis);
|
|
1719
1621
|
const rightAxisMax = d3.max(rightAxis);
|
|
@@ -1726,8 +1628,6 @@ const draw$3 = (node, props) => {
|
|
|
1726
1628
|
yAxisRight.attr('transform', "translate(" + (width - yAxisRightWidth) + ", 0)");
|
|
1727
1629
|
}
|
|
1728
1630
|
/** xScale **/
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
1631
|
const lastIndex = labels && labels.length ? labels.length - 1 : data.reduce((acc, _ref3) => {
|
|
1732
1632
|
let {
|
|
1733
1633
|
values
|
|
@@ -1735,15 +1635,14 @@ const draw$3 = (node, props) => {
|
|
|
1735
1635
|
return Math.max(acc, values.length);
|
|
1736
1636
|
}, 0) - 1;
|
|
1737
1637
|
const xScale = d3.scaleLinear().domain([0, lastIndex]).range([marginLeft + yAxisWidth + (yAxisPadding || 0), width - yAxisRightWidth - marginRight]);
|
|
1738
|
-
const xAxisBottom = d3.axisBottom(xScale).tickFormat(value =>
|
|
1638
|
+
const xAxisBottom = d3.axisBottom(xScale).tickFormat(value =>
|
|
1639
|
+
// @ts-ignore
|
|
1739
1640
|
labels && labels.length > 0 ? labels[value] : 0).ticks(lastIndex);
|
|
1740
|
-
|
|
1741
1641
|
if (typeof xScaleItemWidth === 'number') {
|
|
1742
1642
|
const [x1, x2] = xScale.range();
|
|
1743
1643
|
const chartWidth = x2 - x1;
|
|
1744
1644
|
xAxisBottom.ticks(Math.round(chartWidth / xScaleItemWidth)).tickSizeOuter(0);
|
|
1745
1645
|
}
|
|
1746
|
-
|
|
1747
1646
|
customXAxis && customXAxis(xAxisBottom);
|
|
1748
1647
|
drawGrid({
|
|
1749
1648
|
svg,
|
|
@@ -1754,7 +1653,6 @@ const draw$3 = (node, props) => {
|
|
|
1754
1653
|
drawGridY,
|
|
1755
1654
|
drawGridX
|
|
1756
1655
|
});
|
|
1757
|
-
|
|
1758
1656
|
if (Array.isArray(labels) && labels.length > 0) {
|
|
1759
1657
|
const xAxis = svg.append('g').call(customXAxisSelection ? customXAxisSelection : none).attr('class', lineChartClassNames.lineChartXScaleGlobal).call(xAxisBottom);
|
|
1760
1658
|
const {
|
|
@@ -1762,7 +1660,6 @@ const draw$3 = (node, props) => {
|
|
|
1762
1660
|
} = computeDimensions(xAxis);
|
|
1763
1661
|
xAxis.attr('transform', "translate(0, " + (height - Math.ceil(xAxisHeight) - marginBottom) + ")");
|
|
1764
1662
|
}
|
|
1765
|
-
|
|
1766
1663
|
const line = d3.line().defined(d => d !== null).x((_, index) => xScale(index)).y(d => yScale(d)).curve(curve || d3.curveLinear);
|
|
1767
1664
|
customLine && customLine(line);
|
|
1768
1665
|
const withAreas = data.some(_ref4 => {
|
|
@@ -1771,10 +1668,8 @@ const draw$3 = (node, props) => {
|
|
|
1771
1668
|
} = _ref4;
|
|
1772
1669
|
return fill;
|
|
1773
1670
|
});
|
|
1774
|
-
|
|
1775
1671
|
if (withAreas) {
|
|
1776
1672
|
let dataIndex = -2;
|
|
1777
|
-
|
|
1778
1673
|
const getArea = d => {
|
|
1779
1674
|
const {
|
|
1780
1675
|
minAreaValues
|
|
@@ -1784,20 +1679,16 @@ const draw$3 = (node, props) => {
|
|
|
1784
1679
|
if (index === 0) {
|
|
1785
1680
|
dataIndex = dataIndex + 1;
|
|
1786
1681
|
}
|
|
1787
|
-
|
|
1788
1682
|
let minValue = minTick;
|
|
1789
|
-
|
|
1790
1683
|
if (minAreaValues && typeof minAreaValues[index] === 'number') {
|
|
1791
1684
|
minValue = minAreaValues[index] || minValue;
|
|
1792
1685
|
} else if (minAreaValues) {
|
|
1793
1686
|
minValue = yScale(minValue - value);
|
|
1794
1687
|
}
|
|
1795
|
-
|
|
1796
1688
|
const currData = data[dataIndex];
|
|
1797
1689
|
return stacked ? dataIndex > -1 ? yScale(typeof currData.values[index] !== 'number' ? 0 : currData.values[index]) : yScale(minValue) : yScale(minValue);
|
|
1798
1690
|
}).y1(d => yScale(d)).curve(areaCurve || curve || d3.curveLinear);
|
|
1799
1691
|
};
|
|
1800
|
-
|
|
1801
1692
|
svg.append('g').attr('class', lineChartClassNames.lineChartAreasGlobal).selectAll('path').data(data.filter(_ref5 => {
|
|
1802
1693
|
let {
|
|
1803
1694
|
fill
|
|
@@ -1818,7 +1709,6 @@ const draw$3 = (node, props) => {
|
|
|
1818
1709
|
return areaStyle || '';
|
|
1819
1710
|
});
|
|
1820
1711
|
}
|
|
1821
|
-
|
|
1822
1712
|
svg.append('g').attr('class', lineChartClassNames.lineChartLinesGlobal).selectAll('path').data(data).join('path').attr('class', lineChartClassNames.lineChartLine).attr('d', d => line(d.values)).attr('stroke', _ref8 => {
|
|
1823
1713
|
let {
|
|
1824
1714
|
stroke
|
|
@@ -1830,13 +1720,12 @@ const draw$3 = (node, props) => {
|
|
|
1830
1720
|
} = _ref9;
|
|
1831
1721
|
return style || '';
|
|
1832
1722
|
});
|
|
1833
|
-
const dots = data.filter(
|
|
1723
|
+
const dots = data.filter(_ref0 => {
|
|
1834
1724
|
let {
|
|
1835
1725
|
dot
|
|
1836
|
-
} =
|
|
1726
|
+
} = _ref0;
|
|
1837
1727
|
return dot;
|
|
1838
1728
|
});
|
|
1839
|
-
|
|
1840
1729
|
if (dots.length > 0) {
|
|
1841
1730
|
const dotsGlobal = svg.append('g').attr('class', lineChartClassNames.lineChartDotsGlobalContainer);
|
|
1842
1731
|
dots.forEach(item => {
|
|
@@ -1851,13 +1740,11 @@ const draw$3 = (node, props) => {
|
|
|
1851
1740
|
} = dot;
|
|
1852
1741
|
const dotsGroup = dotsGlobal.append('g').attr('class', lineChartClassNames.lineChartDotsGlobal);
|
|
1853
1742
|
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 || '');
|
|
1854
|
-
|
|
1855
1743
|
if (filter) {
|
|
1856
1744
|
dotsGroup.selectAll('circle').select((_, i, g) => filter(item, i, g) ? g[i] : null).remove();
|
|
1857
1745
|
}
|
|
1858
1746
|
});
|
|
1859
1747
|
}
|
|
1860
|
-
|
|
1861
1748
|
d3.select(node).select("." + labelClassName$1).remove();
|
|
1862
1749
|
withLabels && drawLabel({
|
|
1863
1750
|
node,
|
|
@@ -1867,7 +1754,6 @@ const draw$3 = (node, props) => {
|
|
|
1867
1754
|
xScale,
|
|
1868
1755
|
formatLabel
|
|
1869
1756
|
});
|
|
1870
|
-
|
|
1871
1757
|
if (dynamicTooltipEnable) {
|
|
1872
1758
|
drawTooltip$1({
|
|
1873
1759
|
tooltipLineTop,
|
|
@@ -1886,7 +1772,6 @@ const draw$3 = (node, props) => {
|
|
|
1886
1772
|
lastIndex
|
|
1887
1773
|
});
|
|
1888
1774
|
}
|
|
1889
|
-
|
|
1890
1775
|
customize && customize({
|
|
1891
1776
|
svg,
|
|
1892
1777
|
yScale,
|
|
@@ -1905,9 +1790,7 @@ const LineChart = props => {
|
|
|
1905
1790
|
React.useEffect(() => {
|
|
1906
1791
|
node && draw$3(node, props);
|
|
1907
1792
|
}, [node, props]);
|
|
1908
|
-
|
|
1909
1793
|
const onDraw = () => draw$3(node, props);
|
|
1910
|
-
|
|
1911
1794
|
useResize(props.width, onDraw);
|
|
1912
1795
|
return React__default.createElement("div", {
|
|
1913
1796
|
className: className,
|
|
@@ -1951,7 +1834,8 @@ const drawLines = _ref => {
|
|
|
1951
1834
|
let linesSelection = null;
|
|
1952
1835
|
let areasSelection = null;
|
|
1953
1836
|
let area = null;
|
|
1954
|
-
const line = d3.line().defined(d => d !== null).x((_, index) => xScale(index) + bandwidth / 2)
|
|
1837
|
+
const line = d3.line().defined(d => d !== null).x((_, index) => xScale(index) + bandwidth / 2)
|
|
1838
|
+
// @ts-ignore
|
|
1955
1839
|
.y(d => yScale(d)).curve(curve || d3.curveLinear);
|
|
1956
1840
|
const bandwidth = xScale.bandwidth();
|
|
1957
1841
|
const linesData = lineData.filter(_ref2 => {
|
|
@@ -1966,7 +1850,6 @@ const drawLines = _ref => {
|
|
|
1966
1850
|
} = _ref3;
|
|
1967
1851
|
return lineType === 'area';
|
|
1968
1852
|
});
|
|
1969
|
-
|
|
1970
1853
|
if (linesData.length > 0) {
|
|
1971
1854
|
linesSelection = svg.append('g').attr('class', barChartLinesClassNames.barChartLinesGlobal).selectAll('path').data(linesData).join('path').attr('class', barChartLinesClassNames.barChartLine).attr('d', d => line(d.values)).attr('stroke', _ref4 => {
|
|
1972
1855
|
let {
|
|
@@ -1980,16 +1863,15 @@ const drawLines = _ref => {
|
|
|
1980
1863
|
return fill || 'none';
|
|
1981
1864
|
});
|
|
1982
1865
|
}
|
|
1983
|
-
|
|
1984
1866
|
if (areasData.length > 0) {
|
|
1985
1867
|
let dataIndex = -2;
|
|
1986
1868
|
area = d3.area().x((_, index) => xScale(index) + bandwidth / 2).y0((_, index) => {
|
|
1987
1869
|
if (index === 0) {
|
|
1988
1870
|
dataIndex = dataIndex + 1;
|
|
1989
1871
|
}
|
|
1990
|
-
|
|
1991
1872
|
return stackedLine ? dataIndex > -1 ? yScale(typeof lineData[dataIndex].values[index] !== 'number' ? 0 : lineData[dataIndex].values[index]) : yScale(min) : yScale(min);
|
|
1992
|
-
})
|
|
1873
|
+
})
|
|
1874
|
+
// @ts-ignore
|
|
1993
1875
|
.y1(d => yScale(d)).curve(curve || d3.curveLinear);
|
|
1994
1876
|
areasSelection = svg.append('g').attr('class', barChartLinesClassNames.barChartAreasGlobal).selectAll('path').data(areasData).join('path').attr('class', barChartLinesClassNames.barChartArea).attr('d', d => area && area(d.values)).attr('fill', _ref6 => {
|
|
1995
1877
|
let {
|
|
@@ -1998,7 +1880,6 @@ const drawLines = _ref => {
|
|
|
1998
1880
|
return fill || 'none';
|
|
1999
1881
|
});
|
|
2000
1882
|
}
|
|
2001
|
-
|
|
2002
1883
|
return {
|
|
2003
1884
|
areasSelection,
|
|
2004
1885
|
linesSelection,
|
|
@@ -2071,10 +1952,8 @@ const useSelection = (node, props) => {
|
|
|
2071
1952
|
const onStartDrawing = React.useCallback(e => {
|
|
2072
1953
|
const isTouch = Boolean(e.touches);
|
|
2073
1954
|
e.stopPropagation();
|
|
2074
|
-
|
|
2075
1955
|
if (node && e.which !== 3) {
|
|
2076
1956
|
var _props$margin$bottom, _props$margin, _e$touches$;
|
|
2077
|
-
|
|
2078
1957
|
clearSelection();
|
|
2079
1958
|
selection.current = document.createElement("div");
|
|
2080
1959
|
selection.current.setAttribute("class", barChartClassNames.barChartSelection);
|
|
@@ -2090,14 +1969,11 @@ const useSelection = (node, props) => {
|
|
|
2090
1969
|
const onDraw = React.useCallback(e => {
|
|
2091
1970
|
const isTouch = Boolean(e.touches);
|
|
2092
1971
|
e.stopPropagation();
|
|
2093
|
-
|
|
2094
1972
|
if (node && drawing.current && selection.current) {
|
|
2095
1973
|
var _e$touches$2;
|
|
2096
|
-
|
|
2097
1974
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2098
1975
|
const offsetX = isTouch ? ((_e$touches$2 = e.touches[0]) == null ? void 0 : _e$touches$2.pageX) - node.firstChild.getBoundingClientRect().left : e.offsetX;
|
|
2099
1976
|
const newWidth = offsetX - startX.current;
|
|
2100
|
-
|
|
2101
1977
|
if (offsetX >= 0) {
|
|
2102
1978
|
if (newWidth > 0) {
|
|
2103
1979
|
selection.current.style.marginLeft = "0px";
|
|
@@ -2108,7 +1984,6 @@ const useSelection = (node, props) => {
|
|
|
2108
1984
|
selection.current.style.marginLeft = newWidth + "px";
|
|
2109
1985
|
}
|
|
2110
1986
|
}
|
|
2111
|
-
|
|
2112
1987
|
if (isTouch) {
|
|
2113
1988
|
if (node.offsetLeft > e.touches[0].pageX) {
|
|
2114
1989
|
selection.current.style.right = nodeWidth - startX.current + "px";
|
|
@@ -2126,7 +2001,6 @@ const useSelection = (node, props) => {
|
|
|
2126
2001
|
selection.current.style.width = startX.current + "px";
|
|
2127
2002
|
selection.current.style.marginLeft = "-" + startX.current + "px";
|
|
2128
2003
|
}
|
|
2129
|
-
|
|
2130
2004
|
if (node.offsetLeft + node.offsetWidth < e.pageX) {
|
|
2131
2005
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2132
2006
|
selection.current.style.left = startX.current + "px";
|
|
@@ -2143,12 +2017,10 @@ const useSelection = (node, props) => {
|
|
|
2143
2017
|
const selectionMaxX = selection.current.offsetLeft + selectionWidth <= nodeWidth ? selection.current.offsetLeft + selectionWidth >= 0 ? selection.current.offsetLeft + selectionWidth : 0 : nodeWidth;
|
|
2144
2018
|
const min = Math.round(selectionMinX);
|
|
2145
2019
|
const max = Math.round(selectionMaxX);
|
|
2146
|
-
|
|
2147
2020
|
if (max - min > 0 && props.onSelect) {
|
|
2148
2021
|
props.onSelect([min, max]);
|
|
2149
2022
|
}
|
|
2150
2023
|
}
|
|
2151
|
-
|
|
2152
2024
|
clearSelection();
|
|
2153
2025
|
}, [node, clearSelection]);
|
|
2154
2026
|
React.useEffect(() => {
|
|
@@ -2165,15 +2037,14 @@ const useSelection = (node, props) => {
|
|
|
2165
2037
|
node.addEventListener("touchend", onStopDrawing);
|
|
2166
2038
|
document.addEventListener("mouseup", onStopDrawing);
|
|
2167
2039
|
}
|
|
2168
|
-
|
|
2169
2040
|
return () => {
|
|
2170
|
-
node == null
|
|
2171
|
-
node == null
|
|
2172
|
-
node == null
|
|
2173
|
-
node == null
|
|
2174
|
-
node == null
|
|
2175
|
-
node == null
|
|
2176
|
-
node == null
|
|
2041
|
+
node == null || node.removeEventListener("mousedown", onStartDrawing);
|
|
2042
|
+
node == null || node.removeEventListener("touchstart", onStartDrawing);
|
|
2043
|
+
node == null || node.removeEventListener("mousemove", onDraw);
|
|
2044
|
+
node == null || node.removeEventListener("touchmove", onDraw);
|
|
2045
|
+
node == null || node.removeEventListener("mouseleave", onMouseLeave);
|
|
2046
|
+
node == null || node.removeEventListener("mouseup", onStopDrawing);
|
|
2047
|
+
node == null || node.removeEventListener("touchend", onStopDrawing);
|
|
2177
2048
|
document.removeEventListener("mouseup", onStopDrawing);
|
|
2178
2049
|
};
|
|
2179
2050
|
}, [node]);
|
|
@@ -2193,14 +2064,11 @@ const drawGrid$1 = _ref => {
|
|
|
2193
2064
|
const yTicks = yScale.ticks(yTicksCount);
|
|
2194
2065
|
const range = xScale.range();
|
|
2195
2066
|
const domain = xScale.domain();
|
|
2196
|
-
|
|
2197
2067
|
if (drawGridX) {
|
|
2198
2068
|
global.append('g').selectAll('line').data(yTicks).join('line').attr('class', d => d === 0 ? barChartClassNames.barChartGridLineX + " " + barChartClassNames.barChartGridLineXZero : barChartClassNames.barChartGridLineX).attr('x1', () => range[0]).attr('x2', () => range[1]).attr('y1', d => Math.round(yScale(d))).attr('y2', d => Math.round(yScale(d)));
|
|
2199
2069
|
}
|
|
2200
|
-
|
|
2201
2070
|
if (drawGridY) {
|
|
2202
2071
|
const getX = index => domain[index] !== void 0 ? index === 0 ? range[0] : Math.round(xScale.step() * index + range[0] - xScale.step() / 2 * xScale.padding()) : range[1];
|
|
2203
|
-
|
|
2204
2072
|
global.append('g').selectAll('line').data(Array.from({
|
|
2205
2073
|
length: domain.length + 1
|
|
2206
2074
|
}, (_, index) => index)).join('line').attr('class', d => d === 0 ? barChartClassNames.barChartGridLineY + " " + barChartClassNames.barChartGridLineYZero : barChartClassNames.barChartGridLineY).attr('x1', getX).attr('x2', getX).attr('y1', () => Math.round(yScale(yTicks[0]))).attr('y2', () => Math.round(yScale(yTicks[yTicks.length - 1])));
|
|
@@ -2218,7 +2086,6 @@ const getDomain = _ref => {
|
|
|
2218
2086
|
let MAX = Number.NEGATIVE_INFINITY;
|
|
2219
2087
|
data.forEach(_ref2 => {
|
|
2220
2088
|
let groups = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
|
|
2221
|
-
|
|
2222
2089
|
let groupMax = 0;
|
|
2223
2090
|
let groupMin = 0;
|
|
2224
2091
|
Object.keys(groups).forEach(key => {
|
|
@@ -2227,7 +2094,6 @@ const getDomain = _ref => {
|
|
|
2227
2094
|
let stackMin = 0;
|
|
2228
2095
|
Object.keys(group).forEach(groupKey => {
|
|
2229
2096
|
const value = group[groupKey];
|
|
2230
|
-
|
|
2231
2097
|
if (value > 0) {
|
|
2232
2098
|
stackMax += value;
|
|
2233
2099
|
} else {
|
|
@@ -2240,14 +2106,12 @@ const getDomain = _ref => {
|
|
|
2240
2106
|
MIN = Math.min(MIN, groupMax);
|
|
2241
2107
|
MAX = Math.max(MAX, groupMin);
|
|
2242
2108
|
});
|
|
2243
|
-
|
|
2244
2109
|
if (MIN === 0 && MAX === 0) {
|
|
2245
2110
|
return {
|
|
2246
2111
|
min: typeof minDomainValue === 'number' ? minDomainValue : 0,
|
|
2247
2112
|
max: typeof maxDomainValue === 'number' ? maxDomainValue : 1
|
|
2248
2113
|
};
|
|
2249
2114
|
}
|
|
2250
|
-
|
|
2251
2115
|
return {
|
|
2252
2116
|
min: typeof minDomainValue === 'number' ? minDomainValue : MIN,
|
|
2253
2117
|
max: typeof maxDomainValue === 'number' ? maxDomainValue : MAX
|
|
@@ -2267,10 +2131,9 @@ const marshaling = _ref => {
|
|
|
2267
2131
|
} = _ref;
|
|
2268
2132
|
return data.map((_ref2, groupIndex) => {
|
|
2269
2133
|
let {
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2134
|
+
groupName
|
|
2135
|
+
} = _ref2,
|
|
2136
|
+
groups = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
|
|
2274
2137
|
const marshalledGroup = [];
|
|
2275
2138
|
const hundred = 100;
|
|
2276
2139
|
const bandwidth = xScale.bandwidth();
|
|
@@ -2287,11 +2150,9 @@ const marshaling = _ref => {
|
|
|
2287
2150
|
const x = (barWidth + barPadding) * stackIndex + bandwidth / 2 - barGroupWidth / 2;
|
|
2288
2151
|
const isPositiveValue = value > 0;
|
|
2289
2152
|
const height = isPositiveValue ? Math.abs((yScale(stackMax - value) - yScale(stackMax) + Number.EPSILON) * hundred / hundred) : Math.abs((yScale(stackMin - value) - yScale(stackMin) + Number.EPSILON) * hundred / hundred);
|
|
2290
|
-
|
|
2291
2153
|
if (isPositiveValue) {
|
|
2292
2154
|
stackMax += value;
|
|
2293
2155
|
}
|
|
2294
|
-
|
|
2295
2156
|
const y = isPositiveValue ? (yScale(stackMax) + Number.EPSILON) * hundred / hundred : yScale(stackMin) - yScale(0) + yScale(0);
|
|
2296
2157
|
marshalledGroup.push({
|
|
2297
2158
|
x,
|
|
@@ -2304,7 +2165,6 @@ const marshaling = _ref => {
|
|
|
2304
2165
|
stackIndex,
|
|
2305
2166
|
groupIndex
|
|
2306
2167
|
});
|
|
2307
|
-
|
|
2308
2168
|
if (!isPositiveValue) {
|
|
2309
2169
|
stackMin += value;
|
|
2310
2170
|
}
|
|
@@ -2318,10 +2178,8 @@ const getLabelY = (labelPosition, y2, item) => {
|
|
|
2318
2178
|
switch (labelPosition) {
|
|
2319
2179
|
case 'center':
|
|
2320
2180
|
return item.y + item.height / 2 - y2;
|
|
2321
|
-
|
|
2322
2181
|
case 'bottom':
|
|
2323
2182
|
return item.y + item.height - y2;
|
|
2324
|
-
|
|
2325
2183
|
default:
|
|
2326
2184
|
return item.y;
|
|
2327
2185
|
}
|
|
@@ -2331,10 +2189,8 @@ const getLabel = labelPosition => {
|
|
|
2331
2189
|
switch (labelPosition) {
|
|
2332
2190
|
case 'top':
|
|
2333
2191
|
return LabelTop;
|
|
2334
|
-
|
|
2335
2192
|
case 'bottom':
|
|
2336
2193
|
return LabelBottom;
|
|
2337
|
-
|
|
2338
2194
|
default:
|
|
2339
2195
|
return Label$1;
|
|
2340
2196
|
}
|
|
@@ -2378,9 +2234,7 @@ const drawTooltip$2 = _ref => {
|
|
|
2378
2234
|
const [y1, y2] = yScale.range();
|
|
2379
2235
|
const bandwidth = xScale.bandwidth();
|
|
2380
2236
|
const format = d3.format(',');
|
|
2381
|
-
|
|
2382
2237
|
const getX = index => xScaleBandDomain[index] !== void 0 ? index === 0 ? x1 : Math.round(xScale.step() * index + x1 - xScale.step() / 2 * xScale.padding()) : x2;
|
|
2383
|
-
|
|
2384
2238
|
const groups = xScaleBandDomain.map(value => getX(Number(value) + 1));
|
|
2385
2239
|
const topYDomain = tooltipYDomain ? tooltipYDomain({
|
|
2386
2240
|
data: marshalledData,
|
|
@@ -2403,11 +2257,9 @@ const drawTooltip$2 = _ref => {
|
|
|
2403
2257
|
}, []);
|
|
2404
2258
|
const mouseGlobal = svg.append('g').attr('class', 'lineChartMouseGlobal');
|
|
2405
2259
|
const mouseRect = mouseGlobal.append('rect').attr('width', x2 - x1).attr('height', Math.abs(y1 - y2)).attr('class', barChartClassNames.barChartMouseRect).attr('transform', "translate(" + x1 + ", " + y2 + ")");
|
|
2406
|
-
|
|
2407
2260
|
if (dynamicTooltipEnable) {
|
|
2408
2261
|
const tooltipContainer = tooltipRoot || document.querySelector('body');
|
|
2409
2262
|
let tooltip = d3.select("." + barChartClassNames.barChartMouseTooltip);
|
|
2410
|
-
|
|
2411
2263
|
if (tooltip.size() === 0) {
|
|
2412
2264
|
tooltip = d3.select(tooltipContainer).append('div').attr('class', barChartClassNames.barChartMouseTooltip).style('opacity', '0').style('position', 'absolute').html(() => {
|
|
2413
2265
|
const html = ReactDOMServer.renderToString(React__default.createElement(TooltipFlex, {
|
|
@@ -2416,16 +2268,13 @@ const drawTooltip$2 = _ref => {
|
|
|
2416
2268
|
return html;
|
|
2417
2269
|
});
|
|
2418
2270
|
}
|
|
2419
|
-
|
|
2420
2271
|
const barChartTootipFlex = tooltip.select("." + barChartClassNames.barChartTooltipFlex);
|
|
2421
2272
|
let isVisible = false;
|
|
2422
2273
|
let flagCurrIndex = null;
|
|
2423
|
-
|
|
2424
2274
|
const setVisible = visible => {
|
|
2425
2275
|
isVisible = Boolean(visible);
|
|
2426
2276
|
const opacity = isVisible ? '1' : '0';
|
|
2427
2277
|
tooltip.style('opacity', opacity);
|
|
2428
|
-
|
|
2429
2278
|
if (!isVisible) {
|
|
2430
2279
|
tooltip.attr('class', barChartClassNames.barChartMouseTooltip);
|
|
2431
2280
|
flagCurrIndex = null;
|
|
@@ -2437,7 +2286,6 @@ const drawTooltip$2 = _ref => {
|
|
|
2437
2286
|
tooltip.style('transition', null);
|
|
2438
2287
|
}
|
|
2439
2288
|
};
|
|
2440
|
-
|
|
2441
2289
|
mouseRect.on('mouseout.tooltip', () => setVisible());
|
|
2442
2290
|
mouseRect.on('touchmove.tooltip mousemove.tooltip', event => {
|
|
2443
2291
|
const [docX, docY] = d3.pointer(event, document);
|
|
@@ -2447,57 +2295,45 @@ const drawTooltip$2 = _ref => {
|
|
|
2447
2295
|
const offsetX = docX - nodeX;
|
|
2448
2296
|
const offsetY = docY - nodeY;
|
|
2449
2297
|
const currIndex = groups.findIndex(value => x <= value);
|
|
2450
|
-
|
|
2451
2298
|
if (isBarTooltip) {
|
|
2452
2299
|
const containts = document.elementsFromPoint(event.clientX, event.clientY);
|
|
2453
2300
|
const currBars = d3.select(bars.nodes()[currIndex]).selectAll('rect').nodes();
|
|
2454
2301
|
const isContains = containts.some(item => currBars.includes(item));
|
|
2455
|
-
|
|
2456
2302
|
if (!isContains) {
|
|
2457
2303
|
if (isVisible) {
|
|
2458
2304
|
setVisible(false);
|
|
2459
2305
|
}
|
|
2460
|
-
|
|
2461
2306
|
mouseRect.style('cursor', 'default');
|
|
2462
2307
|
return;
|
|
2463
2308
|
} else {
|
|
2464
2309
|
mouseRect.style('cursor', 'pointer');
|
|
2465
2310
|
}
|
|
2466
2311
|
}
|
|
2467
|
-
|
|
2468
2312
|
const top = (typeof tooltipY === 'number' ? tooltipY : topYDomain[currIndex] - y2) + offsetY;
|
|
2469
2313
|
const left = (tooltipBind ? (xScale(currIndex) || 0) + bandwidth / 2 : x) + offsetX;
|
|
2470
|
-
|
|
2471
2314
|
if (tooltipBind && flagCurrIndex === currIndex) {
|
|
2472
2315
|
return;
|
|
2473
2316
|
}
|
|
2474
|
-
|
|
2475
2317
|
let currData = marshalledData[currIndex];
|
|
2476
|
-
|
|
2477
2318
|
if (Array.isArray(currData) && currData.length === 0) {
|
|
2478
2319
|
return;
|
|
2479
2320
|
}
|
|
2480
|
-
|
|
2481
2321
|
if (lineData) {
|
|
2482
2322
|
const currLineData = lineData.map(_ref4 => {
|
|
2483
2323
|
let {
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2324
|
+
values
|
|
2325
|
+
} = _ref4,
|
|
2326
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded$4);
|
|
2488
2327
|
return _extends({}, rest, {
|
|
2489
2328
|
value: values[currIndex],
|
|
2490
2329
|
groupName: data[currIndex] && data[currIndex].groupName
|
|
2491
2330
|
});
|
|
2492
2331
|
});
|
|
2493
|
-
|
|
2494
2332
|
if (Array.isArray(currLineData) && Array.isArray(currData)) {
|
|
2495
2333
|
currData = currData.concat(currLineData);
|
|
2496
2334
|
}
|
|
2497
2335
|
}
|
|
2498
|
-
|
|
2499
2336
|
const svgWidth = svg.node().getBoundingClientRect().width;
|
|
2500
|
-
|
|
2501
2337
|
if (typeof setTooltipPosition === 'function') {
|
|
2502
2338
|
setTooltipPosition({
|
|
2503
2339
|
left,
|
|
@@ -2508,7 +2344,6 @@ const drawTooltip$2 = _ref => {
|
|
|
2508
2344
|
} else if (!setTooltipPosition) {
|
|
2509
2345
|
tooltip.style('left', left + "px").style('top', top + "px");
|
|
2510
2346
|
}
|
|
2511
|
-
|
|
2512
2347
|
if (renderTooltip) {
|
|
2513
2348
|
barChartTootipFlex.html(() => {
|
|
2514
2349
|
const html = ReactDOMServer.renderToString(React__default.createElement(React__default.Fragment, null, renderTooltip(currData, setTooltipPosition ? {
|
|
@@ -2523,7 +2358,6 @@ const drawTooltip$2 = _ref => {
|
|
|
2523
2358
|
if (!isVisible) {
|
|
2524
2359
|
setVisible(true);
|
|
2525
2360
|
}
|
|
2526
|
-
|
|
2527
2361
|
barChartTootipFlex.html(() => {
|
|
2528
2362
|
const html = ReactDOMServer.renderToString(React__default.createElement(TooltipContainer, {
|
|
2529
2363
|
className: barChartClassNames.barChartTooltip
|
|
@@ -2562,18 +2396,14 @@ const drawTooltip$2 = _ref => {
|
|
|
2562
2396
|
return html;
|
|
2563
2397
|
});
|
|
2564
2398
|
}
|
|
2565
|
-
|
|
2566
2399
|
flagCurrIndex = currIndex;
|
|
2567
|
-
|
|
2568
2400
|
if (!isVisible) {
|
|
2569
2401
|
setVisible(true);
|
|
2570
2402
|
}
|
|
2571
2403
|
});
|
|
2572
2404
|
}
|
|
2573
|
-
|
|
2574
2405
|
const container = d3.select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
|
|
2575
2406
|
const labelContainer = container.append('div').attr('class', barChartClassNames.barChartLabelContainer).style('position', 'absolute').style('top', y2 + "px");
|
|
2576
|
-
|
|
2577
2407
|
const isMouseWithin = (e, callback) => {
|
|
2578
2408
|
const [rectrX, rectrY] = d3.pointer(e, mouseRect);
|
|
2579
2409
|
const [nodeX, nodeY] = d3.pointer(e, node);
|
|
@@ -2581,14 +2411,11 @@ const drawTooltip$2 = _ref => {
|
|
|
2581
2411
|
const y = rectrY - nodeY;
|
|
2582
2412
|
const currIndex = groups.findIndex(value => x <= value);
|
|
2583
2413
|
const dataItem = marshalledData[currIndex][0];
|
|
2584
|
-
|
|
2585
2414
|
if (dataItem.height >= y1 - y) {
|
|
2586
2415
|
callback(dataItem);
|
|
2587
2416
|
}
|
|
2588
2417
|
};
|
|
2589
|
-
|
|
2590
2418
|
mouseGlobal.on("click", e => isMouseWithin(e, dataItem => onBarClick && onBarClick(dataItem))).on("mousemove", e => isMouseWithin(e, dataItem => onBarHover && onBarHover(dataItem))).on("mouseleave", () => onBarHover && onBarHover(undefined));
|
|
2591
|
-
|
|
2592
2419
|
if (labelPosition) {
|
|
2593
2420
|
const concatedData = lineData ? marshalledData.map((stack, index) => stack.concat(lineData.map(_ref6 => {
|
|
2594
2421
|
let {
|
|
@@ -2606,14 +2433,12 @@ const drawTooltip$2 = _ref => {
|
|
|
2606
2433
|
indexFlag,
|
|
2607
2434
|
stacksCount
|
|
2608
2435
|
} = acc;
|
|
2609
|
-
|
|
2610
2436
|
if (stackIndex !== indexFlag) {
|
|
2611
2437
|
return {
|
|
2612
2438
|
indexFlag: stackIndex,
|
|
2613
2439
|
stacksCount: stacksCount + 1
|
|
2614
2440
|
};
|
|
2615
2441
|
}
|
|
2616
|
-
|
|
2617
2442
|
return acc;
|
|
2618
2443
|
}, {
|
|
2619
2444
|
indexFlag: -1,
|
|
@@ -2658,14 +2483,11 @@ const resizeBarWidth = _ref => {
|
|
|
2658
2483
|
const chartWidth = range[1] - range[0];
|
|
2659
2484
|
const barsWidth = data.reduce((acc, _ref2) => {
|
|
2660
2485
|
let curr = _objectWithoutPropertiesLoose(_ref2, _excluded$5);
|
|
2661
|
-
|
|
2662
2486
|
return acc + Object.keys(curr).reduce((acc, _key, index) => index > 0 ? acc + (barWidth || 0) + (barPadding || 0) : acc + barWidth, 0) + groupPadding;
|
|
2663
2487
|
}, groupPadding);
|
|
2664
|
-
|
|
2665
2488
|
if (chartWidth < barsWidth) {
|
|
2666
2489
|
return Math.floor(barWidth * (chartWidth / barsWidth));
|
|
2667
2490
|
}
|
|
2668
|
-
|
|
2669
2491
|
return barWidth;
|
|
2670
2492
|
};
|
|
2671
2493
|
|
|
@@ -2729,7 +2551,6 @@ const draw$4 = (node, props) => {
|
|
|
2729
2551
|
onBarClick,
|
|
2730
2552
|
onBarHover
|
|
2731
2553
|
} = props;
|
|
2732
|
-
|
|
2733
2554
|
if (node !== null && data.length) {
|
|
2734
2555
|
const marginTop = margin ? margin.top : 0;
|
|
2735
2556
|
const marginRight = margin ? margin.right : 0;
|
|
@@ -2788,7 +2609,6 @@ const draw$4 = (node, props) => {
|
|
|
2788
2609
|
customXScale && customXScale(xScale);
|
|
2789
2610
|
const [x1, x2] = xScale.range();
|
|
2790
2611
|
const xAxisBottom = d3.axisBottom(xScale).tickFormat(value => labels[Number(value)]);
|
|
2791
|
-
|
|
2792
2612
|
if (typeof xScaleItemWidth === 'number') {
|
|
2793
2613
|
xAxisBottom.tickValues(xScale.domain().filter((_, i, array) => {
|
|
2794
2614
|
const chartWidth = x2 - x1;
|
|
@@ -2798,7 +2618,6 @@ const draw$4 = (node, props) => {
|
|
|
2798
2618
|
return !(i % divider);
|
|
2799
2619
|
})).tickSizeOuter(0);
|
|
2800
2620
|
}
|
|
2801
|
-
|
|
2802
2621
|
customXAxisBottom && customXAxisBottom(xAxisBottom, {
|
|
2803
2622
|
node,
|
|
2804
2623
|
labels
|
|
@@ -2842,24 +2661,19 @@ const draw$4 = (node, props) => {
|
|
|
2842
2661
|
if (!marker) {
|
|
2843
2662
|
return;
|
|
2844
2663
|
}
|
|
2845
|
-
|
|
2846
2664
|
if (marker.horizontal) {
|
|
2847
2665
|
if (marker.line) {
|
|
2848
2666
|
svg.append('line').style("stroke", marker.lineColor || marker.color || "inherit").style("stroke-width", 1).style("stroke-dasharray", "5, 3").attr("x1", marginLeft + yAxisWidth).attr("y1", yScale(marker.value) + 1).attr("x2", width).attr("y2", yScale(marker.value) + 1);
|
|
2849
2667
|
}
|
|
2850
|
-
|
|
2851
2668
|
svg.append("text").attr("y", yScale(marker.value) + 1).attr("x", marginLeft + yAxisWidth).attr('text-anchor', 'middle').attr("class", ["marker", marker.className].filter(Boolean).join(" ")).style("fill", (marker == null ? void 0 : marker.color) || "inherit").text(marker.label);
|
|
2852
2669
|
return;
|
|
2853
2670
|
}
|
|
2854
|
-
|
|
2855
2671
|
if (marker.line) {
|
|
2856
2672
|
svg.append('line').style("stroke", marker.lineColor || marker.color || "inherit").style("stroke-width", 1).style("stroke-dasharray", "5, 3").attr("x1", width / data.length * marker.value + 1).attr("y1", 0).attr("x2", width / data.length * marker.value + 1).attr("y2", height - marginTop - marginBottom + 8);
|
|
2857
2673
|
}
|
|
2858
|
-
|
|
2859
2674
|
svg.append("text").attr("y", height - 2).attr("x", width / data.length * marker.value + 1).attr('text-anchor', marker.align === 'right' ? 'end' : marker.align === 'left' ? 'start' : 'middle').attr("class", ["marker", marker.className].filter(Boolean).join(" ")).style("fill", (marker == null ? void 0 : marker.color) || "inherit").text(marker.label);
|
|
2860
2675
|
});
|
|
2861
2676
|
let lines = null;
|
|
2862
|
-
|
|
2863
2677
|
if (Array.isArray(lineData) && lineData.length > 0) {
|
|
2864
2678
|
lines = drawLines({
|
|
2865
2679
|
svg,
|
|
@@ -2871,7 +2685,6 @@ const draw$4 = (node, props) => {
|
|
|
2871
2685
|
curve
|
|
2872
2686
|
});
|
|
2873
2687
|
}
|
|
2874
|
-
|
|
2875
2688
|
customBars && customBars({
|
|
2876
2689
|
bars,
|
|
2877
2690
|
yScale,
|
|
@@ -2879,7 +2692,6 @@ const draw$4 = (node, props) => {
|
|
|
2879
2692
|
marshalledData,
|
|
2880
2693
|
lineData
|
|
2881
2694
|
});
|
|
2882
|
-
|
|
2883
2695
|
if (dynamicTooltipEnable || labelPosition) {
|
|
2884
2696
|
drawTooltip$2({
|
|
2885
2697
|
svg,
|
|
@@ -2912,7 +2724,6 @@ const draw$4 = (node, props) => {
|
|
|
2912
2724
|
onBarHover
|
|
2913
2725
|
});
|
|
2914
2726
|
}
|
|
2915
|
-
|
|
2916
2727
|
customize && customize({
|
|
2917
2728
|
svg,
|
|
2918
2729
|
marshalledData,
|
|
@@ -2934,9 +2745,7 @@ const BarChart = props => {
|
|
|
2934
2745
|
React.useEffect(() => {
|
|
2935
2746
|
node && draw$4(node, props);
|
|
2936
2747
|
}, [node, props]);
|
|
2937
|
-
|
|
2938
2748
|
const onDraw = () => draw$4(node, props);
|
|
2939
|
-
|
|
2940
2749
|
useResize(props.width, onDraw);
|
|
2941
2750
|
useSelection(selectable ? node : null, props);
|
|
2942
2751
|
return React__default.createElement("div", {
|
|
@@ -2993,13 +2802,11 @@ const useMarshaling = _ref => {
|
|
|
2993
2802
|
return value;
|
|
2994
2803
|
})]);
|
|
2995
2804
|
}
|
|
2996
|
-
|
|
2997
2805
|
return item.map(_ref4 => {
|
|
2998
2806
|
let {
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
2807
|
+
value
|
|
2808
|
+
} = _ref4,
|
|
2809
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded$6);
|
|
3003
2810
|
return _extends({}, rest, {
|
|
3004
2811
|
value,
|
|
3005
2812
|
width: scaleLinear(value),
|
|
@@ -3013,26 +2820,26 @@ const useMarshaling = _ref => {
|
|
|
3013
2820
|
|
|
3014
2821
|
var _templateObject$b, _templateObject2$5, _templateObject3$2, _templateObject4$2, _templateObject5$2, _templateObject6$2, _templateObject7$1, _templateObject8$1;
|
|
3015
2822
|
const horizontalBarChartClassNames = {
|
|
3016
|
-
horizontalBarChartButtonTd:
|
|
3017
|
-
horizontalBarChartLabelTd:
|
|
3018
|
-
horizontalBarChartLabelCell:
|
|
3019
|
-
horizontalBarChartBarTd:
|
|
3020
|
-
horizontalBarChartBarFlex:
|
|
3021
|
-
horizontalBarChartBar:
|
|
3022
|
-
horizontalBarChartBarFirst:
|
|
3023
|
-
horizontalBarChartBarLast:
|
|
3024
|
-
horizontalBarChartBarOnly:
|
|
3025
|
-
horizontalBarChartTooltipFlex:
|
|
3026
|
-
horizontalBarChartStackWrapper:
|
|
3027
|
-
horizontalBarChartTooltipContainer:
|
|
3028
|
-
horizontalBarChartStackSumContainer:
|
|
3029
|
-
horizontalBarChartStackSum:
|
|
3030
|
-
horizontalBarChartXScaleTd:
|
|
3031
|
-
horizontalBarChartXScaleTicks:
|
|
3032
|
-
horizontalBarChartXScaleTick:
|
|
3033
|
-
horizontalBarChartTooltipItem:
|
|
3034
|
-
horizontalBarChartTooltipName:
|
|
3035
|
-
horizontalBarChartTooltipValue:
|
|
2823
|
+
horizontalBarChartButtonTd: "horizontalBarChartButtonTd",
|
|
2824
|
+
horizontalBarChartLabelTd: "horizontalBarChartLabelTd",
|
|
2825
|
+
horizontalBarChartLabelCell: "horizontalBarChartLabelCell",
|
|
2826
|
+
horizontalBarChartBarTd: "horizontalBarChartBarTd",
|
|
2827
|
+
horizontalBarChartBarFlex: "horizontalBarChartBarFlex",
|
|
2828
|
+
horizontalBarChartBar: "horizontalBarChartBar",
|
|
2829
|
+
horizontalBarChartBarFirst: "horizontalBarChartBarFirst",
|
|
2830
|
+
horizontalBarChartBarLast: "horizontalBarChartBarLast",
|
|
2831
|
+
horizontalBarChartBarOnly: "horizontalBarChartBarOnly",
|
|
2832
|
+
horizontalBarChartTooltipFlex: "horizontalBarChartTooltipFlex",
|
|
2833
|
+
horizontalBarChartStackWrapper: "horizontalBarChartStackWrapper",
|
|
2834
|
+
horizontalBarChartTooltipContainer: "horizontalBarChartTooltipContainer",
|
|
2835
|
+
horizontalBarChartStackSumContainer: "horizontalBarChartStackSumContainer",
|
|
2836
|
+
horizontalBarChartStackSum: "horizontalBarChartStackSum",
|
|
2837
|
+
horizontalBarChartXScaleTd: "horizontalBarChartXScaleTd",
|
|
2838
|
+
horizontalBarChartXScaleTicks: "horizontalBarChartXScaleTicks",
|
|
2839
|
+
horizontalBarChartXScaleTick: "horizontalBarChartXScaleTick",
|
|
2840
|
+
horizontalBarChartTooltipItem: "horizontalBarChartTooltipItem",
|
|
2841
|
+
horizontalBarChartTooltipName: "horizontalBarChartTooltipName",
|
|
2842
|
+
horizontalBarChartTooltipValue: "horizontalBarChartTooltipValue"
|
|
3036
2843
|
};
|
|
3037
2844
|
const Table = /*#__PURE__*/styled__default.table(_templateObject$b || (_templateObject$b = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
|
|
3038
2845
|
const LabelCell = /*#__PURE__*/styled__default.div(_templateObject2$5 || (_templateObject2$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n text-align: right;\n"])));
|
|
@@ -3097,7 +2904,6 @@ const useTooltip = _ref => {
|
|
|
3097
2904
|
}, [tooltipRoot]);
|
|
3098
2905
|
const onMouseMove = React.useCallback((event, bars) => {
|
|
3099
2906
|
let [x, y] = d3.pointer(event, document);
|
|
3100
|
-
|
|
3101
2907
|
if (!tooltipBind && 'getBoundingClientRect' in event.target) {
|
|
3102
2908
|
const {
|
|
3103
2909
|
width,
|
|
@@ -3107,11 +2913,9 @@ const useTooltip = _ref => {
|
|
|
3107
2913
|
x = x - barX + width / 2;
|
|
3108
2914
|
y = y - barY + height / 2;
|
|
3109
2915
|
}
|
|
3110
|
-
|
|
3111
2916
|
if (rootElement) {
|
|
3112
2917
|
rootElement.style.visibility = 'visible';
|
|
3113
2918
|
}
|
|
3114
|
-
|
|
3115
2919
|
reactDom.render(React__default.createElement(Tooltip, {
|
|
3116
2920
|
style: _extends({
|
|
3117
2921
|
left: x,
|
|
@@ -3135,13 +2939,12 @@ const _excluded$7 = ["item", "mouseMove", "mouseLeave", "tooltipBind"];
|
|
|
3135
2939
|
const useStackWrapper = stackedTooltip => {
|
|
3136
2940
|
return React.useMemo(() => stackedTooltip ? _ref => {
|
|
3137
2941
|
let {
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
2942
|
+
item,
|
|
2943
|
+
mouseMove,
|
|
2944
|
+
mouseLeave,
|
|
2945
|
+
tooltipBind
|
|
2946
|
+
} = _ref,
|
|
2947
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
3145
2948
|
return React__default.createElement(StackWrapper, Object.assign({
|
|
3146
2949
|
className: horizontalBarChartClassNames.horizontalBarChartStackWrapper,
|
|
3147
2950
|
onMouseOver: event => mouseMove(event, item),
|
|
@@ -3313,7 +3116,7 @@ const HorizontalBarChart = _ref => {
|
|
|
3313
3116
|
});
|
|
3314
3117
|
return React__default.createElement("tr", {
|
|
3315
3118
|
key: "row-" + rowIndex
|
|
3316
|
-
}, typeof renderButton ===
|
|
3119
|
+
}, typeof renderButton === "function" && React__default.createElement("td", {
|
|
3317
3120
|
className: horizontalBarChartClassNames.horizontalBarChartButtonTd
|
|
3318
3121
|
}, renderButton(item, rowIndex)), React__default.createElement("td", {
|
|
3319
3122
|
className: horizontalBarChartClassNames.horizontalBarChartLabelTd
|
|
@@ -3322,12 +3125,12 @@ const HorizontalBarChart = _ref => {
|
|
|
3322
3125
|
}, labels[rowIndex])), React__default.createElement(BarsTd, {
|
|
3323
3126
|
className: horizontalBarChartClassNames.horizontalBarChartBarTd,
|
|
3324
3127
|
style: {
|
|
3325
|
-
pointerEvents: fullChartTooltip ?
|
|
3128
|
+
pointerEvents: fullChartTooltip ? "none" : "auto"
|
|
3326
3129
|
}
|
|
3327
3130
|
}, React__default.createElement(BarFlex, {
|
|
3328
3131
|
className: horizontalBarChartClassNames.horizontalBarChartBarFlex,
|
|
3329
3132
|
style: {
|
|
3330
|
-
pointerEvents: fullChartTooltip ?
|
|
3133
|
+
pointerEvents: fullChartTooltip ? "none" : "auto"
|
|
3331
3134
|
}
|
|
3332
3135
|
}, React__default.createElement(Stack, {
|
|
3333
3136
|
style: stackedTooltip ? {
|
|
@@ -3338,7 +3141,7 @@ const HorizontalBarChart = _ref => {
|
|
|
3338
3141
|
mouseMove: mouseMove,
|
|
3339
3142
|
mouseLeave: mouseLeave
|
|
3340
3143
|
}), item.map((bar, barIndex, array) => bar.value !== 0 && React__default.createElement(Bar, {
|
|
3341
|
-
key: "bar-" + (bar.name ||
|
|
3144
|
+
key: "bar-" + (bar.name || "") + "-" + barIndex,
|
|
3342
3145
|
formatNativeTitle: formatNativeTitle,
|
|
3343
3146
|
bar: bar,
|
|
3344
3147
|
tooltipBind: tooltipBind,
|
|
@@ -3355,7 +3158,7 @@ const HorizontalBarChart = _ref => {
|
|
|
3355
3158
|
className: horizontalBarChartClassNames.horizontalBarChartStackSum
|
|
3356
3159
|
}, stackSum)))), renderDataTable && renderDataTable(item, stackSum, rowIndex));
|
|
3357
3160
|
}), !withoutXScale && React__default.createElement(XScale, {
|
|
3358
|
-
maxValue: typeof maxValue ===
|
|
3161
|
+
maxValue: typeof maxValue === "number" ? maxValue : fullMax,
|
|
3359
3162
|
scaleTicks: scaleTicks,
|
|
3360
3163
|
renderTicks: renderTicks,
|
|
3361
3164
|
scaleDomain: scaleDomain
|
|
@@ -3387,20 +3190,20 @@ const bubbleChartDefaultProps = {
|
|
|
3387
3190
|
|
|
3388
3191
|
var _templateObject$e, _templateObject2$7;
|
|
3389
3192
|
const bubbleChartClassNames = {
|
|
3390
|
-
bubbleChartYAxis:
|
|
3391
|
-
bubbleChartYAxisZeroTick:
|
|
3392
|
-
bubbleChartXAxis:
|
|
3393
|
-
bubbleChartGridGlobal:
|
|
3394
|
-
bubbleChartGridLineX:
|
|
3395
|
-
bubbleChartGridLineY:
|
|
3396
|
-
bubbleChartCircle:
|
|
3397
|
-
bubbleChartYScaleLabel:
|
|
3398
|
-
bubbleChartTooltip:
|
|
3399
|
-
bubbleChartTooltipContainer:
|
|
3400
|
-
bubbleChartTooltipFlex:
|
|
3401
|
-
bubbleChartTip:
|
|
3402
|
-
};
|
|
3403
|
-
const SvgWrapper$5 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$e || (_templateObject$e = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", ",\n
|
|
3193
|
+
bubbleChartYAxis: "bubbleChartYAxis",
|
|
3194
|
+
bubbleChartYAxisZeroTick: "bubbleChartYAxisZeroTick",
|
|
3195
|
+
bubbleChartXAxis: "bubbleChartXAxis",
|
|
3196
|
+
bubbleChartGridGlobal: "bubbleChartGridGlobal",
|
|
3197
|
+
bubbleChartGridLineX: "bubbleChartGridLineX",
|
|
3198
|
+
bubbleChartGridLineY: "bubbleChartGridLineY",
|
|
3199
|
+
bubbleChartCircle: "bubbleChartCircle",
|
|
3200
|
+
bubbleChartYScaleLabel: "bubbleChartYScaleLabel",
|
|
3201
|
+
bubbleChartTooltip: "bubbleChartTooltip",
|
|
3202
|
+
bubbleChartTooltipContainer: "bubbleChartTooltipContainer",
|
|
3203
|
+
bubbleChartTooltipFlex: "bubbleChartTooltipFlex",
|
|
3204
|
+
bubbleChartTip: "bubbleChartTip"
|
|
3205
|
+
};
|
|
3206
|
+
const SvgWrapper$5 = /*#__PURE__*/styled__default(Wrapper)(_templateObject$e || (_templateObject$e = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", ",\n .", ",\n .", " {\n shape-rendering: crispEdges;\n }\n\n .", ",\n .", " {\n stroke: rgba(149, 149, 149, 0.24);\n }\n\n .", " {\n font-size: 10px;\n }\n"])), bubbleChartClassNames.bubbleChartYAxis, bubbleChartClassNames.bubbleChartXAxis, bubbleChartClassNames.bubbleChartGridGlobal, bubbleChartClassNames.bubbleChartGridLineX, bubbleChartClassNames.bubbleChartGridLineY, bubbleChartClassNames.bubbleChartYScaleLabel);
|
|
3404
3207
|
const TooltipStyles$2 = /*#__PURE__*/styled.createGlobalStyle(_templateObject2$7 || (_templateObject2$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", " {\n position: absolute;\n transition: opacity 150ms cubic-bezier(0.2, 1, 0.6, 1);\n pointer-events: none;\n z-index: 1;\n }\n"])), bubbleChartClassNames.bubbleChartTooltipContainer);
|
|
3405
3208
|
|
|
3406
3209
|
const drawGrid$2 = _ref => {
|
|
@@ -3416,11 +3219,9 @@ const drawGrid$2 = _ref => {
|
|
|
3416
3219
|
const [min, max] = xScale.domain();
|
|
3417
3220
|
const global = svg.append('g').attr('class', bubbleChartClassNames.bubbleChartGridGlobal);
|
|
3418
3221
|
const yTicks = yScale.ticks(yTicksCount);
|
|
3419
|
-
|
|
3420
3222
|
if (drawGridX) {
|
|
3421
3223
|
global.append('g').selectAll('line').data(yTicks).join('line').attr('class', bubbleChartClassNames.bubbleChartGridLineX).attr('x1', () => xScale(min)).attr('x2', () => xScale(max)).attr('y1', d => Math.round(yScale(d))).attr('y2', d => Math.round(yScale(d)));
|
|
3422
3224
|
}
|
|
3423
|
-
|
|
3424
3225
|
if (drawGridY) {
|
|
3425
3226
|
global.append('g').selectAll('line').data(xScale.ticks(yTicksCount)).join('line').attr('class', bubbleChartClassNames.bubbleChartGridLineY).attr('x1', d => Math.round(xScale(d))).attr('x2', d => Math.round(xScale(d))).attr('y1', () => Math.round(yScale(yTicks[0]))).attr('y2', () => Math.round(yScale(yTicks[yTicks.length - 1])));
|
|
3426
3227
|
}
|
|
@@ -3439,11 +3240,9 @@ const drawTooltip$3 = _ref => {
|
|
|
3439
3240
|
const root = tooltipRoot || document.querySelector('body');
|
|
3440
3241
|
const format = d3.format(',');
|
|
3441
3242
|
let container = d3.select(root).select("." + bubbleChartClassNames.bubbleChartTooltip);
|
|
3442
|
-
|
|
3443
3243
|
if (container.node() === null) {
|
|
3444
3244
|
container = d3.select(root).append('div').attr('class', bubbleChartClassNames.bubbleChartTooltip);
|
|
3445
3245
|
}
|
|
3446
|
-
|
|
3447
3246
|
let tooltip = container.append('div').attr('class', bubbleChartClassNames.bubbleChartTooltipContainer + " " + (tooltipClassName || '')).style('opacity', '0');
|
|
3448
3247
|
bubbles.on('mouseover.tooltip', (event, data) => {
|
|
3449
3248
|
const {
|
|
@@ -3504,7 +3303,6 @@ const draw$5 = (node, props) => {
|
|
|
3504
3303
|
tooltipClassName,
|
|
3505
3304
|
renderTooltip
|
|
3506
3305
|
} = props;
|
|
3507
|
-
|
|
3508
3306
|
if (node !== null && data.length) {
|
|
3509
3307
|
const marginTop = margin ? margin.top : 0;
|
|
3510
3308
|
const marginRight = margin ? margin.right : 0;
|
|
@@ -3558,7 +3356,6 @@ const draw$5 = (node, props) => {
|
|
|
3558
3356
|
const yTicksCount = yAxisLeft.tickArguments()[0];
|
|
3559
3357
|
const yAxis = svg.append('g').attr('class', bubbleChartClassNames.bubbleChartYAxis).call(yAxisLeft);
|
|
3560
3358
|
let yScaleLabelHeight = yScaleLabelPadding || 0;
|
|
3561
|
-
|
|
3562
3359
|
if (yScaleLabel) {
|
|
3563
3360
|
const label = svg.append('text').text(yScaleLabel).attr('class', bubbleChartClassNames.bubbleChartYScaleLabel);
|
|
3564
3361
|
const {
|
|
@@ -3568,7 +3365,6 @@ const draw$5 = (node, props) => {
|
|
|
3568
3365
|
yScaleLabelHeight = yScaleLabelHeight + height;
|
|
3569
3366
|
label.attr('transform', "rotate(-90) translate(-" + (yRange1 + marginBottom + width) / 2 + ", " + height + ")");
|
|
3570
3367
|
}
|
|
3571
|
-
|
|
3572
3368
|
yAxis.selectAll('.tick').attr('class', value => {
|
|
3573
3369
|
return value === 0 ? "tick " + bubbleChartClassNames.bubbleChartYAxisZeroTick : 'tick';
|
|
3574
3370
|
});
|
|
@@ -3591,21 +3387,19 @@ const draw$5 = (node, props) => {
|
|
|
3591
3387
|
xValue
|
|
3592
3388
|
} = _ref9;
|
|
3593
3389
|
return xValue;
|
|
3594
|
-
}), d3.max(data,
|
|
3390
|
+
}), d3.max(data, _ref0 => {
|
|
3595
3391
|
let {
|
|
3596
3392
|
xValue
|
|
3597
|
-
} =
|
|
3393
|
+
} = _ref0;
|
|
3598
3394
|
return xValue;
|
|
3599
3395
|
})]).range([marginLeft + yAxisWidth + (yAxisPadding || 0) + yScaleLabelHeight, width - marginRight]);
|
|
3600
3396
|
customXScale && customXScale(xScale);
|
|
3601
3397
|
const xAxisBottom = d3.axisBottom(xScale);
|
|
3602
|
-
|
|
3603
3398
|
if (typeof xScaleItemWidth === 'number') {
|
|
3604
3399
|
const [x1, x2] = xScale.range();
|
|
3605
3400
|
const chartWidth = x2 - x1;
|
|
3606
3401
|
xAxisBottom.ticks(Math.round(chartWidth / xScaleItemWidth)).tickSizeOuter(0);
|
|
3607
3402
|
}
|
|
3608
|
-
|
|
3609
3403
|
const xAxis = svg.append('g').call(xAxisBottom).attr('class', bubbleChartClassNames.bubbleChartXAxis);
|
|
3610
3404
|
customXAxis && customXAxis(xAxis);
|
|
3611
3405
|
yAxis.attr('transform', "translate(" + (marginLeft + yAxisWidth + yScaleLabelHeight) + ", 0)");
|
|
@@ -3618,38 +3412,37 @@ const draw$5 = (node, props) => {
|
|
|
3618
3412
|
drawGridX
|
|
3619
3413
|
});
|
|
3620
3414
|
xAxis.attr('transform', "translate(0, " + (yScale(yTicks[0]) + (xAxisPadding || 0)) + ")");
|
|
3621
|
-
const bubbles = svg.append('g').selectAll('dot').data(data).enter().append('circle').attr('class', bubbleChartClassNames.bubbleChartCircle).attr('cx',
|
|
3415
|
+
const bubbles = svg.append('g').selectAll('dot').data(data).enter().append('circle').attr('class', bubbleChartClassNames.bubbleChartCircle).attr('cx', _ref1 => {
|
|
3622
3416
|
let {
|
|
3623
3417
|
xValue
|
|
3624
|
-
} =
|
|
3418
|
+
} = _ref1;
|
|
3625
3419
|
return xScale(xValue);
|
|
3626
|
-
}).attr('cy',
|
|
3420
|
+
}).attr('cy', _ref10 => {
|
|
3627
3421
|
let {
|
|
3628
3422
|
yValue
|
|
3629
|
-
} =
|
|
3423
|
+
} = _ref10;
|
|
3630
3424
|
return yScale(yValue);
|
|
3631
|
-
}).attr('r',
|
|
3425
|
+
}).attr('r', _ref11 => {
|
|
3632
3426
|
let {
|
|
3633
3427
|
sizeValue
|
|
3634
|
-
} =
|
|
3428
|
+
} = _ref11;
|
|
3635
3429
|
return sizeScale(sizeValue) / 2;
|
|
3636
|
-
}).attr('fill',
|
|
3430
|
+
}).attr('fill', _ref12 => {
|
|
3637
3431
|
let {
|
|
3638
3432
|
color
|
|
3639
|
-
} =
|
|
3433
|
+
} = _ref12;
|
|
3640
3434
|
return color || 'rgba(0, 176, 113, 0.6)';
|
|
3641
|
-
}).attr('stroke',
|
|
3435
|
+
}).attr('stroke', _ref13 => {
|
|
3642
3436
|
let {
|
|
3643
3437
|
stroke
|
|
3644
|
-
} =
|
|
3438
|
+
} = _ref13;
|
|
3645
3439
|
return stroke || 'transparent';
|
|
3646
|
-
}).attr('style',
|
|
3440
|
+
}).attr('style', _ref14 => {
|
|
3647
3441
|
let {
|
|
3648
3442
|
style
|
|
3649
|
-
} =
|
|
3443
|
+
} = _ref14;
|
|
3650
3444
|
return style || bubbleStyle || '';
|
|
3651
3445
|
});
|
|
3652
|
-
|
|
3653
3446
|
if (enableTooltip) {
|
|
3654
3447
|
drawTooltip$3({
|
|
3655
3448
|
bubbles,
|
|
@@ -3658,7 +3451,6 @@ const draw$5 = (node, props) => {
|
|
|
3658
3451
|
renderTooltip
|
|
3659
3452
|
});
|
|
3660
3453
|
}
|
|
3661
|
-
|
|
3662
3454
|
customize && customize({
|
|
3663
3455
|
svg,
|
|
3664
3456
|
bubbles,
|
|
@@ -3688,9 +3480,7 @@ const BubbleChart = props => {
|
|
|
3688
3480
|
React.useEffect(() => {
|
|
3689
3481
|
return () => unmount(tooltipRoot);
|
|
3690
3482
|
}, [tooltipRoot]);
|
|
3691
|
-
|
|
3692
3483
|
const onDraw = () => draw$5(node, props);
|
|
3693
|
-
|
|
3694
3484
|
useResize(props.width, onDraw);
|
|
3695
3485
|
return React__default.createElement("div", {
|
|
3696
3486
|
className: className,
|