gifted-charts-core 0.1.35 → 0.1.37
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 +156 -101
- 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 +19 -17
- package/dist/utils/index.d.ts +10 -3
- package/dist/utils/index.js +29 -12
- package/dist/utils/types.d.ts +7 -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, _17, _18
|
|
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;
|
|
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 _19 = 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 = _19.maxItem, secondaryMinItem = _19.minItem;
|
|
108
|
+
var _20 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepValue = _20.stepValue, secondaryNegativeStepValue = _20.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _20.noOfSectionsBelowXAxis, showSecondaryFractionalValues = _20.showFractionalValues, secondaryRoundToDigits = _20.roundToDigits, secondaryStepHeight = _20.stepHeight, secondaryNegativeStepHeight = _20.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,
|
|
@@ -201,13 +198,18 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
201
198
|
labelsExtraHeight: labelsExtraHeight,
|
|
202
199
|
scrollEventThrottle: scrollEventThrottle,
|
|
203
200
|
xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
|
|
204
|
-
selectedIndex: selectedIndex
|
|
201
|
+
selectedIndex: selectedIndex,
|
|
202
|
+
yAxisOffset: lineConfig.isSecondary
|
|
203
|
+
? (_16 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisOffset) !== null && _16 !== void 0 ? _16 : 0
|
|
204
|
+
: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0
|
|
205
205
|
};
|
|
206
|
-
var lineInBarChartProps2 = __assign(__assign({}, lineInBarChartProps), { lineConfig: lineConfig2, points: points2, data: lineData2 !== null && lineData2 !== void 0 ? lineData2 : []
|
|
206
|
+
var lineInBarChartProps2 = __assign(__assign({}, lineInBarChartProps), { lineConfig: lineConfig2, points: points2, data: lineData2 !== null && lineData2 !== void 0 ? lineData2 : [], yAxisOffset: lineConfig2.isSecondary
|
|
207
|
+
? (_17 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisOffset) !== null && _17 !== void 0 ? _17 : 0
|
|
208
|
+
: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0 });
|
|
207
209
|
var verticalLinesProps = {
|
|
208
210
|
verticalLinesAr: verticalLinesAr,
|
|
209
211
|
verticalLinesSpacing: verticalLinesSpacing,
|
|
210
|
-
spacing: (
|
|
212
|
+
spacing: (_18 = lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.spacing) !== null && _18 !== void 0 ? _18 : spacing,
|
|
211
213
|
initialSpacing: initialSpacing,
|
|
212
214
|
verticalLinesZIndex: verticalLinesZIndex,
|
|
213
215
|
verticalLinesHeight: verticalLinesHeight,
|
|
@@ -262,7 +264,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
262
264
|
: difBwWidthHeight - 40) /
|
|
263
265
|
2 +
|
|
264
266
|
(yAxisAtTop ? (rtl ? (props.width ? 12 : 40) : 12) : 52), ")");
|
|
265
|
-
var
|
|
267
|
+
var _21 = __read(useState(false), 2), canMomentum = _21[0], setCanMomentum = _21[1];
|
|
266
268
|
var isCloseToEnd = function (_a) {
|
|
267
269
|
var layoutMeasurement = _a.layoutMeasurement, contentOffset = _a.contentOffset, contentSize = _a.contentSize;
|
|
268
270
|
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;
|
|
@@ -84,7 +91,7 @@ export declare const maxAndMinUtil: (maxItem: number, minItem: number, roundToDi
|
|
|
84
91
|
export declare const computeMaxAndMinItems: (data: any[] | undefined, roundToDigits?: number, showFractionalValues?: boolean) => MaxAndMin;
|
|
85
92
|
export declare const getLabelTextUtil: (val: string, index: number, showFractionalValues?: boolean, yAxisLabelTexts?: string[], yAxisOffset?: number, yAxisLabelPrefix?: string, yAxisLabelSuffix?: string, roundToDigits?: number, formatYLabel?: (label: string) => string) => string;
|
|
86
93
|
export declare const getXForLineInBar: (index: number, firstBarWidth: number, currentBarWidth: number, yAxisLabelWidth: number, lineConfig: any, spacing: number) => number;
|
|
87
|
-
export declare const getYForLineInBar: (value: number | undefined, shiftY: number | undefined, containerHeight: number, maxValue: number) => number;
|
|
94
|
+
export declare const getYForLineInBar: (value: number | undefined, shiftY: number | undefined, containerHeight: number, maxValue: number, yAxisOffset: number) => number;
|
|
88
95
|
export declare const clone: (obj: any) => any;
|
|
89
96
|
export declare const getLineConfigForBarChart: (lineConfig: lineConfigType, barInitialSpacing: number) => lineConfigType;
|
|
90
97
|
export declare const getNoOfSections: (noOfSections: number | undefined, maxValue: number | undefined, stepValue: number | undefined) => number;
|
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)
|
|
@@ -749,8 +764,10 @@ export var getXForLineInBar = function (index, firstBarWidth, currentBarWidth, y
|
|
|
749
764
|
lineConfig.dataPointsWidth / 2 -
|
|
750
765
|
4;
|
|
751
766
|
};
|
|
752
|
-
export var getYForLineInBar = function (value, shiftY, containerHeight, maxValue) {
|
|
753
|
-
return containerHeight -
|
|
767
|
+
export var getYForLineInBar = function (value, shiftY, containerHeight, maxValue, yAxisOffset) {
|
|
768
|
+
return containerHeight -
|
|
769
|
+
(shiftY !== null && shiftY !== void 0 ? shiftY : 0) -
|
|
770
|
+
(((value !== null && value !== void 0 ? value : 0) - yAxisOffset) * containerHeight) / maxValue;
|
|
754
771
|
};
|
|
755
772
|
export var clone = function (obj) {
|
|
756
773
|
if (obj === null || typeof obj !== 'object' || 'isActiveClone' in obj) {
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -123,6 +123,7 @@ export interface LineInBarChartPropsType {
|
|
|
123
123
|
scrollEventThrottle: number;
|
|
124
124
|
xAxisLabelsVerticalShift: number;
|
|
125
125
|
selectedIndex: number;
|
|
126
|
+
yAxisOffset: number;
|
|
126
127
|
}
|
|
127
128
|
export interface DataPointProps {
|
|
128
129
|
data: any[];
|
|
@@ -134,6 +135,7 @@ export interface DataPointProps {
|
|
|
134
135
|
yAxisLabelWidth: number;
|
|
135
136
|
spacing: number;
|
|
136
137
|
selectedIndex: number;
|
|
138
|
+
yAxisOffset: number;
|
|
137
139
|
}
|
|
138
140
|
export interface referenceConfigType {
|
|
139
141
|
thickness?: number;
|
|
@@ -221,6 +223,10 @@ export interface horizSectionPropTypes {
|
|
|
221
223
|
secondaryStepValue: number;
|
|
222
224
|
secondaryNegativeStepValue: number;
|
|
223
225
|
secondaryNoOfSectionsBelowXAxis: number;
|
|
226
|
+
showSecondaryFractionalValues: boolean;
|
|
227
|
+
secondaryRoundToDigits: number;
|
|
228
|
+
secondaryStepHeight: number;
|
|
229
|
+
secondaryNegativeStepHeight: number;
|
|
224
230
|
}
|
|
225
231
|
interface HorizSectionObject {
|
|
226
232
|
value: string;
|
|
@@ -244,7 +250,7 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
244
250
|
initialSpacing: number;
|
|
245
251
|
data: any[];
|
|
246
252
|
stackData: any[] | undefined;
|
|
247
|
-
secondaryData
|
|
253
|
+
secondaryData?: any[];
|
|
248
254
|
barWidth: number | undefined;
|
|
249
255
|
xAxisThickness: number;
|
|
250
256
|
totalWidth: number;
|