react-native-gifted-charts 1.3.33 → 1.4.1
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/README.md +9 -2
- package/package.json +2 -1
- package/src/BarChart/Animated2DWithGradient.tsx +13 -154
- package/src/BarChart/RenderBars.tsx +29 -179
- package/src/BarChart/RenderStackBars.tsx +22 -104
- package/src/BarChart/index.tsx +87 -686
- package/src/Components/AnimatedThreeDBar/index.tsx +16 -48
- package/src/Components/BarAndLineChartsWrapper/index.tsx +38 -283
- package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +17 -339
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +147 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +157 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +86 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +42 -0
- package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +1 -1
- package/src/Components/BarSpecificComponents/cap.tsx +1 -1
- package/src/Components/common/StripAndLabel.tsx +3 -56
- package/src/Components/lineSvg.tsx +1 -1
- package/src/LineChart/LineChartBicolor.tsx +80 -516
- package/src/LineChart/index.tsx +266 -1778
- package/src/PieChart/index.tsx +20 -84
- package/src/PieChart/main.tsx +47 -119
- package/src/PopulationPyramid/index.tsx +90 -203
- package/src/index.tsx +7 -12
- package/src/BarChart/types.ts +0 -394
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart.tsx +0 -402
- package/src/LineChart/types.ts +0 -575
- package/src/PieChart/types.ts +0 -77
- package/src/PopulationPyramid/types.ts +0 -200
- package/src/utils/constants.ts +0 -333
- package/src/utils/index.tsx +0 -1137
- package/src/utils/types.ts +0 -360
package/src/LineChart/index.tsx
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
Fragment,
|
|
3
|
-
useCallback,
|
|
4
|
-
useEffect,
|
|
5
|
-
useMemo,
|
|
6
|
-
useState,
|
|
7
|
-
useRef,
|
|
8
|
-
} from 'react';
|
|
1
|
+
import React, {Fragment, useCallback, useEffect, useMemo, useRef} from 'react';
|
|
9
2
|
import {
|
|
10
3
|
View,
|
|
11
4
|
Animated,
|
|
@@ -27,40 +20,19 @@ import Svg, {
|
|
|
27
20
|
Line,
|
|
28
21
|
} from 'react-native-svg';
|
|
29
22
|
import {
|
|
30
|
-
svgPath,
|
|
31
|
-
getArrowPoints,
|
|
32
|
-
getAxesAndRulesProps,
|
|
33
|
-
getExtendedContainerHeightWithPadding,
|
|
34
|
-
getSecondaryDataWithOffsetIncluded,
|
|
35
|
-
getAllArrowProperties,
|
|
36
|
-
computeMaxAndMinItems,
|
|
37
|
-
clone,
|
|
38
|
-
getCurvePathWithSegments,
|
|
39
23
|
getSegmentedPathObjects,
|
|
40
|
-
getSegmentString,
|
|
41
24
|
getRegionPathObjects,
|
|
42
|
-
getPathWithHighlight,
|
|
43
|
-
} from '../utils';
|
|
44
|
-
import {
|
|
45
|
-
AxesAndRulesDefaults,
|
|
46
|
-
LineDefaults,
|
|
47
25
|
RANGE_ENTER,
|
|
48
26
|
RANGE_EXIT,
|
|
49
27
|
SEGMENT_END,
|
|
50
28
|
SEGMENT_START,
|
|
51
29
|
STOP,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
defaultPointerConfig,
|
|
55
|
-
screenWidth,
|
|
56
|
-
} from '../utils/constants';
|
|
57
|
-
import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
|
|
58
|
-
import {LineChartPropsType, lineDataItem} from './types';
|
|
59
|
-
import {
|
|
60
|
-
BarAndLineChartsWrapperTypes,
|
|
61
|
-
EdgePosition,
|
|
30
|
+
LineChartPropsType,
|
|
31
|
+
lineDataItem,
|
|
62
32
|
LineSvgProps,
|
|
63
|
-
|
|
33
|
+
useLineChart,
|
|
34
|
+
} from 'gifted-charts-core';
|
|
35
|
+
import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
|
|
64
36
|
import {StripAndLabel} from '../Components/common/StripAndLabel';
|
|
65
37
|
import {Pointer} from '../Components/common/Pointer';
|
|
66
38
|
|
|
@@ -69,156 +41,6 @@ let animations: Array<any> = [];
|
|
|
69
41
|
|
|
70
42
|
export const LineChart = (props: LineChartPropsType) => {
|
|
71
43
|
const scrollRef = props.scrollRef ?? useRef(null);
|
|
72
|
-
const curvature = props.curvature ?? LineDefaults.curvature;
|
|
73
|
-
const curveType = props.curveType ?? LineDefaults.curveType;
|
|
74
|
-
const [scrollX, setScrollX] = useState(0);
|
|
75
|
-
const [arrow1Points, setArrow1Points] = useState('');
|
|
76
|
-
const [arrow2Points, setArrow2Points] = useState('');
|
|
77
|
-
const [arrow3Points, setArrow3Points] = useState('');
|
|
78
|
-
const [arrow4Points, setArrow4Points] = useState('');
|
|
79
|
-
const [arrow5Points, setArrow5Points] = useState('');
|
|
80
|
-
const [secondaryArrowPoints, setSecondaryArrowPoints] = useState('');
|
|
81
|
-
const [pointerIndex, setPointerIndex] = useState(-1);
|
|
82
|
-
const [pointerX, setPointerX] = useState(0);
|
|
83
|
-
const [pointerY, setPointerY] = useState(0);
|
|
84
|
-
const [pointerItem, setPointerItem] = useState({
|
|
85
|
-
pointerShiftX: 0,
|
|
86
|
-
pointerShiftY: 0,
|
|
87
|
-
});
|
|
88
|
-
const [pointerY2, setPointerY2] = useState(0);
|
|
89
|
-
const [pointerItem2, setPointerItem2] = useState({
|
|
90
|
-
pointerShiftX: 0,
|
|
91
|
-
pointerShiftY: 0,
|
|
92
|
-
});
|
|
93
|
-
const [pointerY3, setPointerY3] = useState(0);
|
|
94
|
-
const [pointerItem3, setPointerItem3] = useState({
|
|
95
|
-
pointerShiftX: 0,
|
|
96
|
-
pointerShiftY: 0,
|
|
97
|
-
});
|
|
98
|
-
const [pointerY4, setPointerY4] = useState(0);
|
|
99
|
-
const [pointerItem4, setPointerItem4] = useState({
|
|
100
|
-
pointerShiftX: 0,
|
|
101
|
-
pointerShiftY: 0,
|
|
102
|
-
});
|
|
103
|
-
const [pointerY5, setPointerY5] = useState(0);
|
|
104
|
-
const [pointerItem5, setPointerItem5] = useState({
|
|
105
|
-
pointerShiftX: 0,
|
|
106
|
-
pointerShiftY: 0,
|
|
107
|
-
});
|
|
108
|
-
const [secondaryPointerY, setSecondaryPointerY] = useState(0);
|
|
109
|
-
const [secondaryPointerItem, setSecondaryPointerItem] = useState({
|
|
110
|
-
pointerShiftX: 0,
|
|
111
|
-
pointerShiftY: 0,
|
|
112
|
-
});
|
|
113
|
-
const [responderStartTime, setResponderStartTime] = useState(0);
|
|
114
|
-
const [responderActive, setResponderActive] = useState(false);
|
|
115
|
-
const [points, setPoints] = useState('');
|
|
116
|
-
const [points2, setPoints2] = useState('');
|
|
117
|
-
const [points3, setPoints3] = useState('');
|
|
118
|
-
const [points4, setPoints4] = useState('');
|
|
119
|
-
const [points5, setPoints5] = useState('');
|
|
120
|
-
const [secondaryPoints, setSecondaryPoints] = useState('');
|
|
121
|
-
const [fillPoints, setFillPoints] = useState('');
|
|
122
|
-
const [fillPoints2, setFillPoints2] = useState('');
|
|
123
|
-
const [fillPoints3, setFillPoints3] = useState('');
|
|
124
|
-
const [fillPoints4, setFillPoints4] = useState('');
|
|
125
|
-
const [fillPoints5, setFillPoints5] = useState('');
|
|
126
|
-
const [secondaryFillPoints, setSecondaryFillPoints] = useState('');
|
|
127
|
-
|
|
128
|
-
const [pointsFromSet, setPointsFromSet] = useState<string[]>([]);
|
|
129
|
-
const [fillPointsFromSet, setFillPointsFromSet] = useState<string[]>([]);
|
|
130
|
-
const [arrowPointsFromSet, setArrowPointsFromSet] = useState<string[]>([]);
|
|
131
|
-
|
|
132
|
-
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
133
|
-
const noOfSections = props.noOfSections || 10;
|
|
134
|
-
const containerHeight =
|
|
135
|
-
props.height ??
|
|
136
|
-
((props.stepHeight ?? 0) * noOfSections ||
|
|
137
|
-
AxesAndRulesDefaults.containerHeight);
|
|
138
|
-
const data = useMemo(() => {
|
|
139
|
-
if (!props.data) {
|
|
140
|
-
return [];
|
|
141
|
-
}
|
|
142
|
-
if (props.yAxisOffset) {
|
|
143
|
-
return clone(props.data).map(item => {
|
|
144
|
-
item.value = item.value - (props.yAxisOffset ?? 0);
|
|
145
|
-
return item;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
return props.data;
|
|
149
|
-
}, [props.yAxisOffset, props.data]);
|
|
150
|
-
const data2 = useMemo(() => {
|
|
151
|
-
if (!props.data2) {
|
|
152
|
-
return [];
|
|
153
|
-
}
|
|
154
|
-
if (props.yAxisOffset) {
|
|
155
|
-
return clone(props.data2).map(item => {
|
|
156
|
-
item.value = item.value - (props.yAxisOffset ?? 0);
|
|
157
|
-
return item;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return props.data2;
|
|
161
|
-
}, [props.yAxisOffset, props.data2]);
|
|
162
|
-
const data3 = useMemo(() => {
|
|
163
|
-
if (!props.data3) {
|
|
164
|
-
return [];
|
|
165
|
-
}
|
|
166
|
-
if (props.yAxisOffset) {
|
|
167
|
-
return clone(props.data3).map(item => {
|
|
168
|
-
item.value = item.value - (props.yAxisOffset ?? 0);
|
|
169
|
-
return item;
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
return props.data3;
|
|
173
|
-
}, [props.yAxisOffset, props.data3]);
|
|
174
|
-
const data4 = useMemo(() => {
|
|
175
|
-
if (!props.data4) {
|
|
176
|
-
return [];
|
|
177
|
-
}
|
|
178
|
-
if (props.yAxisOffset) {
|
|
179
|
-
return clone(props.data4).map(item => {
|
|
180
|
-
item.value = item.value - (props.yAxisOffset ?? 0);
|
|
181
|
-
return item;
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
return props.data4;
|
|
185
|
-
}, [props.yAxisOffset, props.data4]);
|
|
186
|
-
const data5 = useMemo(() => {
|
|
187
|
-
if (!props.data5) {
|
|
188
|
-
return [];
|
|
189
|
-
}
|
|
190
|
-
if (props.yAxisOffset) {
|
|
191
|
-
return clone(props.data5).map(item => {
|
|
192
|
-
item.value = item.value - (props.yAxisOffset ?? 0);
|
|
193
|
-
return item;
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
return props.data5;
|
|
197
|
-
}, [props.yAxisOffset, props.data5]);
|
|
198
|
-
|
|
199
|
-
const secondaryData =
|
|
200
|
-
getSecondaryDataWithOffsetIncluded(
|
|
201
|
-
props.secondaryData,
|
|
202
|
-
props.secondaryYAxis,
|
|
203
|
-
) || [];
|
|
204
|
-
|
|
205
|
-
const dataSet = props.dataSet;
|
|
206
|
-
const data0 = useMemo(() => {
|
|
207
|
-
if (props.yAxisOffset) {
|
|
208
|
-
return dataSet?.[0]?.data;
|
|
209
|
-
} else {
|
|
210
|
-
return dataSet?.[0]?.data?.map(item => {
|
|
211
|
-
item.value = item.value - (props.yAxisOffset ?? 0);
|
|
212
|
-
return item;
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}, [props.yAxisOffset, dataSet]);
|
|
216
|
-
|
|
217
|
-
const scrollToEnd = props.scrollToEnd || LineDefaults.scrollToEnd;
|
|
218
|
-
const scrollAnimation = props.scrollAnimation ?? LineDefaults.scrollAnimation;
|
|
219
|
-
const scrollEventThrottle =
|
|
220
|
-
props.scrollEventThrottle ?? LineDefaults.scrollEventThrottle;
|
|
221
|
-
|
|
222
44
|
const opacValue = useMemo(() => new Animated.Value(0), []);
|
|
223
45
|
const widthValue = useMemo(() => new Animated.Value(0), []);
|
|
224
46
|
const widthValue2 = useMemo(() => new Animated.Value(0), []);
|
|
@@ -226,309 +48,263 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
226
48
|
const widthValue4 = useMemo(() => new Animated.Value(0), []);
|
|
227
49
|
const widthValue5 = useMemo(() => new Animated.Value(0), []);
|
|
228
50
|
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
51
|
+
const {
|
|
52
|
+
scrollX,
|
|
53
|
+
setScrollX,
|
|
54
|
+
arrow1Points,
|
|
55
|
+
arrow2Points,
|
|
56
|
+
arrow3Points,
|
|
57
|
+
arrow4Points,
|
|
58
|
+
arrow5Points,
|
|
59
|
+
secondaryArrowPoints,
|
|
60
|
+
setPointerIndex,
|
|
61
|
+
pointerX,
|
|
62
|
+
setPointerX,
|
|
63
|
+
pointerY,
|
|
64
|
+
setPointerY,
|
|
65
|
+
pointerItem,
|
|
66
|
+
setPointerItem,
|
|
67
|
+
pointerY2,
|
|
68
|
+
setPointerY2,
|
|
69
|
+
pointerItem2,
|
|
70
|
+
setPointerItem2,
|
|
71
|
+
pointerY3,
|
|
72
|
+
setPointerY3,
|
|
73
|
+
pointerItem3,
|
|
74
|
+
setPointerItem3,
|
|
75
|
+
pointerY4,
|
|
76
|
+
setPointerY4,
|
|
77
|
+
pointerItem4,
|
|
78
|
+
setPointerItem4,
|
|
79
|
+
pointerY5,
|
|
80
|
+
setPointerY5,
|
|
81
|
+
pointerItem5,
|
|
82
|
+
setPointerItem5,
|
|
83
|
+
secondaryPointerY,
|
|
84
|
+
setSecondaryPointerY,
|
|
85
|
+
secondaryPointerItem,
|
|
86
|
+
setSecondaryPointerItem,
|
|
87
|
+
responderStartTime,
|
|
88
|
+
setResponderStartTime,
|
|
89
|
+
setResponderActive,
|
|
90
|
+
points,
|
|
91
|
+
points2,
|
|
92
|
+
points3,
|
|
93
|
+
points4,
|
|
94
|
+
points5,
|
|
95
|
+
secondaryPoints,
|
|
96
|
+
fillPoints,
|
|
97
|
+
fillPoints2,
|
|
98
|
+
fillPoints3,
|
|
99
|
+
fillPoints4,
|
|
100
|
+
fillPoints5,
|
|
101
|
+
secondaryFillPoints,
|
|
102
|
+
pointsFromSet,
|
|
103
|
+
fillPointsFromSet,
|
|
104
|
+
arrowPointsFromSet,
|
|
105
|
+
selectedIndex,
|
|
106
|
+
setSelectedIndex,
|
|
107
|
+
noOfSections,
|
|
108
|
+
containerHeight,
|
|
109
|
+
data,
|
|
110
|
+
data2,
|
|
111
|
+
data3,
|
|
112
|
+
data4,
|
|
113
|
+
data5,
|
|
114
|
+
secondaryData,
|
|
115
|
+
dataSet,
|
|
116
|
+
data0,
|
|
117
|
+
labelsExtraHeight,
|
|
118
|
+
animationDuration,
|
|
119
|
+
onDataChangeAnimationDuration,
|
|
120
|
+
animateTogether,
|
|
121
|
+
animateOnDataChange,
|
|
122
|
+
startIndex1,
|
|
123
|
+
startIndex2,
|
|
124
|
+
endIndex1,
|
|
125
|
+
endIndex2,
|
|
126
|
+
startIndex3,
|
|
127
|
+
endIndex3,
|
|
128
|
+
startIndex4,
|
|
129
|
+
endIndex4,
|
|
130
|
+
startIndex5,
|
|
131
|
+
endIndex5,
|
|
132
|
+
initialSpacing,
|
|
133
|
+
thickness,
|
|
134
|
+
yAxisLabelWidth,
|
|
135
|
+
spacing,
|
|
136
|
+
xAxisThickness,
|
|
137
|
+
dataPointsHeight1,
|
|
138
|
+
dataPointsWidth1,
|
|
139
|
+
dataPointsRadius1,
|
|
140
|
+
dataPointsColor1,
|
|
141
|
+
dataPointsShape1,
|
|
142
|
+
dataPointsHeight2,
|
|
143
|
+
dataPointsWidth2,
|
|
144
|
+
dataPointsRadius2,
|
|
145
|
+
dataPointsColor2,
|
|
146
|
+
dataPointsShape2,
|
|
147
|
+
dataPointsHeight3,
|
|
148
|
+
dataPointsWidth3,
|
|
149
|
+
dataPointsRadius3,
|
|
150
|
+
dataPointsColor3,
|
|
151
|
+
dataPointsShape3,
|
|
152
|
+
dataPointsHeight4,
|
|
153
|
+
dataPointsWidth4,
|
|
154
|
+
dataPointsRadius4,
|
|
155
|
+
dataPointsColor4,
|
|
156
|
+
dataPointsShape4,
|
|
157
|
+
dataPointsHeight5,
|
|
158
|
+
dataPointsWidth5,
|
|
159
|
+
dataPointsRadius5,
|
|
160
|
+
dataPointsColor5,
|
|
161
|
+
dataPointsShape5,
|
|
162
|
+
atLeastOneAreaChart,
|
|
163
|
+
textFontSize1,
|
|
164
|
+
textFontSize2,
|
|
165
|
+
textFontSize3,
|
|
166
|
+
textFontSize4,
|
|
167
|
+
textFontSize5,
|
|
168
|
+
textColor1,
|
|
169
|
+
textColor2,
|
|
170
|
+
textColor3,
|
|
171
|
+
textColor4,
|
|
172
|
+
textColor5,
|
|
173
|
+
totalWidth,
|
|
174
|
+
maxValue,
|
|
175
|
+
overflowTop,
|
|
176
|
+
extendedContainerHeight,
|
|
177
|
+
getX,
|
|
178
|
+
getY,
|
|
179
|
+
getSecondaryY,
|
|
180
|
+
showValuesAsDataPointsText,
|
|
181
|
+
thickness1,
|
|
182
|
+
thickness2,
|
|
183
|
+
thickness3,
|
|
184
|
+
thickness4,
|
|
185
|
+
thickness5,
|
|
186
|
+
zIndex1,
|
|
187
|
+
zIndex2,
|
|
188
|
+
zIndex3,
|
|
189
|
+
zIndex4,
|
|
190
|
+
zIndex5,
|
|
191
|
+
strokeDashArray1,
|
|
192
|
+
strokeDashArray2,
|
|
193
|
+
strokeDashArray3,
|
|
194
|
+
strokeDashArray4,
|
|
195
|
+
strokeDashArray5,
|
|
196
|
+
rotateLabel,
|
|
197
|
+
isAnimated,
|
|
198
|
+
hideDataPoints1,
|
|
199
|
+
hideDataPoints2,
|
|
200
|
+
hideDataPoints3,
|
|
201
|
+
hideDataPoints4,
|
|
202
|
+
hideDataPoints5,
|
|
203
|
+
color1,
|
|
204
|
+
color2,
|
|
205
|
+
color3,
|
|
206
|
+
color4,
|
|
207
|
+
color5,
|
|
208
|
+
startFillColor1,
|
|
209
|
+
endFillColor1,
|
|
210
|
+
startOpacity1,
|
|
211
|
+
endOpacity1,
|
|
212
|
+
startFillColor2,
|
|
213
|
+
endFillColor2,
|
|
214
|
+
startOpacity2,
|
|
215
|
+
endOpacity2,
|
|
216
|
+
startFillColor3,
|
|
217
|
+
endFillColor3,
|
|
218
|
+
startOpacity3,
|
|
219
|
+
endOpacity3,
|
|
220
|
+
startFillColor4,
|
|
221
|
+
endFillColor4,
|
|
222
|
+
startOpacity4,
|
|
223
|
+
endOpacity4,
|
|
224
|
+
startFillColor5,
|
|
225
|
+
endFillColor5,
|
|
226
|
+
startOpacity5,
|
|
227
|
+
endOpacity5,
|
|
228
|
+
arrowStrokeWidth1,
|
|
229
|
+
arrowStrokeColor1,
|
|
230
|
+
arrowFillColor1,
|
|
231
|
+
arrowStrokeWidth2,
|
|
232
|
+
arrowStrokeColor2,
|
|
233
|
+
arrowFillColor2,
|
|
234
|
+
arrowStrokeWidth3,
|
|
235
|
+
arrowStrokeColor3,
|
|
236
|
+
arrowFillColor3,
|
|
237
|
+
arrowStrokeWidth4,
|
|
238
|
+
arrowStrokeColor4,
|
|
239
|
+
arrowFillColor4,
|
|
240
|
+
arrowStrokeWidth5,
|
|
241
|
+
arrowStrokeColor5,
|
|
242
|
+
arrowFillColor5,
|
|
243
|
+
arrowStrokeWidthsFromSet,
|
|
244
|
+
arrowStrokeColorsFromSet,
|
|
245
|
+
arrowFillColorsFromSet,
|
|
246
|
+
secondaryLineConfig,
|
|
247
|
+
gradientDirection,
|
|
248
|
+
stepHeight,
|
|
249
|
+
noOfSectionsBelowXAxis,
|
|
250
|
+
xAxisTextNumberOfLines,
|
|
251
|
+
xAxisLabelsVerticalShift,
|
|
252
|
+
pointerConfig,
|
|
253
|
+
pointerHeight,
|
|
254
|
+
pointerWidth,
|
|
255
|
+
pointerRadius,
|
|
256
|
+
pointerColor,
|
|
257
|
+
pointerComponent,
|
|
258
|
+
showPointerStrip,
|
|
259
|
+
pointerStripHeight,
|
|
260
|
+
pointerStripWidth,
|
|
261
|
+
pointerStripColor,
|
|
262
|
+
pointerStripUptoDataPoint,
|
|
263
|
+
pointerLabelComponent,
|
|
264
|
+
stripOverPointer,
|
|
265
|
+
shiftPointerLabelX,
|
|
266
|
+
shiftPointerLabelY,
|
|
267
|
+
pointerLabelWidth,
|
|
268
|
+
pointerLabelHeight,
|
|
269
|
+
autoAdjustPointerLabelPosition,
|
|
270
|
+
pointerVanishDelay,
|
|
271
|
+
activatePointersOnLongPress,
|
|
272
|
+
activatePointersDelay,
|
|
273
|
+
persistPointer,
|
|
274
|
+
hidePointer1,
|
|
275
|
+
hidePointer2,
|
|
276
|
+
hidePointer3,
|
|
277
|
+
hidePointer4,
|
|
278
|
+
hidePointer5,
|
|
279
|
+
hideSecondaryPointer,
|
|
280
|
+
pointerEvents,
|
|
281
|
+
focusEnabled,
|
|
282
|
+
showDataPointOnFocus,
|
|
283
|
+
showStripOnFocus,
|
|
284
|
+
showTextOnFocus,
|
|
285
|
+
stripHeight,
|
|
286
|
+
stripWidth,
|
|
287
|
+
stripColor,
|
|
288
|
+
stripOpacity,
|
|
289
|
+
unFocusOnPressOut,
|
|
290
|
+
delayBeforeUnFocus,
|
|
291
|
+
containerHeightIncludingBelowXAxis,
|
|
292
|
+
lineGradient,
|
|
293
|
+
lineGradientDirection,
|
|
294
|
+
lineGradientStartColor,
|
|
295
|
+
lineGradientEndColor,
|
|
296
|
+
barAndLineChartsWrapperProps,
|
|
297
|
+
} = useLineChart({...props, animations});
|
|
275
298
|
|
|
276
299
|
if (!initialData) {
|
|
277
300
|
initialData = data0 ?? [...data];
|
|
278
301
|
animations = initialData.map(item => new Animated.Value(item.value));
|
|
279
302
|
}
|
|
280
303
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const adjustToWidth = props.adjustToWidth || false;
|
|
286
|
-
|
|
287
|
-
const initialSpacing = props.initialSpacing ?? LineDefaults.initialSpacing;
|
|
288
|
-
const endSpacing =
|
|
289
|
-
props.endSpacing ?? (adjustToWidth ? 0 : LineDefaults.endSpacing);
|
|
290
|
-
|
|
291
|
-
const thickness = props.thickness || LineDefaults.thickness;
|
|
292
|
-
|
|
293
|
-
const yAxisLabelWidth =
|
|
294
|
-
props.yAxisLabelWidth ??
|
|
295
|
-
(props.hideYAxisText
|
|
296
|
-
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
297
|
-
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
298
|
-
|
|
299
|
-
const spacing =
|
|
300
|
-
props.spacing ??
|
|
301
|
-
(adjustToWidth
|
|
302
|
-
? ((props.width ?? screenWidth - yAxisLabelWidth) - initialSpacing) /
|
|
303
|
-
Math.max((data0 ?? data).length - 1, 1)
|
|
304
|
-
: LineDefaults.spacing);
|
|
305
|
-
|
|
306
|
-
const xAxisThickness =
|
|
307
|
-
props.xAxisThickness ?? AxesAndRulesDefaults.xAxisThickness;
|
|
308
|
-
const dataPointsHeight1 =
|
|
309
|
-
props.dataPointsHeight1 ??
|
|
310
|
-
props.dataPointsHeight ??
|
|
311
|
-
LineDefaults.dataPointsHeight;
|
|
312
|
-
const dataPointsWidth1 =
|
|
313
|
-
props.dataPointsWidth1 ??
|
|
314
|
-
props.dataPointsWidth ??
|
|
315
|
-
LineDefaults.dataPointsWidth;
|
|
316
|
-
const dataPointsRadius1 =
|
|
317
|
-
props.dataPointsRadius1 ??
|
|
318
|
-
props.dataPointsRadius ??
|
|
319
|
-
LineDefaults.dataPointsRadius;
|
|
320
|
-
const dataPointsColor1 =
|
|
321
|
-
props.dataPointsColor1 ??
|
|
322
|
-
props.dataPointsColor ??
|
|
323
|
-
LineDefaults.dataPointsColor;
|
|
324
|
-
const dataPointsShape1 =
|
|
325
|
-
props.dataPointsShape1 ??
|
|
326
|
-
props.dataPointsShape ??
|
|
327
|
-
LineDefaults.dataPointsShape;
|
|
328
|
-
|
|
329
|
-
const dataPointsHeight2 =
|
|
330
|
-
props.dataPointsHeight2 ??
|
|
331
|
-
props.dataPointsHeight ??
|
|
332
|
-
LineDefaults.dataPointsHeight;
|
|
333
|
-
const dataPointsWidth2 =
|
|
334
|
-
props.dataPointsWidth2 ??
|
|
335
|
-
props.dataPointsWidth ??
|
|
336
|
-
LineDefaults.dataPointsWidth;
|
|
337
|
-
const dataPointsRadius2 =
|
|
338
|
-
props.dataPointsRadius2 ??
|
|
339
|
-
props.dataPointsRadius ??
|
|
340
|
-
LineDefaults.dataPointsRadius;
|
|
341
|
-
const dataPointsColor2 =
|
|
342
|
-
props.dataPointsColor2 ??
|
|
343
|
-
props.dataPointsColor ??
|
|
344
|
-
LineDefaults.dataPointsColor2;
|
|
345
|
-
const dataPointsShape2 =
|
|
346
|
-
props.dataPointsShape2 ??
|
|
347
|
-
props.dataPointsShape ??
|
|
348
|
-
LineDefaults.dataPointsShape;
|
|
349
|
-
|
|
350
|
-
const dataPointsHeight3 =
|
|
351
|
-
props.dataPointsHeight3 ??
|
|
352
|
-
props.dataPointsHeight ??
|
|
353
|
-
LineDefaults.dataPointsHeight;
|
|
354
|
-
const dataPointsWidth3 =
|
|
355
|
-
props.dataPointsWidth3 ??
|
|
356
|
-
props.dataPointsWidth ??
|
|
357
|
-
LineDefaults.dataPointsWidth;
|
|
358
|
-
const dataPointsRadius3 =
|
|
359
|
-
props.dataPointsRadius3 ??
|
|
360
|
-
props.dataPointsRadius ??
|
|
361
|
-
LineDefaults.dataPointsRadius;
|
|
362
|
-
const dataPointsColor3 =
|
|
363
|
-
props.dataPointsColor3 ??
|
|
364
|
-
props.dataPointsColor ??
|
|
365
|
-
LineDefaults.dataPointsColor3;
|
|
366
|
-
const dataPointsShape3 =
|
|
367
|
-
props.dataPointsShape3 ??
|
|
368
|
-
props.dataPointsShape ??
|
|
369
|
-
LineDefaults.dataPointsShape;
|
|
370
|
-
|
|
371
|
-
const dataPointsHeight4 =
|
|
372
|
-
props.dataPointsHeight4 ??
|
|
373
|
-
props.dataPointsHeight ??
|
|
374
|
-
LineDefaults.dataPointsHeight;
|
|
375
|
-
const dataPointsWidth4 =
|
|
376
|
-
props.dataPointsWidth4 ??
|
|
377
|
-
props.dataPointsWidth ??
|
|
378
|
-
LineDefaults.dataPointsWidth;
|
|
379
|
-
const dataPointsRadius4 =
|
|
380
|
-
props.dataPointsRadius4 ??
|
|
381
|
-
props.dataPointsRadius ??
|
|
382
|
-
LineDefaults.dataPointsRadius;
|
|
383
|
-
const dataPointsColor4 =
|
|
384
|
-
props.dataPointsColor4 ??
|
|
385
|
-
props.dataPointsColor ??
|
|
386
|
-
LineDefaults.dataPointsColor;
|
|
387
|
-
const dataPointsShape4 =
|
|
388
|
-
props.dataPointsShape4 ??
|
|
389
|
-
props.dataPointsShape ??
|
|
390
|
-
LineDefaults.dataPointsShape;
|
|
391
|
-
|
|
392
|
-
const dataPointsHeight5 =
|
|
393
|
-
props.dataPointsHeight5 ??
|
|
394
|
-
props.dataPointsHeight ??
|
|
395
|
-
LineDefaults.dataPointsHeight;
|
|
396
|
-
const dataPointsWidth5 =
|
|
397
|
-
props.dataPointsWidth5 ??
|
|
398
|
-
props.dataPointsWidth ??
|
|
399
|
-
LineDefaults.dataPointsWidth;
|
|
400
|
-
const dataPointsRadius5 =
|
|
401
|
-
props.dataPointsRadius5 ??
|
|
402
|
-
props.dataPointsRadius ??
|
|
403
|
-
LineDefaults.dataPointsRadius;
|
|
404
|
-
const dataPointsColor5 =
|
|
405
|
-
props.dataPointsColor5 ??
|
|
406
|
-
props.dataPointsColor ??
|
|
407
|
-
LineDefaults.dataPointsColor;
|
|
408
|
-
const dataPointsShape5 =
|
|
409
|
-
props.dataPointsShape5 ??
|
|
410
|
-
props.dataPointsShape ??
|
|
411
|
-
LineDefaults.dataPointsShape;
|
|
412
|
-
|
|
413
|
-
const areaChart = props.areaChart ?? false;
|
|
414
|
-
const areaChart1 = props.areaChart1 ?? false;
|
|
415
|
-
const areaChart2 = props.areaChart2 ?? false;
|
|
416
|
-
const areaChart3 = props.areaChart3 ?? false;
|
|
417
|
-
const areaChart4 = props.areaChart4 ?? false;
|
|
418
|
-
const areaChart5 = props.areaChart5 ?? false;
|
|
419
|
-
|
|
420
|
-
const atLeastOneAreaChart =
|
|
421
|
-
dataSet?.some(set => set.areaChart) ||
|
|
422
|
-
areaChart ||
|
|
423
|
-
areaChart1 ||
|
|
424
|
-
areaChart2 ||
|
|
425
|
-
areaChart3 ||
|
|
426
|
-
areaChart4 ||
|
|
427
|
-
areaChart5;
|
|
428
|
-
|
|
429
|
-
const stepChart = props.stepChart ?? false;
|
|
430
|
-
const stepChart1 = props.stepChart1 ?? false;
|
|
431
|
-
const stepChart2 = props.stepChart2 ?? false;
|
|
432
|
-
const stepChart3 = props.stepChart3 ?? false;
|
|
433
|
-
const stepChart4 = props.stepChart4 ?? false;
|
|
434
|
-
const stepChart5 = props.stepChart5 ?? false;
|
|
435
|
-
|
|
436
|
-
const edgePosition = props.edgePosition ?? LineDefaults.edgePosition;
|
|
437
|
-
|
|
438
|
-
const textFontSize1 =
|
|
439
|
-
props.textFontSize1 ?? props.textFontSize ?? LineDefaults.textFontSize;
|
|
440
|
-
const textFontSize2 =
|
|
441
|
-
props.textFontSize2 ?? props.textFontSize ?? LineDefaults.textFontSize;
|
|
442
|
-
const textFontSize3 =
|
|
443
|
-
props.textFontSize3 ?? props.textFontSize ?? LineDefaults.textFontSize;
|
|
444
|
-
const textFontSize4 =
|
|
445
|
-
props.textFontSize4 ?? props.textFontSize ?? LineDefaults.textFontSize;
|
|
446
|
-
const textFontSize5 =
|
|
447
|
-
props.textFontSize5 ?? props.textFontSize ?? LineDefaults.textFontSize;
|
|
448
|
-
const textColor1 =
|
|
449
|
-
props.textColor1 ?? props.textColor ?? LineDefaults.textColor;
|
|
450
|
-
const textColor2 =
|
|
451
|
-
props.textColor2 ?? props.textColor ?? LineDefaults.textColor;
|
|
452
|
-
const textColor3 =
|
|
453
|
-
props.textColor3 ?? props.textColor ?? LineDefaults.textColor;
|
|
454
|
-
const textColor4 =
|
|
455
|
-
props.textColor4 ?? props.textColor ?? LineDefaults.textColor;
|
|
456
|
-
const textColor5 =
|
|
457
|
-
props.textColor5 ?? props.textColor ?? LineDefaults.textColor;
|
|
458
|
-
|
|
459
|
-
const totalWidth = initialSpacing + spacing * (data0 ?? data).length;
|
|
460
|
-
|
|
461
|
-
const {maxItem, minItem} = computeMaxAndMinItems(
|
|
462
|
-
data0 ?? data,
|
|
463
|
-
props.roundToDigits,
|
|
464
|
-
props.showFractionalValues,
|
|
465
|
-
);
|
|
466
|
-
|
|
467
|
-
const maxValue = props.maxValue || maxItem;
|
|
468
|
-
const mostNegativeValue = props.mostNegativeValue || minItem;
|
|
469
|
-
|
|
470
|
-
const overflowTop = props.overflowTop ?? 0;
|
|
471
|
-
|
|
472
|
-
const extendedContainerHeight = getExtendedContainerHeightWithPadding(
|
|
473
|
-
containerHeight,
|
|
474
|
-
overflowTop,
|
|
475
|
-
);
|
|
476
|
-
const getX = index => initialSpacing + spacing * index - 1;
|
|
477
|
-
const getY = value =>
|
|
478
|
-
extendedContainerHeight - (value * containerHeight) / maxValue;
|
|
479
|
-
|
|
480
|
-
const {maxItem: secondaryMaxItem} = computeMaxAndMinItems(
|
|
481
|
-
secondaryData,
|
|
482
|
-
props.secondaryYAxis?.roundToDigits,
|
|
483
|
-
props.secondaryYAxis?.showFractionalValues,
|
|
304
|
+
const widthValuesFromSet = useMemo(
|
|
305
|
+
() => dataSet?.map(set => new Animated.Value(0)),
|
|
306
|
+
[],
|
|
484
307
|
);
|
|
485
|
-
const secondaryMaxValue =
|
|
486
|
-
props.secondaryYAxis?.maxValue ?? (secondaryMaxItem || maxValue);
|
|
487
|
-
const getSecondaryY = value =>
|
|
488
|
-
extendedContainerHeight - (value * containerHeight) / secondaryMaxValue;
|
|
489
|
-
const heightUptoXaxis = extendedContainerHeight - xAxisThickness;
|
|
490
|
-
|
|
491
|
-
if (animateOnDataChange) {
|
|
492
|
-
animations.forEach((item, index) => {
|
|
493
|
-
item.addListener(val => {
|
|
494
|
-
const temp = data[index]?.value ?? 0;
|
|
495
|
-
data[index].value = val.value;
|
|
496
|
-
let pp = '',
|
|
497
|
-
ppp = '';
|
|
498
|
-
if (!(dataSet?.[0].curved ?? props.curved)) {
|
|
499
|
-
for (let i = 0; i < (data0 ?? data).length; i++) {
|
|
500
|
-
pp += 'L' + getX(i) + ' ' + getY((data0 ?? data)[i].value) + ' ';
|
|
501
|
-
}
|
|
502
|
-
if (dataSet?.[0]?.areaChart ?? areaChart) {
|
|
503
|
-
ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
504
|
-
ppp += pp;
|
|
505
|
-
ppp +=
|
|
506
|
-
'L' +
|
|
507
|
-
(initialSpacing + spacing * (data.length - 1)) +
|
|
508
|
-
' ' +
|
|
509
|
-
heightUptoXaxis;
|
|
510
|
-
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
511
|
-
}
|
|
512
|
-
newPoints = pp;
|
|
513
|
-
newFillPoints = ppp;
|
|
514
|
-
setPointsOnChange();
|
|
515
|
-
}
|
|
516
|
-
counter++;
|
|
517
|
-
data[index].value = temp;
|
|
518
|
-
});
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
const setPointsOnChange = () => {
|
|
523
|
-
if (counter === data.length) {
|
|
524
|
-
if (!props.curved) {
|
|
525
|
-
setPoints(newPoints.replace('L', 'M'));
|
|
526
|
-
if (areaChart) {
|
|
527
|
-
setFillPoints(newFillPoints.replace('L', 'M'));
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
308
|
|
|
533
309
|
useEffect(() => {
|
|
534
310
|
if (animateOnDataChange) {
|
|
@@ -669,1233 +445,6 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
669
445
|
labelsAppear,
|
|
670
446
|
]);
|
|
671
447
|
|
|
672
|
-
const showValuesAsDataPointsText =
|
|
673
|
-
props.showValuesAsDataPointsText ?? LineDefaults.showValuesAsDataPointsText;
|
|
674
|
-
|
|
675
|
-
const thickness1 =
|
|
676
|
-
props.thickness1 ?? props.thickness ?? LineDefaults.thickness;
|
|
677
|
-
const thickness2 =
|
|
678
|
-
props.thickness2 ?? props.thickness ?? LineDefaults.thickness;
|
|
679
|
-
const thickness3 =
|
|
680
|
-
props.thickness3 ?? props.thickness ?? LineDefaults.thickness;
|
|
681
|
-
const thickness4 =
|
|
682
|
-
props.thickness4 ?? props.thickness ?? LineDefaults.thickness;
|
|
683
|
-
const thickness5 =
|
|
684
|
-
props.thickness5 ?? props.thickness ?? LineDefaults.thickness;
|
|
685
|
-
|
|
686
|
-
const zIndex1 = props.zIndex1 ?? 0;
|
|
687
|
-
const zIndex2 = props.zIndex2 ?? 0;
|
|
688
|
-
const zIndex3 = props.zIndex3 ?? 0;
|
|
689
|
-
const zIndex4 = props.zIndex4 ?? 0;
|
|
690
|
-
const zIndex5 = props.zIndex5 ?? 0;
|
|
691
|
-
|
|
692
|
-
const strokeDashArray1 = props.strokeDashArray1 ?? props.strokeDashArray;
|
|
693
|
-
const strokeDashArray2 = props.strokeDashArray2 ?? props.strokeDashArray;
|
|
694
|
-
const strokeDashArray3 = props.strokeDashArray3 ?? props.strokeDashArray;
|
|
695
|
-
const strokeDashArray4 = props.strokeDashArray4 ?? props.strokeDashArray;
|
|
696
|
-
const strokeDashArray5 = props.strokeDashArray5 ?? props.strokeDashArray;
|
|
697
|
-
|
|
698
|
-
const rotateLabel = props.rotateLabel ?? false;
|
|
699
|
-
const isAnimated = props.isAnimated ?? false;
|
|
700
|
-
const hideDataPoints1 =
|
|
701
|
-
props.hideDataPoints ?? props.hideDataPoints1 ?? false;
|
|
702
|
-
const hideDataPoints2 =
|
|
703
|
-
props.hideDataPoints ?? props.hideDataPoints2 ?? false;
|
|
704
|
-
const hideDataPoints3 =
|
|
705
|
-
props.hideDataPoints ?? props.hideDataPoints3 ?? false;
|
|
706
|
-
const hideDataPoints4 =
|
|
707
|
-
props.hideDataPoints ?? props.hideDataPoints4 ?? false;
|
|
708
|
-
const hideDataPoints5 =
|
|
709
|
-
props.hideDataPoints ?? props.hideDataPoints5 ?? false;
|
|
710
|
-
|
|
711
|
-
const color1 = props.color1 ?? props.color ?? LineDefaults.color;
|
|
712
|
-
const color2 = props.color2 ?? props.color ?? LineDefaults.color;
|
|
713
|
-
const color3 = props.color3 ?? props.color ?? LineDefaults.color;
|
|
714
|
-
const color4 = props.color4 ?? props.color ?? LineDefaults.color;
|
|
715
|
-
const color5 = props.color5 ?? props.color ?? LineDefaults.color;
|
|
716
|
-
|
|
717
|
-
const startFillColor1 =
|
|
718
|
-
props.startFillColor1 ??
|
|
719
|
-
props.startFillColor ??
|
|
720
|
-
LineDefaults.startFillColor;
|
|
721
|
-
const endFillColor1 =
|
|
722
|
-
props.endFillColor1 ?? props.endFillColor ?? LineDefaults.endFillColor;
|
|
723
|
-
const startOpacity = props.startOpacity ?? LineDefaults.startOpacity;
|
|
724
|
-
const endOpacity = props.endOpacity ?? LineDefaults.endOpacity;
|
|
725
|
-
const startOpacity1 = props.startOpacity1 ?? startOpacity;
|
|
726
|
-
const endOpacity1 = props.endOpacity1 ?? endOpacity;
|
|
727
|
-
|
|
728
|
-
const startFillColor2 =
|
|
729
|
-
props.startFillColor2 ??
|
|
730
|
-
props.startFillColor ??
|
|
731
|
-
LineDefaults.startFillColor;
|
|
732
|
-
const endFillColor2 =
|
|
733
|
-
props.endFillColor2 ?? props.endFillColor ?? LineDefaults.endFillColor;
|
|
734
|
-
const startOpacity2 = props.startOpacity2 ?? startOpacity;
|
|
735
|
-
const endOpacity2 = props.endOpacity2 ?? endOpacity;
|
|
736
|
-
|
|
737
|
-
const startFillColor3 =
|
|
738
|
-
props.startFillColor3 ??
|
|
739
|
-
props.startFillColor ??
|
|
740
|
-
LineDefaults.startFillColor;
|
|
741
|
-
const endFillColor3 =
|
|
742
|
-
props.endFillColor3 ?? props.endFillColor ?? LineDefaults.endFillColor;
|
|
743
|
-
const startOpacity3 = props.startOpacity3 ?? startOpacity;
|
|
744
|
-
const endOpacity3 = props.endOpacity3 ?? endOpacity;
|
|
745
|
-
|
|
746
|
-
const startFillColor4 =
|
|
747
|
-
props.startFillColor4 ??
|
|
748
|
-
props.startFillColor ??
|
|
749
|
-
LineDefaults.startFillColor;
|
|
750
|
-
const endFillColor4 =
|
|
751
|
-
props.endFillColor4 ?? props.endFillColor ?? LineDefaults.endFillColor;
|
|
752
|
-
const startOpacity4 = props.startOpacity4 ?? startOpacity;
|
|
753
|
-
const endOpacity4 = props.endOpacity4 ?? endOpacity;
|
|
754
|
-
|
|
755
|
-
const startFillColor5 =
|
|
756
|
-
props.startFillColor5 ??
|
|
757
|
-
props.startFillColor ??
|
|
758
|
-
LineDefaults.startFillColor;
|
|
759
|
-
const endFillColor5 =
|
|
760
|
-
props.endFillColor5 ?? props.endFillColor ?? LineDefaults.endFillColor;
|
|
761
|
-
const startOpacity5 = props.startOpacity5 ?? startOpacity;
|
|
762
|
-
const endOpacity5 = props.endOpacity5 ?? endOpacity;
|
|
763
|
-
|
|
764
|
-
defaultArrowConfig.strokeWidth = dataSet?.[0]?.thickness ?? thickness1;
|
|
765
|
-
defaultArrowConfig.strokeColor = dataSet?.[0]?.color ?? color1;
|
|
766
|
-
|
|
767
|
-
const {
|
|
768
|
-
arrowLength1,
|
|
769
|
-
arrowWidth1,
|
|
770
|
-
arrowStrokeWidth1,
|
|
771
|
-
arrowStrokeColor1,
|
|
772
|
-
arrowFillColor1,
|
|
773
|
-
showArrowBase1,
|
|
774
|
-
arrowLength2,
|
|
775
|
-
arrowWidth2,
|
|
776
|
-
arrowStrokeWidth2,
|
|
777
|
-
arrowStrokeColor2,
|
|
778
|
-
arrowFillColor2,
|
|
779
|
-
showArrowBase2,
|
|
780
|
-
arrowLength3,
|
|
781
|
-
arrowWidth3,
|
|
782
|
-
arrowStrokeWidth3,
|
|
783
|
-
arrowStrokeColor3,
|
|
784
|
-
arrowFillColor3,
|
|
785
|
-
showArrowBase3,
|
|
786
|
-
arrowLength4,
|
|
787
|
-
arrowWidth4,
|
|
788
|
-
arrowStrokeWidth4,
|
|
789
|
-
arrowStrokeColor4,
|
|
790
|
-
arrowFillColor4,
|
|
791
|
-
showArrowBase4,
|
|
792
|
-
arrowLength5,
|
|
793
|
-
arrowWidth5,
|
|
794
|
-
arrowStrokeWidth5,
|
|
795
|
-
arrowStrokeColor5,
|
|
796
|
-
arrowFillColor5,
|
|
797
|
-
showArrowBase5,
|
|
798
|
-
arrowLengthsFromSet,
|
|
799
|
-
arrowWidthsFromSet,
|
|
800
|
-
arrowStrokeWidthsFromSet,
|
|
801
|
-
arrowStrokeColorsFromSet,
|
|
802
|
-
arrowFillColorsFromSet,
|
|
803
|
-
showArrowBasesFromSet,
|
|
804
|
-
} = getAllArrowProperties(props, defaultArrowConfig);
|
|
805
|
-
|
|
806
|
-
const secondaryLineConfig = {
|
|
807
|
-
zIndex: props.secondaryLineConfig?.zIndex ?? zIndex1,
|
|
808
|
-
curved: props.secondaryLineConfig?.curved ?? props.curved,
|
|
809
|
-
curvature: props.secondaryLineConfig?.curvature ?? curvature,
|
|
810
|
-
curveType: props.secondaryLineConfig?.curveType ?? curveType,
|
|
811
|
-
areaChart: props.secondaryLineConfig?.areaChart ?? areaChart,
|
|
812
|
-
color: props.secondaryLineConfig?.color ?? color1,
|
|
813
|
-
thickness: props.secondaryLineConfig?.thickness ?? thickness1,
|
|
814
|
-
zIndex1: props.secondaryLineConfig?.zIndex1 ?? zIndex1,
|
|
815
|
-
strokeDashArray:
|
|
816
|
-
props.secondaryLineConfig?.strokeDashArray ?? strokeDashArray1,
|
|
817
|
-
startIndex: props.secondaryLineConfig?.startIndex ?? startIndex1,
|
|
818
|
-
endIndex: props.secondaryLineConfig?.endIndex ?? endIndex1,
|
|
819
|
-
hideDataPoints:
|
|
820
|
-
props.secondaryLineConfig?.hideDataPoints ?? hideDataPoints1,
|
|
821
|
-
dataPointsHeight:
|
|
822
|
-
props.secondaryLineConfig?.dataPointsHeight ?? dataPointsHeight1,
|
|
823
|
-
dataPointsWidth:
|
|
824
|
-
props.secondaryLineConfig?.dataPointsWidth ?? dataPointsWidth1,
|
|
825
|
-
dataPointsRadius:
|
|
826
|
-
props.secondaryLineConfig?.dataPointsRadius ?? dataPointsRadius1,
|
|
827
|
-
dataPointsColor:
|
|
828
|
-
props.secondaryLineConfig?.dataPointsColor ?? dataPointsColor1,
|
|
829
|
-
dataPointsShape:
|
|
830
|
-
props.secondaryLineConfig?.dataPointsShape ?? dataPointsShape1,
|
|
831
|
-
showValuesAsDataPointsText:
|
|
832
|
-
props.secondaryLineConfig?.showValuesAsDataPointsText ??
|
|
833
|
-
showValuesAsDataPointsText,
|
|
834
|
-
startFillColor:
|
|
835
|
-
props.secondaryLineConfig?.startFillColor ?? startFillColor1,
|
|
836
|
-
endFillColor: props.secondaryLineConfig?.endFillColor ?? endFillColor1,
|
|
837
|
-
startOpacity: props.secondaryLineConfig?.startOpacity ?? startOpacity1,
|
|
838
|
-
endOpacity: props.secondaryLineConfig?.endOpacity ?? endOpacity1,
|
|
839
|
-
textFontSize: props.secondaryLineConfig?.textFontSize ?? textFontSize1,
|
|
840
|
-
textColor: props.secondaryLineConfig?.textColor ?? textColor1,
|
|
841
|
-
showArrow: props.secondaryLineConfig?.showArrow ?? props.showArrows,
|
|
842
|
-
arrowConfig: props.secondaryLineConfig?.arrowConfig ?? props.arrowConfig,
|
|
843
|
-
};
|
|
844
|
-
|
|
845
|
-
const addLeadingAndTrailingPathForAreaFill = (
|
|
846
|
-
initialPath,
|
|
847
|
-
value,
|
|
848
|
-
dataLength,
|
|
849
|
-
) => {
|
|
850
|
-
return (
|
|
851
|
-
'M ' +
|
|
852
|
-
initialSpacing +
|
|
853
|
-
',' +
|
|
854
|
-
heightUptoXaxis +
|
|
855
|
-
' ' +
|
|
856
|
-
'L ' +
|
|
857
|
-
initialSpacing +
|
|
858
|
-
',' +
|
|
859
|
-
getY(value) +
|
|
860
|
-
' ' +
|
|
861
|
-
initialPath +
|
|
862
|
-
' ' +
|
|
863
|
-
'L ' +
|
|
864
|
-
(initialSpacing + spacing * (dataLength - 1)) +
|
|
865
|
-
',' +
|
|
866
|
-
heightUptoXaxis +
|
|
867
|
-
' ' +
|
|
868
|
-
'L ' +
|
|
869
|
-
initialSpacing +
|
|
870
|
-
',' +
|
|
871
|
-
heightUptoXaxis +
|
|
872
|
-
' '
|
|
873
|
-
);
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
const getNextPoint = (data, index, around) => {
|
|
877
|
-
const isLast = index === data.length - 1;
|
|
878
|
-
return isLast && !around
|
|
879
|
-
? ' '
|
|
880
|
-
: ' L' +
|
|
881
|
-
(getX(index) + (around ? (isLast ? 0 : spacing / 2) : spacing)) +
|
|
882
|
-
' ' +
|
|
883
|
-
getY(data[index].value) +
|
|
884
|
-
' ';
|
|
885
|
-
};
|
|
886
|
-
const getStepPath = (data, i) => {
|
|
887
|
-
const around = edgePosition === EdgePosition.AROUND_DATA_POINT;
|
|
888
|
-
return (
|
|
889
|
-
'L' +
|
|
890
|
-
(getX(i) - (around && i > 0 ? spacing / 2 : 0)) +
|
|
891
|
-
' ' +
|
|
892
|
-
getY(data[i].value) +
|
|
893
|
-
getNextPoint(data, i, around)
|
|
894
|
-
);
|
|
895
|
-
};
|
|
896
|
-
|
|
897
|
-
const getSegmentPath = (data, i, lineSegment, startIndex, endIndex) => {
|
|
898
|
-
let path =
|
|
899
|
-
'L' +
|
|
900
|
-
getX(i) +
|
|
901
|
-
' ' +
|
|
902
|
-
getY(data[i].value) +
|
|
903
|
-
' ' +
|
|
904
|
-
getSegmentString(lineSegment, i, SEGMENT_START, SEGMENT_END);
|
|
905
|
-
|
|
906
|
-
if (highlightedRange) {
|
|
907
|
-
path += getPathWithHighlight(
|
|
908
|
-
data,
|
|
909
|
-
i,
|
|
910
|
-
highlightedRange,
|
|
911
|
-
startIndex,
|
|
912
|
-
endIndex,
|
|
913
|
-
getX,
|
|
914
|
-
getY,
|
|
915
|
-
);
|
|
916
|
-
}
|
|
917
|
-
return path;
|
|
918
|
-
};
|
|
919
|
-
|
|
920
|
-
useEffect(() => {
|
|
921
|
-
if (dataSet) {
|
|
922
|
-
const pointsArray: string[] = [];
|
|
923
|
-
const arrowPointsArray: string[] = [];
|
|
924
|
-
const fillPointsArray: string[] = [];
|
|
925
|
-
dataSet.map((set, index) => {
|
|
926
|
-
const setData = set.data.map(item => {
|
|
927
|
-
item.value = item.value - (props.yAxisOffset ?? 0);
|
|
928
|
-
return item;
|
|
929
|
-
});
|
|
930
|
-
if (set.curved ?? props.curved) {
|
|
931
|
-
const pArray: Array<Array<number>> = [];
|
|
932
|
-
for (let i = 0; i < setData.length; i++) {
|
|
933
|
-
if (
|
|
934
|
-
i >= (set.startIndex ?? 0) &&
|
|
935
|
-
i <= (set.endIndex ?? set.data.length - 1)
|
|
936
|
-
) {
|
|
937
|
-
pArray.push([getX(i), getY(setData[i].value)]);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
let xx = svgPath(
|
|
941
|
-
pArray,
|
|
942
|
-
set.curveType ?? curveType,
|
|
943
|
-
set.curvature ?? curvature,
|
|
944
|
-
);
|
|
945
|
-
pointsArray.push(
|
|
946
|
-
getCurvePathWithSegments(
|
|
947
|
-
xx,
|
|
948
|
-
set.lineSegments,
|
|
949
|
-
SEGMENT_START,
|
|
950
|
-
SEGMENT_END,
|
|
951
|
-
),
|
|
952
|
-
);
|
|
953
|
-
|
|
954
|
-
// For Arrow-
|
|
955
|
-
if (setData.length > 1 && (set.showArrow ?? props.showArrows)) {
|
|
956
|
-
let arrowTipY = pArray[pArray.length - 1][1];
|
|
957
|
-
let arrowTipX = pArray[pArray.length - 1][0];
|
|
958
|
-
let y1 = pArray[pArray.length - 2][1];
|
|
959
|
-
let x1 = pArray[pArray.length - 2][0];
|
|
960
|
-
|
|
961
|
-
let arrowPoints = getArrowPoints(
|
|
962
|
-
arrowTipX,
|
|
963
|
-
arrowTipY,
|
|
964
|
-
x1,
|
|
965
|
-
y1,
|
|
966
|
-
arrowLengthsFromSet[index],
|
|
967
|
-
arrowWidthsFromSet[index],
|
|
968
|
-
showArrowBasesFromSet[index],
|
|
969
|
-
);
|
|
970
|
-
|
|
971
|
-
arrowPointsArray.push(arrowPoints);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
// For Area charts-
|
|
975
|
-
if ((set.areaChart || areaChart) && setData.length) {
|
|
976
|
-
xx = addLeadingAndTrailingPathForAreaFill(
|
|
977
|
-
xx,
|
|
978
|
-
setData[0].value,
|
|
979
|
-
setData.length,
|
|
980
|
-
);
|
|
981
|
-
fillPointsArray.push(xx);
|
|
982
|
-
}
|
|
983
|
-
} else {
|
|
984
|
-
let pp = '';
|
|
985
|
-
for (let i = 0; i < setData.length; i++) {
|
|
986
|
-
if (
|
|
987
|
-
i >= (set.startIndex ?? 0) &&
|
|
988
|
-
i <= (set.endIndex ?? set.data.length - 1)
|
|
989
|
-
) {
|
|
990
|
-
if (set.stepChart || stepChart) {
|
|
991
|
-
pp += getStepPath(setData, i);
|
|
992
|
-
} else {
|
|
993
|
-
pp += getSegmentPath(
|
|
994
|
-
setData,
|
|
995
|
-
i,
|
|
996
|
-
set.lineSegments,
|
|
997
|
-
set.startIndex ?? 0,
|
|
998
|
-
set.endIndex ?? set.data.length - 1,
|
|
999
|
-
);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
pointsArray.push(pp.replace('L', 'M'));
|
|
1004
|
-
|
|
1005
|
-
// For Arrow-
|
|
1006
|
-
if (setData.length > 1 && (set.showArrow ?? props.showArrows)) {
|
|
1007
|
-
let ppArray = pp.trim().split(' ');
|
|
1008
|
-
let arrowTipY = parseInt(ppArray[ppArray.length - 1]);
|
|
1009
|
-
let arrowTipX = parseInt(
|
|
1010
|
-
ppArray[ppArray.length - 2].replace('L', ''),
|
|
1011
|
-
);
|
|
1012
|
-
let y1 = parseInt(ppArray[ppArray.length - 3]);
|
|
1013
|
-
let x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''));
|
|
1014
|
-
|
|
1015
|
-
let arrowPoints = getArrowPoints(
|
|
1016
|
-
arrowTipX,
|
|
1017
|
-
arrowTipY,
|
|
1018
|
-
x1,
|
|
1019
|
-
y1,
|
|
1020
|
-
arrowLengthsFromSet[index],
|
|
1021
|
-
arrowWidthsFromSet[index],
|
|
1022
|
-
showArrowBasesFromSet[index],
|
|
1023
|
-
);
|
|
1024
|
-
|
|
1025
|
-
arrowPointsArray.push(arrowPoints);
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
// For Area charts-
|
|
1029
|
-
if ((set.areaChart || areaChart) && setData.length) {
|
|
1030
|
-
let ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1031
|
-
ppp += pp;
|
|
1032
|
-
ppp +=
|
|
1033
|
-
'L' +
|
|
1034
|
-
(initialSpacing + spacing * (setData.length - 1)) +
|
|
1035
|
-
' ' +
|
|
1036
|
-
heightUptoXaxis;
|
|
1037
|
-
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1038
|
-
fillPointsArray.push(ppp.replace('L', 'M'));
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
});
|
|
1042
|
-
|
|
1043
|
-
setPointsFromSet(pointsArray);
|
|
1044
|
-
setArrowPointsFromSet(arrowPointsArray);
|
|
1045
|
-
setFillPointsFromSet(fillPointsArray);
|
|
1046
|
-
} else {
|
|
1047
|
-
let pp = '',
|
|
1048
|
-
pp2 = '',
|
|
1049
|
-
pp3 = '',
|
|
1050
|
-
pp4 = '',
|
|
1051
|
-
pp5 = '';
|
|
1052
|
-
if (!props.curved) {
|
|
1053
|
-
for (let i = 0; i < data.length; i++) {
|
|
1054
|
-
if (i >= startIndex1 && i <= endIndex1 && !animateOnDataChange) {
|
|
1055
|
-
if (stepChart || stepChart1) {
|
|
1056
|
-
pp += getStepPath(data, i);
|
|
1057
|
-
} else {
|
|
1058
|
-
pp += getSegmentPath(
|
|
1059
|
-
data,
|
|
1060
|
-
i,
|
|
1061
|
-
lineSegments,
|
|
1062
|
-
startIndex1,
|
|
1063
|
-
endIndex1,
|
|
1064
|
-
);
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
if (data2.length && i >= startIndex2 && i <= endIndex2) {
|
|
1068
|
-
if (stepChart || stepChart2) {
|
|
1069
|
-
pp2 += getStepPath(data2, i);
|
|
1070
|
-
(' ');
|
|
1071
|
-
} else {
|
|
1072
|
-
pp2 += getSegmentPath(
|
|
1073
|
-
data2,
|
|
1074
|
-
i,
|
|
1075
|
-
lineSegments2,
|
|
1076
|
-
startIndex2,
|
|
1077
|
-
endIndex2,
|
|
1078
|
-
);
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
if (data3.length && i >= startIndex3 && i <= endIndex3) {
|
|
1082
|
-
if (stepChart || stepChart3) {
|
|
1083
|
-
pp3 += getStepPath(data3, i);
|
|
1084
|
-
} else {
|
|
1085
|
-
pp3 += getSegmentPath(
|
|
1086
|
-
data3,
|
|
1087
|
-
i,
|
|
1088
|
-
lineSegments3,
|
|
1089
|
-
startIndex3,
|
|
1090
|
-
endIndex3,
|
|
1091
|
-
);
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
if (data4.length && i >= startIndex4 && i <= endIndex4) {
|
|
1095
|
-
if (stepChart || stepChart4) {
|
|
1096
|
-
pp4 += getStepPath(data4, i);
|
|
1097
|
-
} else {
|
|
1098
|
-
pp4 += getSegmentPath(
|
|
1099
|
-
data4,
|
|
1100
|
-
i,
|
|
1101
|
-
lineSegments4,
|
|
1102
|
-
startIndex4,
|
|
1103
|
-
endIndex4,
|
|
1104
|
-
);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
if (data5.length && i >= startIndex5 && i <= endIndex5) {
|
|
1108
|
-
if (stepChart || stepChart5) {
|
|
1109
|
-
pp5 += getStepPath(data5, i);
|
|
1110
|
-
} else {
|
|
1111
|
-
pp5 += getSegmentPath(
|
|
1112
|
-
data5,
|
|
1113
|
-
i,
|
|
1114
|
-
lineSegments5,
|
|
1115
|
-
startIndex5,
|
|
1116
|
-
endIndex5,
|
|
1117
|
-
);
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
setPoints2(pp2.replace('L', 'M'));
|
|
1122
|
-
setPoints3(pp3.replace('L', 'M'));
|
|
1123
|
-
setPoints4(pp4.replace('L', 'M'));
|
|
1124
|
-
setPoints5(pp5.replace('L', 'M'));
|
|
1125
|
-
|
|
1126
|
-
setPoints(pp.replace('L', 'M'));
|
|
1127
|
-
|
|
1128
|
-
if (data.length > 1 && (props.showArrow1 || props.showArrows)) {
|
|
1129
|
-
let ppArray = pp.trim().split(' ');
|
|
1130
|
-
let arrowTipY = parseInt(ppArray[ppArray.length - 1]);
|
|
1131
|
-
let arrowTipX = parseInt(
|
|
1132
|
-
ppArray[ppArray.length - 2].replace('L', ''),
|
|
1133
|
-
);
|
|
1134
|
-
let y1 = parseInt(ppArray[ppArray.length - 3]);
|
|
1135
|
-
let x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''));
|
|
1136
|
-
|
|
1137
|
-
let arrowPoints = getArrowPoints(
|
|
1138
|
-
arrowTipX,
|
|
1139
|
-
arrowTipY,
|
|
1140
|
-
x1,
|
|
1141
|
-
y1,
|
|
1142
|
-
arrowLength1,
|
|
1143
|
-
arrowWidth1,
|
|
1144
|
-
showArrowBase1,
|
|
1145
|
-
);
|
|
1146
|
-
|
|
1147
|
-
setArrow1Points(arrowPoints);
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
if (data2.length > 1 && (props.showArrow2 || props.showArrows)) {
|
|
1151
|
-
let ppArray = pp2.trim().split(' ');
|
|
1152
|
-
let arrowTipY = parseInt(ppArray[ppArray.length - 1]);
|
|
1153
|
-
let arrowTipX = parseInt(
|
|
1154
|
-
ppArray[ppArray.length - 2].replace('L', ''),
|
|
1155
|
-
);
|
|
1156
|
-
let y1 = parseInt(ppArray[ppArray.length - 3]);
|
|
1157
|
-
let x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''));
|
|
1158
|
-
|
|
1159
|
-
let arrowPoints = getArrowPoints(
|
|
1160
|
-
arrowTipX,
|
|
1161
|
-
arrowTipY,
|
|
1162
|
-
x1,
|
|
1163
|
-
y1,
|
|
1164
|
-
arrowLength2,
|
|
1165
|
-
arrowWidth2,
|
|
1166
|
-
showArrowBase2,
|
|
1167
|
-
);
|
|
1168
|
-
|
|
1169
|
-
setArrow2Points(arrowPoints);
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
if (data3.length > 1 && (props.showArrow3 || props.showArrows)) {
|
|
1173
|
-
let ppArray = pp3.trim().split(' ');
|
|
1174
|
-
let arrowTipY = parseInt(ppArray[ppArray.length - 1]);
|
|
1175
|
-
let arrowTipX = parseInt(
|
|
1176
|
-
ppArray[ppArray.length - 2].replace('L', ''),
|
|
1177
|
-
);
|
|
1178
|
-
let y1 = parseInt(ppArray[ppArray.length - 3]);
|
|
1179
|
-
let x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''));
|
|
1180
|
-
|
|
1181
|
-
let arrowPoints = getArrowPoints(
|
|
1182
|
-
arrowTipX,
|
|
1183
|
-
arrowTipY,
|
|
1184
|
-
x1,
|
|
1185
|
-
y1,
|
|
1186
|
-
arrowLength3,
|
|
1187
|
-
arrowWidth3,
|
|
1188
|
-
showArrowBase3,
|
|
1189
|
-
);
|
|
1190
|
-
|
|
1191
|
-
setArrow3Points(arrowPoints);
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
if (data4.length > 1 && (props.showArrow4 || props.showArrows)) {
|
|
1195
|
-
let ppArray = pp4.trim().split(' ');
|
|
1196
|
-
let arrowTipY = parseInt(ppArray[ppArray.length - 1]);
|
|
1197
|
-
let arrowTipX = parseInt(
|
|
1198
|
-
ppArray[ppArray.length - 2].replace('L', ''),
|
|
1199
|
-
);
|
|
1200
|
-
let y1 = parseInt(ppArray[ppArray.length - 3]);
|
|
1201
|
-
let x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''));
|
|
1202
|
-
|
|
1203
|
-
let arrowPoints = getArrowPoints(
|
|
1204
|
-
arrowTipX,
|
|
1205
|
-
arrowTipY,
|
|
1206
|
-
x1,
|
|
1207
|
-
y1,
|
|
1208
|
-
arrowLength4,
|
|
1209
|
-
arrowWidth4,
|
|
1210
|
-
showArrowBase4,
|
|
1211
|
-
);
|
|
1212
|
-
|
|
1213
|
-
setArrow4Points(arrowPoints);
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
if (data5.length > 1 && (props.showArrow5 || props.showArrows)) {
|
|
1217
|
-
let ppArray = pp5.trim().split(' ');
|
|
1218
|
-
let arrowTipY = parseInt(ppArray[ppArray.length - 1]);
|
|
1219
|
-
let arrowTipX = parseInt(
|
|
1220
|
-
ppArray[ppArray.length - 2].replace('L', ''),
|
|
1221
|
-
);
|
|
1222
|
-
let y1 = parseInt(ppArray[ppArray.length - 3]);
|
|
1223
|
-
let x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''));
|
|
1224
|
-
|
|
1225
|
-
let arrowPoints = getArrowPoints(
|
|
1226
|
-
arrowTipX,
|
|
1227
|
-
arrowTipY,
|
|
1228
|
-
x1,
|
|
1229
|
-
y1,
|
|
1230
|
-
arrowLength5,
|
|
1231
|
-
arrowWidth5,
|
|
1232
|
-
showArrowBase5,
|
|
1233
|
-
);
|
|
1234
|
-
|
|
1235
|
-
setArrow5Points(arrowPoints);
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
/*************************** For Area Charts *************************/
|
|
1239
|
-
if (atLeastOneAreaChart) {
|
|
1240
|
-
let ppp = '',
|
|
1241
|
-
ppp2 = '',
|
|
1242
|
-
ppp3 = '',
|
|
1243
|
-
ppp4 = '',
|
|
1244
|
-
ppp5 = '';
|
|
1245
|
-
|
|
1246
|
-
if (
|
|
1247
|
-
(areaChart || areaChart1) &&
|
|
1248
|
-
data.length &&
|
|
1249
|
-
!animateOnDataChange
|
|
1250
|
-
) {
|
|
1251
|
-
ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1252
|
-
ppp += pp;
|
|
1253
|
-
ppp +=
|
|
1254
|
-
'L' +
|
|
1255
|
-
(initialSpacing + spacing * (data.length - 1)) +
|
|
1256
|
-
' ' +
|
|
1257
|
-
heightUptoXaxis;
|
|
1258
|
-
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1259
|
-
setFillPoints(ppp.replace('L', 'M'));
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
if ((areaChart || areaChart2) && data2.length) {
|
|
1263
|
-
ppp2 = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1264
|
-
ppp2 += pp2;
|
|
1265
|
-
ppp2 +=
|
|
1266
|
-
'L' +
|
|
1267
|
-
(initialSpacing + spacing * (data.length - 1)) +
|
|
1268
|
-
' ' +
|
|
1269
|
-
heightUptoXaxis;
|
|
1270
|
-
ppp2 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1271
|
-
setFillPoints2(ppp2.replace('L', 'M'));
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
if ((areaChart || areaChart3) && data3.length) {
|
|
1275
|
-
ppp3 = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1276
|
-
ppp3 += pp3;
|
|
1277
|
-
ppp3 +=
|
|
1278
|
-
'L' +
|
|
1279
|
-
(initialSpacing + spacing * (data.length - 1)) +
|
|
1280
|
-
' ' +
|
|
1281
|
-
heightUptoXaxis;
|
|
1282
|
-
ppp3 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1283
|
-
setFillPoints3(ppp3.replace('L', 'M'));
|
|
1284
|
-
}
|
|
1285
|
-
if ((areaChart || areaChart4) && data4.length) {
|
|
1286
|
-
ppp4 = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1287
|
-
ppp4 += pp4;
|
|
1288
|
-
ppp4 +=
|
|
1289
|
-
'L' +
|
|
1290
|
-
(initialSpacing + spacing * (data.length - 1)) +
|
|
1291
|
-
' ' +
|
|
1292
|
-
heightUptoXaxis;
|
|
1293
|
-
ppp4 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1294
|
-
setFillPoints4(ppp4.replace('L', 'M'));
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
if ((areaChart || areaChart5) && data5.length) {
|
|
1298
|
-
ppp5 = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1299
|
-
ppp5 += pp5;
|
|
1300
|
-
ppp5 +=
|
|
1301
|
-
'L' +
|
|
1302
|
-
(initialSpacing + spacing * (data.length - 1)) +
|
|
1303
|
-
' ' +
|
|
1304
|
-
heightUptoXaxis;
|
|
1305
|
-
ppp5 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1306
|
-
setFillPoints5(ppp5.replace('L', 'M'));
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
/*************************************************************************************/
|
|
1311
|
-
} else {
|
|
1312
|
-
const p1Array: Array<Array<number>> = [],
|
|
1313
|
-
p2Array: Array<Array<number>> = [],
|
|
1314
|
-
p3Array: Array<Array<number>> = [],
|
|
1315
|
-
p4Array: Array<Array<number>> = [],
|
|
1316
|
-
p5Array: Array<Array<number>> = [];
|
|
1317
|
-
for (let i = 0; i < data.length; i++) {
|
|
1318
|
-
if (i >= startIndex1 && i <= endIndex1) {
|
|
1319
|
-
p1Array.push([getX(i), getY(data[i].value)]);
|
|
1320
|
-
}
|
|
1321
|
-
if (data2.length && i >= startIndex2 && i <= endIndex2) {
|
|
1322
|
-
p2Array.push([getX(i), getY(data2[i].value)]);
|
|
1323
|
-
}
|
|
1324
|
-
if (data3.length && i >= startIndex3 && i <= endIndex3) {
|
|
1325
|
-
p3Array.push([getX(i), getY(data3[i].value)]);
|
|
1326
|
-
}
|
|
1327
|
-
if (data4.length && i >= startIndex4 && i <= endIndex4) {
|
|
1328
|
-
p4Array.push([getX(i), getY(data4[i].value)]);
|
|
1329
|
-
}
|
|
1330
|
-
if (data5.length && i >= startIndex5 && i <= endIndex5) {
|
|
1331
|
-
p5Array.push([getX(i), getY(data5[i].value)]);
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
let xx = svgPath(p1Array, curveType, curvature);
|
|
1336
|
-
let xx2 = svgPath(p2Array, curveType, curvature);
|
|
1337
|
-
let xx3 = svgPath(p3Array, curveType, curvature);
|
|
1338
|
-
let xx4 = svgPath(p4Array, curveType, curvature);
|
|
1339
|
-
let xx5 = svgPath(p5Array, curveType, curvature);
|
|
1340
|
-
|
|
1341
|
-
setPoints(
|
|
1342
|
-
getCurvePathWithSegments(
|
|
1343
|
-
xx,
|
|
1344
|
-
lineSegments,
|
|
1345
|
-
SEGMENT_START,
|
|
1346
|
-
SEGMENT_END,
|
|
1347
|
-
),
|
|
1348
|
-
);
|
|
1349
|
-
setPoints2(
|
|
1350
|
-
getCurvePathWithSegments(
|
|
1351
|
-
xx2,
|
|
1352
|
-
lineSegments2,
|
|
1353
|
-
SEGMENT_START,
|
|
1354
|
-
SEGMENT_END,
|
|
1355
|
-
),
|
|
1356
|
-
);
|
|
1357
|
-
setPoints3(
|
|
1358
|
-
getCurvePathWithSegments(
|
|
1359
|
-
xx3,
|
|
1360
|
-
lineSegments3,
|
|
1361
|
-
SEGMENT_START,
|
|
1362
|
-
SEGMENT_END,
|
|
1363
|
-
),
|
|
1364
|
-
);
|
|
1365
|
-
setPoints4(
|
|
1366
|
-
getCurvePathWithSegments(
|
|
1367
|
-
xx4,
|
|
1368
|
-
lineSegments4,
|
|
1369
|
-
SEGMENT_START,
|
|
1370
|
-
SEGMENT_END,
|
|
1371
|
-
),
|
|
1372
|
-
);
|
|
1373
|
-
setPoints5(
|
|
1374
|
-
getCurvePathWithSegments(
|
|
1375
|
-
xx5,
|
|
1376
|
-
lineSegments5,
|
|
1377
|
-
SEGMENT_START,
|
|
1378
|
-
SEGMENT_END,
|
|
1379
|
-
),
|
|
1380
|
-
);
|
|
1381
|
-
|
|
1382
|
-
if (data.length > 1 && (props.showArrow1 || props.showArrows)) {
|
|
1383
|
-
let arrowTipY = p1Array[p1Array.length - 1][1];
|
|
1384
|
-
let arrowTipX = p1Array[p1Array.length - 1][0];
|
|
1385
|
-
let y1 = p1Array[p1Array.length - 2][1];
|
|
1386
|
-
let x1 = p1Array[p1Array.length - 2][0];
|
|
1387
|
-
|
|
1388
|
-
let arrowPoints = getArrowPoints(
|
|
1389
|
-
arrowTipX,
|
|
1390
|
-
arrowTipY,
|
|
1391
|
-
x1,
|
|
1392
|
-
y1,
|
|
1393
|
-
arrowLength1,
|
|
1394
|
-
arrowWidth1,
|
|
1395
|
-
showArrowBase1,
|
|
1396
|
-
);
|
|
1397
|
-
|
|
1398
|
-
setArrow1Points(arrowPoints);
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
if (data2.length > 1 && (props.showArrow2 || props.showArrows)) {
|
|
1402
|
-
let arrowTipY = p2Array[p2Array.length - 1][1];
|
|
1403
|
-
let arrowTipX = p2Array[p2Array.length - 1][0];
|
|
1404
|
-
let y1 = p2Array[p2Array.length - 2][1];
|
|
1405
|
-
let x1 = p2Array[p2Array.length - 2][0];
|
|
1406
|
-
|
|
1407
|
-
let arrowPoints = getArrowPoints(
|
|
1408
|
-
arrowTipX,
|
|
1409
|
-
arrowTipY,
|
|
1410
|
-
x1,
|
|
1411
|
-
y1,
|
|
1412
|
-
arrowLength2,
|
|
1413
|
-
arrowWidth2,
|
|
1414
|
-
showArrowBase2,
|
|
1415
|
-
);
|
|
1416
|
-
|
|
1417
|
-
setArrow2Points(arrowPoints);
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
if (data3.length > 1 && (props.showArrow3 || props.showArrows)) {
|
|
1421
|
-
let arrowTipY = p3Array[p3Array.length - 1][1];
|
|
1422
|
-
let arrowTipX = p3Array[p3Array.length - 1][0];
|
|
1423
|
-
let y1 = p3Array[p3Array.length - 2][1];
|
|
1424
|
-
let x1 = p3Array[p3Array.length - 2][0];
|
|
1425
|
-
|
|
1426
|
-
let arrowPoints = getArrowPoints(
|
|
1427
|
-
arrowTipX,
|
|
1428
|
-
arrowTipY,
|
|
1429
|
-
x1,
|
|
1430
|
-
y1,
|
|
1431
|
-
arrowLength3,
|
|
1432
|
-
arrowWidth3,
|
|
1433
|
-
showArrowBase3,
|
|
1434
|
-
);
|
|
1435
|
-
|
|
1436
|
-
setArrow2Points(arrowPoints);
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
if (data4.length > 1 && (props.showArrow4 || props.showArrows)) {
|
|
1440
|
-
let arrowTipY = p4Array[p4Array.length - 1][1];
|
|
1441
|
-
let arrowTipX = p4Array[p4Array.length - 1][0];
|
|
1442
|
-
let y1 = p4Array[p4Array.length - 2][1];
|
|
1443
|
-
let x1 = p4Array[p4Array.length - 2][0];
|
|
1444
|
-
|
|
1445
|
-
let arrowPoints = getArrowPoints(
|
|
1446
|
-
arrowTipX,
|
|
1447
|
-
arrowTipY,
|
|
1448
|
-
x1,
|
|
1449
|
-
y1,
|
|
1450
|
-
arrowLength4,
|
|
1451
|
-
arrowWidth4,
|
|
1452
|
-
showArrowBase4,
|
|
1453
|
-
);
|
|
1454
|
-
|
|
1455
|
-
setArrow2Points(arrowPoints);
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
if (data5.length > 1 && (props.showArrow5 || props.showArrows)) {
|
|
1459
|
-
let arrowTipY = p5Array[p5Array.length - 1][1];
|
|
1460
|
-
let arrowTipX = p5Array[p5Array.length - 1][0];
|
|
1461
|
-
let y1 = p5Array[p5Array.length - 2][1];
|
|
1462
|
-
let x1 = p5Array[p5Array.length - 2][0];
|
|
1463
|
-
|
|
1464
|
-
let arrowPoints = getArrowPoints(
|
|
1465
|
-
arrowTipX,
|
|
1466
|
-
arrowTipY,
|
|
1467
|
-
x1,
|
|
1468
|
-
y1,
|
|
1469
|
-
arrowLength5,
|
|
1470
|
-
arrowWidth5,
|
|
1471
|
-
showArrowBase5,
|
|
1472
|
-
);
|
|
1473
|
-
|
|
1474
|
-
setArrow2Points(arrowPoints);
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
/*************************** For Area Charts *************************/
|
|
1478
|
-
|
|
1479
|
-
if (atLeastOneAreaChart) {
|
|
1480
|
-
if ((areaChart || areaChart1) && data.length) {
|
|
1481
|
-
xx = addLeadingAndTrailingPathForAreaFill(
|
|
1482
|
-
xx,
|
|
1483
|
-
data[0].value,
|
|
1484
|
-
data.length,
|
|
1485
|
-
);
|
|
1486
|
-
setFillPoints(xx);
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
if ((areaChart || areaChart2) && data2.length) {
|
|
1490
|
-
xx2 = addLeadingAndTrailingPathForAreaFill(
|
|
1491
|
-
xx2,
|
|
1492
|
-
data2[0].value,
|
|
1493
|
-
data2.length,
|
|
1494
|
-
);
|
|
1495
|
-
setFillPoints2(xx2);
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
if ((areaChart || areaChart3) && data3.length) {
|
|
1499
|
-
xx3 = addLeadingAndTrailingPathForAreaFill(
|
|
1500
|
-
xx3,
|
|
1501
|
-
data3[0].value,
|
|
1502
|
-
data3.length,
|
|
1503
|
-
);
|
|
1504
|
-
setFillPoints3(xx3);
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
if ((areaChart || areaChart4) && data4.length) {
|
|
1508
|
-
xx4 = addLeadingAndTrailingPathForAreaFill(
|
|
1509
|
-
xx4,
|
|
1510
|
-
data4[0].value,
|
|
1511
|
-
data4.length,
|
|
1512
|
-
);
|
|
1513
|
-
setFillPoints4(xx4);
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
if ((areaChart || areaChart5) && data5.length) {
|
|
1517
|
-
xx5 = addLeadingAndTrailingPathForAreaFill(
|
|
1518
|
-
xx5,
|
|
1519
|
-
data5[0].value,
|
|
1520
|
-
data5.length,
|
|
1521
|
-
);
|
|
1522
|
-
setFillPoints5(xx5);
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
/*************************************************************************************/
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
}, [
|
|
1530
|
-
animateOnDataChange,
|
|
1531
|
-
areaChart,
|
|
1532
|
-
areaChart1,
|
|
1533
|
-
areaChart2,
|
|
1534
|
-
containerHeight,
|
|
1535
|
-
data,
|
|
1536
|
-
data2,
|
|
1537
|
-
data3,
|
|
1538
|
-
data4,
|
|
1539
|
-
data5,
|
|
1540
|
-
// data0,
|
|
1541
|
-
dataPointsWidth1,
|
|
1542
|
-
dataPointsWidth2,
|
|
1543
|
-
dataPointsWidth3,
|
|
1544
|
-
dataPointsWidth4,
|
|
1545
|
-
dataPointsWidth5,
|
|
1546
|
-
initialSpacing,
|
|
1547
|
-
maxValue,
|
|
1548
|
-
props.curved,
|
|
1549
|
-
spacing,
|
|
1550
|
-
xAxisThickness,
|
|
1551
|
-
startIndex1,
|
|
1552
|
-
endIndex1,
|
|
1553
|
-
startIndex2,
|
|
1554
|
-
endIndex2,
|
|
1555
|
-
startIndex3,
|
|
1556
|
-
endIndex3,
|
|
1557
|
-
startIndex4,
|
|
1558
|
-
endIndex4,
|
|
1559
|
-
startIndex5,
|
|
1560
|
-
endIndex5,
|
|
1561
|
-
arrowLength1,
|
|
1562
|
-
arrowWidth1,
|
|
1563
|
-
showArrowBase1,
|
|
1564
|
-
props.showArrow1,
|
|
1565
|
-
props.showArrows,
|
|
1566
|
-
props.showArrow2,
|
|
1567
|
-
props.showArrow3,
|
|
1568
|
-
props.showArrow4,
|
|
1569
|
-
props.showArrow5,
|
|
1570
|
-
arrowLength2,
|
|
1571
|
-
arrowWidth2,
|
|
1572
|
-
showArrowBase2,
|
|
1573
|
-
arrowLength3,
|
|
1574
|
-
arrowWidth3,
|
|
1575
|
-
showArrowBase3,
|
|
1576
|
-
arrowLength4,
|
|
1577
|
-
arrowWidth4,
|
|
1578
|
-
showArrowBase4,
|
|
1579
|
-
arrowLength5,
|
|
1580
|
-
arrowWidth5,
|
|
1581
|
-
showArrowBase5,
|
|
1582
|
-
]);
|
|
1583
|
-
|
|
1584
|
-
useEffect(() => {
|
|
1585
|
-
let pp = '';
|
|
1586
|
-
if (!secondaryLineConfig.curved) {
|
|
1587
|
-
for (let i = 0; i < secondaryData.length; i++) {
|
|
1588
|
-
if (
|
|
1589
|
-
i >= secondaryLineConfig.startIndex &&
|
|
1590
|
-
i <= secondaryLineConfig.endIndex &&
|
|
1591
|
-
!animateOnDataChange
|
|
1592
|
-
) {
|
|
1593
|
-
pp +=
|
|
1594
|
-
'L' + getX(i) + ' ' + getSecondaryY(secondaryData[i].value) + ' ';
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
setSecondaryPoints(pp.replace('L', 'M'));
|
|
1599
|
-
|
|
1600
|
-
if (secondaryData.length > 1 && secondaryLineConfig.showArrow) {
|
|
1601
|
-
let ppArray = pp.trim().split(' ');
|
|
1602
|
-
let arrowTipY = parseInt(ppArray[ppArray.length - 1]);
|
|
1603
|
-
let arrowTipX = parseInt(ppArray[ppArray.length - 2].replace('L', ''));
|
|
1604
|
-
let y1 = parseInt(ppArray[ppArray.length - 3]);
|
|
1605
|
-
let x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''));
|
|
1606
|
-
|
|
1607
|
-
let arrowPoints = getArrowPoints(
|
|
1608
|
-
arrowTipX,
|
|
1609
|
-
arrowTipY,
|
|
1610
|
-
x1,
|
|
1611
|
-
y1,
|
|
1612
|
-
secondaryLineConfig.arrowConfig?.length,
|
|
1613
|
-
secondaryLineConfig.arrowConfig?.width,
|
|
1614
|
-
secondaryLineConfig.arrowConfig?.showArrowBase,
|
|
1615
|
-
);
|
|
1616
|
-
|
|
1617
|
-
setSecondaryArrowPoints(arrowPoints);
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
/*************************** For Area Chart *************************/
|
|
1621
|
-
if (secondaryLineConfig.areaChart) {
|
|
1622
|
-
let ppp = '';
|
|
1623
|
-
|
|
1624
|
-
if (secondaryData.length && !animateOnDataChange) {
|
|
1625
|
-
ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1626
|
-
ppp += pp;
|
|
1627
|
-
ppp +=
|
|
1628
|
-
'L' +
|
|
1629
|
-
(initialSpacing + spacing * (secondaryData.length - 1)) +
|
|
1630
|
-
' ' +
|
|
1631
|
-
heightUptoXaxis;
|
|
1632
|
-
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
1633
|
-
setSecondaryFillPoints(ppp.replace('L', 'M'));
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
} else {
|
|
1637
|
-
/*************************** For Curved Charts *************************/
|
|
1638
|
-
const p1Array: Array<Array<number>> = [];
|
|
1639
|
-
for (let i = 0; i < secondaryData.length; i++) {
|
|
1640
|
-
if (
|
|
1641
|
-
i >= secondaryLineConfig.startIndex &&
|
|
1642
|
-
i <= secondaryLineConfig.endIndex
|
|
1643
|
-
) {
|
|
1644
|
-
p1Array.push([getX(i), getSecondaryY(secondaryData[i].value)]);
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
let xx = svgPath(
|
|
1649
|
-
p1Array,
|
|
1650
|
-
secondaryLineConfig.curveType,
|
|
1651
|
-
secondaryLineConfig.curvature,
|
|
1652
|
-
);
|
|
1653
|
-
|
|
1654
|
-
setSecondaryPoints(xx);
|
|
1655
|
-
|
|
1656
|
-
if (secondaryData.length > 1 && (props.showArrow1 || props.showArrows)) {
|
|
1657
|
-
let arrowTipY = p1Array[p1Array.length - 1][1];
|
|
1658
|
-
let arrowTipX = p1Array[p1Array.length - 1][0];
|
|
1659
|
-
let y1 = p1Array[p1Array.length - 2][1];
|
|
1660
|
-
let x1 = p1Array[p1Array.length - 2][0];
|
|
1661
|
-
|
|
1662
|
-
let arrowPoints = getArrowPoints(
|
|
1663
|
-
arrowTipX,
|
|
1664
|
-
arrowTipY,
|
|
1665
|
-
x1,
|
|
1666
|
-
y1,
|
|
1667
|
-
arrowLength1,
|
|
1668
|
-
arrowWidth1,
|
|
1669
|
-
showArrowBase1,
|
|
1670
|
-
);
|
|
1671
|
-
|
|
1672
|
-
setSecondaryArrowPoints(arrowPoints);
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
/*************************** For Curved Area Charts *************************/
|
|
1676
|
-
|
|
1677
|
-
if (secondaryLineConfig.areaChart) {
|
|
1678
|
-
if (secondaryData.length) {
|
|
1679
|
-
xx = addLeadingAndTrailingPathForAreaFill(
|
|
1680
|
-
xx,
|
|
1681
|
-
secondaryData[0].value,
|
|
1682
|
-
secondaryData.length,
|
|
1683
|
-
);
|
|
1684
|
-
setSecondaryFillPoints(xx);
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
}, [secondaryData, secondaryLineConfig]);
|
|
1689
|
-
|
|
1690
|
-
const gradientDirection = props.gradientDirection ?? 'vertical';
|
|
1691
|
-
const horizSections = [{value: '0'}];
|
|
1692
|
-
const stepHeight = props.stepHeight || containerHeight / noOfSections;
|
|
1693
|
-
const stepValue = props.stepValue || maxValue / noOfSections;
|
|
1694
|
-
const noOfSectionsBelowXAxis =
|
|
1695
|
-
props.noOfSectionsBelowXAxis || -mostNegativeValue / (stepValue || 1);
|
|
1696
|
-
|
|
1697
|
-
const showXAxisIndices =
|
|
1698
|
-
props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices;
|
|
1699
|
-
const xAxisIndicesHeight =
|
|
1700
|
-
props.xAxisIndicesHeight ?? AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
1701
|
-
const xAxisIndicesWidth =
|
|
1702
|
-
props.xAxisIndicesWidth ?? AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
1703
|
-
const xAxisIndicesColor =
|
|
1704
|
-
props.xAxisIndicesColor ?? AxesAndRulesDefaults.xAxisIndicesColor;
|
|
1705
|
-
|
|
1706
|
-
// const yAxisThickness = props.yAxisThickness ?? 1;
|
|
1707
|
-
const xAxisTextNumberOfLines =
|
|
1708
|
-
props.xAxisTextNumberOfLines ?? AxesAndRulesDefaults.xAxisTextNumberOfLines;
|
|
1709
|
-
const xAxisLabelsVerticalShift =
|
|
1710
|
-
props.xAxisLabelsVerticalShift ??
|
|
1711
|
-
AxesAndRulesDefaults.xAxisLabelsVerticalShift;
|
|
1712
|
-
const horizontalRulesStyle = props.horizontalRulesStyle;
|
|
1713
|
-
const showFractionalValues =
|
|
1714
|
-
props.showFractionalValues ?? AxesAndRulesDefaults.showFractionalValues;
|
|
1715
|
-
|
|
1716
|
-
const horizontal = false;
|
|
1717
|
-
const yAxisAtTop = false;
|
|
1718
|
-
|
|
1719
|
-
defaultPointerConfig.pointerStripHeight = containerHeight;
|
|
1720
|
-
|
|
1721
|
-
const pointerConfig = props.pointerConfig;
|
|
1722
|
-
const getPointerProps = props.getPointerProps || null;
|
|
1723
|
-
const pointerHeight = pointerConfig?.height ?? defaultPointerConfig.height;
|
|
1724
|
-
const pointerWidth = pointerConfig?.width ?? defaultPointerConfig.width;
|
|
1725
|
-
const pointerRadius = pointerConfig?.radius ?? defaultPointerConfig.radius;
|
|
1726
|
-
const pointerColor =
|
|
1727
|
-
pointerConfig?.pointerColor ?? defaultPointerConfig.pointerColor;
|
|
1728
|
-
const pointerComponent =
|
|
1729
|
-
pointerConfig?.pointerComponent ?? defaultPointerConfig.pointerComponent;
|
|
1730
|
-
|
|
1731
|
-
const showPointerStrip =
|
|
1732
|
-
pointerConfig?.showPointerStrip === false
|
|
1733
|
-
? false
|
|
1734
|
-
: defaultPointerConfig.showPointerStrip;
|
|
1735
|
-
const pointerStripHeight =
|
|
1736
|
-
pointerConfig?.pointerStripHeight ??
|
|
1737
|
-
defaultPointerConfig.pointerStripHeight;
|
|
1738
|
-
const pointerStripWidth =
|
|
1739
|
-
pointerConfig?.pointerStripWidth ?? defaultPointerConfig.pointerStripWidth;
|
|
1740
|
-
const pointerStripColor =
|
|
1741
|
-
pointerConfig?.pointerStripColor ?? defaultPointerConfig.pointerStripColor;
|
|
1742
|
-
const pointerStripUptoDataPoint =
|
|
1743
|
-
pointerConfig?.pointerStripUptoDataPoint ??
|
|
1744
|
-
defaultPointerConfig.pointerStripUptoDataPoint;
|
|
1745
|
-
const pointerLabelComponent =
|
|
1746
|
-
pointerConfig?.pointerLabelComponent ??
|
|
1747
|
-
defaultPointerConfig.pointerLabelComponent;
|
|
1748
|
-
const stripOverPointer =
|
|
1749
|
-
pointerConfig?.stripOverPointer ?? defaultPointerConfig.stripOverPointer;
|
|
1750
|
-
const shiftPointerLabelX =
|
|
1751
|
-
pointerConfig?.shiftPointerLabelX ??
|
|
1752
|
-
defaultPointerConfig.shiftPointerLabelX;
|
|
1753
|
-
const shiftPointerLabelY =
|
|
1754
|
-
pointerConfig?.shiftPointerLabelY ??
|
|
1755
|
-
defaultPointerConfig.shiftPointerLabelY;
|
|
1756
|
-
const pointerLabelWidth =
|
|
1757
|
-
pointerConfig?.pointerLabelWidth ?? defaultPointerConfig.pointerLabelWidth;
|
|
1758
|
-
const pointerLabelHeight =
|
|
1759
|
-
pointerConfig?.pointerLabelHeight ??
|
|
1760
|
-
defaultPointerConfig.pointerLabelHeight;
|
|
1761
|
-
const autoAdjustPointerLabelPosition =
|
|
1762
|
-
pointerConfig?.autoAdjustPointerLabelPosition ??
|
|
1763
|
-
defaultPointerConfig.autoAdjustPointerLabelPosition;
|
|
1764
|
-
const pointerVanishDelay =
|
|
1765
|
-
pointerConfig?.pointerVanishDelay ??
|
|
1766
|
-
defaultPointerConfig.pointerVanishDelay;
|
|
1767
|
-
const activatePointersOnLongPress =
|
|
1768
|
-
pointerConfig?.activatePointersOnLongPress ??
|
|
1769
|
-
defaultPointerConfig.activatePointersOnLongPress;
|
|
1770
|
-
const activatePointersDelay =
|
|
1771
|
-
pointerConfig?.activatePointersDelay ??
|
|
1772
|
-
defaultPointerConfig.activatePointersDelay;
|
|
1773
|
-
const initialPointerIndex =
|
|
1774
|
-
pointerConfig?.initialPointerIndex ??
|
|
1775
|
-
defaultPointerConfig.initialPointerIndex;
|
|
1776
|
-
const initialPointerAppearDelay =
|
|
1777
|
-
pointerConfig?.initialPointerAppearDelay ??
|
|
1778
|
-
(isAnimated
|
|
1779
|
-
? animationDuration
|
|
1780
|
-
: defaultPointerConfig.initialPointerAppearDelay);
|
|
1781
|
-
const persistPointer =
|
|
1782
|
-
pointerConfig?.persistPointer ?? defaultPointerConfig.persistPointer;
|
|
1783
|
-
const hidePointer1 =
|
|
1784
|
-
pointerConfig?.hidePointer1 ?? defaultPointerConfig.hidePointer1;
|
|
1785
|
-
const hidePointer2 =
|
|
1786
|
-
pointerConfig?.hidePointer2 ?? defaultPointerConfig.hidePointer2;
|
|
1787
|
-
const hidePointer3 =
|
|
1788
|
-
pointerConfig?.hidePointer3 ?? defaultPointerConfig.hidePointer3;
|
|
1789
|
-
const hidePointer4 =
|
|
1790
|
-
pointerConfig?.hidePointer4 ?? defaultPointerConfig.hidePointer4;
|
|
1791
|
-
const hidePointer5 =
|
|
1792
|
-
pointerConfig?.hidePointer5 ?? defaultPointerConfig.hidePointer5;
|
|
1793
|
-
const hideSecondaryPointer =
|
|
1794
|
-
pointerConfig?.hideSecondaryPointer ??
|
|
1795
|
-
defaultPointerConfig.hideSecondaryPointer;
|
|
1796
|
-
const resetPointerOnDataChange =
|
|
1797
|
-
pointerConfig?.resetPointerOnDataChange ??
|
|
1798
|
-
defaultPointerConfig.resetPointerOnDataChange;
|
|
1799
|
-
const pointerEvents = pointerConfig?.pointerEvents;
|
|
1800
|
-
const disableScroll =
|
|
1801
|
-
props.disableScroll ||
|
|
1802
|
-
(pointerConfig
|
|
1803
|
-
? activatePointersOnLongPress
|
|
1804
|
-
? responderActive
|
|
1805
|
-
? true
|
|
1806
|
-
: false
|
|
1807
|
-
: true
|
|
1808
|
-
: false);
|
|
1809
|
-
const showScrollIndicator =
|
|
1810
|
-
props.showScrollIndicator ?? LineDefaults.showScrollIndicator;
|
|
1811
|
-
|
|
1812
|
-
const focusEnabled = props.focusEnabled ?? LineDefaults.focusEnabled;
|
|
1813
|
-
const showDataPointOnFocus =
|
|
1814
|
-
props.showDataPointOnFocus ?? LineDefaults.showDataPointOnFocus;
|
|
1815
|
-
const showStripOnFocus =
|
|
1816
|
-
props.showStripOnFocus ?? LineDefaults.showStripOnFocus;
|
|
1817
|
-
const showTextOnFocus = props.showTextOnFocus ?? LineDefaults.showTextOnFocus;
|
|
1818
|
-
const stripHeight = props.stripHeight;
|
|
1819
|
-
const stripWidth = props.stripWidth ?? LineDefaults.stripWidth;
|
|
1820
|
-
const stripColor = props.stripColor ?? color1;
|
|
1821
|
-
const stripOpacity = props.stripOpacity ?? (startOpacity1 + endOpacity1) / 2;
|
|
1822
|
-
const unFocusOnPressOut =
|
|
1823
|
-
props.unFocusOnPressOut ?? LineDefaults.unFocusOnPressOut;
|
|
1824
|
-
const delayBeforeUnFocus =
|
|
1825
|
-
props.delayBeforeUnFocus ?? LineDefaults.delayBeforeUnFocus;
|
|
1826
|
-
|
|
1827
|
-
const containerHeightIncludingBelowXAxis =
|
|
1828
|
-
extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
1829
|
-
|
|
1830
|
-
const lineGradient = props.lineGradient ?? LineDefaults.lineGradient;
|
|
1831
|
-
const lineGradientDirection = props.lineGradientDirection ?? 'vertical';
|
|
1832
|
-
const lineGradientStartColor =
|
|
1833
|
-
props.lineGradientStartColor ?? LineDefaults.lineGradientStartColor;
|
|
1834
|
-
const lineGradientEndColor =
|
|
1835
|
-
props.lineGradientEndColor ?? LineDefaults.lineGradientEndColor;
|
|
1836
|
-
|
|
1837
|
-
const getPointerY = value =>
|
|
1838
|
-
value
|
|
1839
|
-
? containerHeight -
|
|
1840
|
-
(value * containerHeight) / maxValue -
|
|
1841
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1842
|
-
10
|
|
1843
|
-
: 0;
|
|
1844
|
-
|
|
1845
|
-
const initialisePointers = () => {
|
|
1846
|
-
if (initialPointerIndex !== -1) {
|
|
1847
|
-
const item = (data0 ?? data)[initialPointerIndex];
|
|
1848
|
-
const x =
|
|
1849
|
-
initialSpacing +
|
|
1850
|
-
spacing * initialPointerIndex -
|
|
1851
|
-
(pointerRadius || pointerWidth / 2) -
|
|
1852
|
-
1;
|
|
1853
|
-
const y = getPointerY(item.value);
|
|
1854
|
-
const y2 = getPointerY(data2?.[initialPointerIndex]?.value);
|
|
1855
|
-
const y3 = getPointerY(data3?.[initialPointerIndex]?.value);
|
|
1856
|
-
const y4 = getPointerY(data4?.[initialPointerIndex]?.value);
|
|
1857
|
-
const y5 = getPointerY(data5?.[initialPointerIndex]?.value);
|
|
1858
|
-
|
|
1859
|
-
if (initialPointerAppearDelay) {
|
|
1860
|
-
setTimeout(() => {
|
|
1861
|
-
setPointerConfig(initialPointerIndex, item, x, y, y2, y3, y4, y5);
|
|
1862
|
-
}, initialPointerAppearDelay);
|
|
1863
|
-
} else {
|
|
1864
|
-
setPointerConfig(initialPointerIndex, item, x, y, y2, y3, y4, y5);
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
};
|
|
1868
|
-
|
|
1869
|
-
useEffect(() => {
|
|
1870
|
-
initialisePointers();
|
|
1871
|
-
}, []);
|
|
1872
|
-
|
|
1873
|
-
useEffect(() => {
|
|
1874
|
-
if (resetPointerOnDataChange) {
|
|
1875
|
-
initialisePointers();
|
|
1876
|
-
}
|
|
1877
|
-
}, [data]);
|
|
1878
|
-
|
|
1879
|
-
const setPointerConfig = (
|
|
1880
|
-
initialPointerIndex,
|
|
1881
|
-
item,
|
|
1882
|
-
x,
|
|
1883
|
-
y,
|
|
1884
|
-
y2,
|
|
1885
|
-
y3,
|
|
1886
|
-
y4,
|
|
1887
|
-
y5,
|
|
1888
|
-
) => {
|
|
1889
|
-
setPointerIndex(initialPointerIndex);
|
|
1890
|
-
setPointerItem(item);
|
|
1891
|
-
setPointerX(x);
|
|
1892
|
-
setPointerY(y);
|
|
1893
|
-
setPointerY2(y2);
|
|
1894
|
-
setPointerY3(y3);
|
|
1895
|
-
setPointerY4(y4);
|
|
1896
|
-
setPointerY5(y5);
|
|
1897
|
-
};
|
|
1898
|
-
|
|
1899
448
|
const renderLabel = (
|
|
1900
449
|
index: number,
|
|
1901
450
|
label: String,
|
|
@@ -2133,7 +682,7 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
2133
682
|
(item.value * containerHeight) / maxValue - 2 + overflowTop
|
|
2134
683
|
}
|
|
2135
684
|
opacity={currentStripOpacity}
|
|
2136
|
-
fill={
|
|
685
|
+
fill={currentStripColor}
|
|
2137
686
|
/>
|
|
2138
687
|
) : null}
|
|
2139
688
|
{hideDataPoints ? null : (
|
|
@@ -3596,74 +2145,13 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
3596
2145
|
);
|
|
3597
2146
|
};
|
|
3598
2147
|
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
shiftX: 0,
|
|
3609
|
-
shiftY: 0,
|
|
3610
|
-
scrollRef,
|
|
3611
|
-
yAxisAtTop,
|
|
3612
|
-
initialSpacing,
|
|
3613
|
-
data: data0 ?? data,
|
|
3614
|
-
stackData: undefined, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
3615
|
-
secondaryData: secondaryData,
|
|
3616
|
-
barWidth: 0, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
3617
|
-
xAxisThickness,
|
|
3618
|
-
totalWidth,
|
|
3619
|
-
disableScroll,
|
|
3620
|
-
showScrollIndicator,
|
|
3621
|
-
scrollToEnd,
|
|
3622
|
-
scrollToIndex: props.scrollToIndex,
|
|
3623
|
-
scrollAnimation,
|
|
3624
|
-
scrollEventThrottle,
|
|
3625
|
-
indicatorColor: props.indicatorColor,
|
|
3626
|
-
setSelectedIndex,
|
|
3627
|
-
spacing,
|
|
3628
|
-
showLine: false,
|
|
3629
|
-
lineConfig: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
3630
|
-
lineConfig2: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
3631
|
-
maxValue,
|
|
3632
|
-
lineData: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
3633
|
-
lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
3634
|
-
animatedWidth,
|
|
3635
|
-
lineBehindBars: false,
|
|
3636
|
-
points,
|
|
3637
|
-
points2: '', // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
3638
|
-
arrowPoints: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
3639
|
-
renderChartContent,
|
|
3640
|
-
remainingScrollViewProps,
|
|
3641
|
-
|
|
3642
|
-
//horizSectionProps-
|
|
3643
|
-
width: props.width,
|
|
3644
|
-
horizSections,
|
|
3645
|
-
endSpacing,
|
|
3646
|
-
horizontalRulesStyle,
|
|
3647
|
-
noOfSections,
|
|
3648
|
-
showFractionalValues,
|
|
3649
|
-
|
|
3650
|
-
axesAndRulesProps: getAxesAndRulesProps(props, stepValue, undefined),
|
|
3651
|
-
|
|
3652
|
-
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
3653
|
-
yAxisOffset: props.yAxisOffset,
|
|
3654
|
-
rotateYAxisTexts: 0,
|
|
3655
|
-
hideAxesAndRules: props.hideAxesAndRules,
|
|
3656
|
-
|
|
3657
|
-
showXAxisIndices,
|
|
3658
|
-
xAxisIndicesHeight,
|
|
3659
|
-
xAxisIndicesWidth,
|
|
3660
|
-
xAxisIndicesColor,
|
|
3661
|
-
pointerConfig,
|
|
3662
|
-
getPointerProps,
|
|
3663
|
-
pointerIndex,
|
|
3664
|
-
pointerX,
|
|
3665
|
-
pointerY,
|
|
3666
|
-
};
|
|
3667
|
-
|
|
3668
|
-
return <BarAndLineChartsWrapper {...barAndLineChartsWrapperProps} />;
|
|
2148
|
+
return (
|
|
2149
|
+
<BarAndLineChartsWrapper
|
|
2150
|
+
{...barAndLineChartsWrapperProps}
|
|
2151
|
+
scrollRef={scrollRef}
|
|
2152
|
+
animatedWidth={animatedWidth}
|
|
2153
|
+
renderChartContent={renderChartContent}
|
|
2154
|
+
remainingScrollViewProps={remainingScrollViewProps}
|
|
2155
|
+
/>
|
|
2156
|
+
);
|
|
3669
2157
|
};
|