gifted-charts-core 0.1.35 → 0.1.36
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/RenderStackBars.js +10 -3
- package/dist/BarChart/index.d.ts +6 -1
- package/dist/BarChart/index.js +146 -97
- package/dist/BarChart/types.d.ts +16 -2
- package/dist/LineChart/LineChartBiColor.js +1 -1
- package/dist/LineChart/index.js +222 -190
- package/dist/LineChart/types.d.ts +1 -0
- package/dist/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +43 -43
- package/dist/components/BarAndLineChartsWrapper/index.js +12 -15
- package/dist/utils/index.d.ts +9 -2
- package/dist/utils/index.js +25 -10
- package/dist/utils/types.d.ts +5 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AxesAndRulesDefaults } from '../../utils/constants';
|
|
2
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
|
|
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;
|
|
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;
|
|
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, showSecondaryFractionalValues = props.showSecondaryFractionalValues, secondaryRoundToDigits = props.secondaryRoundToDigits, secondaryStepHeight = props.secondaryStepHeight, secondaryNegativeStepHeight = props.secondaryNegativeStepHeight;
|
|
6
6
|
var yAxisExtraHeightAtTop = trimYAxisAtTop ? 0 : yAxisExtraHeight;
|
|
7
7
|
/***********************************************************************************************************************************
|
|
8
8
|
* *
|
|
@@ -14,38 +14,38 @@ export var getHorizSectionVals = function (props) {
|
|
|
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
16
|
stepValue: secondaryStepValue,
|
|
17
|
-
stepHeight:
|
|
17
|
+
stepHeight: secondaryStepHeight,
|
|
18
18
|
negativeStepValue: secondaryNegativeStepValue,
|
|
19
|
-
negativeStepHeight:
|
|
20
|
-
showFractionalValues:
|
|
21
|
-
roundToDigits:
|
|
19
|
+
negativeStepHeight: secondaryNegativeStepHeight,
|
|
20
|
+
showFractionalValues: showSecondaryFractionalValues,
|
|
21
|
+
roundToDigits: secondaryRoundToDigits,
|
|
22
22
|
noOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis,
|
|
23
|
-
showYAxisIndices: (
|
|
24
|
-
yAxisIndicesHeight: (
|
|
25
|
-
yAxisIndicesWidth: (
|
|
26
|
-
yAxisIndicesColor: (
|
|
27
|
-
yAxisSide: (
|
|
23
|
+
showYAxisIndices: (_b = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showYAxisIndices) !== null && _b !== void 0 ? _b : showYAxisIndices,
|
|
24
|
+
yAxisIndicesHeight: (_c = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesHeight) !== null && _c !== void 0 ? _c : yAxisIndicesHeight,
|
|
25
|
+
yAxisIndicesWidth: (_d = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesWidth) !== null && _d !== void 0 ? _d : yAxisIndicesWidth,
|
|
26
|
+
yAxisIndicesColor: (_e = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesColor) !== null && _e !== void 0 ? _e : yAxisIndicesColor,
|
|
27
|
+
yAxisSide: (_f = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisSide) !== null && _f !== void 0 ? _f : yAxisSide,
|
|
28
28
|
yAxisOffset: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisOffset,
|
|
29
|
-
yAxisThickness: (
|
|
30
|
-
yAxisColor: (
|
|
31
|
-
yAxisLabelContainerStyle: (
|
|
29
|
+
yAxisThickness: (_g = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisThickness) !== null && _g !== void 0 ? _g : yAxisThickness,
|
|
30
|
+
yAxisColor: (_h = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisColor) !== null && _h !== void 0 ? _h : yAxisColor,
|
|
31
|
+
yAxisLabelContainerStyle: (_j = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelContainerStyle) !== null && _j !== void 0 ? _j : yAxisLabelContainerStyle,
|
|
32
32
|
yAxisLabelTexts: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelTexts,
|
|
33
|
-
yAxisTextStyle: (
|
|
34
|
-
yAxisTextNumberOfLines: (
|
|
35
|
-
yAxisLabelWidth: (
|
|
36
|
-
hideYAxisText: (
|
|
37
|
-
yAxisLabelPrefix: (
|
|
38
|
-
yAxisLabelSuffix: (
|
|
39
|
-
hideOrigin: (
|
|
33
|
+
yAxisTextStyle: (_k = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisTextStyle) !== null && _k !== void 0 ? _k : yAxisTextStyle,
|
|
34
|
+
yAxisTextNumberOfLines: (_l = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisTextNumberOfLines) !== null && _l !== void 0 ? _l : yAxisTextNumberOfLines,
|
|
35
|
+
yAxisLabelWidth: (_m = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelWidth) !== null && _m !== void 0 ? _m : yAxisLabelWidth,
|
|
36
|
+
hideYAxisText: (_o = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.hideYAxisText) !== null && _o !== void 0 ? _o : hideYAxisText,
|
|
37
|
+
yAxisLabelPrefix: (_p = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelPrefix) !== null && _p !== void 0 ? _p : yAxisLabelPrefix,
|
|
38
|
+
yAxisLabelSuffix: (_q = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelSuffix) !== null && _q !== void 0 ? _q : yAxisLabelSuffix,
|
|
39
|
+
hideOrigin: (_r = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.hideOrigin) !== null && _r !== void 0 ? _r : hideOrigin,
|
|
40
40
|
formatYLabel: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.formatYLabel
|
|
41
41
|
};
|
|
42
42
|
secondaryYAxisConfig.maxValue =
|
|
43
|
-
(
|
|
43
|
+
(_s = secondaryYAxisConfig.maxValue) !== null && _s !== void 0 ? _s : (secondaryMaxItem || maxValue);
|
|
44
44
|
secondaryYAxisConfig.mostNegativeValue =
|
|
45
|
-
(
|
|
45
|
+
(_t = secondaryYAxisConfig.mostNegativeValue) !== null && _t !== void 0 ? _t : secondaryMinItem;
|
|
46
46
|
secondaryYAxisConfig.stepHeight =
|
|
47
47
|
secondaryYAxisConfig.stepHeight ||
|
|
48
|
-
containerHeight / ((
|
|
48
|
+
containerHeight / ((_u = secondaryYAxisConfig.noOfSections) !== null && _u !== void 0 ? _u : noOfSections);
|
|
49
49
|
var horizSections = [];
|
|
50
50
|
for (var i = 0; i <= noOfSections; i++) {
|
|
51
51
|
var value = maxValue - stepValue * i;
|
|
@@ -54,7 +54,7 @@ export var getHorizSectionVals = function (props) {
|
|
|
54
54
|
}
|
|
55
55
|
horizSections.push({
|
|
56
56
|
value: (yAxisLabelTexts === null || yAxisLabelTexts === void 0 ? void 0 : yAxisLabelTexts.length)
|
|
57
|
-
? (
|
|
57
|
+
? (_v = yAxisLabelTexts[noOfSections + noOfSectionsBelowXAxis - i]) !== null && _v !== void 0 ? _v : value.toString()
|
|
58
58
|
: value.toString()
|
|
59
59
|
});
|
|
60
60
|
}
|
|
@@ -67,24 +67,24 @@ export var getHorizSectionVals = function (props) {
|
|
|
67
67
|
}
|
|
68
68
|
horizSectionsBelow.push({
|
|
69
69
|
value: props.yAxisLabelTexts
|
|
70
|
-
? (
|
|
70
|
+
? (_w = props.yAxisLabelTexts[noOfSectionsBelowXAxis - i]) !== null && _w !== void 0 ? _w : value.toString()
|
|
71
71
|
: value.toString()
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
var secondaryHorizSections = [];
|
|
76
76
|
if (secondaryYAxis) {
|
|
77
|
-
for (var i = 0; i <= ((
|
|
77
|
+
for (var i = 0; i <= ((_x = secondaryYAxisConfig.noOfSections) !== null && _x !== void 0 ? _x : noOfSections); i++) {
|
|
78
78
|
var value = secondaryYAxisConfig.stepValue * i;
|
|
79
79
|
if (secondaryYAxisConfig.showFractionalValues ||
|
|
80
80
|
secondaryYAxisConfig.roundToDigits) {
|
|
81
|
-
value = parseFloat(value.toFixed((
|
|
81
|
+
value = parseFloat(value.toFixed((_y = secondaryYAxisConfig.roundToDigits) !== null && _y !== void 0 ? _y : AxesAndRulesDefaults.roundToDigits));
|
|
82
82
|
}
|
|
83
83
|
secondaryHorizSections.push({
|
|
84
|
-
value: ((
|
|
85
|
-
? (
|
|
84
|
+
value: ((_z = secondaryYAxisConfig.yAxisLabelTexts) === null || _z === void 0 ? void 0 : _z.length)
|
|
85
|
+
? (_1 = secondaryYAxisConfig.yAxisLabelTexts[i + ((_0 = secondaryYAxisConfig.noOfSectionsBelowXAxis) !== null && _0 !== void 0 ? _0 : 0)
|
|
86
86
|
// - noOfSectionsBelowXAxis - 1
|
|
87
|
-
]) !== null &&
|
|
87
|
+
]) !== null && _1 !== void 0 ? _1 : value.toString()
|
|
88
88
|
: value.toString()
|
|
89
89
|
});
|
|
90
90
|
}
|
|
@@ -96,11 +96,11 @@ export var getHorizSectionVals = function (props) {
|
|
|
96
96
|
(i - secondaryYAxisConfig.noOfSectionsBelowXAxis - 1);
|
|
97
97
|
if (secondaryYAxisConfig.showFractionalValues ||
|
|
98
98
|
secondaryYAxisConfig.roundToDigits) {
|
|
99
|
-
value = parseFloat(value.toFixed((
|
|
99
|
+
value = parseFloat(value.toFixed((_2 = secondaryYAxisConfig.roundToDigits) !== null && _2 !== void 0 ? _2 : AxesAndRulesDefaults.roundToDigits));
|
|
100
100
|
}
|
|
101
101
|
secondaryHorizSectionsBelow.push({
|
|
102
|
-
value: ((
|
|
103
|
-
? (
|
|
102
|
+
value: ((_3 = secondaryYAxisConfig.yAxisLabelTexts) === null || _3 === void 0 ? void 0 : _3.length)
|
|
103
|
+
? (_4 = secondaryYAxisConfig.yAxisLabelTexts[i - 1]) !== null && _4 !== void 0 ? _4 : value.toString()
|
|
104
104
|
: value.toString()
|
|
105
105
|
});
|
|
106
106
|
}
|
|
@@ -121,12 +121,12 @@ export var getHorizSectionVals = function (props) {
|
|
|
121
121
|
};
|
|
122
122
|
showReferenceLine1 = referenceLinesConfig.showReferenceLine1 || false;
|
|
123
123
|
referenceLine1Position =
|
|
124
|
-
(
|
|
124
|
+
(_5 = referenceLinesConfig.referenceLine1Position) !== null && _5 !== void 0 ? _5 : (referenceLinesConfig.referenceLine1Position || containerHeight / 2);
|
|
125
125
|
referenceLine1Config = referenceLinesConfig.referenceLine1Config
|
|
126
126
|
? {
|
|
127
127
|
thickness: referenceLinesConfig.referenceLine1Config.thickness ||
|
|
128
128
|
defaultReferenceConfig.thickness,
|
|
129
|
-
width: (
|
|
129
|
+
width: (_6 = referenceLinesConfig.referenceLine1Config.width) !== null && _6 !== void 0 ? _6 : defaultReferenceConfig.width,
|
|
130
130
|
color: referenceLinesConfig.referenceLine1Config.color ||
|
|
131
131
|
defaultReferenceConfig.color,
|
|
132
132
|
type: referenceLinesConfig.referenceLine1Config.type ||
|
|
@@ -139,17 +139,17 @@ export var getHorizSectionVals = function (props) {
|
|
|
139
139
|
defaultReferenceConfig.labelText,
|
|
140
140
|
labelTextStyle: referenceLinesConfig.referenceLine1Config.labelTextStyle ||
|
|
141
141
|
defaultReferenceConfig.labelTextStyle,
|
|
142
|
-
zIndex: (
|
|
142
|
+
zIndex: (_7 = referenceLinesConfig.referenceLine1Config.zIndex) !== null && _7 !== void 0 ? _7 : defaultReferenceConfig.zIndex
|
|
143
143
|
}
|
|
144
144
|
: defaultReferenceConfig;
|
|
145
145
|
showReferenceLine2 = referenceLinesConfig.showReferenceLine2 || false;
|
|
146
146
|
referenceLine2Position =
|
|
147
|
-
(
|
|
147
|
+
(_8 = referenceLinesConfig.referenceLine2Position) !== null && _8 !== void 0 ? _8 : (referenceLinesConfig.referenceLine2Position || (3 * containerHeight) / 2);
|
|
148
148
|
referenceLine2Config = referenceLinesConfig.referenceLine2Config
|
|
149
149
|
? {
|
|
150
150
|
thickness: referenceLinesConfig.referenceLine2Config.thickness ||
|
|
151
151
|
defaultReferenceConfig.thickness,
|
|
152
|
-
width: (
|
|
152
|
+
width: (_9 = referenceLinesConfig.referenceLine2Config.width) !== null && _9 !== void 0 ? _9 : defaultReferenceConfig.width,
|
|
153
153
|
color: referenceLinesConfig.referenceLine2Config.color ||
|
|
154
154
|
defaultReferenceConfig.color,
|
|
155
155
|
type: referenceLinesConfig.referenceLine2Config.type ||
|
|
@@ -162,17 +162,17 @@ export var getHorizSectionVals = function (props) {
|
|
|
162
162
|
defaultReferenceConfig.labelText,
|
|
163
163
|
labelTextStyle: referenceLinesConfig.referenceLine2Config.labelTextStyle ||
|
|
164
164
|
defaultReferenceConfig.labelTextStyle,
|
|
165
|
-
zIndex: (
|
|
165
|
+
zIndex: (_10 = referenceLinesConfig.referenceLine2Config.zIndex) !== null && _10 !== void 0 ? _10 : defaultReferenceConfig.zIndex
|
|
166
166
|
}
|
|
167
167
|
: defaultReferenceConfig;
|
|
168
168
|
showReferenceLine3 = referenceLinesConfig.showReferenceLine3 || false;
|
|
169
169
|
referenceLine3Position =
|
|
170
|
-
(
|
|
170
|
+
(_11 = referenceLinesConfig.referenceLine3Position) !== null && _11 !== void 0 ? _11 : (referenceLinesConfig.referenceLine3Position || containerHeight / 3);
|
|
171
171
|
referenceLine3Config = referenceLinesConfig.referenceLine3Config
|
|
172
172
|
? {
|
|
173
173
|
thickness: referenceLinesConfig.referenceLine3Config.thickness ||
|
|
174
174
|
defaultReferenceConfig.thickness,
|
|
175
|
-
width: (
|
|
175
|
+
width: (_12 = referenceLinesConfig.referenceLine3Config.width) !== null && _12 !== void 0 ? _12 : defaultReferenceConfig.width,
|
|
176
176
|
color: referenceLinesConfig.referenceLine3Config.color ||
|
|
177
177
|
defaultReferenceConfig.color,
|
|
178
178
|
type: referenceLinesConfig.referenceLine3Config.type ||
|
|
@@ -185,7 +185,7 @@ export var getHorizSectionVals = function (props) {
|
|
|
185
185
|
defaultReferenceConfig.labelText,
|
|
186
186
|
labelTextStyle: referenceLinesConfig.referenceLine3Config.labelTextStyle ||
|
|
187
187
|
defaultReferenceConfig.labelTextStyle,
|
|
188
|
-
zIndex: (
|
|
188
|
+
zIndex: (_13 = referenceLinesConfig.referenceLine3Config.zIndex) !== null && _13 !== void 0 ? _13 : defaultReferenceConfig.zIndex
|
|
189
189
|
}
|
|
190
190
|
: defaultReferenceConfig;
|
|
191
191
|
var getLabelTexts = function (val, index) {
|
|
@@ -38,7 +38,7 @@ import { useEffect, useState } from 'react';
|
|
|
38
38
|
import { AxesAndRulesDefaults, BarDefaults } from '../../utils/constants';
|
|
39
39
|
import { computeMaxAndMinItems } from '../../utils';
|
|
40
40
|
export var useBarAndLineChartsWrapper = function (props) {
|
|
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
|
|
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;
|
|
42
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;
|
|
43
43
|
var yAxisAtTop = rtl ? !props.yAxisAtTop : props.yAxisAtTop;
|
|
44
44
|
var hideOrigin = (_a = axesAndRulesProps.hideOrigin) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.hideOrigin;
|
|
@@ -104,17 +104,10 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
104
104
|
var secondaryDataArrayWithMinValue = (secondaryData === null || secondaryData === void 0 ? void 0 : secondaryData.length)
|
|
105
105
|
? secondaryData
|
|
106
106
|
: setWithMinValueInDataset === null || setWithMinValueInDataset === void 0 ? void 0 : setWithMinValueInDataset.data;
|
|
107
|
-
var
|
|
108
|
-
var
|
|
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
|
|
112
|
-
? Math.ceil(((_20 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue) !== null && _20 !== void 0 ? _20 : secondaryMinItem) /
|
|
113
|
-
-secondaryNegativeStepValue)
|
|
114
|
-
: 0);
|
|
107
|
+
var _17 = 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 = _17.maxItem, secondaryMinItem = _17.minItem;
|
|
108
|
+
var _18 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepValue = _18.stepValue, secondaryNegativeStepValue = _18.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _18.noOfSectionsBelowXAxis, showSecondaryFractionalValues = _18.showFractionalValues, secondaryRoundToDigits = _18.roundToDigits, secondaryStepHeight = _18.stepHeight, secondaryNegativeStepHeight = _18.negativeStepHeight;
|
|
115
109
|
var primaryYAxisHeightBelowOrigin = noOfSectionsBelowXAxis * negativeStepHeight;
|
|
116
|
-
var secondaryYAxisHeightBelowOrigin = secondaryNoOfSectionsBelowXAxis *
|
|
117
|
-
((_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);
|
|
110
|
+
var secondaryYAxisHeightBelowOrigin = secondaryNoOfSectionsBelowXAxis * secondaryNegativeStepHeight;
|
|
118
111
|
var biggerNegativeYAxisHeight = Math.max(primaryYAxisHeightBelowOrigin, secondaryYAxisHeightBelowOrigin);
|
|
119
112
|
var containerHeightIncludingBelowXAxis = extendedContainerHeight + biggerNegativeYAxisHeight;
|
|
120
113
|
var horizSectionProps = {
|
|
@@ -181,7 +174,11 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
181
174
|
secondaryMinItem: secondaryMinItem,
|
|
182
175
|
secondaryStepValue: secondaryStepValue,
|
|
183
176
|
secondaryNegativeStepValue: secondaryNegativeStepValue,
|
|
184
|
-
secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis
|
|
177
|
+
secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis,
|
|
178
|
+
showSecondaryFractionalValues: showSecondaryFractionalValues,
|
|
179
|
+
secondaryRoundToDigits: secondaryRoundToDigits,
|
|
180
|
+
secondaryStepHeight: secondaryStepHeight,
|
|
181
|
+
secondaryNegativeStepHeight: secondaryNegativeStepHeight
|
|
185
182
|
};
|
|
186
183
|
var lineInBarChartProps = {
|
|
187
184
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
@@ -190,7 +187,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
190
187
|
containerHeight: containerHeight,
|
|
191
188
|
containerHeightIncludingBelowXAxis: containerHeightIncludingBelowXAxis,
|
|
192
189
|
lineConfig: lineConfig,
|
|
193
|
-
maxValue: (
|
|
190
|
+
maxValue: (_15 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _15 !== void 0 ? _15 : maxValue,
|
|
194
191
|
animatedWidth: animatedWidth,
|
|
195
192
|
lineBehindBars: lineBehindBars,
|
|
196
193
|
points: points,
|
|
@@ -207,7 +204,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
207
204
|
var verticalLinesProps = {
|
|
208
205
|
verticalLinesAr: verticalLinesAr,
|
|
209
206
|
verticalLinesSpacing: verticalLinesSpacing,
|
|
210
|
-
spacing: (
|
|
207
|
+
spacing: (_16 = lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.spacing) !== null && _16 !== void 0 ? _16 : spacing,
|
|
211
208
|
initialSpacing: initialSpacing,
|
|
212
209
|
verticalLinesZIndex: verticalLinesZIndex,
|
|
213
210
|
verticalLinesHeight: verticalLinesHeight,
|
|
@@ -262,7 +259,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
262
259
|
: difBwWidthHeight - 40) /
|
|
263
260
|
2 +
|
|
264
261
|
(yAxisAtTop ? (rtl ? (props.width ? 12 : 40) : 12) : 52), ")");
|
|
265
|
-
var
|
|
262
|
+
var _19 = __read(useState(false), 2), canMomentum = _19[0], setCanMomentum = _19[1];
|
|
266
263
|
var isCloseToEnd = function (_a) {
|
|
267
264
|
var layoutMeasurement = _a.layoutMeasurement, contentOffset = _a.contentOffset, contentSize = _a.contentSize;
|
|
268
265
|
return isRTL
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ColorValue } from 'react-native';
|
|
2
2
|
import { type IDataSanitisationProps, type lineDataItem } from '../LineChart/types';
|
|
3
|
-
import { type arrowConfigType, CurveType, type HighlightedRange, type LineProperties, type LineSegment, Framework, referenceConfigType } from './types';
|
|
3
|
+
import { type arrowConfigType, CurveType, type HighlightedRange, type LineProperties, type LineSegment, Framework, referenceConfigType, secondaryYAxisType } from './types';
|
|
4
4
|
import { type lineConfigType, type BarChartPropsType, type FocusedBarConfig, type barDataItem } from '../BarChart/types';
|
|
5
5
|
import { type extendedLineChartPropsType } from '../LineChart';
|
|
6
6
|
import { type extendedBarChartPropsType } from '../BarChart';
|
|
@@ -31,8 +31,15 @@ interface ReferenceLinesConfig {
|
|
|
31
31
|
interface IgetAxesAndRulesProps extends BarChartPropsType {
|
|
32
32
|
verticalLinesUptoDataPoint?: boolean;
|
|
33
33
|
referenceLinesConfig: ReferenceLinesConfig;
|
|
34
|
+
secondaryYAxisConfig: secondaryYAxisType & {
|
|
35
|
+
stepHeight: number;
|
|
36
|
+
stepValue: number;
|
|
37
|
+
negativeStepHeight: number;
|
|
38
|
+
negativeStepValue: number;
|
|
39
|
+
noOfSectionsBelowXAxis: number;
|
|
40
|
+
};
|
|
34
41
|
}
|
|
35
|
-
export declare const getAxesAndRulesProps: (props: extendedBarChartPropsType, stepValue: number, roundToDigits: number, negativeStepValue
|
|
42
|
+
export declare const getAxesAndRulesProps: (props: extendedBarChartPropsType, containerHeight: number, stepHeight: number, stepValue: number, noOfSections: number, roundToDigits: number, negativeStepValue: number, secondaryMaxValue: number, secondaryMinItem: number, showSecondaryFractionalValues: boolean, secondaryRoundToDigits: number) => IgetAxesAndRulesProps;
|
|
36
43
|
export declare const getExtendedContainerHeightWithPadding: (containerHeight: number, overflowTop?: number) => number;
|
|
37
44
|
export declare const getSecondaryDataWithOffsetIncluded: (secondaryData?: barDataItem[] | lineDataItem[], secondaryYAxis?: any | undefined, showDataPointsForMissingValues?: boolean, interpolateMissingValues?: boolean, onlyPositive?: boolean) => barDataItem[] | lineDataItem[] | undefined;
|
|
38
45
|
export declare const getArrowProperty: (property: string, count: number, props: extendedLineChartPropsType, defaultArrowConfig: arrowConfigType) => any;
|
package/dist/utils/index.js
CHANGED
|
@@ -486,11 +486,9 @@ export var getArrowPoints = function (arrowTipX, arrowTipY, x1, y1, arrowLength,
|
|
|
486
486
|
arrowPoints += " L".concat(arrowTipX, " ").concat(arrowTipY);
|
|
487
487
|
return arrowPoints;
|
|
488
488
|
};
|
|
489
|
-
export var getAxesAndRulesProps = function (props, stepValue, roundToDigits, negativeStepValue,
|
|
490
|
-
var _a, _b, _c, _d, _e;
|
|
491
|
-
var secondaryYAxis =
|
|
492
|
-
? {}
|
|
493
|
-
: props.secondaryYAxis;
|
|
489
|
+
export var getAxesAndRulesProps = function (props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits) {
|
|
490
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
491
|
+
var secondaryYAxis = typeof props.secondaryYAxis === 'boolean' ? {} : props.secondaryYAxis;
|
|
494
492
|
var axesAndRulesProps = {
|
|
495
493
|
yAxisSide: props.yAxisSide,
|
|
496
494
|
yAxisLabelContainerStyle: props.yAxisLabelContainerStyle,
|
|
@@ -553,17 +551,33 @@ export var getAxesAndRulesProps = function (props, stepValue, roundToDigits, neg
|
|
|
553
551
|
verticalLinesUptoDataPoint: props.verticalLinesUptoDataPoint,
|
|
554
552
|
roundToDigits: roundToDigits,
|
|
555
553
|
stepValue: stepValue,
|
|
556
|
-
negativeStepValue: negativeStepValue
|
|
554
|
+
negativeStepValue: negativeStepValue,
|
|
557
555
|
secondaryYAxis: props.secondaryYAxis,
|
|
558
556
|
formatYLabel: props.formatYLabel,
|
|
559
|
-
secondaryXAxis: props.secondaryXAxis
|
|
557
|
+
secondaryXAxis: props.secondaryXAxis,
|
|
558
|
+
secondaryYAxisConfig: {
|
|
559
|
+
stepHeight: 0,
|
|
560
|
+
stepValue: 0,
|
|
561
|
+
negativeStepHeight: 0,
|
|
562
|
+
negativeStepValue: 0,
|
|
563
|
+
noOfSectionsBelowXAxis: 0
|
|
564
|
+
}
|
|
560
565
|
};
|
|
561
566
|
if (((_d = props.secondaryYAxis) !== null && _d !== void 0 ? _d : (_e = props.lineConfig) === null || _e === void 0 ? void 0 : _e.isSecondary) &&
|
|
562
|
-
|
|
567
|
+
secondaryMaxValue !== undefined &&
|
|
563
568
|
secondaryYAxis &&
|
|
564
569
|
secondaryYAxis.maxValue === undefined) {
|
|
565
|
-
axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue:
|
|
570
|
+
axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue: secondaryMaxValue });
|
|
566
571
|
}
|
|
572
|
+
var secondaryNoOfSections = (_f = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSections) !== null && _f !== void 0 ? _f : noOfSections;
|
|
573
|
+
var secondaryStepValue = (_g = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepValue) !== null && _g !== void 0 ? _g : ((_h = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _h !== void 0 ? _h : secondaryMaxValue) / secondaryNoOfSections;
|
|
574
|
+
var secondaryStepHeight = (_j = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight) !== null && _j !== void 0 ? _j : containerHeight / secondaryNoOfSections;
|
|
575
|
+
var secondaryNegativeStepValue = (_k = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepValue) !== null && _k !== void 0 ? _k : secondaryStepValue;
|
|
576
|
+
var secondaryNoOfSectionsBelowXAxis = (_l = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSectionsBelowXAxis) !== null && _l !== void 0 ? _l : (secondaryNegativeStepValue
|
|
577
|
+
? Math.ceil(((_m = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue) !== null && _m !== void 0 ? _m : secondaryMinItem) /
|
|
578
|
+
-secondaryNegativeStepValue)
|
|
579
|
+
: 0);
|
|
580
|
+
axesAndRulesProps.secondaryYAxisConfig = __assign(__assign({}, secondaryYAxis), { stepHeight: secondaryStepHeight, stepValue: secondaryStepValue, negativeStepHeight: (_o = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepHeight) !== null && _o !== void 0 ? _o : secondaryStepHeight, negativeStepValue: secondaryNegativeStepValue, noOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis, showFractionalValues: showSecondaryFractionalValues, roundToDigits: secondaryRoundToDigits });
|
|
567
581
|
return axesAndRulesProps;
|
|
568
582
|
};
|
|
569
583
|
export var getExtendedContainerHeightWithPadding = function (containerHeight, overflowTop) { return containerHeight + (overflowTop !== null && overflowTop !== void 0 ? overflowTop : 0) + 10; };
|
|
@@ -676,7 +690,8 @@ export var maxAndMinUtil = function (maxItem, minItem, roundToDigits, showFracti
|
|
|
676
690
|
var range = maxItem - minItem;
|
|
677
691
|
var stepValue = range / 10;
|
|
678
692
|
maxItem += stepValue;
|
|
679
|
-
minItem =
|
|
693
|
+
minItem =
|
|
694
|
+
minItem !== 0 ? minItem + (minItem < 0 ? -stepValue : stepValue) : minItem;
|
|
680
695
|
// maxItem *= 10 * (roundToDigits ?? 1)
|
|
681
696
|
// maxItem = maxItem + (10 - (maxItem % 10))
|
|
682
697
|
// maxItem /= 10 * (roundToDigits ?? 1)
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -221,6 +221,10 @@ export interface horizSectionPropTypes {
|
|
|
221
221
|
secondaryStepValue: number;
|
|
222
222
|
secondaryNegativeStepValue: number;
|
|
223
223
|
secondaryNoOfSectionsBelowXAxis: number;
|
|
224
|
+
showSecondaryFractionalValues: boolean;
|
|
225
|
+
secondaryRoundToDigits: number;
|
|
226
|
+
secondaryStepHeight: number;
|
|
227
|
+
secondaryNegativeStepHeight: number;
|
|
224
228
|
}
|
|
225
229
|
interface HorizSectionObject {
|
|
226
230
|
value: string;
|
|
@@ -244,7 +248,7 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
244
248
|
initialSpacing: number;
|
|
245
249
|
data: any[];
|
|
246
250
|
stackData: any[] | undefined;
|
|
247
|
-
secondaryData
|
|
251
|
+
secondaryData?: any[];
|
|
248
252
|
barWidth: number | undefined;
|
|
249
253
|
xAxisThickness: number;
|
|
250
254
|
totalWidth: number;
|