gifted-charts-core 0.1.28 → 0.1.30
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/BarChart/types.d.ts +1 -0
- package/dist/LineChart/index.d.ts +0 -1
- package/dist/LineChart/index.js +0 -2
- package/dist/LineChart/types.d.ts +1 -0
- package/dist/PieChart/index.d.ts +1 -1
- package/dist/PieChart/index.js +6 -2
- package/dist/PieChart/main.d.ts +35 -1
- package/dist/PieChart/main.js +68 -11
- package/dist/PieChart/types.d.ts +8 -3
- package/dist/components/BarAndLineChartsWrapper/getHorizSectionsVals.d.ts +3 -1
- package/dist/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +44 -48
- package/dist/components/BarAndLineChartsWrapper/index.js +34 -9
- package/dist/index.d.ts +1 -1
- package/dist/utils/index.d.ts +21 -0
- package/dist/utils/index.js +25 -5
- package/dist/utils/types.d.ts +15 -1
- package/package.json +1 -1
package/dist/BarChart/types.d.ts
CHANGED
|
@@ -374,7 +374,6 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
|
|
|
374
374
|
stripStrokeDashArray: number[] | undefined;
|
|
375
375
|
unFocusOnPressOut: boolean;
|
|
376
376
|
delayBeforeUnFocus: number;
|
|
377
|
-
containerHeightIncludingBelowXAxis: number;
|
|
378
377
|
lineGradient: boolean;
|
|
379
378
|
lineGradientDirection: string;
|
|
380
379
|
lineGradientStartColor: string;
|
package/dist/LineChart/index.js
CHANGED
|
@@ -938,7 +938,6 @@ export var useLineChart = function (props) {
|
|
|
938
938
|
var stripStrokeDashArray = props.stripStrokeDashArray;
|
|
939
939
|
var unFocusOnPressOut = (_288 = props.unFocusOnPressOut) !== null && _288 !== void 0 ? _288 : LineDefaults.unFocusOnPressOut;
|
|
940
940
|
var delayBeforeUnFocus = (_289 = props.delayBeforeUnFocus) !== null && _289 !== void 0 ? _289 : LineDefaults.delayBeforeUnFocus;
|
|
941
|
-
var containerHeightIncludingBelowXAxis = extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
942
941
|
var lineGradient = (_290 = props.lineGradient) !== null && _290 !== void 0 ? _290 : LineDefaults.lineGradient;
|
|
943
942
|
var lineGradientDirection = (_291 = props.lineGradientDirection) !== null && _291 !== void 0 ? _291 : 'vertical';
|
|
944
943
|
var lineGradientStartColor = (_292 = props.lineGradientStartColor) !== null && _292 !== void 0 ? _292 : LineDefaults.lineGradientStartColor;
|
|
@@ -1428,7 +1427,6 @@ export var useLineChart = function (props) {
|
|
|
1428
1427
|
stripStrokeDashArray: stripStrokeDashArray,
|
|
1429
1428
|
unFocusOnPressOut: unFocusOnPressOut,
|
|
1430
1429
|
delayBeforeUnFocus: delayBeforeUnFocus,
|
|
1431
|
-
containerHeightIncludingBelowXAxis: containerHeightIncludingBelowXAxis,
|
|
1432
1430
|
lineGradient: lineGradient,
|
|
1433
1431
|
lineGradientDirection: lineGradientDirection,
|
|
1434
1432
|
lineGradientStartColor: lineGradientStartColor,
|
|
@@ -81,6 +81,7 @@ export interface LineChartPropsType {
|
|
|
81
81
|
showReferenceLine3?: boolean;
|
|
82
82
|
referenceLine3Config?: referenceConfigType;
|
|
83
83
|
referenceLine3Position?: number;
|
|
84
|
+
referenceLinesOverChartContent?: boolean;
|
|
84
85
|
showVerticalLines?: boolean;
|
|
85
86
|
verticalLinesUptoDataPoint?: boolean;
|
|
86
87
|
verticalLinesThickness?: number;
|
package/dist/PieChart/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type pieDataItem, type PieChartPropsType } from './types';
|
|
|
2
2
|
import { type ColorValue } from 'react-native';
|
|
3
3
|
interface IusePieChart {
|
|
4
4
|
radius: number;
|
|
5
|
-
|
|
5
|
+
extraRadius: number;
|
|
6
6
|
pi: number;
|
|
7
7
|
selectedIndex: number;
|
|
8
8
|
setSelectedIndex: (index: number) => void;
|
package/dist/PieChart/index.js
CHANGED
|
@@ -19,7 +19,11 @@ import { getTextSizeForPieLabels } from '../utils';
|
|
|
19
19
|
export var usePieChart = function (props) {
|
|
20
20
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
21
21
|
var radius = (_a = props.radius) !== null && _a !== void 0 ? _a : 120;
|
|
22
|
-
var
|
|
22
|
+
var extraRadius = (_b = props.extraRadius) !== null && _b !== void 0 ? _b : (props.showExternalLabels
|
|
23
|
+
? 40
|
|
24
|
+
: ((_c = props.focusOnPress) !== null && _c !== void 0 ? _c : props.sectionAutoFocus)
|
|
25
|
+
? radius / 10
|
|
26
|
+
: 0);
|
|
23
27
|
var pi = props.semiCircle ? Math.PI / 2 : Math.PI;
|
|
24
28
|
var _w = __read(useState((_d = props.focusedPieIndex) !== null && _d !== void 0 ? _d : -1), 2), selectedIndex = _w[0], setSelectedIndex = _w[1]; // at the start, nothing is selected
|
|
25
29
|
// because we're going to use a useEffect, we need startAngle and total to be state variables
|
|
@@ -94,7 +98,7 @@ export var usePieChart = function (props) {
|
|
|
94
98
|
: 0;
|
|
95
99
|
return {
|
|
96
100
|
radius: radius,
|
|
97
|
-
|
|
101
|
+
extraRadius: extraRadius,
|
|
98
102
|
pi: pi,
|
|
99
103
|
selectedIndex: selectedIndex,
|
|
100
104
|
setSelectedIndex: setSelectedIndex,
|
package/dist/PieChart/main.d.ts
CHANGED
|
@@ -45,5 +45,39 @@ export declare const getPieChartMainProps: (props: PieChartMainProps) => {
|
|
|
45
45
|
acc: number;
|
|
46
46
|
paddingHorizontal: number;
|
|
47
47
|
paddingVertical: number;
|
|
48
|
-
|
|
48
|
+
extraRadius: number;
|
|
49
|
+
showExternalLabels: boolean | undefined;
|
|
50
|
+
labelLineConfig: {
|
|
51
|
+
length: number;
|
|
52
|
+
tailLength: number;
|
|
53
|
+
color: import("react-native").ColorValue;
|
|
54
|
+
thickness: number;
|
|
55
|
+
labelComponentWidth: number;
|
|
56
|
+
labelComponentHeight: number;
|
|
57
|
+
labelComponentMargin: number;
|
|
58
|
+
};
|
|
59
|
+
externalLabelComponent: ((item?: pieDataItem, index?: number) => any) | undefined;
|
|
60
|
+
getExternaLabelProperties: (item: pieDataItem, mx: number, my: number, cx: number, cy: number) => {
|
|
61
|
+
labelLineColor: string;
|
|
62
|
+
labelLineThickness: number;
|
|
63
|
+
labelComponentHeight: number;
|
|
64
|
+
inX: number;
|
|
65
|
+
inY: number;
|
|
66
|
+
outX: number;
|
|
67
|
+
outY: number;
|
|
68
|
+
finalX: number;
|
|
69
|
+
labelComponentX: number;
|
|
70
|
+
localExternalLabelComponent: null;
|
|
71
|
+
} | {
|
|
72
|
+
labelLineColor: import("react-native").ColorValue;
|
|
73
|
+
labelLineThickness: number;
|
|
74
|
+
labelComponentHeight: number;
|
|
75
|
+
inX: number;
|
|
76
|
+
inY: number;
|
|
77
|
+
outX: number;
|
|
78
|
+
outY: number;
|
|
79
|
+
finalX: number;
|
|
80
|
+
labelComponentX: number;
|
|
81
|
+
localExternalLabelComponent: ((item?: pieDataItem, index?: number) => any) | undefined;
|
|
82
|
+
};
|
|
49
83
|
};
|
package/dist/PieChart/main.js
CHANGED
|
@@ -34,10 +34,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
34
34
|
}
|
|
35
35
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
36
|
};
|
|
37
|
-
import { getTextSizeForPieLabels } from '../utils';
|
|
37
|
+
import { defaultLabelLineConfig, emptyExternaLabelProperties, getTextSizeForPieLabels } from '../utils';
|
|
38
38
|
export var getPieChartMainProps = function (props) {
|
|
39
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
40
|
-
var isThreeD = props.isThreeD, isBiggerPie = props.isBiggerPie, paddingHorizontal = props.paddingHorizontal, paddingVertical = props.paddingVertical,
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
|
40
|
+
var isThreeD = props.isThreeD, isBiggerPie = props.isBiggerPie, paddingHorizontal = props.paddingHorizontal, paddingVertical = props.paddingVertical, extraRadius = props.extraRadius, showExternalLabels = props.showExternalLabels, externalLabelComponent = props.externalLabelComponent;
|
|
41
41
|
var propData = props.data;
|
|
42
42
|
var data = [];
|
|
43
43
|
var itemHasInnerComponent = false;
|
|
@@ -72,7 +72,16 @@ export var getPieChartMainProps = function (props) {
|
|
|
72
72
|
var showText = (_m = props.showText) !== null && _m !== void 0 ? _m : false;
|
|
73
73
|
var textColor = (_o = props.textColor) !== null && _o !== void 0 ? _o : '';
|
|
74
74
|
var textSize = getTextSizeForPieLabels((_p = props.textSize) !== null && _p !== void 0 ? _p : 0, radius);
|
|
75
|
-
var
|
|
75
|
+
var labelLineConfig = {
|
|
76
|
+
length: (_r = (_q = props.labelLineConfig) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : defaultLabelLineConfig.length,
|
|
77
|
+
tailLength: (_t = (_s = props.labelLineConfig) === null || _s === void 0 ? void 0 : _s.tailLength) !== null && _t !== void 0 ? _t : defaultLabelLineConfig.tailLength,
|
|
78
|
+
color: (_v = (_u = props.labelLineConfig) === null || _u === void 0 ? void 0 : _u.color) !== null && _v !== void 0 ? _v : defaultLabelLineConfig.color,
|
|
79
|
+
thickness: (_x = (_w = props.labelLineConfig) === null || _w === void 0 ? void 0 : _w.thickness) !== null && _x !== void 0 ? _x : defaultLabelLineConfig.thickness,
|
|
80
|
+
labelComponentWidth: (_z = (_y = props.labelLineConfig) === null || _y === void 0 ? void 0 : _y.labelComponentWidth) !== null && _z !== void 0 ? _z : defaultLabelLineConfig.labelComponentWidth,
|
|
81
|
+
labelComponentHeight: (_1 = (_0 = props.labelLineConfig) === null || _0 === void 0 ? void 0 : _0.labelComponentHeight) !== null && _1 !== void 0 ? _1 : defaultLabelLineConfig.labelComponentHeight,
|
|
82
|
+
labelComponentMargin: (_3 = (_2 = props.labelLineConfig) === null || _2 === void 0 ? void 0 : _2.labelComponentMargin) !== null && _3 !== void 0 ? _3 : defaultLabelLineConfig.labelComponentMargin
|
|
83
|
+
};
|
|
84
|
+
var tiltAngle = (_4 = props.tiltAngle) !== null && _4 !== void 0 ? _4 : '55deg';
|
|
76
85
|
if (tiltAngle &&
|
|
77
86
|
!isNaN(Number(tiltAngle)) &&
|
|
78
87
|
!(tiltAngle + '').endsWith('deg')) {
|
|
@@ -84,12 +93,12 @@ export var getPieChartMainProps = function (props) {
|
|
|
84
93
|
: donut || props.centerLabelComponent
|
|
85
94
|
? 'outward'
|
|
86
95
|
: 'mid';
|
|
87
|
-
var showTextBackground = (
|
|
88
|
-
var textBackgroundColor = (
|
|
89
|
-
var showValuesAsLabels = (
|
|
90
|
-
var showGradient = (
|
|
91
|
-
var gradientCenterColor = (
|
|
92
|
-
var toggleFocusOnPress = (
|
|
96
|
+
var showTextBackground = (_5 = props.showTextBackground) !== null && _5 !== void 0 ? _5 : false;
|
|
97
|
+
var textBackgroundColor = (_6 = props.textBackgroundColor) !== null && _6 !== void 0 ? _6 : 'white';
|
|
98
|
+
var showValuesAsLabels = (_7 = props.showValuesAsLabels) !== null && _7 !== void 0 ? _7 : false;
|
|
99
|
+
var showGradient = (_8 = props.showGradient) !== null && _8 !== void 0 ? _8 : false;
|
|
100
|
+
var gradientCenterColor = (_9 = props.gradientCenterColor) !== null && _9 !== void 0 ? _9 : 'white';
|
|
101
|
+
var toggleFocusOnPress = (_10 = props.toggleFocusOnPress) !== null && _10 !== void 0 ? _10 : true;
|
|
93
102
|
var minShiftX = 0;
|
|
94
103
|
var maxShiftX = 0;
|
|
95
104
|
var minShiftY = 0;
|
|
@@ -134,6 +143,50 @@ export var getPieChartMainProps = function (props) {
|
|
|
134
143
|
return pAcc + (acc - pAcc) / 2;
|
|
135
144
|
});
|
|
136
145
|
pData = __spreadArray([0], __read(pData), false);
|
|
146
|
+
var getExternaLabelProperties = function (item, mx, my, cx, cy) {
|
|
147
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
148
|
+
if (!showExternalLabels)
|
|
149
|
+
return emptyExternaLabelProperties;
|
|
150
|
+
var labelLineLength = (_b = (_a = item.labelLineConfig) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : labelLineConfig.length;
|
|
151
|
+
var labelTailLength = (_d = (_c = item.labelLineConfig) === null || _c === void 0 ? void 0 : _c.tailLength) !== null && _d !== void 0 ? _d : labelLineConfig.tailLength;
|
|
152
|
+
var labelLineColor = (_f = (_e = item.labelLineConfig) === null || _e === void 0 ? void 0 : _e.color) !== null && _f !== void 0 ? _f : labelLineConfig.color;
|
|
153
|
+
var labelLineThickness = (_h = (_g = item.labelLineConfig) === null || _g === void 0 ? void 0 : _g.thickness) !== null && _h !== void 0 ? _h : labelLineConfig.thickness;
|
|
154
|
+
var labelComponentWidth = (_k = (_j = item.labelLineConfig) === null || _j === void 0 ? void 0 : _j.labelComponentWidth) !== null && _k !== void 0 ? _k : labelLineConfig.labelComponentWidth;
|
|
155
|
+
var labelComponentHeight = (_m = (_l = item.labelLineConfig) === null || _l === void 0 ? void 0 : _l.labelComponentHeight) !== null && _m !== void 0 ? _m : labelLineConfig.labelComponentHeight;
|
|
156
|
+
var labelComponentMargin = (_p = (_o = item.labelLineConfig) === null || _o === void 0 ? void 0 : _o.labelComponentMargin) !== null && _p !== void 0 ? _p : labelLineConfig.labelComponentMargin;
|
|
157
|
+
var isRightHalf = mx > cx;
|
|
158
|
+
var slope = (my - cy) / (mx - cx);
|
|
159
|
+
var xFactor = labelTailLength / Math.sqrt(1 + slope * slope);
|
|
160
|
+
var yFactor = (labelTailLength * slope) / Math.sqrt(1 + slope * slope);
|
|
161
|
+
var outX = mx + (isRightHalf ? xFactor : -xFactor);
|
|
162
|
+
var outY = my + (isRightHalf ? yFactor : -yFactor);
|
|
163
|
+
var inX = mx + (isRightHalf ? -xFactor : xFactor);
|
|
164
|
+
var inY = my + (isRightHalf ? -yFactor : yFactor);
|
|
165
|
+
var finalX = isRightHalf ? cx * 2 + labelLineLength : -labelLineLength;
|
|
166
|
+
finalX = isRightHalf
|
|
167
|
+
? finalX > outX
|
|
168
|
+
? finalX
|
|
169
|
+
: outX
|
|
170
|
+
: finalX < outX
|
|
171
|
+
? finalX
|
|
172
|
+
: outX;
|
|
173
|
+
var labelComponentX = isRightHalf
|
|
174
|
+
? finalX + labelComponentMargin
|
|
175
|
+
: finalX - labelComponentWidth - labelComponentMargin;
|
|
176
|
+
var localExternalLabelComponent = (_q = item.externalLabelComponent) !== null && _q !== void 0 ? _q : props.externalLabelComponent;
|
|
177
|
+
return {
|
|
178
|
+
labelLineColor: labelLineColor,
|
|
179
|
+
labelLineThickness: labelLineThickness,
|
|
180
|
+
labelComponentHeight: labelComponentHeight,
|
|
181
|
+
inX: inX,
|
|
182
|
+
inY: inY,
|
|
183
|
+
outX: outX,
|
|
184
|
+
outY: outY,
|
|
185
|
+
finalX: finalX,
|
|
186
|
+
labelComponentX: labelComponentX,
|
|
187
|
+
localExternalLabelComponent: localExternalLabelComponent
|
|
188
|
+
};
|
|
189
|
+
};
|
|
137
190
|
return {
|
|
138
191
|
isThreeD: isThreeD,
|
|
139
192
|
isBiggerPie: isBiggerPie,
|
|
@@ -180,6 +233,10 @@ export var getPieChartMainProps = function (props) {
|
|
|
180
233
|
acc: acc,
|
|
181
234
|
paddingHorizontal: paddingHorizontal,
|
|
182
235
|
paddingVertical: paddingVertical,
|
|
183
|
-
|
|
236
|
+
extraRadius: extraRadius,
|
|
237
|
+
showExternalLabels: showExternalLabels,
|
|
238
|
+
labelLineConfig: labelLineConfig,
|
|
239
|
+
externalLabelComponent: externalLabelComponent,
|
|
240
|
+
getExternaLabelProperties: getExternaLabelProperties
|
|
184
241
|
};
|
|
185
242
|
};
|
package/dist/PieChart/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ColorValue } from 'react-native';
|
|
2
2
|
import { type FontStyle } from 'react-native-svg';
|
|
3
|
-
import { LabelsPosition } from '../utils/types';
|
|
3
|
+
import { LabelLineConfig, LabelsPosition } from '../utils/types';
|
|
4
4
|
export interface PieChartPropsType {
|
|
5
5
|
radius?: number;
|
|
6
6
|
isThreeD?: boolean;
|
|
@@ -44,7 +44,7 @@ export interface PieChartPropsType {
|
|
|
44
44
|
setSelectedIndex?: Function;
|
|
45
45
|
sectionAutoFocus?: boolean;
|
|
46
46
|
onLabelPress?: Function;
|
|
47
|
-
|
|
47
|
+
extraRadius?: number;
|
|
48
48
|
inwardExtraLengthForFocused?: number;
|
|
49
49
|
pieInnerComponent?: (item?: pieDataItem, index?: number) => any;
|
|
50
50
|
pieInnerComponentHeight?: number;
|
|
@@ -59,6 +59,9 @@ export interface PieChartPropsType {
|
|
|
59
59
|
isAnimated?: boolean;
|
|
60
60
|
animationDuration?: number;
|
|
61
61
|
focusedPieIndex?: number;
|
|
62
|
+
showExternalLabels?: boolean;
|
|
63
|
+
labelLineConfig?: LabelLineConfig;
|
|
64
|
+
externalLabelComponent?: (item?: pieDataItem, index?: number) => any;
|
|
62
65
|
}
|
|
63
66
|
export interface pieDataItem {
|
|
64
67
|
value: number;
|
|
@@ -91,11 +94,13 @@ export interface pieDataItem {
|
|
|
91
94
|
isEndEdgeCurved?: boolean;
|
|
92
95
|
startEdgeRadius?: number;
|
|
93
96
|
endEdgeRadius?: number;
|
|
97
|
+
labelLineConfig?: LabelLineConfig;
|
|
98
|
+
externalLabelComponent?: (item?: pieDataItem, index?: number) => any;
|
|
94
99
|
}
|
|
95
100
|
export interface PieChartMainProps extends PieChartPropsType {
|
|
96
101
|
setSelectedIndex: Function;
|
|
97
102
|
isBiggerPie?: boolean;
|
|
98
103
|
paddingHorizontal: number;
|
|
99
104
|
paddingVertical: number;
|
|
100
|
-
|
|
105
|
+
extraRadius: number;
|
|
101
106
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type HorizSectionsType, type horizSectionPropTypes, type secondaryYAxisType } from '../../utils/types';
|
|
2
2
|
export declare const getHorizSectionVals: (props: horizSectionPropTypes) => {
|
|
3
|
-
secondaryYAxisConfig: secondaryYAxisType
|
|
3
|
+
secondaryYAxisConfig: secondaryYAxisType & {
|
|
4
|
+
stepValue: number;
|
|
5
|
+
};
|
|
4
6
|
horizSections: HorizSectionsType;
|
|
5
7
|
yAxisExtraHeightAtTop: number;
|
|
6
8
|
secondaryHorizSections: HorizSectionsType;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AxesAndRulesDefaults } from '../../utils/constants';
|
|
2
|
-
import {
|
|
2
|
+
import { getLabelTextUtil } from '../../utils';
|
|
3
3
|
export var getHorizSectionVals = function (props) {
|
|
4
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15
|
|
5
|
-
var width = props.width, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, totalWidth = props.totalWidth, endSpacing = props.endSpacing, yAxisSide = props.yAxisSide, noOfSections = props.noOfSections, yAxisLabelWidth = props.yAxisLabelWidth, yAxisLabelContainerStyle = props.yAxisLabelContainerStyle, yAxisThickness = props.yAxisThickness, yAxisColor = props.yAxisColor, yAxisExtraHeight = props.yAxisExtraHeight, trimYAxisAtTop = props.trimYAxisAtTop, dashWidth = props.dashWidth, dashGap = props.dashGap, rulesType = props.rulesType, rulesThickness = props.rulesThickness, spacing = props.spacing, showYAxisIndices = props.showYAxisIndices, yAxisIndicesHeight = props.yAxisIndicesHeight, yAxisIndicesWidth = props.yAxisIndicesWidth, yAxisIndicesColor = props.yAxisIndicesColor, hideOrigin = props.hideOrigin, hideYAxisText = props.hideYAxisText, showFractionalValues = props.showFractionalValues, yAxisTextNumberOfLines = props.yAxisTextNumberOfLines, yAxisLabelPrefix = props.yAxisLabelPrefix, yAxisLabelSuffix = props.yAxisLabelSuffix, yAxisTextStyle = props.yAxisTextStyle, containerHeight = props.containerHeight, maxValue = props.maxValue, referenceLinesConfig = props.referenceLinesConfig, yAxisLabelTexts = props.yAxisLabelTexts, stepValue = props.stepValue, negativeStepValue = props.negativeStepValue, roundToDigits = props.roundToDigits, yAxisOffset = props.yAxisOffset, formatYLabel = props.formatYLabel,
|
|
4
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
|
|
5
|
+
var width = props.width, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, totalWidth = props.totalWidth, endSpacing = props.endSpacing, yAxisSide = props.yAxisSide, noOfSections = props.noOfSections, yAxisLabelWidth = props.yAxisLabelWidth, yAxisLabelContainerStyle = props.yAxisLabelContainerStyle, yAxisThickness = props.yAxisThickness, yAxisColor = props.yAxisColor, yAxisExtraHeight = props.yAxisExtraHeight, trimYAxisAtTop = props.trimYAxisAtTop, dashWidth = props.dashWidth, dashGap = props.dashGap, rulesType = props.rulesType, rulesThickness = props.rulesThickness, spacing = props.spacing, showYAxisIndices = props.showYAxisIndices, yAxisIndicesHeight = props.yAxisIndicesHeight, yAxisIndicesWidth = props.yAxisIndicesWidth, yAxisIndicesColor = props.yAxisIndicesColor, hideOrigin = props.hideOrigin, hideYAxisText = props.hideYAxisText, showFractionalValues = props.showFractionalValues, yAxisTextNumberOfLines = props.yAxisTextNumberOfLines, yAxisLabelPrefix = props.yAxisLabelPrefix, yAxisLabelSuffix = props.yAxisLabelSuffix, yAxisTextStyle = props.yAxisTextStyle, containerHeight = props.containerHeight, maxValue = props.maxValue, referenceLinesConfig = props.referenceLinesConfig, yAxisLabelTexts = props.yAxisLabelTexts, stepValue = props.stepValue, negativeStepValue = props.negativeStepValue, roundToDigits = props.roundToDigits, yAxisOffset = props.yAxisOffset, formatYLabel = props.formatYLabel, secondaryMaxItem = props.secondaryMaxItem, secondaryMinItem = props.secondaryMinItem, secondaryYAxis = props.secondaryYAxis, secondaryStepValue = props.secondaryStepValue, secondaryNegativeStepValue = props.secondaryNegativeStepValue, secondaryNoOfSectionsBelowXAxis = props.secondaryNoOfSectionsBelowXAxis;
|
|
6
6
|
var yAxisExtraHeightAtTop = trimYAxisAtTop ? 0 : yAxisExtraHeight;
|
|
7
7
|
/***********************************************************************************************************************************
|
|
8
8
|
* *
|
|
@@ -13,43 +13,39 @@ export var getHorizSectionVals = function (props) {
|
|
|
13
13
|
noOfSections: (_a = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSections) !== null && _a !== void 0 ? _a : noOfSections,
|
|
14
14
|
maxValue: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue,
|
|
15
15
|
mostNegativeValue: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue,
|
|
16
|
-
stepValue:
|
|
16
|
+
stepValue: secondaryStepValue,
|
|
17
17
|
stepHeight: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight,
|
|
18
|
-
negativeStepValue:
|
|
19
|
-
negativeStepHeight: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.
|
|
18
|
+
negativeStepValue: secondaryNegativeStepValue,
|
|
19
|
+
negativeStepHeight: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepHeight,
|
|
20
20
|
showFractionalValues: (_b = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showFractionalValues) !== null && _b !== void 0 ? _b : showFractionalValues,
|
|
21
21
|
roundToDigits: (_c = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.roundToDigits) !== null && _c !== void 0 ? _c : roundToDigits,
|
|
22
|
-
noOfSectionsBelowXAxis:
|
|
23
|
-
showYAxisIndices: (
|
|
24
|
-
yAxisIndicesHeight: (
|
|
25
|
-
yAxisIndicesWidth: (
|
|
26
|
-
yAxisIndicesColor: (
|
|
27
|
-
yAxisSide: (
|
|
22
|
+
noOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis,
|
|
23
|
+
showYAxisIndices: (_d = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showYAxisIndices) !== null && _d !== void 0 ? _d : showYAxisIndices,
|
|
24
|
+
yAxisIndicesHeight: (_e = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesHeight) !== null && _e !== void 0 ? _e : yAxisIndicesHeight,
|
|
25
|
+
yAxisIndicesWidth: (_f = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesWidth) !== null && _f !== void 0 ? _f : yAxisIndicesWidth,
|
|
26
|
+
yAxisIndicesColor: (_g = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesColor) !== null && _g !== void 0 ? _g : yAxisIndicesColor,
|
|
27
|
+
yAxisSide: (_h = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisSide) !== null && _h !== void 0 ? _h : yAxisSide,
|
|
28
28
|
yAxisOffset: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisOffset,
|
|
29
|
-
yAxisThickness: (
|
|
30
|
-
yAxisColor: (
|
|
31
|
-
yAxisLabelContainerStyle: (
|
|
32
|
-
yAxisLabelTexts: (
|
|
33
|
-
yAxisTextStyle: (
|
|
34
|
-
yAxisTextNumberOfLines: (
|
|
35
|
-
yAxisLabelWidth: (
|
|
36
|
-
hideYAxisText: (
|
|
37
|
-
yAxisLabelPrefix: (
|
|
38
|
-
yAxisLabelSuffix: (
|
|
39
|
-
hideOrigin: (
|
|
29
|
+
yAxisThickness: (_j = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisThickness) !== null && _j !== void 0 ? _j : yAxisThickness,
|
|
30
|
+
yAxisColor: (_k = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisColor) !== null && _k !== void 0 ? _k : yAxisColor,
|
|
31
|
+
yAxisLabelContainerStyle: (_l = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelContainerStyle) !== null && _l !== void 0 ? _l : yAxisLabelContainerStyle,
|
|
32
|
+
yAxisLabelTexts: (_m = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelTexts) !== null && _m !== void 0 ? _m : yAxisLabelTexts,
|
|
33
|
+
yAxisTextStyle: (_o = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisTextStyle) !== null && _o !== void 0 ? _o : yAxisTextStyle,
|
|
34
|
+
yAxisTextNumberOfLines: (_p = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisTextNumberOfLines) !== null && _p !== void 0 ? _p : yAxisTextNumberOfLines,
|
|
35
|
+
yAxisLabelWidth: (_q = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelWidth) !== null && _q !== void 0 ? _q : yAxisLabelWidth,
|
|
36
|
+
hideYAxisText: (_r = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.hideYAxisText) !== null && _r !== void 0 ? _r : hideYAxisText,
|
|
37
|
+
yAxisLabelPrefix: (_s = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelPrefix) !== null && _s !== void 0 ? _s : yAxisLabelPrefix,
|
|
38
|
+
yAxisLabelSuffix: (_t = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelSuffix) !== null && _t !== void 0 ? _t : yAxisLabelSuffix,
|
|
39
|
+
hideOrigin: (_u = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.hideOrigin) !== null && _u !== void 0 ? _u : hideOrigin,
|
|
40
40
|
formatYLabel: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.formatYLabel
|
|
41
41
|
};
|
|
42
|
-
var _20 = computeMaxAndMinItems(secondaryData, secondaryYAxisConfig.roundToDigits, secondaryYAxisConfig.showFractionalValues), maxItem = _20.maxItem, minItem = _20.minItem;
|
|
43
42
|
secondaryYAxisConfig.maxValue =
|
|
44
|
-
(
|
|
43
|
+
(_v = secondaryYAxisConfig.maxValue) !== null && _v !== void 0 ? _v : (secondaryMaxItem || maxValue);
|
|
45
44
|
secondaryYAxisConfig.mostNegativeValue =
|
|
46
|
-
(
|
|
47
|
-
secondaryYAxisConfig.stepValue =
|
|
48
|
-
(_y = secondaryYAxisConfig.stepValue) !== null && _y !== void 0 ? _y : ((_z = secondaryYAxisConfig.maxValue) !== null && _z !== void 0 ? _z : 0) /
|
|
49
|
-
((_0 = secondaryYAxisConfig.noOfSections) !== null && _0 !== void 0 ? _0 : noOfSections);
|
|
45
|
+
(_w = secondaryYAxisConfig.mostNegativeValue) !== null && _w !== void 0 ? _w : secondaryMinItem;
|
|
50
46
|
secondaryYAxisConfig.stepHeight =
|
|
51
47
|
secondaryYAxisConfig.stepHeight ||
|
|
52
|
-
containerHeight / ((
|
|
48
|
+
containerHeight / ((_x = secondaryYAxisConfig.noOfSections) !== null && _x !== void 0 ? _x : noOfSections);
|
|
53
49
|
var horizSections = [];
|
|
54
50
|
for (var i = 0; i <= noOfSections; i++) {
|
|
55
51
|
var value = maxValue - stepValue * i;
|
|
@@ -58,7 +54,7 @@ export var getHorizSectionVals = function (props) {
|
|
|
58
54
|
}
|
|
59
55
|
horizSections.push({
|
|
60
56
|
value: (yAxisLabelTexts === null || yAxisLabelTexts === void 0 ? void 0 : yAxisLabelTexts.length)
|
|
61
|
-
? (
|
|
57
|
+
? (_y = yAxisLabelTexts[noOfSections + noOfSectionsBelowXAxis - i]) !== null && _y !== void 0 ? _y : value.toString()
|
|
62
58
|
: value.toString()
|
|
63
59
|
});
|
|
64
60
|
}
|
|
@@ -71,22 +67,22 @@ export var getHorizSectionVals = function (props) {
|
|
|
71
67
|
}
|
|
72
68
|
horizSectionsBelow.push({
|
|
73
69
|
value: props.yAxisLabelTexts
|
|
74
|
-
? (
|
|
70
|
+
? (_z = props.yAxisLabelTexts[noOfSectionsBelowXAxis - i]) !== null && _z !== void 0 ? _z : value.toString()
|
|
75
71
|
: value.toString()
|
|
76
72
|
});
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
75
|
var secondaryHorizSections = [];
|
|
80
76
|
if (secondaryYAxis) {
|
|
81
|
-
for (var i = 0; i <= ((
|
|
77
|
+
for (var i = 0; i <= ((_0 = secondaryYAxisConfig.noOfSections) !== null && _0 !== void 0 ? _0 : noOfSections); i++) {
|
|
82
78
|
var value = secondaryYAxisConfig.stepValue * i;
|
|
83
79
|
if (secondaryYAxisConfig.showFractionalValues ||
|
|
84
80
|
secondaryYAxisConfig.roundToDigits) {
|
|
85
|
-
value = parseFloat(value.toFixed((
|
|
81
|
+
value = parseFloat(value.toFixed((_1 = secondaryYAxisConfig.roundToDigits) !== null && _1 !== void 0 ? _1 : AxesAndRulesDefaults.roundToDigits));
|
|
86
82
|
}
|
|
87
83
|
secondaryHorizSections.push({
|
|
88
|
-
value: ((
|
|
89
|
-
? (
|
|
84
|
+
value: ((_2 = secondaryYAxisConfig.yAxisLabelTexts) === null || _2 === void 0 ? void 0 : _2.length)
|
|
85
|
+
? (_3 = secondaryYAxisConfig.yAxisLabelTexts[i - noOfSectionsBelowXAxis - 1]) !== null && _3 !== void 0 ? _3 : value.toString()
|
|
90
86
|
: value.toString()
|
|
91
87
|
});
|
|
92
88
|
}
|
|
@@ -98,11 +94,11 @@ export var getHorizSectionVals = function (props) {
|
|
|
98
94
|
(i - secondaryYAxisConfig.noOfSectionsBelowXAxis - 1);
|
|
99
95
|
if (secondaryYAxisConfig.showFractionalValues ||
|
|
100
96
|
secondaryYAxisConfig.roundToDigits) {
|
|
101
|
-
value = parseFloat(value.toFixed((
|
|
97
|
+
value = parseFloat(value.toFixed((_4 = secondaryYAxisConfig.roundToDigits) !== null && _4 !== void 0 ? _4 : AxesAndRulesDefaults.roundToDigits));
|
|
102
98
|
}
|
|
103
99
|
secondaryHorizSectionsBelow.push({
|
|
104
|
-
value: ((
|
|
105
|
-
? (
|
|
100
|
+
value: ((_5 = secondaryYAxisConfig.yAxisLabelTexts) === null || _5 === void 0 ? void 0 : _5.length)
|
|
101
|
+
? (_6 = secondaryYAxisConfig.yAxisLabelTexts[i - 1]) !== null && _6 !== void 0 ? _6 : value.toString()
|
|
106
102
|
: value.toString()
|
|
107
103
|
});
|
|
108
104
|
}
|
|
@@ -123,12 +119,12 @@ export var getHorizSectionVals = function (props) {
|
|
|
123
119
|
};
|
|
124
120
|
showReferenceLine1 = referenceLinesConfig.showReferenceLine1 || false;
|
|
125
121
|
referenceLine1Position =
|
|
126
|
-
(
|
|
122
|
+
(_7 = referenceLinesConfig.referenceLine1Position) !== null && _7 !== void 0 ? _7 : (referenceLinesConfig.referenceLine1Position || containerHeight / 2);
|
|
127
123
|
referenceLine1Config = referenceLinesConfig.referenceLine1Config
|
|
128
124
|
? {
|
|
129
125
|
thickness: referenceLinesConfig.referenceLine1Config.thickness ||
|
|
130
126
|
defaultReferenceConfig.thickness,
|
|
131
|
-
width: (
|
|
127
|
+
width: (_8 = referenceLinesConfig.referenceLine1Config.width) !== null && _8 !== void 0 ? _8 : defaultReferenceConfig.width,
|
|
132
128
|
color: referenceLinesConfig.referenceLine1Config.color ||
|
|
133
129
|
defaultReferenceConfig.color,
|
|
134
130
|
type: referenceLinesConfig.referenceLine1Config.type ||
|
|
@@ -141,17 +137,17 @@ export var getHorizSectionVals = function (props) {
|
|
|
141
137
|
defaultReferenceConfig.labelText,
|
|
142
138
|
labelTextStyle: referenceLinesConfig.referenceLine1Config.labelTextStyle ||
|
|
143
139
|
defaultReferenceConfig.labelTextStyle,
|
|
144
|
-
zIndex: (
|
|
140
|
+
zIndex: (_9 = referenceLinesConfig.referenceLine1Config.zIndex) !== null && _9 !== void 0 ? _9 : defaultReferenceConfig.zIndex
|
|
145
141
|
}
|
|
146
142
|
: defaultReferenceConfig;
|
|
147
143
|
showReferenceLine2 = referenceLinesConfig.showReferenceLine2 || false;
|
|
148
144
|
referenceLine2Position =
|
|
149
|
-
(
|
|
145
|
+
(_10 = referenceLinesConfig.referenceLine2Position) !== null && _10 !== void 0 ? _10 : (referenceLinesConfig.referenceLine2Position || (3 * containerHeight) / 2);
|
|
150
146
|
referenceLine2Config = referenceLinesConfig.referenceLine2Config
|
|
151
147
|
? {
|
|
152
148
|
thickness: referenceLinesConfig.referenceLine2Config.thickness ||
|
|
153
149
|
defaultReferenceConfig.thickness,
|
|
154
|
-
width: (
|
|
150
|
+
width: (_11 = referenceLinesConfig.referenceLine2Config.width) !== null && _11 !== void 0 ? _11 : defaultReferenceConfig.width,
|
|
155
151
|
color: referenceLinesConfig.referenceLine2Config.color ||
|
|
156
152
|
defaultReferenceConfig.color,
|
|
157
153
|
type: referenceLinesConfig.referenceLine2Config.type ||
|
|
@@ -164,17 +160,17 @@ export var getHorizSectionVals = function (props) {
|
|
|
164
160
|
defaultReferenceConfig.labelText,
|
|
165
161
|
labelTextStyle: referenceLinesConfig.referenceLine2Config.labelTextStyle ||
|
|
166
162
|
defaultReferenceConfig.labelTextStyle,
|
|
167
|
-
zIndex: (
|
|
163
|
+
zIndex: (_12 = referenceLinesConfig.referenceLine2Config.zIndex) !== null && _12 !== void 0 ? _12 : defaultReferenceConfig.zIndex
|
|
168
164
|
}
|
|
169
165
|
: defaultReferenceConfig;
|
|
170
166
|
showReferenceLine3 = referenceLinesConfig.showReferenceLine3 || false;
|
|
171
167
|
referenceLine3Position =
|
|
172
|
-
(
|
|
168
|
+
(_13 = referenceLinesConfig.referenceLine3Position) !== null && _13 !== void 0 ? _13 : (referenceLinesConfig.referenceLine3Position || containerHeight / 3);
|
|
173
169
|
referenceLine3Config = referenceLinesConfig.referenceLine3Config
|
|
174
170
|
? {
|
|
175
171
|
thickness: referenceLinesConfig.referenceLine3Config.thickness ||
|
|
176
172
|
defaultReferenceConfig.thickness,
|
|
177
|
-
width: (
|
|
173
|
+
width: (_14 = referenceLinesConfig.referenceLine3Config.width) !== null && _14 !== void 0 ? _14 : defaultReferenceConfig.width,
|
|
178
174
|
color: referenceLinesConfig.referenceLine3Config.color ||
|
|
179
175
|
defaultReferenceConfig.color,
|
|
180
176
|
type: referenceLinesConfig.referenceLine3Config.type ||
|
|
@@ -187,7 +183,7 @@ export var getHorizSectionVals = function (props) {
|
|
|
187
183
|
defaultReferenceConfig.labelText,
|
|
188
184
|
labelTextStyle: referenceLinesConfig.referenceLine3Config.labelTextStyle ||
|
|
189
185
|
defaultReferenceConfig.labelTextStyle,
|
|
190
|
-
zIndex: (
|
|
186
|
+
zIndex: (_15 = referenceLinesConfig.referenceLine3Config.zIndex) !== null && _15 !== void 0 ? _15 : defaultReferenceConfig.zIndex
|
|
191
187
|
}
|
|
192
188
|
: defaultReferenceConfig;
|
|
193
189
|
var getLabelTexts = function (val, index) {
|
|
@@ -36,9 +36,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
36
36
|
};
|
|
37
37
|
import { useEffect, useState } from 'react';
|
|
38
38
|
import { AxesAndRulesDefaults, BarDefaults } from '../../utils/constants';
|
|
39
|
+
import { computeMaxAndMinItems } from '../../utils';
|
|
39
40
|
export var useBarAndLineChartsWrapper = function (props) {
|
|
40
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
|
|
41
|
-
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL, selectedIndex = props.selectedIndex;
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
|
|
42
|
+
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, dataSet = props.dataSet, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL, selectedIndex = props.selectedIndex;
|
|
42
43
|
var yAxisAtTop = rtl ? !props.yAxisAtTop : props.yAxisAtTop;
|
|
43
44
|
var hideOrigin = (_a = axesAndRulesProps.hideOrigin) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.hideOrigin;
|
|
44
45
|
var yAxisSide = (_b = axesAndRulesProps.yAxisSide) !== null && _b !== void 0 ? _b : AxesAndRulesDefaults.yAxisSide;
|
|
@@ -92,6 +93,28 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
92
93
|
var secondaryXAxis = axesAndRulesProps.secondaryXAxis;
|
|
93
94
|
var verticalLinesAr = noOfVerticalLines
|
|
94
95
|
? __spreadArray([], __read(Array(noOfVerticalLines).keys()), false) : __spreadArray([], __read(Array(stackData ? stackData.length : data.length).keys()), false);
|
|
96
|
+
var extendedContainerHeight = containerHeight + overflowTop + 10;
|
|
97
|
+
var dataSetArray = __spreadArray([], __read((dataSet !== null && dataSet !== void 0 ? dataSet : [])), false);
|
|
98
|
+
var setWithMinValueInDataset = (_12 = (_11 = dataSetArray
|
|
99
|
+
.filter(function (set) { return set.isSecondary; })).sort) === null || _12 === void 0 ? void 0 : _12.call(_11, function (a, b) {
|
|
100
|
+
var minA = Math.min.apply(Math, __spreadArray([], __read(a.data.map(function (item) { return item.value; })), false));
|
|
101
|
+
var minB = Math.min.apply(Math, __spreadArray([], __read(b.data.map(function (item) { return item.value; })), false));
|
|
102
|
+
return minA - minB;
|
|
103
|
+
})[0];
|
|
104
|
+
var secondaryDataArrayWithMinValue = (secondaryData === null || secondaryData === void 0 ? void 0 : secondaryData.length)
|
|
105
|
+
? secondaryData
|
|
106
|
+
: setWithMinValueInDataset === null || setWithMinValueInDataset === void 0 ? void 0 : setWithMinValueInDataset.data;
|
|
107
|
+
var _25 = computeMaxAndMinItems(secondaryDataArrayWithMinValue, (_13 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.roundToDigits) !== null && _13 !== void 0 ? _13 : roundToDigits, (_14 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showFractionalValues) !== null && _14 !== void 0 ? _14 : showFractionalValues), secondaryMaxItem = _25.maxItem, secondaryMinItem = _25.minItem;
|
|
108
|
+
var secondaryStepValue = (_15 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepValue) !== null && _15 !== void 0 ? _15 : ((_16 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _16 !== void 0 ? _16 : 0) /
|
|
109
|
+
((_17 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSections) !== null && _17 !== void 0 ? _17 : noOfSections);
|
|
110
|
+
var secondaryNegativeStepValue = (_18 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepValue) !== null && _18 !== void 0 ? _18 : secondaryStepValue;
|
|
111
|
+
var secondaryNoOfSectionsBelowXAxis = (_19 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSectionsBelowXAxis) !== null && _19 !== void 0 ? _19 : (secondaryNegativeStepValue ? Math.ceil(((_20 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue) !== null && _20 !== void 0 ? _20 : secondaryMinItem) /
|
|
112
|
+
-secondaryNegativeStepValue) : 0);
|
|
113
|
+
var primaryYAxisHeightBelowOrigin = noOfSectionsBelowXAxis * negativeStepHeight;
|
|
114
|
+
var secondaryYAxisHeightBelowOrigin = secondaryNoOfSectionsBelowXAxis *
|
|
115
|
+
((_22 = (_21 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepHeight) !== null && _21 !== void 0 ? _21 : secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight) !== null && _22 !== void 0 ? _22 : stepHeight);
|
|
116
|
+
var biggerNegativeYAxisHeight = Math.max(primaryYAxisHeightBelowOrigin, secondaryYAxisHeightBelowOrigin);
|
|
117
|
+
var containerHeightIncludingBelowXAxis = extendedContainerHeight + biggerNegativeYAxisHeight;
|
|
95
118
|
var horizSectionProps = {
|
|
96
119
|
chartType: chartType,
|
|
97
120
|
width: width,
|
|
@@ -149,10 +172,14 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
149
172
|
stepValue: stepValue,
|
|
150
173
|
negativeStepValue: negativeStepValue,
|
|
151
174
|
roundToDigits: roundToDigits,
|
|
152
|
-
secondaryData: secondaryData,
|
|
153
175
|
secondaryYAxis: secondaryYAxis,
|
|
154
176
|
formatYLabel: axesAndRulesProps.formatYLabel,
|
|
155
|
-
secondaryXAxis: secondaryXAxis
|
|
177
|
+
secondaryXAxis: secondaryXAxis,
|
|
178
|
+
secondaryMaxItem: secondaryMaxItem,
|
|
179
|
+
secondaryMinItem: secondaryMinItem,
|
|
180
|
+
secondaryStepValue: secondaryStepValue,
|
|
181
|
+
secondaryNegativeStepValue: secondaryNegativeStepValue,
|
|
182
|
+
secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis
|
|
156
183
|
};
|
|
157
184
|
var lineInBarChartProps = {
|
|
158
185
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
@@ -160,7 +187,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
160
187
|
spacing: spacing,
|
|
161
188
|
containerHeight: containerHeight,
|
|
162
189
|
lineConfig: lineConfig,
|
|
163
|
-
maxValue: (
|
|
190
|
+
maxValue: (_23 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _23 !== void 0 ? _23 : maxValue,
|
|
164
191
|
animatedWidth: animatedWidth,
|
|
165
192
|
lineBehindBars: lineBehindBars,
|
|
166
193
|
points: points,
|
|
@@ -174,12 +201,10 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
174
201
|
selectedIndex: selectedIndex
|
|
175
202
|
};
|
|
176
203
|
var lineInBarChartProps2 = __assign(__assign({}, lineInBarChartProps), { lineConfig: lineConfig2, points: points2, data: lineData2 !== null && lineData2 !== void 0 ? lineData2 : [] });
|
|
177
|
-
var extendedContainerHeight = containerHeight + overflowTop + 10;
|
|
178
|
-
var containerHeightIncludingBelowXAxis = extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
179
204
|
var verticalLinesProps = {
|
|
180
205
|
verticalLinesAr: verticalLinesAr,
|
|
181
206
|
verticalLinesSpacing: verticalLinesSpacing,
|
|
182
|
-
spacing: (
|
|
207
|
+
spacing: (_24 = lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.spacing) !== null && _24 !== void 0 ? _24 : spacing,
|
|
183
208
|
initialSpacing: initialSpacing,
|
|
184
209
|
verticalLinesZIndex: verticalLinesZIndex,
|
|
185
210
|
verticalLinesHeight: verticalLinesHeight,
|
|
@@ -234,7 +259,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
234
259
|
: difBwWidthHeight - 40) /
|
|
235
260
|
2 +
|
|
236
261
|
(yAxisAtTop ? (rtl ? (props.width ? 12 : 40) : 12) : 52), ")");
|
|
237
|
-
var
|
|
262
|
+
var _26 = __read(useState(false), 2), canMomentum = _26[0], setCanMomentum = _26[1];
|
|
238
263
|
var isCloseToEnd = function (_a) {
|
|
239
264
|
var layoutMeasurement = _a.layoutMeasurement, contentOffset = _a.contentOffset, contentSize = _a.contentSize;
|
|
240
265
|
return isRTL
|
package/dist/index.d.ts
CHANGED
|
@@ -36,4 +36,4 @@ export { type StripAndLabelProps } from './components/common/types';
|
|
|
36
36
|
/***********************************************************************************************************************/
|
|
37
37
|
export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset } from './utils';
|
|
38
38
|
export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
|
|
39
|
-
export { type RuleType, type RuleTypes, type RulesConfig, CurveType, EdgePosition, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type horizSectionPropTypes, type HorizSectionsType, type BarAndLineChartsWrapperTypes, type Pointer, type HighlightedRange, type LineSegment, type LineSvgProps, type LineProperties, type DataSet, Framework, type XAxisConfig, type LineInBarChartPropsType, type DataPointProps, type Linecap, type IntersectionAreaConfig } from './utils/types';
|
|
39
|
+
export { type RuleType, type RuleTypes, type RulesConfig, CurveType, EdgePosition, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type horizSectionPropTypes, type HorizSectionsType, type BarAndLineChartsWrapperTypes, type Pointer, type HighlightedRange, type LineSegment, type LineSvgProps, type LineProperties, type DataSet, Framework, type XAxisConfig, type LineInBarChartPropsType, type DataPointProps, type Linecap, type IntersectionAreaConfig, type LabelLineConfig } from './utils/types';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -99,4 +99,25 @@ export declare const getTextSizeForPieLabels: (textSize: number, radius: number)
|
|
|
99
99
|
export declare const adjustToOffset: (data: lineDataItem[], yAxisOffset?: number) => lineDataItem[];
|
|
100
100
|
export declare const getSanitisedData: (data: lineDataItem[] | undefined, dataSanitisationProps: IDataSanitisationProps) => lineDataItem[];
|
|
101
101
|
export declare const getStrokeDashArray: (strokeDash?: number[] | string, framework?: Framework) => number[] | string | undefined;
|
|
102
|
+
export declare const emptyExternaLabelProperties: {
|
|
103
|
+
labelLineColor: string;
|
|
104
|
+
labelLineThickness: number;
|
|
105
|
+
labelComponentHeight: number;
|
|
106
|
+
inX: number;
|
|
107
|
+
inY: number;
|
|
108
|
+
outX: number;
|
|
109
|
+
outY: number;
|
|
110
|
+
finalX: number;
|
|
111
|
+
labelComponentX: number;
|
|
112
|
+
localExternalLabelComponent: null;
|
|
113
|
+
};
|
|
114
|
+
export declare const defaultLabelLineConfig: {
|
|
115
|
+
length: number;
|
|
116
|
+
tailLength: number;
|
|
117
|
+
color: string;
|
|
118
|
+
thickness: number;
|
|
119
|
+
labelComponentWidth: number;
|
|
120
|
+
labelComponentHeight: number;
|
|
121
|
+
labelComponentMargin: number;
|
|
122
|
+
};
|
|
102
123
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -658,10 +658,7 @@ export var maxAndMinUtil = function (maxItem, minItem, roundToDigits, showFracti
|
|
|
658
658
|
maxItem /= 10 * (roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1);
|
|
659
659
|
maxItem = parseFloat(maxItem.toFixed(roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1));
|
|
660
660
|
if (minItem !== 0) {
|
|
661
|
-
minItem
|
|
662
|
-
minItem = minItem - (10 + (minItem % 10));
|
|
663
|
-
minItem /= 10 * (roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1);
|
|
664
|
-
minItem = parseFloat(minItem.toFixed(roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1));
|
|
661
|
+
minItem += minItem / 10;
|
|
665
662
|
}
|
|
666
663
|
}
|
|
667
664
|
else {
|
|
@@ -910,7 +907,9 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
|
|
|
910
907
|
.slice()
|
|
911
908
|
.reverse()
|
|
912
909
|
.findIndex(function (item) { return typeof item.value === 'number'; });
|
|
913
|
-
var secondPreIndex = tempSecondPreIndex >= 0
|
|
910
|
+
var secondPreIndex = tempSecondPreIndex >= 0
|
|
911
|
+
? secondPreCount - tempSecondPreIndex
|
|
912
|
+
: tempSecondPreIndex;
|
|
914
913
|
count = preValidIndex - secondPreIndex;
|
|
915
914
|
step = (data[secondPreIndex].value - data[preValidIndex].value) / count;
|
|
916
915
|
data[index].value =
|
|
@@ -1024,3 +1023,24 @@ export var getStrokeDashArray = function (strokeDash, framework) {
|
|
|
1024
1023
|
}
|
|
1025
1024
|
return strokeDashArrayOrString;
|
|
1026
1025
|
};
|
|
1026
|
+
export var emptyExternaLabelProperties = {
|
|
1027
|
+
labelLineColor: '',
|
|
1028
|
+
labelLineThickness: 0,
|
|
1029
|
+
labelComponentHeight: 0,
|
|
1030
|
+
inX: 0,
|
|
1031
|
+
inY: 0,
|
|
1032
|
+
outX: 0,
|
|
1033
|
+
outY: 0,
|
|
1034
|
+
finalX: 0,
|
|
1035
|
+
labelComponentX: 0,
|
|
1036
|
+
localExternalLabelComponent: null
|
|
1037
|
+
};
|
|
1038
|
+
export var defaultLabelLineConfig = {
|
|
1039
|
+
length: 10,
|
|
1040
|
+
tailLength: 8,
|
|
1041
|
+
color: 'black',
|
|
1042
|
+
thickness: 1,
|
|
1043
|
+
labelComponentWidth: 20,
|
|
1044
|
+
labelComponentHeight: 10,
|
|
1045
|
+
labelComponentMargin: 4
|
|
1046
|
+
};
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -210,12 +210,16 @@ export interface horizSectionPropTypes {
|
|
|
210
210
|
stepValue: number;
|
|
211
211
|
negativeStepValue: number;
|
|
212
212
|
roundToDigits: number | undefined;
|
|
213
|
-
secondaryData: any[] | undefined;
|
|
214
213
|
secondaryYAxis: secondaryYAxisType | null;
|
|
215
214
|
formatYLabel?: (label: string) => string;
|
|
216
215
|
onlyReferenceLines?: boolean;
|
|
217
216
|
renderReferenceLines?: boolean;
|
|
218
217
|
secondaryXAxis?: XAxisConfig;
|
|
218
|
+
secondaryMaxItem: number;
|
|
219
|
+
secondaryMinItem: number;
|
|
220
|
+
secondaryStepValue: number;
|
|
221
|
+
secondaryNegativeStepValue: number;
|
|
222
|
+
secondaryNoOfSectionsBelowXAxis: number;
|
|
219
223
|
}
|
|
220
224
|
interface HorizSectionObject {
|
|
221
225
|
value: string;
|
|
@@ -293,6 +297,7 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
293
297
|
isRTL?: boolean;
|
|
294
298
|
extraWidthDueToDataPoint?: number;
|
|
295
299
|
nestedScrollEnabled?: boolean;
|
|
300
|
+
dataSet?: DataSet[];
|
|
296
301
|
}
|
|
297
302
|
export interface Pointer {
|
|
298
303
|
height?: number;
|
|
@@ -400,4 +405,13 @@ export interface DataSet {
|
|
|
400
405
|
export interface IntersectionAreaConfig {
|
|
401
406
|
fillColor?: ColorValue;
|
|
402
407
|
}
|
|
408
|
+
export interface LabelLineConfig {
|
|
409
|
+
length?: number;
|
|
410
|
+
tailLength?: number;
|
|
411
|
+
color?: ColorValue;
|
|
412
|
+
thickness?: number;
|
|
413
|
+
labelComponentWidth?: number;
|
|
414
|
+
labelComponentHeight?: number;
|
|
415
|
+
labelComponentMargin?: number;
|
|
416
|
+
}
|
|
403
417
|
export {};
|