gifted-charts-core 0.1.29 → 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/PieChart/main.js +8 -8
- 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/utils/index.js +1 -4
- package/dist/utils/types.d.ts +6 -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,
|
package/dist/PieChart/main.js
CHANGED
|
@@ -34,7 +34,7 @@ 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 { emptyExternaLabelProperties, getTextSizeForPieLabels } from '../utils';
|
|
37
|
+
import { defaultLabelLineConfig, emptyExternaLabelProperties, getTextSizeForPieLabels } from '../utils';
|
|
38
38
|
export var getPieChartMainProps = function (props) {
|
|
39
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
40
|
var isThreeD = props.isThreeD, isBiggerPie = props.isBiggerPie, paddingHorizontal = props.paddingHorizontal, paddingVertical = props.paddingVertical, extraRadius = props.extraRadius, showExternalLabels = props.showExternalLabels, externalLabelComponent = props.externalLabelComponent;
|
|
@@ -73,13 +73,13 @@ export var getPieChartMainProps = function (props) {
|
|
|
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
75
|
var labelLineConfig = {
|
|
76
|
-
length: (_r = (_q = props.labelLineConfig) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r :
|
|
77
|
-
tailLength: (_t = (_s = props.labelLineConfig) === null || _s === void 0 ? void 0 : _s.tailLength) !== null && _t !== void 0 ? _t :
|
|
78
|
-
color: (_v = (_u = props.labelLineConfig) === null || _u === void 0 ? void 0 : _u.color) !== null && _v !== void 0 ? _v :
|
|
79
|
-
thickness: (_x = (_w = props.labelLineConfig) === null || _w === void 0 ? void 0 : _w.thickness) !== null && _x !== void 0 ? _x :
|
|
80
|
-
labelComponentWidth: (_z = (_y = props.labelLineConfig) === null || _y === void 0 ? void 0 : _y.labelComponentWidth) !== null && _z !== void 0 ? _z :
|
|
81
|
-
labelComponentHeight: (_1 = (_0 = props.labelLineConfig) === null || _0 === void 0 ? void 0 : _0.labelComponentHeight) !== null && _1 !== void 0 ? _1 :
|
|
82
|
-
labelComponentMargin: (_3 = (_2 = props.labelLineConfig) === null || _2 === void 0 ? void 0 : _2.labelComponentMargin) !== null && _3 !== void 0 ? _3 :
|
|
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
83
|
};
|
|
84
84
|
var tiltAngle = (_4 = props.tiltAngle) !== null && _4 !== void 0 ? _4 : '55deg';
|
|
85
85
|
if (tiltAngle &&
|
|
@@ -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/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 {
|
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;
|