@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
package/dist/charts.esm.js
CHANGED
|
@@ -6,45 +6,25 @@ import { uniqueId } from 'lodash-es';
|
|
|
6
6
|
import { unmountComponentAtNode, render } from 'react-dom';
|
|
7
7
|
|
|
8
8
|
function _extends() {
|
|
9
|
-
_extends = Object.assign
|
|
10
|
-
for (var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
for (var key in source) {
|
|
14
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
15
|
-
target[key] = source[key];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
9
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
10
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
11
|
+
var t = arguments[e];
|
|
12
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
18
13
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return _extends.apply(this, arguments);
|
|
14
|
+
return n;
|
|
15
|
+
}, _extends.apply(null, arguments);
|
|
24
16
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
33
|
-
key = sourceKeys[i];
|
|
34
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
35
|
-
target[key] = source[key];
|
|
17
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
18
|
+
if (null == r) return {};
|
|
19
|
+
var t = {};
|
|
20
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
21
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
22
|
+
t[n] = r[n];
|
|
36
23
|
}
|
|
37
|
-
|
|
38
|
-
return target;
|
|
24
|
+
return t;
|
|
39
25
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!raw) {
|
|
43
|
-
raw = strings.slice(0);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
strings.raw = raw;
|
|
47
|
-
return strings;
|
|
26
|
+
function _taggedTemplateLiteralLoose(e, t) {
|
|
27
|
+
return t || (t = e.slice(0)), e.raw = t, e;
|
|
48
28
|
}
|
|
49
29
|
|
|
50
30
|
var _templateObject;
|
|
@@ -75,8 +55,8 @@ const useResize = (width, callback, delay) => {
|
|
|
75
55
|
return callback ? throttle(callback, delay || THROTTLE_DELAY) : undefined;
|
|
76
56
|
}, [callback, delay]);
|
|
77
57
|
useEffect(() => {
|
|
78
|
-
throttledCallback && typeof width !==
|
|
79
|
-
return () => throttledCallback && window.removeEventListener(
|
|
58
|
+
throttledCallback && typeof width !== "number" && window.addEventListener("resize", throttledCallback);
|
|
59
|
+
return () => throttledCallback && window.removeEventListener("resize", throttledCallback);
|
|
80
60
|
}, [width, throttledCallback]);
|
|
81
61
|
};
|
|
82
62
|
|
|
@@ -99,11 +79,9 @@ function animate(_ref) {
|
|
|
99
79
|
let requestId;
|
|
100
80
|
requestAnimationFrame(function requestAnimate(time) {
|
|
101
81
|
let timeFraction = (time - start) / duration;
|
|
102
|
-
|
|
103
82
|
if (timeFraction < 1) {
|
|
104
83
|
requestId = requestAnimationFrame(requestAnimate);
|
|
105
84
|
}
|
|
106
|
-
|
|
107
85
|
if (timeFraction > 1) cancelAnimationFrame(requestId);
|
|
108
86
|
const progress = timing(timeFraction);
|
|
109
87
|
draw(progress, requestId);
|
|
@@ -112,7 +90,6 @@ function animate(_ref) {
|
|
|
112
90
|
const easeOutQuad = time => time * (2 - time);
|
|
113
91
|
|
|
114
92
|
const range = (num, min, max) => Math.min(Math.max(num, min), max);
|
|
115
|
-
|
|
116
93
|
const defaultRefs = {
|
|
117
94
|
animation: 0,
|
|
118
95
|
speed: 0,
|
|
@@ -148,7 +125,6 @@ const useSwipe = (node, _ref) => {
|
|
|
148
125
|
const maxX = width - nodeWidth;
|
|
149
126
|
const translateX = range(newX, -maxX, 0);
|
|
150
127
|
container.style('transform', "translateX(" + translateX + "px)");
|
|
151
|
-
|
|
152
128
|
if (refs.current.currentX) {
|
|
153
129
|
const hundred = 100;
|
|
154
130
|
const now = Date.now();
|
|
@@ -158,7 +134,6 @@ const useSwipe = (node, _ref) => {
|
|
|
158
134
|
refs.current.speed = speedX;
|
|
159
135
|
refs.current.timestamp = now;
|
|
160
136
|
}
|
|
161
|
-
|
|
162
137
|
refs.current.currentX = translateX;
|
|
163
138
|
onSwipe && onSwipe(translateX, container);
|
|
164
139
|
}, [onSwipe, width, node, container]);
|
|
@@ -170,16 +145,13 @@ const useSwipe = (node, _ref) => {
|
|
|
170
145
|
};
|
|
171
146
|
documentSelect.on('mousemove.swipe touchmove.swipe mouseup.swipe touchend.swipe', null);
|
|
172
147
|
body.style('cursor', null);
|
|
173
|
-
|
|
174
148
|
if (width > nodeWidth) {
|
|
175
149
|
container.style('cursor', 'grab');
|
|
176
150
|
} else {
|
|
177
151
|
container.style('cursor', null);
|
|
178
152
|
}
|
|
179
|
-
|
|
180
153
|
const dt = Date.now() - refs.current.timestamp;
|
|
181
154
|
const dtEnd = 44;
|
|
182
|
-
|
|
183
155
|
if (dt < dtEnd) {
|
|
184
156
|
animate({
|
|
185
157
|
duration: duration,
|
|
@@ -191,7 +163,6 @@ const useSwipe = (node, _ref) => {
|
|
|
191
163
|
const maxX = width - nodeWidth;
|
|
192
164
|
const translateX = range(currX, -maxX, 0);
|
|
193
165
|
const transX = Math.max(Math.min(currX, maxX), 0);
|
|
194
|
-
|
|
195
166
|
if (refs.current.currentX !== transX) {
|
|
196
167
|
container.style('transform', "translateX(" + translateX + "px)");
|
|
197
168
|
onSwipe && onSwipe(translateX, container);
|
|
@@ -210,12 +181,10 @@ const useSwipe = (node, _ref) => {
|
|
|
210
181
|
};
|
|
211
182
|
body.style('cursor', 'grabbing');
|
|
212
183
|
container.style('cursor', 'grabbing');
|
|
213
|
-
|
|
214
184
|
if (refs.current.animation) {
|
|
215
185
|
cancelAnimationFrame(refs.current.animation);
|
|
216
186
|
refs.current = defaultRefs;
|
|
217
187
|
}
|
|
218
|
-
|
|
219
188
|
refs.current.startX = Math.max(x + left, 0);
|
|
220
189
|
documentSelect.on('mousemove.swipe touchmove.swipe', onMove);
|
|
221
190
|
documentSelect.on('mouseup.swipe touchend.swipe', onEnd);
|
|
@@ -225,7 +194,6 @@ const useSwipe = (node, _ref) => {
|
|
|
225
194
|
const {
|
|
226
195
|
width: nodeWidth
|
|
227
196
|
} = node.getBoundingClientRect();
|
|
228
|
-
|
|
229
197
|
if (width > nodeWidth) {
|
|
230
198
|
container.style('cursor', 'grab');
|
|
231
199
|
container.on('mousedown.swipe touchstart.swipe', onStart);
|
|
@@ -237,12 +205,11 @@ const useSwipe = (node, _ref) => {
|
|
|
237
205
|
const _excluded = ["children", "width", "onSwipe"];
|
|
238
206
|
const SwipeScroll = _ref => {
|
|
239
207
|
let {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
208
|
+
children,
|
|
209
|
+
width,
|
|
210
|
+
onSwipe
|
|
211
|
+
} = _ref,
|
|
212
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
246
213
|
const [ref, draggingNode] = useNode();
|
|
247
214
|
useSwipe(draggingNode, _extends({
|
|
248
215
|
width,
|
|
@@ -261,24 +228,19 @@ const degByIndex = (index, count) => {
|
|
|
261
228
|
const deg = degs / count * index;
|
|
262
229
|
return deg;
|
|
263
230
|
};
|
|
264
|
-
|
|
265
231
|
const getTextAnchor = (index, length) => {
|
|
266
232
|
const deg = degByIndex(index, length);
|
|
267
233
|
const halfAngle = 180;
|
|
268
|
-
|
|
269
234
|
if ([0, halfAngle].includes(deg)) {
|
|
270
235
|
return 'middle';
|
|
271
236
|
}
|
|
272
|
-
|
|
273
237
|
if (deg < halfAngle) {
|
|
274
238
|
return 'start';
|
|
275
239
|
}
|
|
276
|
-
|
|
277
240
|
return 'end';
|
|
278
241
|
};
|
|
279
242
|
|
|
280
243
|
var _templateObject$2;
|
|
281
|
-
|
|
282
244
|
const getTranslate = _ref => {
|
|
283
245
|
let {
|
|
284
246
|
anchor,
|
|
@@ -286,7 +248,6 @@ const getTranslate = _ref => {
|
|
|
286
248
|
translateX,
|
|
287
249
|
translateY
|
|
288
250
|
} = _ref;
|
|
289
|
-
|
|
290
251
|
if (index === 0 && anchor === 'middle') {
|
|
291
252
|
return "translate(calc(-50% + " + translateX + "px), calc(-100% + " + translateY + "px))";
|
|
292
253
|
} else if (anchor === 'middle') {
|
|
@@ -296,10 +257,8 @@ const getTranslate = _ref => {
|
|
|
296
257
|
} else if (anchor === 'end') {
|
|
297
258
|
return "translate(calc(-100% + " + translateX + "px), calc(-50% + " + translateY + "px))";
|
|
298
259
|
}
|
|
299
|
-
|
|
300
260
|
return "translate(" + translateX + "px, " + translateY + "px)";
|
|
301
261
|
};
|
|
302
|
-
|
|
303
262
|
const LabelContainer = /*#__PURE__*/styled.div.attrs(props => ({
|
|
304
263
|
style: {
|
|
305
264
|
transform: getTranslate(props)
|
|
@@ -324,13 +283,9 @@ const drawRadialLabels = _ref => {
|
|
|
324
283
|
} = _ref;
|
|
325
284
|
const d3container = select(node);
|
|
326
285
|
d3container.selectAll("." + labelClassName).remove();
|
|
327
|
-
|
|
328
286
|
const pxToValue = value => maxValue / radius * value;
|
|
329
|
-
|
|
330
287
|
const axisX = i => radiusScale(maxValue + pxToValue(xOffset || 0)) * Math.cos(angleSlice * i - Math.PI / 2);
|
|
331
|
-
|
|
332
288
|
const axisY = i => radiusScale((maxValue + pxToValue(yOffset || 0)) * Math.sin(angleSlice * i - Math.PI / 2));
|
|
333
|
-
|
|
334
289
|
const labels = Array.from({
|
|
335
290
|
length: dataLength
|
|
336
291
|
}, (_, index) => ({
|
|
@@ -366,17 +321,15 @@ const getTranslate$1 = _ref => {
|
|
|
366
321
|
translateX,
|
|
367
322
|
translateY
|
|
368
323
|
} = _ref;
|
|
369
|
-
|
|
370
|
-
if (index === 0 && anchor === 'middle') {
|
|
324
|
+
if (index === 0 && anchor === "middle") {
|
|
371
325
|
return "translate(calc(-50% + " + translateX + "px), calc(-100% + " + translateY + "px))";
|
|
372
|
-
} else if (anchor ===
|
|
326
|
+
} else if (anchor === "middle") {
|
|
373
327
|
return "translate(calc(-50% + " + translateX + "px), calc(" + translateY + "px))";
|
|
374
|
-
} else if (anchor ===
|
|
328
|
+
} else if (anchor === "start") {
|
|
375
329
|
return "translate(calc(" + translateX + "px), calc(-50% + " + translateY + "px))";
|
|
376
|
-
} else if (anchor ===
|
|
330
|
+
} else if (anchor === "end") {
|
|
377
331
|
return "translate(calc(-100% + " + translateX + "px), calc(-50% + " + translateY + "px))";
|
|
378
332
|
}
|
|
379
|
-
|
|
380
333
|
return "translate(" + translateX + "px, " + translateY + "px)";
|
|
381
334
|
};
|
|
382
335
|
const Label = /*#__PURE__*/styled.div(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n font-size: 12px;\n"])));
|
|
@@ -418,7 +371,6 @@ const draw = (node, props) => {
|
|
|
418
371
|
labelIndex,
|
|
419
372
|
selectLabel: _selectLabel
|
|
420
373
|
} = props;
|
|
421
|
-
|
|
422
374
|
if (node !== null && data.length) {
|
|
423
375
|
const defaultBleedLength = 10;
|
|
424
376
|
const bleedLength = typeof props.bleedLength === 'number' ? props.bleedLength : defaultBleedLength;
|
|
@@ -447,23 +399,23 @@ const draw = (node, props) => {
|
|
|
447
399
|
const ticks = scaleLinear().domain([0, maxValue || 1]).range([]).ticks(props.levels || defaultLevels);
|
|
448
400
|
const lastTick = ticks[ticks.length - 1];
|
|
449
401
|
const newLastTick = lastTick + (ticks[1] - ticks[0]);
|
|
450
|
-
|
|
451
402
|
if (lastTick < maxValue) {
|
|
452
403
|
ticks.push(newLastTick);
|
|
453
404
|
}
|
|
454
|
-
|
|
455
405
|
const levels = props.levels || ticks.length - 1;
|
|
456
406
|
const newMaxValue = ticks[ticks.length - 1];
|
|
457
407
|
const angleSlice = Math.PI * 2 / data[0].length;
|
|
458
408
|
const radiusScale = scaleLinear().range([0, radius]).domain([0, newMaxValue]);
|
|
459
|
-
const radarLine = lineRadial().curve(curveLinearClosed)
|
|
409
|
+
const radarLine = lineRadial().curve(curveLinearClosed)
|
|
410
|
+
// @ts-ignore
|
|
460
411
|
.radius(_ref3 => {
|
|
461
412
|
let {
|
|
462
413
|
value
|
|
463
414
|
} = _ref3;
|
|
464
415
|
return radiusScale(value);
|
|
465
416
|
}).angle((_, i) => i * angleSlice);
|
|
466
|
-
const radarValue = lineRadial().curve(curve || curveLinearClosed)
|
|
417
|
+
const radarValue = lineRadial().curve(curve || curveLinearClosed)
|
|
418
|
+
// @ts-ignore
|
|
467
419
|
.radius(_ref4 => {
|
|
468
420
|
let {
|
|
469
421
|
value
|
|
@@ -473,11 +425,8 @@ const draw = (node, props) => {
|
|
|
473
425
|
const svg = appendSvg(node, width, height);
|
|
474
426
|
const globalCenter = svg.append('g');
|
|
475
427
|
const levelsGrid = range$1(1, levels + 1).reverse();
|
|
476
|
-
|
|
477
428
|
const axisGridY = value => -value * radius / levels;
|
|
478
|
-
|
|
479
429
|
const getAxisValue = value => newMaxValue * value / levels;
|
|
480
|
-
|
|
481
430
|
const gridGlobal = globalCenter.append('g').attr('class', radarChartclassNames.radarAxis).selectAll().data([data[0]]).enter();
|
|
482
431
|
const radarGlobal = globalCenter.append('g').attr('class', radarChartclassNames.radar);
|
|
483
432
|
const axis = gridGlobal.selectAll().data(data[0].map(_ref5 => {
|
|
@@ -487,7 +436,6 @@ const draw = (node, props) => {
|
|
|
487
436
|
return name;
|
|
488
437
|
})).enter();
|
|
489
438
|
let maxGridHeight = 0;
|
|
490
|
-
|
|
491
439
|
if (polar) {
|
|
492
440
|
levelsGrid.forEach(value => {
|
|
493
441
|
const path = gridGlobal.append('circle').attr('cx', 0).attr('cy', 0).attr('r', () => radius / levels * value);
|
|
@@ -497,7 +445,8 @@ const draw = (node, props) => {
|
|
|
497
445
|
});
|
|
498
446
|
} else {
|
|
499
447
|
levelsGrid.map(getAxisValue).forEach(value => {
|
|
500
|
-
const path = gridGlobal.append('path').attr('d', () =>
|
|
448
|
+
const path = gridGlobal.append('path').attr('d', () =>
|
|
449
|
+
// @ts-ignore
|
|
501
450
|
radarLine(Array.from({
|
|
502
451
|
length: data[0].length
|
|
503
452
|
}, () => ({
|
|
@@ -508,10 +457,10 @@ const draw = (node, props) => {
|
|
|
508
457
|
maxGridHeight = Math.max(maxGridHeight, pathHeight);
|
|
509
458
|
});
|
|
510
459
|
}
|
|
511
|
-
|
|
512
460
|
const radiusByMaxValue = radiusScale(newMaxValue) + bleedLength;
|
|
513
461
|
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)));
|
|
514
|
-
radarGlobal.selectAll('path').data(data).join('path').attr('class', radarChartclassNames.radarPolygon).attr('style', (_, index) => (radarStyles == null ? void 0 : radarStyles[index]) || '').attr('d', d => radarValue(
|
|
462
|
+
radarGlobal.selectAll('path').data(data).join('path').attr('class', radarChartclassNames.radarPolygon).attr('style', (_, index) => (radarStyles == null ? void 0 : radarStyles[index]) || '').attr('d', d => radarValue(
|
|
463
|
+
// @ts-ignore
|
|
515
464
|
d.map(dataItem => _extends({}, dataItem, {
|
|
516
465
|
value: dataItem.value - minValue
|
|
517
466
|
}))));
|
|
@@ -574,7 +523,6 @@ const draw = (node, props) => {
|
|
|
574
523
|
if (_selectLabel) {
|
|
575
524
|
const items = data.map(item => item[index]);
|
|
576
525
|
const item = data[labelIndex || 0][index];
|
|
577
|
-
|
|
578
526
|
_selectLabel(label, {
|
|
579
527
|
index,
|
|
580
528
|
item,
|
|
@@ -584,12 +532,10 @@ const draw = (node, props) => {
|
|
|
584
532
|
}
|
|
585
533
|
}
|
|
586
534
|
});
|
|
587
|
-
|
|
588
535
|
if (svgElements) {
|
|
589
536
|
const html = ReactDOMServer.renderToString(svgElements);
|
|
590
537
|
svg.append('g').html(html);
|
|
591
538
|
}
|
|
592
|
-
|
|
593
539
|
customize && customize(svg);
|
|
594
540
|
}
|
|
595
541
|
};
|
|
@@ -603,9 +549,7 @@ const RadarChart = props => {
|
|
|
603
549
|
useEffect(() => {
|
|
604
550
|
node && draw(node, props);
|
|
605
551
|
}, [node, props]);
|
|
606
|
-
|
|
607
552
|
const onDraw = () => draw(node, props);
|
|
608
|
-
|
|
609
553
|
useResize(props.width, onDraw);
|
|
610
554
|
return React.createElement("div", {
|
|
611
555
|
className: className,
|
|
@@ -673,7 +617,6 @@ const drawRadialLabels$1 = _ref => {
|
|
|
673
617
|
} = _ref;
|
|
674
618
|
const d3container = select(node);
|
|
675
619
|
d3container.selectAll("." + pieChartclassNames.pieRadialLabel).remove();
|
|
676
|
-
|
|
677
620
|
if (enableRadialLabels) {
|
|
678
621
|
const defaultRadialLabelsLinkHorizontalLength = 4;
|
|
679
622
|
const outerArc = arc().innerRadius(radius).outerRadius(radius);
|
|
@@ -685,47 +628,52 @@ const drawRadialLabels$1 = _ref => {
|
|
|
685
628
|
const posCPi = [(radius + (radialLabelsLinkHorizontalLength || defaultRadialLabelsLinkHorizontalLength)) * midFactor, posC[1]];
|
|
686
629
|
return [[posA[0], posA[1]], [posB[0] + (radialAngleXOffset || 0) * midFactor, posB[1] - (radialLabelYOffset || 0) * d.index], [posCPi[0], posCPi[1] - (radialLabelYOffset || 0) * d.index]];
|
|
687
630
|
});
|
|
688
|
-
|
|
689
631
|
const getPosition = d => {
|
|
690
632
|
const pos = outerArc.centroid(d);
|
|
691
633
|
return [(radius + (radialLabelsLinkHorizontalLength || defaultRadialLabelsLinkHorizontalLength)) * getMidFactor(d), pos[1]];
|
|
692
634
|
};
|
|
693
|
-
|
|
694
635
|
const defaultRadialLabelsTextXOffset = 4;
|
|
695
|
-
d3container.selectAll('allLabels').data(dataReady).enter().append('div')
|
|
636
|
+
d3container.selectAll('allLabels').data(dataReady).enter().append('div')
|
|
637
|
+
// @ts-ignore
|
|
696
638
|
.html(d => {
|
|
697
|
-
const html = ReactDOMServer.renderToString(
|
|
639
|
+
const html = ReactDOMServer.renderToString(
|
|
640
|
+
// @ts-ignore
|
|
698
641
|
formatRadialLabel ? formatRadialLabel(d) : d.data.name);
|
|
699
642
|
return html;
|
|
700
|
-
}).attr('class', pieChartclassNames.pieRadialLabel)
|
|
643
|
+
}).attr('class', pieChartclassNames.pieRadialLabel)
|
|
644
|
+
// @ts-ignore
|
|
701
645
|
.style('transform', d => getTranslate$1({
|
|
702
646
|
anchor: getAlign(d),
|
|
703
647
|
index: d.index,
|
|
704
648
|
translateX,
|
|
705
649
|
translateY: translateY - (radialLabelYOffset || 0) * d.index
|
|
706
|
-
}))
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
650
|
+
}))
|
|
651
|
+
// @ts-ignore
|
|
652
|
+
.style('left',
|
|
653
|
+
// @ts-ignore
|
|
654
|
+
d => getPosition(d)[0] - (getAlign(d) === 'start' ? -(radialLabelsTextXOffset || defaultRadialLabelsTextXOffset) : radialLabelsTextXOffset || defaultRadialLabelsTextXOffset) + "px")
|
|
655
|
+
// @ts-ignore
|
|
656
|
+
.style('top', d => getPosition(d)[1] + "px")
|
|
657
|
+
// @ts-ignore
|
|
710
658
|
.style('text-align', getAlign);
|
|
711
659
|
}
|
|
712
660
|
};
|
|
713
661
|
|
|
714
|
-
var _templateObject$6, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7, _templateObject8, _templateObject9,
|
|
662
|
+
var _templateObject$6, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7, _templateObject8, _templateObject9, _templateObject0, _templateObject1, _templateObject10, _templateObject11, _templateObject12;
|
|
715
663
|
const TooltipFlex = /*#__PURE__*/styled.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"])));
|
|
716
664
|
const LabelFlex = /*#__PURE__*/styled(TooltipFlex)(_templateObject2$1 || (_templateObject2$1 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
|
|
717
665
|
const LabelFlexCenter = /*#__PURE__*/styled(LabelFlex)(_templateObject3$1 || (_templateObject3$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n align-items: center;\n"])));
|
|
718
|
-
const TooltipContainer = /*#__PURE__*/styled.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"])));
|
|
666
|
+
const TooltipContainer = /*#__PURE__*/styled.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"])));
|
|
719
667
|
const TooltipGroupName = /*#__PURE__*/styled.div(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 14px;\n margin-bottom: 6px;\n"])));
|
|
720
|
-
const TooltipItem = /*#__PURE__*/styled.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"])));
|
|
668
|
+
const TooltipItem = /*#__PURE__*/styled.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"])));
|
|
721
669
|
const ColFlex = /*#__PURE__*/styled.div(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n margin-right: 4px;\n"])));
|
|
722
670
|
const ColorBox = /*#__PURE__*/styled.div(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-right: 4px;\n width: 10px;\n height: 10px;\n border-radius: 2px;\n"])));
|
|
723
671
|
const ColorLine = /*#__PURE__*/styled(ColorBox)(_templateObject9 || (_templateObject9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 2px;\n border-radius: 0;\n"])));
|
|
724
|
-
const Name$1 = /*#__PURE__*/styled.div(
|
|
725
|
-
const Value = /*#__PURE__*/styled.div(
|
|
726
|
-
const Label$1 = /*#__PURE__*/styled.div(
|
|
727
|
-
const LabelTop = /*#__PURE__*/styled(Label$1)(
|
|
728
|
-
const LabelBottom = /*#__PURE__*/styled(Label$1)(
|
|
672
|
+
const Name$1 = /*#__PURE__*/styled.div(_templateObject0 || (_templateObject0 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-right: 4px;\n"])));
|
|
673
|
+
const Value = /*#__PURE__*/styled.div(_templateObject1 || (_templateObject1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n text-align: right;\n flex-shrink: 0;\n flex-grow: 1;\n"])));
|
|
674
|
+
const Label$1 = /*#__PURE__*/styled.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"])));
|
|
675
|
+
const LabelTop = /*#__PURE__*/styled(Label$1)(_templateObject11 || (_templateObject11 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n top: 6px;\n"])));
|
|
676
|
+
const LabelBottom = /*#__PURE__*/styled(Label$1)(_templateObject12 || (_templateObject12 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n bottom: 6px;\n"])));
|
|
729
677
|
|
|
730
678
|
const drawTooltip = _ref => {
|
|
731
679
|
let {
|
|
@@ -748,26 +696,21 @@ const drawTooltip = _ref => {
|
|
|
748
696
|
const pieTooltipContainer = select(container).select("." + pieChartclassNames.pieTooltipContainer);
|
|
749
697
|
const isEmpty = pieTooltipContainer.empty();
|
|
750
698
|
const tooltipContainer = isEmpty ? select(container).append('div').attr('class', pieChartclassNames.pieTooltipContainer + " " + (tooltipClassName || '')).style('position', 'absolute').style('opacity', '0').style('z-index', '103') : pieTooltipContainer;
|
|
751
|
-
|
|
752
699
|
if (tooltipStyle) {
|
|
753
700
|
Object.entries(tooltipStyle).forEach(_ref2 => {
|
|
754
701
|
let [prop, val] = _ref2;
|
|
755
702
|
return tooltipContainer.style(prop, val);
|
|
756
703
|
});
|
|
757
704
|
}
|
|
758
|
-
|
|
759
705
|
tooltipContainer.html('');
|
|
760
706
|
let isVisible = false;
|
|
761
|
-
|
|
762
707
|
const setVisible = visible => {
|
|
763
708
|
isVisible = Boolean(visible);
|
|
764
709
|
const opacity = isVisible ? '1' : '0';
|
|
765
710
|
tooltipContainer.style('opacity', opacity);
|
|
766
711
|
};
|
|
767
|
-
|
|
768
712
|
const setPosition = (event, pieChartDatum) => {
|
|
769
713
|
let [x, y] = pointer(event, document);
|
|
770
|
-
|
|
771
714
|
if (!tooltipBind && fullChartTooltip) {
|
|
772
715
|
const [itemX, itemY] = pointer(event, event.target);
|
|
773
716
|
x = x - itemX;
|
|
@@ -789,10 +732,8 @@ const drawTooltip = _ref => {
|
|
|
789
732
|
x = itemX + itemWidth / 2 + arcX;
|
|
790
733
|
y = itemY + itemHeight / 2 + arcY;
|
|
791
734
|
}
|
|
792
|
-
|
|
793
735
|
tooltipContainer.style('left', x + 'px').style('top', y + 'px');
|
|
794
736
|
};
|
|
795
|
-
|
|
796
737
|
const setTooltip = (event, pieChartDatum) => {
|
|
797
738
|
setVisible(true);
|
|
798
739
|
setPosition(event, pieChartDatum);
|
|
@@ -825,28 +766,23 @@ const drawTooltip = _ref => {
|
|
|
825
766
|
return html;
|
|
826
767
|
});
|
|
827
768
|
};
|
|
828
|
-
|
|
829
769
|
if (fullChartTooltip) {
|
|
830
770
|
global.on('mouseover.fulltooltip', event => setTooltip(event));
|
|
831
771
|
global.on('mouseout.fulltooltip', () => {
|
|
832
772
|
tooltipContainer.html('');
|
|
833
773
|
setVisible();
|
|
834
774
|
});
|
|
835
|
-
|
|
836
775
|
if (width && height) {
|
|
837
776
|
global.append('circle').attr('class', pieChartclassNames.pieFullChartTooltipCircle).attr('r', radius).attr('cx', 0).attr('cy', 0);
|
|
838
777
|
}
|
|
839
|
-
|
|
840
778
|
if (!tooltipBind) {
|
|
841
779
|
global.on('touchmove.tooltipBind mousemove.tooltipBind', event => setPosition(event));
|
|
842
780
|
}
|
|
843
781
|
} else {
|
|
844
782
|
allSlices.on('mouseover.slice', setTooltip);
|
|
845
|
-
|
|
846
783
|
if (!tooltipBind) {
|
|
847
784
|
allSlices.on('touchmove.slice mousemove.slice', setPosition);
|
|
848
785
|
}
|
|
849
|
-
|
|
850
786
|
allSlices.on('mouseout.slice', () => {
|
|
851
787
|
tooltipContainer.html('');
|
|
852
788
|
setVisible();
|
|
@@ -887,7 +823,6 @@ const draw$1 = (node, props) => {
|
|
|
887
823
|
renderTooltip,
|
|
888
824
|
tooltipStyle
|
|
889
825
|
} = props;
|
|
890
|
-
|
|
891
826
|
if (node !== null && data.length) {
|
|
892
827
|
const marginTop = margin ? margin.top : 0;
|
|
893
828
|
const marginRight = margin ? margin.right : 0;
|
|
@@ -905,56 +840,58 @@ const draw$1 = (node, props) => {
|
|
|
905
840
|
const maxPadAngle = 45;
|
|
906
841
|
const dividerPadAngle = 100;
|
|
907
842
|
const fullAngle = 360;
|
|
908
|
-
const pie$1 = pie().startAngle(-degreesToRadians(startAngle || 0)).endAngle(degreesToRadians(endAngle || fullAngle)).padAngle(padAngle ? Math.max(Math.min(padAngle / dividerPadAngle, maxPadAngle), 0) : 0).sort(null)
|
|
843
|
+
const pie$1 = pie().startAngle(-degreesToRadians(startAngle || 0)).endAngle(degreesToRadians(endAngle || fullAngle)).padAngle(padAngle ? Math.max(Math.min(padAngle / dividerPadAngle, maxPadAngle), 0) : 0).sort(null)
|
|
844
|
+
// @ts-ignore
|
|
909
845
|
.value(_ref => {
|
|
910
846
|
let {
|
|
911
847
|
value
|
|
912
848
|
} = _ref;
|
|
913
849
|
return value;
|
|
914
|
-
});
|
|
915
|
-
|
|
850
|
+
});
|
|
851
|
+
// @ts-ignore
|
|
916
852
|
const dataReady = pie$1(data);
|
|
917
853
|
const maxOuterRadius = 0.95;
|
|
918
854
|
const arc$1 = arc().cornerRadius(cornerRadius || 0).innerRadius(radius).outerRadius(radius * Math.min(Math.max(outerRadius || 0, 0), maxOuterRadius));
|
|
919
|
-
|
|
920
855
|
if (typeof backgroundColor === 'string') {
|
|
921
|
-
global.append('path').attr('fill', backgroundColor).attr('d', () =>
|
|
856
|
+
global.append('path').attr('fill', backgroundColor).attr('d', () =>
|
|
857
|
+
// @ts-ignore
|
|
922
858
|
arc$1({
|
|
923
859
|
startAngle: degreesToRadians(0),
|
|
924
860
|
endAngle: degreesToRadians(fullAngle)
|
|
925
861
|
}));
|
|
926
862
|
}
|
|
927
|
-
|
|
928
863
|
const format$1 = format(',');
|
|
929
|
-
const allSlices = global.selectAll('allSlices').data(dataReady).enter().append('path')
|
|
864
|
+
const allSlices = global.selectAll('allSlices').data(dataReady).enter().append('path')
|
|
865
|
+
// @ts-ignore
|
|
930
866
|
.attr('d', arc$1);
|
|
931
867
|
allSlices.attr('class', pieChartclassNames.pieSlice).attr('fill', _ref2 => {
|
|
932
868
|
let {
|
|
933
869
|
index
|
|
934
870
|
} = _ref2;
|
|
935
871
|
return data[index].color || '';
|
|
936
|
-
}).attr('stroke', borderColor || '').attr('stroke-width', borderWidth || 0).attr('style', onClick ? 'cursor: pointer' : '').on('click',
|
|
937
|
-
|
|
872
|
+
}).attr('stroke', borderColor || '').attr('stroke-width', borderWidth || 0).attr('style', onClick ? 'cursor: pointer' : '').on('click',
|
|
873
|
+
// @ts-ignore
|
|
874
|
+
(_, d) => onClick && onClick(data[d.index])).append('svg:title').text(d => formatSliceTitle ?
|
|
875
|
+
// @ts-ignore
|
|
938
876
|
formatSliceTitle(d) : fullChartTooltip || withTooltip ? '' : (data[d.index].name || '') + " (" + format$1(data[d.index].value) + ")");
|
|
939
|
-
|
|
940
877
|
if (enableSlicesLabels) {
|
|
941
|
-
const text = global.selectAll('allSlices').data(dataReady).enter().append('text').attr('class', pieChartclassNames.pieSliceLabel).attr('text-anchor', 'middle').attr('dominant-baseline', 'central').attr('transform',
|
|
878
|
+
const text = global.selectAll('allSlices').data(dataReady).enter().append('text').attr('class', pieChartclassNames.pieSliceLabel).attr('text-anchor', 'middle').attr('dominant-baseline', 'central').attr('transform',
|
|
879
|
+
// @ts-ignore
|
|
942
880
|
d => 'translate(' + arc$1.centroid(d) + ')');
|
|
943
|
-
text.append('tspan').attr('class', pieChartclassNames.pieSliceLabelValue)
|
|
881
|
+
text.append('tspan').attr('class', pieChartclassNames.pieSliceLabelValue)
|
|
882
|
+
// @ts-ignore
|
|
944
883
|
.text(d => {
|
|
945
884
|
const deg = radiansToDegrees(d.endAngle - d.startAngle);
|
|
946
|
-
|
|
947
885
|
if (!slicesLabelsSkipAngle || deg > slicesLabelsSkipAngle) {
|
|
948
886
|
return formatSliceLabel ? formatSliceLabel(d) : d.value;
|
|
949
887
|
}
|
|
950
888
|
});
|
|
951
|
-
|
|
952
889
|
if (enableSlicesLabelsName) {
|
|
953
|
-
text.append('tspan').attr('class', pieChartclassNames.pieSliceLabelName)
|
|
890
|
+
text.append('tspan').attr('class', pieChartclassNames.pieSliceLabelName)
|
|
891
|
+
// @ts-ignore
|
|
954
892
|
.text(d => formatSliceLabelName ? formatSliceLabelName(d) : d.data.name).attr('x', '0').attr('dy', '1.2em');
|
|
955
893
|
}
|
|
956
894
|
}
|
|
957
|
-
|
|
958
895
|
drawRadialLabels$1({
|
|
959
896
|
arc: arc$1,
|
|
960
897
|
enableRadialLabels,
|
|
@@ -970,7 +907,6 @@ const draw$1 = (node, props) => {
|
|
|
970
907
|
radialLabelYOffset,
|
|
971
908
|
radialAngleXOffset
|
|
972
909
|
});
|
|
973
|
-
|
|
974
910
|
if (withTooltip || fullChartTooltip) {
|
|
975
911
|
drawTooltip({
|
|
976
912
|
fullChartTooltip,
|
|
@@ -987,7 +923,6 @@ const draw$1 = (node, props) => {
|
|
|
987
923
|
radius
|
|
988
924
|
});
|
|
989
925
|
}
|
|
990
|
-
|
|
991
926
|
if (svgElements) {
|
|
992
927
|
const html = ReactDOMServer.renderToString(svgElements);
|
|
993
928
|
svg.append('g').html(html);
|
|
@@ -1005,9 +940,7 @@ const PieChart = props => {
|
|
|
1005
940
|
useEffect(() => {
|
|
1006
941
|
node && draw$1(node, props);
|
|
1007
942
|
}, [node, props]);
|
|
1008
|
-
|
|
1009
943
|
const onDraw = () => draw$1(node, props);
|
|
1010
|
-
|
|
1011
944
|
useResize(props.width, onDraw);
|
|
1012
945
|
return React.createElement("div", {
|
|
1013
946
|
className: className,
|
|
@@ -1033,25 +966,20 @@ const legendClassNames = {
|
|
|
1033
966
|
legendTickLine: 'd3-legend-tick-line',
|
|
1034
967
|
legendTickText: 'd3-legend-tick-text'
|
|
1035
968
|
};
|
|
1036
|
-
|
|
1037
969
|
function ramp(color, n) {
|
|
1038
970
|
if (n === void 0) {
|
|
1039
971
|
n = defaultN;
|
|
1040
972
|
}
|
|
1041
|
-
|
|
1042
973
|
const canvas = document.createElement('canvas');
|
|
1043
974
|
canvas.width = n;
|
|
1044
975
|
canvas.height = 1;
|
|
1045
976
|
const context = canvas.getContext('2d');
|
|
1046
|
-
|
|
1047
977
|
for (let i = 0; i < n; ++i) {
|
|
1048
978
|
context.fillStyle = color(i / (n - 1));
|
|
1049
979
|
context.fillRect(i, 0, 1, 1);
|
|
1050
980
|
}
|
|
1051
|
-
|
|
1052
981
|
return canvas;
|
|
1053
982
|
}
|
|
1054
|
-
|
|
1055
983
|
const legendDefaultParams = {
|
|
1056
984
|
tickSize: 6,
|
|
1057
985
|
height: 44,
|
|
@@ -1077,9 +1005,9 @@ const getLegend = _ref => {
|
|
|
1077
1005
|
tickValues,
|
|
1078
1006
|
titleMarginBottom
|
|
1079
1007
|
} = _ref;
|
|
1080
|
-
const svg = create('svg').attr('width', width).attr('height', height)
|
|
1008
|
+
const svg = create('svg').attr('width', width).attr('height', height)
|
|
1009
|
+
// @ts-ignore
|
|
1081
1010
|
.attr('viewBox', [0, 0, width, height]).style('overflow', 'visible').style('display', 'block');
|
|
1082
|
-
|
|
1083
1011
|
let tickAdjust = g => {
|
|
1084
1012
|
const tick = g.selectAll('.tick');
|
|
1085
1013
|
tick.selectAll('.tick line').attr('y1', marginTop + marginBottom - height).attr('class', legendClassNames.legendTickLine);
|
|
@@ -1087,56 +1015,57 @@ const getLegend = _ref => {
|
|
|
1087
1015
|
tick.attr('class', legendClassNames.legendTick);
|
|
1088
1016
|
return tick;
|
|
1089
1017
|
};
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1018
|
+
let x;
|
|
1019
|
+
// Continuous
|
|
1093
1020
|
if (color.interpolate) {
|
|
1094
1021
|
const n = Math.min(color.domain().length, color.range().length);
|
|
1095
1022
|
x = color.copy().rangeRound(quantize(interpolate(marginLeft, width - marginRight), n));
|
|
1096
1023
|
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(quantize(interpolate(0, 1), n))).toDataURL());
|
|
1097
|
-
}
|
|
1024
|
+
}
|
|
1025
|
+
// Sequential
|
|
1098
1026
|
else if (color.interpolator) {
|
|
1099
1027
|
x = Object.assign(color.copy().interpolator(interpolateRound(marginLeft, width - marginRight)), {
|
|
1100
1028
|
range() {
|
|
1101
1029
|
return [marginLeft, width - marginRight];
|
|
1102
1030
|
}
|
|
1103
|
-
|
|
1104
1031
|
});
|
|
1105
|
-
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());
|
|
1106
|
-
|
|
1032
|
+
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());
|
|
1033
|
+
// scaleSequentialQuantile doesn’t implement ticks or tickFormat.
|
|
1107
1034
|
if (!x.ticks) {
|
|
1108
1035
|
if (tickValues === undefined) {
|
|
1109
1036
|
const n = Math.round(ticks + 1);
|
|
1110
1037
|
tickValues = range$1(n).map(i => quantile(color.domain(), i / (n - 1)));
|
|
1111
1038
|
}
|
|
1112
|
-
|
|
1113
1039
|
if (typeof tickFormat !== 'function') {
|
|
1114
1040
|
tickFormat = format(tickFormat === undefined ? ',f' : tickFormat);
|
|
1115
1041
|
}
|
|
1116
1042
|
}
|
|
1117
1043
|
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
.
|
|
1044
|
+
svg.append('g').attr('transform', "translate(0," + (height - marginBottom) + ")")
|
|
1045
|
+
// @ts-ignore
|
|
1046
|
+
.call(axisBottom(x).ticks(ticks, typeof tickFormat === 'string' ? tickFormat : undefined)
|
|
1047
|
+
// @ts-ignore
|
|
1048
|
+
.tickFormat(typeof tickFormat === 'function' ? tickFormat : undefined).tickSize(tickSize)
|
|
1049
|
+
// @ts-ignore
|
|
1121
1050
|
.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));
|
|
1122
1051
|
return svg;
|
|
1123
1052
|
};
|
|
1124
1053
|
|
|
1125
1054
|
var _templateObject$7;
|
|
1126
1055
|
const calendarChartClassNames = /*#__PURE__*/_extends({
|
|
1127
|
-
calendarChart:
|
|
1128
|
-
calendarYear:
|
|
1129
|
-
calendarAxis:
|
|
1130
|
-
calendarBody:
|
|
1131
|
-
calendarHeader:
|
|
1132
|
-
calendarYearTitle:
|
|
1133
|
-
calendarWeekDay:
|
|
1134
|
-
calendarMonth:
|
|
1135
|
-
calendarDays:
|
|
1136
|
-
calendarDay:
|
|
1056
|
+
calendarChart: "calendarChart",
|
|
1057
|
+
calendarYear: "calendarYear",
|
|
1058
|
+
calendarAxis: "calendarAxis",
|
|
1059
|
+
calendarBody: "calendarBody",
|
|
1060
|
+
calendarHeader: "calendarHeader",
|
|
1061
|
+
calendarYearTitle: "calendarYearTitle",
|
|
1062
|
+
calendarWeekDay: "calendarWeekDay",
|
|
1063
|
+
calendarMonth: "calendarMonth",
|
|
1064
|
+
calendarDays: "calendarDays",
|
|
1065
|
+
calendarDay: "calendarDay"
|
|
1137
1066
|
}, legendClassNames);
|
|
1138
|
-
const headerHeight =
|
|
1139
|
-
const SvgWrapper$2 = /*#__PURE__*/styled(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);
|
|
1067
|
+
const headerHeight = "20px";
|
|
1068
|
+
const SvgWrapper$2 = /*#__PURE__*/styled(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);
|
|
1140
1069
|
|
|
1141
1070
|
const draw$2 = (node, props) => {
|
|
1142
1071
|
const {
|
|
@@ -1149,28 +1078,20 @@ const draw$2 = (node, props) => {
|
|
|
1149
1078
|
colorRange,
|
|
1150
1079
|
legendProps
|
|
1151
1080
|
} = props;
|
|
1152
|
-
|
|
1153
1081
|
if (node !== null && data.length) {
|
|
1154
1082
|
const years = group(data, d => d.date.getUTCFullYear());
|
|
1155
1083
|
const cellOffset = typeof props.cellOffset === 'number' ? props.cellOffset : 0;
|
|
1156
1084
|
const weekDays = 7;
|
|
1157
1085
|
const defaultCellSize = 18;
|
|
1158
1086
|
const cellSize = props.cellSize || defaultCellSize;
|
|
1159
|
-
|
|
1160
1087
|
const countDay = i => startSunday ? i : (i + (weekDays - 1)) % weekDays;
|
|
1161
|
-
|
|
1162
1088
|
const days = weekdays || ['вс', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'];
|
|
1163
1089
|
const sundayIndex = 6;
|
|
1164
|
-
|
|
1165
1090
|
const formatDay = i => startSunday ? days[i] : i === sundayIndex ? days[0] : days[i + 1];
|
|
1166
|
-
|
|
1167
1091
|
const formatDate = utcFormat('%x');
|
|
1168
1092
|
const timeWeek = startSunday ? utcSunday : utcMonday;
|
|
1169
|
-
|
|
1170
1093
|
const getTimeWeekCount = (from, to) => timeWeek.count(utcYear(from), to);
|
|
1171
|
-
|
|
1172
1094
|
const getMonthSpacing = date => date.getUTCMonth() * (monthSpacing || 0);
|
|
1173
|
-
|
|
1174
1095
|
const formatMonth = utcFormat('%b');
|
|
1175
1096
|
const max$1 = max(data.map(_ref => {
|
|
1176
1097
|
let {
|
|
@@ -1184,7 +1105,8 @@ const draw$2 = (node, props) => {
|
|
|
1184
1105
|
} = _ref2;
|
|
1185
1106
|
return value;
|
|
1186
1107
|
}));
|
|
1187
|
-
const color = colorRange ? scaleLinear().domain([min$1, max$1])
|
|
1108
|
+
const color = colorRange ? scaleLinear().domain([min$1, max$1])
|
|
1109
|
+
// @ts-ignore
|
|
1188
1110
|
.range(colorRange) : scaleSequential(interpolator || interpolateGreens).domain([min$1, +max$1]);
|
|
1189
1111
|
let chartWidth = 0;
|
|
1190
1112
|
years.forEach((values, year) => {
|
|
@@ -1197,10 +1119,12 @@ const draw$2 = (node, props) => {
|
|
|
1197
1119
|
});
|
|
1198
1120
|
select(node).select("." + calendarChartClassNames.calendarChart).remove();
|
|
1199
1121
|
const container = select(node).append('div').attr('class', calendarChartClassNames.calendarChart);
|
|
1200
|
-
const year = container.selectAll('div')
|
|
1122
|
+
const year = container.selectAll('div')
|
|
1123
|
+
// @ts-ignore
|
|
1201
1124
|
.data(years).join('div').attr('class', calendarChartClassNames.calendarYear);
|
|
1202
1125
|
const calendarWeekdays = year.append('div').attr('class', calendarChartClassNames.calendarAxis);
|
|
1203
|
-
calendarWeekdays.append('div').attr('class', calendarChartClassNames.calendarYearTitle)
|
|
1126
|
+
calendarWeekdays.append('div').attr('class', calendarChartClassNames.calendarYearTitle)
|
|
1127
|
+
// @ts-ignore
|
|
1204
1128
|
.text(_ref3 => {
|
|
1205
1129
|
let [key] = _ref3;
|
|
1206
1130
|
return key;
|
|
@@ -1208,32 +1132,39 @@ const draw$2 = (node, props) => {
|
|
|
1208
1132
|
calendarWeekdays.selectAll('span').data(range$1(weekDays)).join('div').attr('class', calendarChartClassNames.calendarWeekDay).style('height', cellSize + 'px').style('margin-bottom', cellOffset + 'px').text(formatDay);
|
|
1209
1133
|
const body = year.append('div').attr('class', calendarChartClassNames.calendarBody);
|
|
1210
1134
|
const header = body.append('div').attr('class', calendarChartClassNames.calendarHeader);
|
|
1211
|
-
header.selectAll('div')
|
|
1135
|
+
header.selectAll('div')
|
|
1136
|
+
// @ts-ignore
|
|
1212
1137
|
.data(_ref4 => {
|
|
1213
1138
|
let [_, values] = _ref4;
|
|
1214
1139
|
const fullYearlastMonth = 12;
|
|
1215
1140
|
const fullYearlastDate = 31;
|
|
1216
1141
|
return utcMonths(utcMonth(new Date(values[0].date.getUTCFullYear(), 1, 1)), utcMonth(new Date(values[0].date.getUTCFullYear(), fullYearlastMonth, fullYearlastDate)));
|
|
1217
|
-
}).join('div').attr('class', calendarChartClassNames.calendarMonth).style('left', d => getTimeWeekCount(d, timeWeek.ceil(d)) * (cellSize + cellOffset) + getMonthSpacing(d) + 'px')
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1142
|
+
}).join('div').attr('class', calendarChartClassNames.calendarMonth).style('left', d => getTimeWeekCount(d, timeWeek.ceil(d)) * (cellSize + cellOffset) + getMonthSpacing(d) + 'px')
|
|
1143
|
+
// @ts-ignore
|
|
1144
|
+
.text(formatMonth);
|
|
1145
|
+
// @ts-ignore
|
|
1146
|
+
body.append('div').attr('class', calendarChartClassNames.calendarDays).style('height', (cellSize + cellOffset) * weekDays + 'px').style('width', chartWidth + 'px').selectAll('div')
|
|
1147
|
+
// @ts-ignore
|
|
1221
1148
|
.data(_ref5 => {
|
|
1222
1149
|
let [, values] = _ref5;
|
|
1223
1150
|
return values;
|
|
1224
|
-
}).join('div')
|
|
1151
|
+
}).join('div')
|
|
1152
|
+
// @ts-ignore
|
|
1225
1153
|
.each((data, index, elements) => {
|
|
1226
1154
|
if (onEachDay) {
|
|
1227
1155
|
const element = elements[index];
|
|
1228
1156
|
const currColor = color(data.value);
|
|
1229
1157
|
onEachDay(data, element, currColor);
|
|
1230
1158
|
}
|
|
1231
|
-
}).attr('class', calendarChartClassNames.calendarDay).style('width', cellSize + 'px').style('height', cellSize + 'px')
|
|
1232
|
-
|
|
1233
|
-
d =>
|
|
1234
|
-
|
|
1159
|
+
}).attr('class', calendarChartClassNames.calendarDay).style('width', cellSize + 'px').style('height', cellSize + 'px')
|
|
1160
|
+
// @ts-ignore
|
|
1161
|
+
.style('left', d => getTimeWeekCount(d.date, d.date) * (cellSize + cellOffset) + getMonthSpacing(d.date) + 'px').style('top',
|
|
1162
|
+
// @ts-ignore
|
|
1163
|
+
d => countDay(d.date.getUTCDay()) * (cellSize + cellOffset) + 'px')
|
|
1164
|
+
// @ts-ignore
|
|
1165
|
+
.style('background-color', d => color(d.value))
|
|
1166
|
+
// @ts-ignore
|
|
1235
1167
|
.attr('title', d => formatDate(d.date) + " - " + d.value);
|
|
1236
|
-
|
|
1237
1168
|
if (typeof legendProps === 'object') {
|
|
1238
1169
|
const legend = getLegend(_extends({
|
|
1239
1170
|
color: color
|
|
@@ -1262,7 +1193,8 @@ const CalendarChart = props => {
|
|
|
1262
1193
|
} = props;
|
|
1263
1194
|
const [ref, node] = useNode();
|
|
1264
1195
|
useEffect(() => {
|
|
1265
|
-
node && draw$2(node, props);
|
|
1196
|
+
node && draw$2(node, props);
|
|
1197
|
+
// eslint-disable-next-line
|
|
1266
1198
|
}, [node, data, startSunday, weekdays, cellOffset, cellSize, interpolator, monthSpacing, colorRange, legendProps]);
|
|
1267
1199
|
return React.createElement(SvgWrapper$2, {
|
|
1268
1200
|
ref: ref,
|
|
@@ -1277,7 +1209,6 @@ CalendarChart.defaultProps = {
|
|
|
1277
1209
|
function computeDimensions(selection) {
|
|
1278
1210
|
let dimensions;
|
|
1279
1211
|
const node = selection.node();
|
|
1280
|
-
|
|
1281
1212
|
if (node instanceof SVGGraphicsElement) {
|
|
1282
1213
|
// check if node is svg element
|
|
1283
1214
|
dimensions = node.getBBox();
|
|
@@ -1285,7 +1216,6 @@ function computeDimensions(selection) {
|
|
|
1285
1216
|
// else is html element
|
|
1286
1217
|
dimensions = node.getBoundingClientRect();
|
|
1287
1218
|
}
|
|
1288
|
-
|
|
1289
1219
|
return dimensions;
|
|
1290
1220
|
}
|
|
1291
1221
|
|
|
@@ -1300,7 +1230,6 @@ const stackedData = data => {
|
|
|
1300
1230
|
const stacks = {};
|
|
1301
1231
|
return data.map((item, index) => {
|
|
1302
1232
|
stacks[index] = {};
|
|
1303
|
-
|
|
1304
1233
|
if (index > 0) {
|
|
1305
1234
|
return _extends({}, item, {
|
|
1306
1235
|
values: item.values.map((value, valuesIndex) => {
|
|
@@ -1314,38 +1243,37 @@ const stackedData = data => {
|
|
|
1314
1243
|
stacks[index][valuesIndex] = Number(value);
|
|
1315
1244
|
});
|
|
1316
1245
|
}
|
|
1317
|
-
|
|
1318
1246
|
return item;
|
|
1319
1247
|
});
|
|
1320
1248
|
};
|
|
1321
1249
|
|
|
1322
1250
|
var _templateObject$8, _templateObject2$2;
|
|
1323
1251
|
const lineChartClassNames = {
|
|
1324
|
-
lineChartYScaleGlobal:
|
|
1325
|
-
lineChartYScaleRight:
|
|
1326
|
-
lineChartXScaleGlobal:
|
|
1327
|
-
lineChartLinesGlobal:
|
|
1328
|
-
lineChartLine:
|
|
1329
|
-
lineChartAreasGlobal:
|
|
1330
|
-
lineChartArea:
|
|
1331
|
-
lineChartDotsGlobalContainer:
|
|
1332
|
-
lineChartDotsGlobal:
|
|
1333
|
-
lineChartDot:
|
|
1334
|
-
lineChartGridGlobal:
|
|
1335
|
-
lineChartGridLineX:
|
|
1336
|
-
lineChartGridLineY:
|
|
1337
|
-
lineChartLabelContainer:
|
|
1338
|
-
lineChartLabelFlex:
|
|
1339
|
-
lineChartLabel:
|
|
1340
|
-
lineChartMouseGlobal:
|
|
1341
|
-
lineChartMouseLine:
|
|
1342
|
-
lineChartMouseRect:
|
|
1343
|
-
lineChartMouseCircle:
|
|
1344
|
-
lineChartMouseLabelContainer:
|
|
1345
|
-
lineChartMouseLabel:
|
|
1346
|
-
};
|
|
1347
|
-
const SvgWrapper$3 = /*#__PURE__*/styled(Wrapper)(_templateObject$8 || (_templateObject$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", ",\n
|
|
1348
|
-
const TooltipStyles = /*#__PURE__*/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);
|
|
1252
|
+
lineChartYScaleGlobal: "lineChartYScaleGlobal",
|
|
1253
|
+
lineChartYScaleRight: "lineChartYScaleRight",
|
|
1254
|
+
lineChartXScaleGlobal: "lineChartXScaleGlobal",
|
|
1255
|
+
lineChartLinesGlobal: "lineChartLinesGlobal",
|
|
1256
|
+
lineChartLine: "lineChartLine",
|
|
1257
|
+
lineChartAreasGlobal: "lineChartAreasGlobal",
|
|
1258
|
+
lineChartArea: "lineChartArea",
|
|
1259
|
+
lineChartDotsGlobalContainer: "lineChartDotsGlobalContainer",
|
|
1260
|
+
lineChartDotsGlobal: "lineChartDotsGlobal",
|
|
1261
|
+
lineChartDot: "lineChartDot",
|
|
1262
|
+
lineChartGridGlobal: "lineChartGridGlobal",
|
|
1263
|
+
lineChartGridLineX: "lineChartGridLineX",
|
|
1264
|
+
lineChartGridLineY: "lineChartGridLineY",
|
|
1265
|
+
lineChartLabelContainer: "lineChartLabelContainer",
|
|
1266
|
+
lineChartLabelFlex: "lineChartLabelFlex",
|
|
1267
|
+
lineChartLabel: "lineChartLabel",
|
|
1268
|
+
lineChartMouseGlobal: "lineChartMouseGlobal",
|
|
1269
|
+
lineChartMouseLine: "lineChartMouseLine",
|
|
1270
|
+
lineChartMouseRect: "lineChartMouseRect",
|
|
1271
|
+
lineChartMouseCircle: "lineChartMouseCircle",
|
|
1272
|
+
lineChartMouseLabelContainer: "lineChartMouseLabelContainer",
|
|
1273
|
+
lineChartMouseLabel: "lineChartMouseLabel"
|
|
1274
|
+
};
|
|
1275
|
+
const SvgWrapper$3 = /*#__PURE__*/styled(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);
|
|
1276
|
+
const TooltipStyles = /*#__PURE__*/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);
|
|
1349
1277
|
|
|
1350
1278
|
const drawGrid = _ref => {
|
|
1351
1279
|
let {
|
|
@@ -1360,11 +1288,9 @@ const drawGrid = _ref => {
|
|
|
1360
1288
|
if (!drawGridY && !drawGridX) return;
|
|
1361
1289
|
const global = svg.append('g').attr('class', lineChartClassNames.lineChartGridGlobal);
|
|
1362
1290
|
const yTicks = yScale.ticks(yTicksCount);
|
|
1363
|
-
|
|
1364
1291
|
if (drawGridX) {
|
|
1365
1292
|
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)));
|
|
1366
1293
|
}
|
|
1367
|
-
|
|
1368
1294
|
if (drawGridY) {
|
|
1369
1295
|
global.append('g').selectAll('line').data(Array.from({
|
|
1370
1296
|
length: lastIndex + 1
|
|
@@ -1387,8 +1313,8 @@ const drawLabel = _ref => {
|
|
|
1387
1313
|
eachLabel
|
|
1388
1314
|
} = _ref;
|
|
1389
1315
|
const labelsDiv = select(node).append('div').attr('class', labelClassName$1);
|
|
1390
|
-
const format$1 = format(',');
|
|
1391
|
-
|
|
1316
|
+
const format$1 = format(',');
|
|
1317
|
+
// @ts-ignore
|
|
1392
1318
|
data.forEach(_ref2 => {
|
|
1393
1319
|
let {
|
|
1394
1320
|
values
|
|
@@ -1400,7 +1326,8 @@ const drawLabel = _ref => {
|
|
|
1400
1326
|
className: lineChartClassNames.lineChartLabel
|
|
1401
1327
|
}, formatLabel ? formatLabel(d, index, elements) : format$1(d))));
|
|
1402
1328
|
return html;
|
|
1403
|
-
})
|
|
1329
|
+
})
|
|
1330
|
+
// @ts-ignore
|
|
1404
1331
|
.each(eachLabel ? eachLabel : none);
|
|
1405
1332
|
});
|
|
1406
1333
|
};
|
|
@@ -1456,14 +1383,11 @@ const drawTooltip$1 = _ref => {
|
|
|
1456
1383
|
return stroke || 'none';
|
|
1457
1384
|
}).style('opacity', '0');
|
|
1458
1385
|
let labelContainer = select("." + lineChartClassNames.lineChartMouseLabelContainer);
|
|
1459
|
-
|
|
1460
1386
|
if (labelContainer.size() === 0) {
|
|
1461
1387
|
labelContainer = select(container).append('div').attr('class', lineChartClassNames.lineChartMouseLabelContainer);
|
|
1462
1388
|
}
|
|
1463
|
-
|
|
1464
1389
|
let labels = null;
|
|
1465
1390
|
let isVisible = false;
|
|
1466
|
-
|
|
1467
1391
|
const setVisible = visible => {
|
|
1468
1392
|
isVisible = Boolean(visible);
|
|
1469
1393
|
const opacity = isVisible ? '1' : '0';
|
|
@@ -1471,7 +1395,6 @@ const drawTooltip$1 = _ref => {
|
|
|
1471
1395
|
circles.style('opacity', opacity);
|
|
1472
1396
|
labels && labels.style('opacity', opacity);
|
|
1473
1397
|
};
|
|
1474
|
-
|
|
1475
1398
|
const mouseMove = event => {
|
|
1476
1399
|
const [docX, docY] = pointer(event, document);
|
|
1477
1400
|
const [rectrX] = pointer(event, mouseRect);
|
|
@@ -1480,41 +1403,33 @@ const drawTooltip$1 = _ref => {
|
|
|
1480
1403
|
const left = nodeX + (docX - nodeX);
|
|
1481
1404
|
const currIndex = Math.abs(xScale.invert(x));
|
|
1482
1405
|
const positions = {};
|
|
1483
|
-
|
|
1484
1406
|
const getValue = values => {
|
|
1485
1407
|
// The returning result is fixed for the task: https://jr.everpoint.ru/browse/PUB-5648
|
|
1486
1408
|
// Before the task it was like this (and I don't know why):
|
|
1487
|
-
|
|
1488
1409
|
/* return !isVoid(values[Math.floor(currIndex + 1)])
|
|
1489
1410
|
? values[Math.floor(currIndex)]
|
|
1490
1411
|
: null;*/
|
|
1491
1412
|
return values[Math.floor(currIndex)];
|
|
1492
1413
|
};
|
|
1493
|
-
|
|
1494
1414
|
lines.forEach((line, index) => {
|
|
1495
1415
|
let pos = {
|
|
1496
1416
|
x: 0,
|
|
1497
1417
|
y: 0
|
|
1498
1418
|
};
|
|
1499
|
-
|
|
1500
1419
|
if (!line.hasAttribute('d') || argData[index].tooltipOff) {
|
|
1501
1420
|
positions[index] = pos;
|
|
1502
1421
|
return;
|
|
1503
1422
|
}
|
|
1504
|
-
|
|
1505
1423
|
if (!dotSnapping) {
|
|
1506
1424
|
let beginning = 0;
|
|
1507
1425
|
let end = line.getTotalLength();
|
|
1508
1426
|
let target = null;
|
|
1509
|
-
|
|
1510
1427
|
while (true) {
|
|
1511
1428
|
target = Math.floor((beginning + end) / 2);
|
|
1512
1429
|
pos = line.getPointAtLength(target);
|
|
1513
|
-
|
|
1514
1430
|
if ((target === end || target === beginning) && pos.x !== x) {
|
|
1515
1431
|
break;
|
|
1516
1432
|
}
|
|
1517
|
-
|
|
1518
1433
|
if (pos.x > x) {
|
|
1519
1434
|
end = target;
|
|
1520
1435
|
} else if (pos.x < x) {
|
|
@@ -1523,7 +1438,6 @@ const drawTooltip$1 = _ref => {
|
|
|
1523
1438
|
break;
|
|
1524
1439
|
}
|
|
1525
1440
|
}
|
|
1526
|
-
|
|
1527
1441
|
positions[index] = pos;
|
|
1528
1442
|
} else {
|
|
1529
1443
|
const [x1, x2] = xScale.range();
|
|
@@ -1546,10 +1460,9 @@ const drawTooltip$1 = _ref => {
|
|
|
1546
1460
|
});
|
|
1547
1461
|
const datas = chartData.map((_ref7, i) => {
|
|
1548
1462
|
let {
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1463
|
+
values
|
|
1464
|
+
} = _ref7,
|
|
1465
|
+
rest = _objectWithoutPropertiesLoose(_ref7, _excluded$1);
|
|
1553
1466
|
return _extends({}, rest, {
|
|
1554
1467
|
value: getValue(values),
|
|
1555
1468
|
invertValue: positions[i] ? yScale.invert(positions[i].y) : 0
|
|
@@ -1561,16 +1474,13 @@ const drawTooltip$1 = _ref => {
|
|
|
1561
1474
|
} = _ref8;
|
|
1562
1475
|
return isVoid(value);
|
|
1563
1476
|
});
|
|
1564
|
-
|
|
1565
1477
|
if (noHasData && isVisible) {
|
|
1566
1478
|
setVisible();
|
|
1567
1479
|
} else if (!isVisible && !noHasData) {
|
|
1568
1480
|
setVisible(true);
|
|
1569
1481
|
}
|
|
1570
|
-
|
|
1571
1482
|
const topIndex = Object.keys(positions).reduce((acc, key, index) => {
|
|
1572
1483
|
var _datas$Number, _datas$Number2;
|
|
1573
|
-
|
|
1574
1484
|
const prevValue = (_datas$Number = datas[Number(acc)]) == null ? void 0 : _datas$Number.value;
|
|
1575
1485
|
const value = (_datas$Number2 = datas[Number(key)]) == null ? void 0 : _datas$Number2.value;
|
|
1576
1486
|
const dynamicDotOff = argData == null ? void 0 : argData[index].dynamicDotOff;
|
|
@@ -1578,15 +1488,12 @@ const drawTooltip$1 = _ref => {
|
|
|
1578
1488
|
}, '0');
|
|
1579
1489
|
const labelTexts = labels && labels.style('left', (_, i) => {
|
|
1580
1490
|
var _positions$i$x, _positions$i;
|
|
1581
|
-
|
|
1582
1491
|
return !dotSnapping ? left + "px" : ((_positions$i$x = (_positions$i = positions[i]) == null ? void 0 : _positions$i.x) != null ? _positions$i$x : 0) + "px";
|
|
1583
1492
|
}).style('top', (_, i) => {
|
|
1584
1493
|
var _positions$index$y, _positions$index;
|
|
1585
|
-
|
|
1586
1494
|
const index = typeof stackedTooltipIndex === 'number' ? stackedTooltipIndex : stackedTooltip ? topIndex : i;
|
|
1587
1495
|
return ((_positions$index$y = (_positions$index = positions[index]) == null ? void 0 : _positions$index.y) != null ? _positions$index$y : 0) + (docY - nodeY) + "px";
|
|
1588
1496
|
}).select("." + lineChartClassNames.lineChartLabel);
|
|
1589
|
-
|
|
1590
1497
|
if (renderTooltip && labels) {
|
|
1591
1498
|
labels.html((_, index) => {
|
|
1592
1499
|
return ReactDOMServer.renderToString(React.createElement(LabelContainer$1, {
|
|
@@ -1605,16 +1512,13 @@ const drawTooltip$1 = _ref => {
|
|
|
1605
1512
|
return formatDynamicTooltip ? formatDynamicTooltip(invertValue, value) : format$1(invertValue);
|
|
1606
1513
|
});
|
|
1607
1514
|
}
|
|
1608
|
-
|
|
1609
1515
|
mouseLine.attr('d', () => {
|
|
1610
1516
|
var _positions$topIndex;
|
|
1611
|
-
|
|
1612
1517
|
let d = 'M' + x + ',' + y1;
|
|
1613
1518
|
d += ' ' + x + ',' + (tooltipLineTop ? y2 : ((_positions$topIndex = positions[topIndex]) == null ? void 0 : _positions$topIndex.y) || 0);
|
|
1614
1519
|
return d;
|
|
1615
1520
|
});
|
|
1616
1521
|
};
|
|
1617
|
-
|
|
1618
1522
|
mouseRect.on('mouseover.tooltip', event => {
|
|
1619
1523
|
labels = labelContainer.selectAll('div').data(data).join('div').attr('class', lineChartClassNames.lineChartMouseLabel + " " + (tooltipClassName || '')).style('opacity', '0').style('position', 'absolute').html(() => {
|
|
1620
1524
|
const html = ReactDOMServer.renderToString(React.createElement(LabelContainer$1, {
|
|
@@ -1667,7 +1571,6 @@ const draw$3 = (node, props) => {
|
|
|
1667
1571
|
dotSnapping,
|
|
1668
1572
|
rightAxis
|
|
1669
1573
|
} = props;
|
|
1670
|
-
|
|
1671
1574
|
if (node !== null && chartData.length) {
|
|
1672
1575
|
const data = stacked ? stackedData(chartData) : chartData;
|
|
1673
1576
|
const marginTop = margin ? margin.top : 0;
|
|
@@ -1705,7 +1608,6 @@ const draw$3 = (node, props) => {
|
|
|
1705
1608
|
} = computeDimensions(yAxis);
|
|
1706
1609
|
yAxis.attr('transform', "translate(" + (marginLeft + yAxisWidth) + ", 0)");
|
|
1707
1610
|
let yAxisRightWidth = 0;
|
|
1708
|
-
|
|
1709
1611
|
if (rightAxis) {
|
|
1710
1612
|
const rightAxisMin = min(rightAxis);
|
|
1711
1613
|
const rightAxisMax = max(rightAxis);
|
|
@@ -1718,8 +1620,6 @@ const draw$3 = (node, props) => {
|
|
|
1718
1620
|
yAxisRight.attr('transform', "translate(" + (width - yAxisRightWidth) + ", 0)");
|
|
1719
1621
|
}
|
|
1720
1622
|
/** xScale **/
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
1623
|
const lastIndex = labels && labels.length ? labels.length - 1 : data.reduce((acc, _ref3) => {
|
|
1724
1624
|
let {
|
|
1725
1625
|
values
|
|
@@ -1727,15 +1627,14 @@ const draw$3 = (node, props) => {
|
|
|
1727
1627
|
return Math.max(acc, values.length);
|
|
1728
1628
|
}, 0) - 1;
|
|
1729
1629
|
const xScale = scaleLinear().domain([0, lastIndex]).range([marginLeft + yAxisWidth + (yAxisPadding || 0), width - yAxisRightWidth - marginRight]);
|
|
1730
|
-
const xAxisBottom = axisBottom(xScale).tickFormat(value =>
|
|
1630
|
+
const xAxisBottom = axisBottom(xScale).tickFormat(value =>
|
|
1631
|
+
// @ts-ignore
|
|
1731
1632
|
labels && labels.length > 0 ? labels[value] : 0).ticks(lastIndex);
|
|
1732
|
-
|
|
1733
1633
|
if (typeof xScaleItemWidth === 'number') {
|
|
1734
1634
|
const [x1, x2] = xScale.range();
|
|
1735
1635
|
const chartWidth = x2 - x1;
|
|
1736
1636
|
xAxisBottom.ticks(Math.round(chartWidth / xScaleItemWidth)).tickSizeOuter(0);
|
|
1737
1637
|
}
|
|
1738
|
-
|
|
1739
1638
|
customXAxis && customXAxis(xAxisBottom);
|
|
1740
1639
|
drawGrid({
|
|
1741
1640
|
svg,
|
|
@@ -1746,7 +1645,6 @@ const draw$3 = (node, props) => {
|
|
|
1746
1645
|
drawGridY,
|
|
1747
1646
|
drawGridX
|
|
1748
1647
|
});
|
|
1749
|
-
|
|
1750
1648
|
if (Array.isArray(labels) && labels.length > 0) {
|
|
1751
1649
|
const xAxis = svg.append('g').call(customXAxisSelection ? customXAxisSelection : none).attr('class', lineChartClassNames.lineChartXScaleGlobal).call(xAxisBottom);
|
|
1752
1650
|
const {
|
|
@@ -1754,7 +1652,6 @@ const draw$3 = (node, props) => {
|
|
|
1754
1652
|
} = computeDimensions(xAxis);
|
|
1755
1653
|
xAxis.attr('transform', "translate(0, " + (height - Math.ceil(xAxisHeight) - marginBottom) + ")");
|
|
1756
1654
|
}
|
|
1757
|
-
|
|
1758
1655
|
const line$1 = line().defined(d => d !== null).x((_, index) => xScale(index)).y(d => yScale(d)).curve(curve || curveLinear);
|
|
1759
1656
|
customLine && customLine(line$1);
|
|
1760
1657
|
const withAreas = data.some(_ref4 => {
|
|
@@ -1763,10 +1660,8 @@ const draw$3 = (node, props) => {
|
|
|
1763
1660
|
} = _ref4;
|
|
1764
1661
|
return fill;
|
|
1765
1662
|
});
|
|
1766
|
-
|
|
1767
1663
|
if (withAreas) {
|
|
1768
1664
|
let dataIndex = -2;
|
|
1769
|
-
|
|
1770
1665
|
const getArea = d => {
|
|
1771
1666
|
const {
|
|
1772
1667
|
minAreaValues
|
|
@@ -1776,20 +1671,16 @@ const draw$3 = (node, props) => {
|
|
|
1776
1671
|
if (index === 0) {
|
|
1777
1672
|
dataIndex = dataIndex + 1;
|
|
1778
1673
|
}
|
|
1779
|
-
|
|
1780
1674
|
let minValue = minTick;
|
|
1781
|
-
|
|
1782
1675
|
if (minAreaValues && typeof minAreaValues[index] === 'number') {
|
|
1783
1676
|
minValue = minAreaValues[index] || minValue;
|
|
1784
1677
|
} else if (minAreaValues) {
|
|
1785
1678
|
minValue = yScale(minValue - value);
|
|
1786
1679
|
}
|
|
1787
|
-
|
|
1788
1680
|
const currData = data[dataIndex];
|
|
1789
1681
|
return stacked ? dataIndex > -1 ? yScale(typeof currData.values[index] !== 'number' ? 0 : currData.values[index]) : yScale(minValue) : yScale(minValue);
|
|
1790
1682
|
}).y1(d => yScale(d)).curve(areaCurve || curve || curveLinear);
|
|
1791
1683
|
};
|
|
1792
|
-
|
|
1793
1684
|
svg.append('g').attr('class', lineChartClassNames.lineChartAreasGlobal).selectAll('path').data(data.filter(_ref5 => {
|
|
1794
1685
|
let {
|
|
1795
1686
|
fill
|
|
@@ -1810,7 +1701,6 @@ const draw$3 = (node, props) => {
|
|
|
1810
1701
|
return areaStyle || '';
|
|
1811
1702
|
});
|
|
1812
1703
|
}
|
|
1813
|
-
|
|
1814
1704
|
svg.append('g').attr('class', lineChartClassNames.lineChartLinesGlobal).selectAll('path').data(data).join('path').attr('class', lineChartClassNames.lineChartLine).attr('d', d => line$1(d.values)).attr('stroke', _ref8 => {
|
|
1815
1705
|
let {
|
|
1816
1706
|
stroke
|
|
@@ -1822,13 +1712,12 @@ const draw$3 = (node, props) => {
|
|
|
1822
1712
|
} = _ref9;
|
|
1823
1713
|
return style || '';
|
|
1824
1714
|
});
|
|
1825
|
-
const dots = data.filter(
|
|
1715
|
+
const dots = data.filter(_ref0 => {
|
|
1826
1716
|
let {
|
|
1827
1717
|
dot
|
|
1828
|
-
} =
|
|
1718
|
+
} = _ref0;
|
|
1829
1719
|
return dot;
|
|
1830
1720
|
});
|
|
1831
|
-
|
|
1832
1721
|
if (dots.length > 0) {
|
|
1833
1722
|
const dotsGlobal = svg.append('g').attr('class', lineChartClassNames.lineChartDotsGlobalContainer);
|
|
1834
1723
|
dots.forEach(item => {
|
|
@@ -1843,13 +1732,11 @@ const draw$3 = (node, props) => {
|
|
|
1843
1732
|
} = dot;
|
|
1844
1733
|
const dotsGroup = dotsGlobal.append('g').attr('class', lineChartClassNames.lineChartDotsGlobal);
|
|
1845
1734
|
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 || '');
|
|
1846
|
-
|
|
1847
1735
|
if (filter) {
|
|
1848
1736
|
dotsGroup.selectAll('circle').select((_, i, g) => filter(item, i, g) ? g[i] : null).remove();
|
|
1849
1737
|
}
|
|
1850
1738
|
});
|
|
1851
1739
|
}
|
|
1852
|
-
|
|
1853
1740
|
select(node).select("." + labelClassName$1).remove();
|
|
1854
1741
|
withLabels && drawLabel({
|
|
1855
1742
|
node,
|
|
@@ -1859,7 +1746,6 @@ const draw$3 = (node, props) => {
|
|
|
1859
1746
|
xScale,
|
|
1860
1747
|
formatLabel
|
|
1861
1748
|
});
|
|
1862
|
-
|
|
1863
1749
|
if (dynamicTooltipEnable) {
|
|
1864
1750
|
drawTooltip$1({
|
|
1865
1751
|
tooltipLineTop,
|
|
@@ -1878,7 +1764,6 @@ const draw$3 = (node, props) => {
|
|
|
1878
1764
|
lastIndex
|
|
1879
1765
|
});
|
|
1880
1766
|
}
|
|
1881
|
-
|
|
1882
1767
|
customize && customize({
|
|
1883
1768
|
svg,
|
|
1884
1769
|
yScale,
|
|
@@ -1897,9 +1782,7 @@ const LineChart = props => {
|
|
|
1897
1782
|
useEffect(() => {
|
|
1898
1783
|
node && draw$3(node, props);
|
|
1899
1784
|
}, [node, props]);
|
|
1900
|
-
|
|
1901
1785
|
const onDraw = () => draw$3(node, props);
|
|
1902
|
-
|
|
1903
1786
|
useResize(props.width, onDraw);
|
|
1904
1787
|
return React.createElement("div", {
|
|
1905
1788
|
className: className,
|
|
@@ -1943,7 +1826,8 @@ const drawLines = _ref => {
|
|
|
1943
1826
|
let linesSelection = null;
|
|
1944
1827
|
let areasSelection = null;
|
|
1945
1828
|
let area$1 = null;
|
|
1946
|
-
const line$1 = line().defined(d => d !== null).x((_, index) => xScale(index) + bandwidth / 2)
|
|
1829
|
+
const line$1 = line().defined(d => d !== null).x((_, index) => xScale(index) + bandwidth / 2)
|
|
1830
|
+
// @ts-ignore
|
|
1947
1831
|
.y(d => yScale(d)).curve(curve || curveLinear);
|
|
1948
1832
|
const bandwidth = xScale.bandwidth();
|
|
1949
1833
|
const linesData = lineData.filter(_ref2 => {
|
|
@@ -1958,7 +1842,6 @@ const drawLines = _ref => {
|
|
|
1958
1842
|
} = _ref3;
|
|
1959
1843
|
return lineType === 'area';
|
|
1960
1844
|
});
|
|
1961
|
-
|
|
1962
1845
|
if (linesData.length > 0) {
|
|
1963
1846
|
linesSelection = svg.append('g').attr('class', barChartLinesClassNames.barChartLinesGlobal).selectAll('path').data(linesData).join('path').attr('class', barChartLinesClassNames.barChartLine).attr('d', d => line$1(d.values)).attr('stroke', _ref4 => {
|
|
1964
1847
|
let {
|
|
@@ -1972,16 +1855,15 @@ const drawLines = _ref => {
|
|
|
1972
1855
|
return fill || 'none';
|
|
1973
1856
|
});
|
|
1974
1857
|
}
|
|
1975
|
-
|
|
1976
1858
|
if (areasData.length > 0) {
|
|
1977
1859
|
let dataIndex = -2;
|
|
1978
1860
|
area$1 = area().x((_, index) => xScale(index) + bandwidth / 2).y0((_, index) => {
|
|
1979
1861
|
if (index === 0) {
|
|
1980
1862
|
dataIndex = dataIndex + 1;
|
|
1981
1863
|
}
|
|
1982
|
-
|
|
1983
1864
|
return stackedLine ? dataIndex > -1 ? yScale(typeof lineData[dataIndex].values[index] !== 'number' ? 0 : lineData[dataIndex].values[index]) : yScale(min) : yScale(min);
|
|
1984
|
-
})
|
|
1865
|
+
})
|
|
1866
|
+
// @ts-ignore
|
|
1985
1867
|
.y1(d => yScale(d)).curve(curve || curveLinear);
|
|
1986
1868
|
areasSelection = svg.append('g').attr('class', barChartLinesClassNames.barChartAreasGlobal).selectAll('path').data(areasData).join('path').attr('class', barChartLinesClassNames.barChartArea).attr('d', d => area$1 && area$1(d.values)).attr('fill', _ref6 => {
|
|
1987
1869
|
let {
|
|
@@ -1990,7 +1872,6 @@ const drawLines = _ref => {
|
|
|
1990
1872
|
return fill || 'none';
|
|
1991
1873
|
});
|
|
1992
1874
|
}
|
|
1993
|
-
|
|
1994
1875
|
return {
|
|
1995
1876
|
areasSelection,
|
|
1996
1877
|
linesSelection,
|
|
@@ -2063,10 +1944,8 @@ const useSelection = (node, props) => {
|
|
|
2063
1944
|
const onStartDrawing = useCallback(e => {
|
|
2064
1945
|
const isTouch = Boolean(e.touches);
|
|
2065
1946
|
e.stopPropagation();
|
|
2066
|
-
|
|
2067
1947
|
if (node && e.which !== 3) {
|
|
2068
1948
|
var _props$margin$bottom, _props$margin, _e$touches$;
|
|
2069
|
-
|
|
2070
1949
|
clearSelection();
|
|
2071
1950
|
selection.current = document.createElement("div");
|
|
2072
1951
|
selection.current.setAttribute("class", barChartClassNames.barChartSelection);
|
|
@@ -2082,14 +1961,11 @@ const useSelection = (node, props) => {
|
|
|
2082
1961
|
const onDraw = useCallback(e => {
|
|
2083
1962
|
const isTouch = Boolean(e.touches);
|
|
2084
1963
|
e.stopPropagation();
|
|
2085
|
-
|
|
2086
1964
|
if (node && drawing.current && selection.current) {
|
|
2087
1965
|
var _e$touches$2;
|
|
2088
|
-
|
|
2089
1966
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2090
1967
|
const offsetX = isTouch ? ((_e$touches$2 = e.touches[0]) == null ? void 0 : _e$touches$2.pageX) - node.firstChild.getBoundingClientRect().left : e.offsetX;
|
|
2091
1968
|
const newWidth = offsetX - startX.current;
|
|
2092
|
-
|
|
2093
1969
|
if (offsetX >= 0) {
|
|
2094
1970
|
if (newWidth > 0) {
|
|
2095
1971
|
selection.current.style.marginLeft = "0px";
|
|
@@ -2100,7 +1976,6 @@ const useSelection = (node, props) => {
|
|
|
2100
1976
|
selection.current.style.marginLeft = newWidth + "px";
|
|
2101
1977
|
}
|
|
2102
1978
|
}
|
|
2103
|
-
|
|
2104
1979
|
if (isTouch) {
|
|
2105
1980
|
if (node.offsetLeft > e.touches[0].pageX) {
|
|
2106
1981
|
selection.current.style.right = nodeWidth - startX.current + "px";
|
|
@@ -2118,7 +1993,6 @@ const useSelection = (node, props) => {
|
|
|
2118
1993
|
selection.current.style.width = startX.current + "px";
|
|
2119
1994
|
selection.current.style.marginLeft = "-" + startX.current + "px";
|
|
2120
1995
|
}
|
|
2121
|
-
|
|
2122
1996
|
if (node.offsetLeft + node.offsetWidth < e.pageX) {
|
|
2123
1997
|
const nodeWidth = node.firstChild.getBoundingClientRect().width;
|
|
2124
1998
|
selection.current.style.left = startX.current + "px";
|
|
@@ -2135,12 +2009,10 @@ const useSelection = (node, props) => {
|
|
|
2135
2009
|
const selectionMaxX = selection.current.offsetLeft + selectionWidth <= nodeWidth ? selection.current.offsetLeft + selectionWidth >= 0 ? selection.current.offsetLeft + selectionWidth : 0 : nodeWidth;
|
|
2136
2010
|
const min = Math.round(selectionMinX);
|
|
2137
2011
|
const max = Math.round(selectionMaxX);
|
|
2138
|
-
|
|
2139
2012
|
if (max - min > 0 && props.onSelect) {
|
|
2140
2013
|
props.onSelect([min, max]);
|
|
2141
2014
|
}
|
|
2142
2015
|
}
|
|
2143
|
-
|
|
2144
2016
|
clearSelection();
|
|
2145
2017
|
}, [node, clearSelection]);
|
|
2146
2018
|
useEffect(() => {
|
|
@@ -2157,15 +2029,14 @@ const useSelection = (node, props) => {
|
|
|
2157
2029
|
node.addEventListener("touchend", onStopDrawing);
|
|
2158
2030
|
document.addEventListener("mouseup", onStopDrawing);
|
|
2159
2031
|
}
|
|
2160
|
-
|
|
2161
2032
|
return () => {
|
|
2162
|
-
node == null
|
|
2163
|
-
node == null
|
|
2164
|
-
node == null
|
|
2165
|
-
node == null
|
|
2166
|
-
node == null
|
|
2167
|
-
node == null
|
|
2168
|
-
node == null
|
|
2033
|
+
node == null || node.removeEventListener("mousedown", onStartDrawing);
|
|
2034
|
+
node == null || node.removeEventListener("touchstart", onStartDrawing);
|
|
2035
|
+
node == null || node.removeEventListener("mousemove", onDraw);
|
|
2036
|
+
node == null || node.removeEventListener("touchmove", onDraw);
|
|
2037
|
+
node == null || node.removeEventListener("mouseleave", onMouseLeave);
|
|
2038
|
+
node == null || node.removeEventListener("mouseup", onStopDrawing);
|
|
2039
|
+
node == null || node.removeEventListener("touchend", onStopDrawing);
|
|
2169
2040
|
document.removeEventListener("mouseup", onStopDrawing);
|
|
2170
2041
|
};
|
|
2171
2042
|
}, [node]);
|
|
@@ -2185,14 +2056,11 @@ const drawGrid$1 = _ref => {
|
|
|
2185
2056
|
const yTicks = yScale.ticks(yTicksCount);
|
|
2186
2057
|
const range = xScale.range();
|
|
2187
2058
|
const domain = xScale.domain();
|
|
2188
|
-
|
|
2189
2059
|
if (drawGridX) {
|
|
2190
2060
|
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)));
|
|
2191
2061
|
}
|
|
2192
|
-
|
|
2193
2062
|
if (drawGridY) {
|
|
2194
2063
|
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];
|
|
2195
|
-
|
|
2196
2064
|
global.append('g').selectAll('line').data(Array.from({
|
|
2197
2065
|
length: domain.length + 1
|
|
2198
2066
|
}, (_, 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])));
|
|
@@ -2210,7 +2078,6 @@ const getDomain = _ref => {
|
|
|
2210
2078
|
let MAX = Number.NEGATIVE_INFINITY;
|
|
2211
2079
|
data.forEach(_ref2 => {
|
|
2212
2080
|
let groups = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
|
|
2213
|
-
|
|
2214
2081
|
let groupMax = 0;
|
|
2215
2082
|
let groupMin = 0;
|
|
2216
2083
|
Object.keys(groups).forEach(key => {
|
|
@@ -2219,7 +2086,6 @@ const getDomain = _ref => {
|
|
|
2219
2086
|
let stackMin = 0;
|
|
2220
2087
|
Object.keys(group).forEach(groupKey => {
|
|
2221
2088
|
const value = group[groupKey];
|
|
2222
|
-
|
|
2223
2089
|
if (value > 0) {
|
|
2224
2090
|
stackMax += value;
|
|
2225
2091
|
} else {
|
|
@@ -2232,14 +2098,12 @@ const getDomain = _ref => {
|
|
|
2232
2098
|
MIN = Math.min(MIN, groupMax);
|
|
2233
2099
|
MAX = Math.max(MAX, groupMin);
|
|
2234
2100
|
});
|
|
2235
|
-
|
|
2236
2101
|
if (MIN === 0 && MAX === 0) {
|
|
2237
2102
|
return {
|
|
2238
2103
|
min: typeof minDomainValue === 'number' ? minDomainValue : 0,
|
|
2239
2104
|
max: typeof maxDomainValue === 'number' ? maxDomainValue : 1
|
|
2240
2105
|
};
|
|
2241
2106
|
}
|
|
2242
|
-
|
|
2243
2107
|
return {
|
|
2244
2108
|
min: typeof minDomainValue === 'number' ? minDomainValue : MIN,
|
|
2245
2109
|
max: typeof maxDomainValue === 'number' ? maxDomainValue : MAX
|
|
@@ -2259,10 +2123,9 @@ const marshaling = _ref => {
|
|
|
2259
2123
|
} = _ref;
|
|
2260
2124
|
return data.map((_ref2, groupIndex) => {
|
|
2261
2125
|
let {
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2126
|
+
groupName
|
|
2127
|
+
} = _ref2,
|
|
2128
|
+
groups = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
|
|
2266
2129
|
const marshalledGroup = [];
|
|
2267
2130
|
const hundred = 100;
|
|
2268
2131
|
const bandwidth = xScale.bandwidth();
|
|
@@ -2279,11 +2142,9 @@ const marshaling = _ref => {
|
|
|
2279
2142
|
const x = (barWidth + barPadding) * stackIndex + bandwidth / 2 - barGroupWidth / 2;
|
|
2280
2143
|
const isPositiveValue = value > 0;
|
|
2281
2144
|
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);
|
|
2282
|
-
|
|
2283
2145
|
if (isPositiveValue) {
|
|
2284
2146
|
stackMax += value;
|
|
2285
2147
|
}
|
|
2286
|
-
|
|
2287
2148
|
const y = isPositiveValue ? (yScale(stackMax) + Number.EPSILON) * hundred / hundred : yScale(stackMin) - yScale(0) + yScale(0);
|
|
2288
2149
|
marshalledGroup.push({
|
|
2289
2150
|
x,
|
|
@@ -2296,7 +2157,6 @@ const marshaling = _ref => {
|
|
|
2296
2157
|
stackIndex,
|
|
2297
2158
|
groupIndex
|
|
2298
2159
|
});
|
|
2299
|
-
|
|
2300
2160
|
if (!isPositiveValue) {
|
|
2301
2161
|
stackMin += value;
|
|
2302
2162
|
}
|
|
@@ -2310,10 +2170,8 @@ const getLabelY = (labelPosition, y2, item) => {
|
|
|
2310
2170
|
switch (labelPosition) {
|
|
2311
2171
|
case 'center':
|
|
2312
2172
|
return item.y + item.height / 2 - y2;
|
|
2313
|
-
|
|
2314
2173
|
case 'bottom':
|
|
2315
2174
|
return item.y + item.height - y2;
|
|
2316
|
-
|
|
2317
2175
|
default:
|
|
2318
2176
|
return item.y;
|
|
2319
2177
|
}
|
|
@@ -2323,10 +2181,8 @@ const getLabel = labelPosition => {
|
|
|
2323
2181
|
switch (labelPosition) {
|
|
2324
2182
|
case 'top':
|
|
2325
2183
|
return LabelTop;
|
|
2326
|
-
|
|
2327
2184
|
case 'bottom':
|
|
2328
2185
|
return LabelBottom;
|
|
2329
|
-
|
|
2330
2186
|
default:
|
|
2331
2187
|
return Label$1;
|
|
2332
2188
|
}
|
|
@@ -2370,9 +2226,7 @@ const drawTooltip$2 = _ref => {
|
|
|
2370
2226
|
const [y1, y2] = yScale.range();
|
|
2371
2227
|
const bandwidth = xScale.bandwidth();
|
|
2372
2228
|
const format$1 = format(',');
|
|
2373
|
-
|
|
2374
2229
|
const getX = index => xScaleBandDomain[index] !== void 0 ? index === 0 ? x1 : Math.round(xScale.step() * index + x1 - xScale.step() / 2 * xScale.padding()) : x2;
|
|
2375
|
-
|
|
2376
2230
|
const groups = xScaleBandDomain.map(value => getX(Number(value) + 1));
|
|
2377
2231
|
const topYDomain = tooltipYDomain ? tooltipYDomain({
|
|
2378
2232
|
data: marshalledData,
|
|
@@ -2395,11 +2249,9 @@ const drawTooltip$2 = _ref => {
|
|
|
2395
2249
|
}, []);
|
|
2396
2250
|
const mouseGlobal = svg.append('g').attr('class', 'lineChartMouseGlobal');
|
|
2397
2251
|
const mouseRect = mouseGlobal.append('rect').attr('width', x2 - x1).attr('height', Math.abs(y1 - y2)).attr('class', barChartClassNames.barChartMouseRect).attr('transform', "translate(" + x1 + ", " + y2 + ")");
|
|
2398
|
-
|
|
2399
2252
|
if (dynamicTooltipEnable) {
|
|
2400
2253
|
const tooltipContainer = tooltipRoot || document.querySelector('body');
|
|
2401
2254
|
let tooltip = select("." + barChartClassNames.barChartMouseTooltip);
|
|
2402
|
-
|
|
2403
2255
|
if (tooltip.size() === 0) {
|
|
2404
2256
|
tooltip = select(tooltipContainer).append('div').attr('class', barChartClassNames.barChartMouseTooltip).style('opacity', '0').style('position', 'absolute').html(() => {
|
|
2405
2257
|
const html = ReactDOMServer.renderToString(React.createElement(TooltipFlex, {
|
|
@@ -2408,16 +2260,13 @@ const drawTooltip$2 = _ref => {
|
|
|
2408
2260
|
return html;
|
|
2409
2261
|
});
|
|
2410
2262
|
}
|
|
2411
|
-
|
|
2412
2263
|
const barChartTootipFlex = tooltip.select("." + barChartClassNames.barChartTooltipFlex);
|
|
2413
2264
|
let isVisible = false;
|
|
2414
2265
|
let flagCurrIndex = null;
|
|
2415
|
-
|
|
2416
2266
|
const setVisible = visible => {
|
|
2417
2267
|
isVisible = Boolean(visible);
|
|
2418
2268
|
const opacity = isVisible ? '1' : '0';
|
|
2419
2269
|
tooltip.style('opacity', opacity);
|
|
2420
|
-
|
|
2421
2270
|
if (!isVisible) {
|
|
2422
2271
|
tooltip.attr('class', barChartClassNames.barChartMouseTooltip);
|
|
2423
2272
|
flagCurrIndex = null;
|
|
@@ -2429,7 +2278,6 @@ const drawTooltip$2 = _ref => {
|
|
|
2429
2278
|
tooltip.style('transition', null);
|
|
2430
2279
|
}
|
|
2431
2280
|
};
|
|
2432
|
-
|
|
2433
2281
|
mouseRect.on('mouseout.tooltip', () => setVisible());
|
|
2434
2282
|
mouseRect.on('touchmove.tooltip mousemove.tooltip', event => {
|
|
2435
2283
|
const [docX, docY] = pointer(event, document);
|
|
@@ -2439,57 +2287,45 @@ const drawTooltip$2 = _ref => {
|
|
|
2439
2287
|
const offsetX = docX - nodeX;
|
|
2440
2288
|
const offsetY = docY - nodeY;
|
|
2441
2289
|
const currIndex = groups.findIndex(value => x <= value);
|
|
2442
|
-
|
|
2443
2290
|
if (isBarTooltip) {
|
|
2444
2291
|
const containts = document.elementsFromPoint(event.clientX, event.clientY);
|
|
2445
2292
|
const currBars = select(bars.nodes()[currIndex]).selectAll('rect').nodes();
|
|
2446
2293
|
const isContains = containts.some(item => currBars.includes(item));
|
|
2447
|
-
|
|
2448
2294
|
if (!isContains) {
|
|
2449
2295
|
if (isVisible) {
|
|
2450
2296
|
setVisible(false);
|
|
2451
2297
|
}
|
|
2452
|
-
|
|
2453
2298
|
mouseRect.style('cursor', 'default');
|
|
2454
2299
|
return;
|
|
2455
2300
|
} else {
|
|
2456
2301
|
mouseRect.style('cursor', 'pointer');
|
|
2457
2302
|
}
|
|
2458
2303
|
}
|
|
2459
|
-
|
|
2460
2304
|
const top = (typeof tooltipY === 'number' ? tooltipY : topYDomain[currIndex] - y2) + offsetY;
|
|
2461
2305
|
const left = (tooltipBind ? (xScale(currIndex) || 0) + bandwidth / 2 : x) + offsetX;
|
|
2462
|
-
|
|
2463
2306
|
if (tooltipBind && flagCurrIndex === currIndex) {
|
|
2464
2307
|
return;
|
|
2465
2308
|
}
|
|
2466
|
-
|
|
2467
2309
|
let currData = marshalledData[currIndex];
|
|
2468
|
-
|
|
2469
2310
|
if (Array.isArray(currData) && currData.length === 0) {
|
|
2470
2311
|
return;
|
|
2471
2312
|
}
|
|
2472
|
-
|
|
2473
2313
|
if (lineData) {
|
|
2474
2314
|
const currLineData = lineData.map(_ref4 => {
|
|
2475
2315
|
let {
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2316
|
+
values
|
|
2317
|
+
} = _ref4,
|
|
2318
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded$4);
|
|
2480
2319
|
return _extends({}, rest, {
|
|
2481
2320
|
value: values[currIndex],
|
|
2482
2321
|
groupName: data[currIndex] && data[currIndex].groupName
|
|
2483
2322
|
});
|
|
2484
2323
|
});
|
|
2485
|
-
|
|
2486
2324
|
if (Array.isArray(currLineData) && Array.isArray(currData)) {
|
|
2487
2325
|
currData = currData.concat(currLineData);
|
|
2488
2326
|
}
|
|
2489
2327
|
}
|
|
2490
|
-
|
|
2491
2328
|
const svgWidth = svg.node().getBoundingClientRect().width;
|
|
2492
|
-
|
|
2493
2329
|
if (typeof setTooltipPosition === 'function') {
|
|
2494
2330
|
setTooltipPosition({
|
|
2495
2331
|
left,
|
|
@@ -2500,7 +2336,6 @@ const drawTooltip$2 = _ref => {
|
|
|
2500
2336
|
} else if (!setTooltipPosition) {
|
|
2501
2337
|
tooltip.style('left', left + "px").style('top', top + "px");
|
|
2502
2338
|
}
|
|
2503
|
-
|
|
2504
2339
|
if (renderTooltip) {
|
|
2505
2340
|
barChartTootipFlex.html(() => {
|
|
2506
2341
|
const html = ReactDOMServer.renderToString(React.createElement(React.Fragment, null, renderTooltip(currData, setTooltipPosition ? {
|
|
@@ -2515,7 +2350,6 @@ const drawTooltip$2 = _ref => {
|
|
|
2515
2350
|
if (!isVisible) {
|
|
2516
2351
|
setVisible(true);
|
|
2517
2352
|
}
|
|
2518
|
-
|
|
2519
2353
|
barChartTootipFlex.html(() => {
|
|
2520
2354
|
const html = ReactDOMServer.renderToString(React.createElement(TooltipContainer, {
|
|
2521
2355
|
className: barChartClassNames.barChartTooltip
|
|
@@ -2554,18 +2388,14 @@ const drawTooltip$2 = _ref => {
|
|
|
2554
2388
|
return html;
|
|
2555
2389
|
});
|
|
2556
2390
|
}
|
|
2557
|
-
|
|
2558
2391
|
flagCurrIndex = currIndex;
|
|
2559
|
-
|
|
2560
2392
|
if (!isVisible) {
|
|
2561
2393
|
setVisible(true);
|
|
2562
2394
|
}
|
|
2563
2395
|
});
|
|
2564
2396
|
}
|
|
2565
|
-
|
|
2566
2397
|
const container = select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
|
|
2567
2398
|
const labelContainer = container.append('div').attr('class', barChartClassNames.barChartLabelContainer).style('position', 'absolute').style('top', y2 + "px");
|
|
2568
|
-
|
|
2569
2399
|
const isMouseWithin = (e, callback) => {
|
|
2570
2400
|
const [rectrX, rectrY] = pointer(e, mouseRect);
|
|
2571
2401
|
const [nodeX, nodeY] = pointer(e, node);
|
|
@@ -2573,14 +2403,11 @@ const drawTooltip$2 = _ref => {
|
|
|
2573
2403
|
const y = rectrY - nodeY;
|
|
2574
2404
|
const currIndex = groups.findIndex(value => x <= value);
|
|
2575
2405
|
const dataItem = marshalledData[currIndex][0];
|
|
2576
|
-
|
|
2577
2406
|
if (dataItem.height >= y1 - y) {
|
|
2578
2407
|
callback(dataItem);
|
|
2579
2408
|
}
|
|
2580
2409
|
};
|
|
2581
|
-
|
|
2582
2410
|
mouseGlobal.on("click", e => isMouseWithin(e, dataItem => onBarClick && onBarClick(dataItem))).on("mousemove", e => isMouseWithin(e, dataItem => onBarHover && onBarHover(dataItem))).on("mouseleave", () => onBarHover && onBarHover(undefined));
|
|
2583
|
-
|
|
2584
2411
|
if (labelPosition) {
|
|
2585
2412
|
const concatedData = lineData ? marshalledData.map((stack, index) => stack.concat(lineData.map(_ref6 => {
|
|
2586
2413
|
let {
|
|
@@ -2598,14 +2425,12 @@ const drawTooltip$2 = _ref => {
|
|
|
2598
2425
|
indexFlag,
|
|
2599
2426
|
stacksCount
|
|
2600
2427
|
} = acc;
|
|
2601
|
-
|
|
2602
2428
|
if (stackIndex !== indexFlag) {
|
|
2603
2429
|
return {
|
|
2604
2430
|
indexFlag: stackIndex,
|
|
2605
2431
|
stacksCount: stacksCount + 1
|
|
2606
2432
|
};
|
|
2607
2433
|
}
|
|
2608
|
-
|
|
2609
2434
|
return acc;
|
|
2610
2435
|
}, {
|
|
2611
2436
|
indexFlag: -1,
|
|
@@ -2650,14 +2475,11 @@ const resizeBarWidth = _ref => {
|
|
|
2650
2475
|
const chartWidth = range[1] - range[0];
|
|
2651
2476
|
const barsWidth = data.reduce((acc, _ref2) => {
|
|
2652
2477
|
let curr = _objectWithoutPropertiesLoose(_ref2, _excluded$5);
|
|
2653
|
-
|
|
2654
2478
|
return acc + Object.keys(curr).reduce((acc, _key, index) => index > 0 ? acc + (barWidth || 0) + (barPadding || 0) : acc + barWidth, 0) + groupPadding;
|
|
2655
2479
|
}, groupPadding);
|
|
2656
|
-
|
|
2657
2480
|
if (chartWidth < barsWidth) {
|
|
2658
2481
|
return Math.floor(barWidth * (chartWidth / barsWidth));
|
|
2659
2482
|
}
|
|
2660
|
-
|
|
2661
2483
|
return barWidth;
|
|
2662
2484
|
};
|
|
2663
2485
|
|
|
@@ -2721,7 +2543,6 @@ const draw$4 = (node, props) => {
|
|
|
2721
2543
|
onBarClick,
|
|
2722
2544
|
onBarHover
|
|
2723
2545
|
} = props;
|
|
2724
|
-
|
|
2725
2546
|
if (node !== null && data.length) {
|
|
2726
2547
|
const marginTop = margin ? margin.top : 0;
|
|
2727
2548
|
const marginRight = margin ? margin.right : 0;
|
|
@@ -2780,7 +2601,6 @@ const draw$4 = (node, props) => {
|
|
|
2780
2601
|
customXScale && customXScale(xScale);
|
|
2781
2602
|
const [x1, x2] = xScale.range();
|
|
2782
2603
|
const xAxisBottom = axisBottom(xScale).tickFormat(value => labels[Number(value)]);
|
|
2783
|
-
|
|
2784
2604
|
if (typeof xScaleItemWidth === 'number') {
|
|
2785
2605
|
xAxisBottom.tickValues(xScale.domain().filter((_, i, array) => {
|
|
2786
2606
|
const chartWidth = x2 - x1;
|
|
@@ -2790,7 +2610,6 @@ const draw$4 = (node, props) => {
|
|
|
2790
2610
|
return !(i % divider);
|
|
2791
2611
|
})).tickSizeOuter(0);
|
|
2792
2612
|
}
|
|
2793
|
-
|
|
2794
2613
|
customXAxisBottom && customXAxisBottom(xAxisBottom, {
|
|
2795
2614
|
node,
|
|
2796
2615
|
labels
|
|
@@ -2834,24 +2653,19 @@ const draw$4 = (node, props) => {
|
|
|
2834
2653
|
if (!marker) {
|
|
2835
2654
|
return;
|
|
2836
2655
|
}
|
|
2837
|
-
|
|
2838
2656
|
if (marker.horizontal) {
|
|
2839
2657
|
if (marker.line) {
|
|
2840
2658
|
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);
|
|
2841
2659
|
}
|
|
2842
|
-
|
|
2843
2660
|
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);
|
|
2844
2661
|
return;
|
|
2845
2662
|
}
|
|
2846
|
-
|
|
2847
2663
|
if (marker.line) {
|
|
2848
2664
|
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);
|
|
2849
2665
|
}
|
|
2850
|
-
|
|
2851
2666
|
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);
|
|
2852
2667
|
});
|
|
2853
2668
|
let lines = null;
|
|
2854
|
-
|
|
2855
2669
|
if (Array.isArray(lineData) && lineData.length > 0) {
|
|
2856
2670
|
lines = drawLines({
|
|
2857
2671
|
svg,
|
|
@@ -2863,7 +2677,6 @@ const draw$4 = (node, props) => {
|
|
|
2863
2677
|
curve
|
|
2864
2678
|
});
|
|
2865
2679
|
}
|
|
2866
|
-
|
|
2867
2680
|
customBars && customBars({
|
|
2868
2681
|
bars,
|
|
2869
2682
|
yScale,
|
|
@@ -2871,7 +2684,6 @@ const draw$4 = (node, props) => {
|
|
|
2871
2684
|
marshalledData,
|
|
2872
2685
|
lineData
|
|
2873
2686
|
});
|
|
2874
|
-
|
|
2875
2687
|
if (dynamicTooltipEnable || labelPosition) {
|
|
2876
2688
|
drawTooltip$2({
|
|
2877
2689
|
svg,
|
|
@@ -2904,7 +2716,6 @@ const draw$4 = (node, props) => {
|
|
|
2904
2716
|
onBarHover
|
|
2905
2717
|
});
|
|
2906
2718
|
}
|
|
2907
|
-
|
|
2908
2719
|
customize && customize({
|
|
2909
2720
|
svg,
|
|
2910
2721
|
marshalledData,
|
|
@@ -2926,9 +2737,7 @@ const BarChart = props => {
|
|
|
2926
2737
|
useEffect(() => {
|
|
2927
2738
|
node && draw$4(node, props);
|
|
2928
2739
|
}, [node, props]);
|
|
2929
|
-
|
|
2930
2740
|
const onDraw = () => draw$4(node, props);
|
|
2931
|
-
|
|
2932
2741
|
useResize(props.width, onDraw);
|
|
2933
2742
|
useSelection(selectable ? node : null, props);
|
|
2934
2743
|
return React.createElement("div", {
|
|
@@ -2985,13 +2794,11 @@ const useMarshaling = _ref => {
|
|
|
2985
2794
|
return value;
|
|
2986
2795
|
})]);
|
|
2987
2796
|
}
|
|
2988
|
-
|
|
2989
2797
|
return item.map(_ref4 => {
|
|
2990
2798
|
let {
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2799
|
+
value
|
|
2800
|
+
} = _ref4,
|
|
2801
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded$6);
|
|
2995
2802
|
return _extends({}, rest, {
|
|
2996
2803
|
value,
|
|
2997
2804
|
width: scaleLinear$1(value),
|
|
@@ -3005,26 +2812,26 @@ const useMarshaling = _ref => {
|
|
|
3005
2812
|
|
|
3006
2813
|
var _templateObject$b, _templateObject2$5, _templateObject3$2, _templateObject4$2, _templateObject5$2, _templateObject6$2, _templateObject7$1, _templateObject8$1;
|
|
3007
2814
|
const horizontalBarChartClassNames = {
|
|
3008
|
-
horizontalBarChartButtonTd:
|
|
3009
|
-
horizontalBarChartLabelTd:
|
|
3010
|
-
horizontalBarChartLabelCell:
|
|
3011
|
-
horizontalBarChartBarTd:
|
|
3012
|
-
horizontalBarChartBarFlex:
|
|
3013
|
-
horizontalBarChartBar:
|
|
3014
|
-
horizontalBarChartBarFirst:
|
|
3015
|
-
horizontalBarChartBarLast:
|
|
3016
|
-
horizontalBarChartBarOnly:
|
|
3017
|
-
horizontalBarChartTooltipFlex:
|
|
3018
|
-
horizontalBarChartStackWrapper:
|
|
3019
|
-
horizontalBarChartTooltipContainer:
|
|
3020
|
-
horizontalBarChartStackSumContainer:
|
|
3021
|
-
horizontalBarChartStackSum:
|
|
3022
|
-
horizontalBarChartXScaleTd:
|
|
3023
|
-
horizontalBarChartXScaleTicks:
|
|
3024
|
-
horizontalBarChartXScaleTick:
|
|
3025
|
-
horizontalBarChartTooltipItem:
|
|
3026
|
-
horizontalBarChartTooltipName:
|
|
3027
|
-
horizontalBarChartTooltipValue:
|
|
2815
|
+
horizontalBarChartButtonTd: "horizontalBarChartButtonTd",
|
|
2816
|
+
horizontalBarChartLabelTd: "horizontalBarChartLabelTd",
|
|
2817
|
+
horizontalBarChartLabelCell: "horizontalBarChartLabelCell",
|
|
2818
|
+
horizontalBarChartBarTd: "horizontalBarChartBarTd",
|
|
2819
|
+
horizontalBarChartBarFlex: "horizontalBarChartBarFlex",
|
|
2820
|
+
horizontalBarChartBar: "horizontalBarChartBar",
|
|
2821
|
+
horizontalBarChartBarFirst: "horizontalBarChartBarFirst",
|
|
2822
|
+
horizontalBarChartBarLast: "horizontalBarChartBarLast",
|
|
2823
|
+
horizontalBarChartBarOnly: "horizontalBarChartBarOnly",
|
|
2824
|
+
horizontalBarChartTooltipFlex: "horizontalBarChartTooltipFlex",
|
|
2825
|
+
horizontalBarChartStackWrapper: "horizontalBarChartStackWrapper",
|
|
2826
|
+
horizontalBarChartTooltipContainer: "horizontalBarChartTooltipContainer",
|
|
2827
|
+
horizontalBarChartStackSumContainer: "horizontalBarChartStackSumContainer",
|
|
2828
|
+
horizontalBarChartStackSum: "horizontalBarChartStackSum",
|
|
2829
|
+
horizontalBarChartXScaleTd: "horizontalBarChartXScaleTd",
|
|
2830
|
+
horizontalBarChartXScaleTicks: "horizontalBarChartXScaleTicks",
|
|
2831
|
+
horizontalBarChartXScaleTick: "horizontalBarChartXScaleTick",
|
|
2832
|
+
horizontalBarChartTooltipItem: "horizontalBarChartTooltipItem",
|
|
2833
|
+
horizontalBarChartTooltipName: "horizontalBarChartTooltipName",
|
|
2834
|
+
horizontalBarChartTooltipValue: "horizontalBarChartTooltipValue"
|
|
3028
2835
|
};
|
|
3029
2836
|
const Table = /*#__PURE__*/styled.table(_templateObject$b || (_templateObject$b = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
|
|
3030
2837
|
const LabelCell = /*#__PURE__*/styled.div(_templateObject2$5 || (_templateObject2$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n text-align: right;\n"])));
|
|
@@ -3089,7 +2896,6 @@ const useTooltip = _ref => {
|
|
|
3089
2896
|
}, [tooltipRoot]);
|
|
3090
2897
|
const onMouseMove = useCallback((event, bars) => {
|
|
3091
2898
|
let [x, y] = pointer(event, document);
|
|
3092
|
-
|
|
3093
2899
|
if (!tooltipBind && 'getBoundingClientRect' in event.target) {
|
|
3094
2900
|
const {
|
|
3095
2901
|
width,
|
|
@@ -3099,11 +2905,9 @@ const useTooltip = _ref => {
|
|
|
3099
2905
|
x = x - barX + width / 2;
|
|
3100
2906
|
y = y - barY + height / 2;
|
|
3101
2907
|
}
|
|
3102
|
-
|
|
3103
2908
|
if (rootElement) {
|
|
3104
2909
|
rootElement.style.visibility = 'visible';
|
|
3105
2910
|
}
|
|
3106
|
-
|
|
3107
2911
|
render(React.createElement(Tooltip, {
|
|
3108
2912
|
style: _extends({
|
|
3109
2913
|
left: x,
|
|
@@ -3127,13 +2931,12 @@ const _excluded$7 = ["item", "mouseMove", "mouseLeave", "tooltipBind"];
|
|
|
3127
2931
|
const useStackWrapper = stackedTooltip => {
|
|
3128
2932
|
return useMemo(() => stackedTooltip ? _ref => {
|
|
3129
2933
|
let {
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
2934
|
+
item,
|
|
2935
|
+
mouseMove,
|
|
2936
|
+
mouseLeave,
|
|
2937
|
+
tooltipBind
|
|
2938
|
+
} = _ref,
|
|
2939
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
3137
2940
|
return React.createElement(StackWrapper, Object.assign({
|
|
3138
2941
|
className: horizontalBarChartClassNames.horizontalBarChartStackWrapper,
|
|
3139
2942
|
onMouseOver: event => mouseMove(event, item),
|
|
@@ -3305,7 +3108,7 @@ const HorizontalBarChart = _ref => {
|
|
|
3305
3108
|
});
|
|
3306
3109
|
return React.createElement("tr", {
|
|
3307
3110
|
key: "row-" + rowIndex
|
|
3308
|
-
}, typeof renderButton ===
|
|
3111
|
+
}, typeof renderButton === "function" && React.createElement("td", {
|
|
3309
3112
|
className: horizontalBarChartClassNames.horizontalBarChartButtonTd
|
|
3310
3113
|
}, renderButton(item, rowIndex)), React.createElement("td", {
|
|
3311
3114
|
className: horizontalBarChartClassNames.horizontalBarChartLabelTd
|
|
@@ -3314,12 +3117,12 @@ const HorizontalBarChart = _ref => {
|
|
|
3314
3117
|
}, labels[rowIndex])), React.createElement(BarsTd, {
|
|
3315
3118
|
className: horizontalBarChartClassNames.horizontalBarChartBarTd,
|
|
3316
3119
|
style: {
|
|
3317
|
-
pointerEvents: fullChartTooltip ?
|
|
3120
|
+
pointerEvents: fullChartTooltip ? "none" : "auto"
|
|
3318
3121
|
}
|
|
3319
3122
|
}, React.createElement(BarFlex, {
|
|
3320
3123
|
className: horizontalBarChartClassNames.horizontalBarChartBarFlex,
|
|
3321
3124
|
style: {
|
|
3322
|
-
pointerEvents: fullChartTooltip ?
|
|
3125
|
+
pointerEvents: fullChartTooltip ? "none" : "auto"
|
|
3323
3126
|
}
|
|
3324
3127
|
}, React.createElement(Stack, {
|
|
3325
3128
|
style: stackedTooltip ? {
|
|
@@ -3330,7 +3133,7 @@ const HorizontalBarChart = _ref => {
|
|
|
3330
3133
|
mouseMove: mouseMove,
|
|
3331
3134
|
mouseLeave: mouseLeave
|
|
3332
3135
|
}), item.map((bar, barIndex, array) => bar.value !== 0 && React.createElement(Bar, {
|
|
3333
|
-
key: "bar-" + (bar.name ||
|
|
3136
|
+
key: "bar-" + (bar.name || "") + "-" + barIndex,
|
|
3334
3137
|
formatNativeTitle: formatNativeTitle,
|
|
3335
3138
|
bar: bar,
|
|
3336
3139
|
tooltipBind: tooltipBind,
|
|
@@ -3347,7 +3150,7 @@ const HorizontalBarChart = _ref => {
|
|
|
3347
3150
|
className: horizontalBarChartClassNames.horizontalBarChartStackSum
|
|
3348
3151
|
}, stackSum)))), renderDataTable && renderDataTable(item, stackSum, rowIndex));
|
|
3349
3152
|
}), !withoutXScale && React.createElement(XScale, {
|
|
3350
|
-
maxValue: typeof maxValue ===
|
|
3153
|
+
maxValue: typeof maxValue === "number" ? maxValue : fullMax,
|
|
3351
3154
|
scaleTicks: scaleTicks,
|
|
3352
3155
|
renderTicks: renderTicks,
|
|
3353
3156
|
scaleDomain: scaleDomain
|
|
@@ -3379,20 +3182,20 @@ const bubbleChartDefaultProps = {
|
|
|
3379
3182
|
|
|
3380
3183
|
var _templateObject$e, _templateObject2$7;
|
|
3381
3184
|
const bubbleChartClassNames = {
|
|
3382
|
-
bubbleChartYAxis:
|
|
3383
|
-
bubbleChartYAxisZeroTick:
|
|
3384
|
-
bubbleChartXAxis:
|
|
3385
|
-
bubbleChartGridGlobal:
|
|
3386
|
-
bubbleChartGridLineX:
|
|
3387
|
-
bubbleChartGridLineY:
|
|
3388
|
-
bubbleChartCircle:
|
|
3389
|
-
bubbleChartYScaleLabel:
|
|
3390
|
-
bubbleChartTooltip:
|
|
3391
|
-
bubbleChartTooltipContainer:
|
|
3392
|
-
bubbleChartTooltipFlex:
|
|
3393
|
-
bubbleChartTip:
|
|
3394
|
-
};
|
|
3395
|
-
const SvgWrapper$5 = /*#__PURE__*/styled(Wrapper)(_templateObject$e || (_templateObject$e = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .", ",\n
|
|
3185
|
+
bubbleChartYAxis: "bubbleChartYAxis",
|
|
3186
|
+
bubbleChartYAxisZeroTick: "bubbleChartYAxisZeroTick",
|
|
3187
|
+
bubbleChartXAxis: "bubbleChartXAxis",
|
|
3188
|
+
bubbleChartGridGlobal: "bubbleChartGridGlobal",
|
|
3189
|
+
bubbleChartGridLineX: "bubbleChartGridLineX",
|
|
3190
|
+
bubbleChartGridLineY: "bubbleChartGridLineY",
|
|
3191
|
+
bubbleChartCircle: "bubbleChartCircle",
|
|
3192
|
+
bubbleChartYScaleLabel: "bubbleChartYScaleLabel",
|
|
3193
|
+
bubbleChartTooltip: "bubbleChartTooltip",
|
|
3194
|
+
bubbleChartTooltipContainer: "bubbleChartTooltipContainer",
|
|
3195
|
+
bubbleChartTooltipFlex: "bubbleChartTooltipFlex",
|
|
3196
|
+
bubbleChartTip: "bubbleChartTip"
|
|
3197
|
+
};
|
|
3198
|
+
const SvgWrapper$5 = /*#__PURE__*/styled(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);
|
|
3396
3199
|
const TooltipStyles$2 = /*#__PURE__*/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);
|
|
3397
3200
|
|
|
3398
3201
|
const drawGrid$2 = _ref => {
|
|
@@ -3408,11 +3211,9 @@ const drawGrid$2 = _ref => {
|
|
|
3408
3211
|
const [min, max] = xScale.domain();
|
|
3409
3212
|
const global = svg.append('g').attr('class', bubbleChartClassNames.bubbleChartGridGlobal);
|
|
3410
3213
|
const yTicks = yScale.ticks(yTicksCount);
|
|
3411
|
-
|
|
3412
3214
|
if (drawGridX) {
|
|
3413
3215
|
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)));
|
|
3414
3216
|
}
|
|
3415
|
-
|
|
3416
3217
|
if (drawGridY) {
|
|
3417
3218
|
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])));
|
|
3418
3219
|
}
|
|
@@ -3431,11 +3232,9 @@ const drawTooltip$3 = _ref => {
|
|
|
3431
3232
|
const root = tooltipRoot || document.querySelector('body');
|
|
3432
3233
|
const format$1 = format(',');
|
|
3433
3234
|
let container = select(root).select("." + bubbleChartClassNames.bubbleChartTooltip);
|
|
3434
|
-
|
|
3435
3235
|
if (container.node() === null) {
|
|
3436
3236
|
container = select(root).append('div').attr('class', bubbleChartClassNames.bubbleChartTooltip);
|
|
3437
3237
|
}
|
|
3438
|
-
|
|
3439
3238
|
let tooltip = container.append('div').attr('class', bubbleChartClassNames.bubbleChartTooltipContainer + " " + (tooltipClassName || '')).style('opacity', '0');
|
|
3440
3239
|
bubbles.on('mouseover.tooltip', (event, data) => {
|
|
3441
3240
|
const {
|
|
@@ -3496,7 +3295,6 @@ const draw$5 = (node, props) => {
|
|
|
3496
3295
|
tooltipClassName,
|
|
3497
3296
|
renderTooltip
|
|
3498
3297
|
} = props;
|
|
3499
|
-
|
|
3500
3298
|
if (node !== null && data.length) {
|
|
3501
3299
|
const marginTop = margin ? margin.top : 0;
|
|
3502
3300
|
const marginRight = margin ? margin.right : 0;
|
|
@@ -3550,7 +3348,6 @@ const draw$5 = (node, props) => {
|
|
|
3550
3348
|
const yTicksCount = yAxisLeft.tickArguments()[0];
|
|
3551
3349
|
const yAxis = svg.append('g').attr('class', bubbleChartClassNames.bubbleChartYAxis).call(yAxisLeft);
|
|
3552
3350
|
let yScaleLabelHeight = yScaleLabelPadding || 0;
|
|
3553
|
-
|
|
3554
3351
|
if (yScaleLabel) {
|
|
3555
3352
|
const label = svg.append('text').text(yScaleLabel).attr('class', bubbleChartClassNames.bubbleChartYScaleLabel);
|
|
3556
3353
|
const {
|
|
@@ -3560,7 +3357,6 @@ const draw$5 = (node, props) => {
|
|
|
3560
3357
|
yScaleLabelHeight = yScaleLabelHeight + height;
|
|
3561
3358
|
label.attr('transform', "rotate(-90) translate(-" + (yRange1 + marginBottom + width) / 2 + ", " + height + ")");
|
|
3562
3359
|
}
|
|
3563
|
-
|
|
3564
3360
|
yAxis.selectAll('.tick').attr('class', value => {
|
|
3565
3361
|
return value === 0 ? "tick " + bubbleChartClassNames.bubbleChartYAxisZeroTick : 'tick';
|
|
3566
3362
|
});
|
|
@@ -3583,21 +3379,19 @@ const draw$5 = (node, props) => {
|
|
|
3583
3379
|
xValue
|
|
3584
3380
|
} = _ref9;
|
|
3585
3381
|
return xValue;
|
|
3586
|
-
}), max(data,
|
|
3382
|
+
}), max(data, _ref0 => {
|
|
3587
3383
|
let {
|
|
3588
3384
|
xValue
|
|
3589
|
-
} =
|
|
3385
|
+
} = _ref0;
|
|
3590
3386
|
return xValue;
|
|
3591
3387
|
})]).range([marginLeft + yAxisWidth + (yAxisPadding || 0) + yScaleLabelHeight, width - marginRight]);
|
|
3592
3388
|
customXScale && customXScale(xScale);
|
|
3593
3389
|
const xAxisBottom = axisBottom(xScale);
|
|
3594
|
-
|
|
3595
3390
|
if (typeof xScaleItemWidth === 'number') {
|
|
3596
3391
|
const [x1, x2] = xScale.range();
|
|
3597
3392
|
const chartWidth = x2 - x1;
|
|
3598
3393
|
xAxisBottom.ticks(Math.round(chartWidth / xScaleItemWidth)).tickSizeOuter(0);
|
|
3599
3394
|
}
|
|
3600
|
-
|
|
3601
3395
|
const xAxis = svg.append('g').call(xAxisBottom).attr('class', bubbleChartClassNames.bubbleChartXAxis);
|
|
3602
3396
|
customXAxis && customXAxis(xAxis);
|
|
3603
3397
|
yAxis.attr('transform', "translate(" + (marginLeft + yAxisWidth + yScaleLabelHeight) + ", 0)");
|
|
@@ -3610,38 +3404,37 @@ const draw$5 = (node, props) => {
|
|
|
3610
3404
|
drawGridX
|
|
3611
3405
|
});
|
|
3612
3406
|
xAxis.attr('transform', "translate(0, " + (yScale(yTicks[0]) + (xAxisPadding || 0)) + ")");
|
|
3613
|
-
const bubbles = svg.append('g').selectAll('dot').data(data).enter().append('circle').attr('class', bubbleChartClassNames.bubbleChartCircle).attr('cx',
|
|
3407
|
+
const bubbles = svg.append('g').selectAll('dot').data(data).enter().append('circle').attr('class', bubbleChartClassNames.bubbleChartCircle).attr('cx', _ref1 => {
|
|
3614
3408
|
let {
|
|
3615
3409
|
xValue
|
|
3616
|
-
} =
|
|
3410
|
+
} = _ref1;
|
|
3617
3411
|
return xScale(xValue);
|
|
3618
|
-
}).attr('cy',
|
|
3412
|
+
}).attr('cy', _ref10 => {
|
|
3619
3413
|
let {
|
|
3620
3414
|
yValue
|
|
3621
|
-
} =
|
|
3415
|
+
} = _ref10;
|
|
3622
3416
|
return yScale(yValue);
|
|
3623
|
-
}).attr('r',
|
|
3417
|
+
}).attr('r', _ref11 => {
|
|
3624
3418
|
let {
|
|
3625
3419
|
sizeValue
|
|
3626
|
-
} =
|
|
3420
|
+
} = _ref11;
|
|
3627
3421
|
return sizeScale(sizeValue) / 2;
|
|
3628
|
-
}).attr('fill',
|
|
3422
|
+
}).attr('fill', _ref12 => {
|
|
3629
3423
|
let {
|
|
3630
3424
|
color
|
|
3631
|
-
} =
|
|
3425
|
+
} = _ref12;
|
|
3632
3426
|
return color || 'rgba(0, 176, 113, 0.6)';
|
|
3633
|
-
}).attr('stroke',
|
|
3427
|
+
}).attr('stroke', _ref13 => {
|
|
3634
3428
|
let {
|
|
3635
3429
|
stroke
|
|
3636
|
-
} =
|
|
3430
|
+
} = _ref13;
|
|
3637
3431
|
return stroke || 'transparent';
|
|
3638
|
-
}).attr('style',
|
|
3432
|
+
}).attr('style', _ref14 => {
|
|
3639
3433
|
let {
|
|
3640
3434
|
style
|
|
3641
|
-
} =
|
|
3435
|
+
} = _ref14;
|
|
3642
3436
|
return style || bubbleStyle || '';
|
|
3643
3437
|
});
|
|
3644
|
-
|
|
3645
3438
|
if (enableTooltip) {
|
|
3646
3439
|
drawTooltip$3({
|
|
3647
3440
|
bubbles,
|
|
@@ -3650,7 +3443,6 @@ const draw$5 = (node, props) => {
|
|
|
3650
3443
|
renderTooltip
|
|
3651
3444
|
});
|
|
3652
3445
|
}
|
|
3653
|
-
|
|
3654
3446
|
customize && customize({
|
|
3655
3447
|
svg,
|
|
3656
3448
|
bubbles,
|
|
@@ -3680,9 +3472,7 @@ const BubbleChart = props => {
|
|
|
3680
3472
|
useEffect(() => {
|
|
3681
3473
|
return () => unmount(tooltipRoot);
|
|
3682
3474
|
}, [tooltipRoot]);
|
|
3683
|
-
|
|
3684
3475
|
const onDraw = () => draw$5(node, props);
|
|
3685
|
-
|
|
3686
3476
|
useResize(props.width, onDraw);
|
|
3687
3477
|
return React.createElement("div", {
|
|
3688
3478
|
className: className,
|