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.
@@ -17,7 +17,7 @@ var __read = (this && this.__read) || function (o, n) {
17
17
  import { useState } from 'react';
18
18
  export var useRenderStackBars = function (props) {
19
19
  var _a, _b, _c, _d, _e, _f, _g, _h;
20
- var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, propSpacing = props.propSpacing, initialSpacing = props.initialSpacing, stackData = props.stackData, isAnimated = props.isAnimated, xAxisThickness = props.xAxisThickness, renderTooltip = props.renderTooltip, leftShiftForTooltip = props.leftShiftForTooltip, leftShiftForLastIndexTooltip = props.leftShiftForLastIndexTooltip, autoCenterTooltip = props.autoCenterTooltip, horizontal = props.horizontal;
20
+ var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, propSpacing = props.propSpacing, initialSpacing = props.initialSpacing, stackData = props.stackData, isAnimated = props.isAnimated, xAxisThickness = props.xAxisThickness, renderTooltip = props.renderTooltip, leftShiftForTooltip = props.leftShiftForTooltip, leftShiftForLastIndexTooltip = props.leftShiftForLastIndexTooltip, autoCenterTooltip = props.autoCenterTooltip, horizontal = props.horizontal, stepHeight = props.stepHeight, stepValue = props.stepValue, negativeStepHeight = props.negativeStepHeight, negativeStepValue = props.negativeStepValue, secondaryStepHeight = props.secondaryStepHeight, secondaryStepValue = props.secondaryStepValue, secondaryNegativeStepHeight = props.secondaryNegativeStepHeight, secondaryNegativeStepValue = props.secondaryNegativeStepValue;
21
21
  var containsNegativeValue = item.stacks.some(function (item) { return item.value < 0; });
22
22
  var noAnimation = containsNegativeValue || !isAnimated;
23
23
  var localBarInnerComponent = (_a = item.barInnerComponent) !== null && _a !== void 0 ? _a : props.barInnerComponent;
@@ -29,13 +29,20 @@ export var useRenderStackBars = function (props) {
29
29
  ((_e = (_d = stackData[i].stacks[0].barWidth) !== null && _d !== void 0 ? _d : props.barWidth) !== null && _e !== void 0 ? _e : 30);
30
30
  }
31
31
  var disablePress = (_f = props.disablePress) !== null && _f !== void 0 ? _f : false;
32
+ var heightFactor = item.isSecondary
33
+ ? secondaryStepHeight / secondaryStepValue
34
+ : stepHeight / stepValue;
35
+ var negativeHeightFactor = item.isSecondary
36
+ ? secondaryNegativeStepHeight / secondaryNegativeStepValue
37
+ : negativeStepHeight / negativeStepValue;
32
38
  var totalHeight = props.item.stacks.reduce(function (acc, stack) {
33
39
  return acc +
34
- (Math.abs(stack.value) * (containerHeight !== null && containerHeight !== void 0 ? containerHeight : 200)) / (maxValue || 200);
40
+ Math.abs(stack.value) *
41
+ (stack.value < 0 ? negativeHeightFactor : heightFactor);
35
42
  }, 0);
36
43
  var _j = __read(useState(noAnimation ? totalHeight : 1), 2), height = _j[0], setHeight = _j[1];
37
44
  var getBarHeight = function (value, marginBottom) {
38
- return ((Math.abs(value) * (containerHeight !== null && containerHeight !== void 0 ? containerHeight : 200)) / (maxValue || 200) -
45
+ return (Math.abs(value) * (value < 0 ? negativeHeightFactor : heightFactor) -
39
46
  (marginBottom !== null && marginBottom !== void 0 ? marginBottom : 0));
40
47
  };
41
48
  var getPosition = function (index) {
@@ -87,7 +87,6 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
87
87
  appearingOpacity: Animated.AnimatedInterpolation<string | number> | undefined;
88
88
  autoShiftLabels: boolean;
89
89
  yAxisAtTop: boolean;
90
- secondaryData: import("..").lineDataItem[] | barDataItem[] | undefined;
91
90
  disableScroll: boolean;
92
91
  showScrollIndicator: boolean;
93
92
  scrollToEnd: boolean;
@@ -186,6 +185,12 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
186
185
  negativeStepHeight: number;
187
186
  negativeStepValue: number;
188
187
  secondaryXAxis: import("../utils/types").XAxisConfig | undefined;
188
+ secondaryYAxis: boolean | secondaryYAxisType | undefined;
189
+ secondaryStepHeight: number;
190
+ secondaryStepValue: number;
191
+ secondaryNegativeStepHeight: number;
192
+ secondaryNegativeStepValue: number;
193
+ secondaryNoOfSectionsBelowXAxis: number;
189
194
  };
190
195
  barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes;
191
196
  yAxisExtraHeightAtTop: number;
@@ -26,15 +26,15 @@ var __read = (this && this.__read) || function (o, n) {
26
26
  return ar;
27
27
  };
28
28
  import { useEffect, useMemo, useState } from 'react';
29
- import { getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getLineConfigForBarChart, getMaxValue, getMostNegativeValue, getNoOfSections, getSecondaryDataWithOffsetIncluded, getXForLineInBar, getYForLineInBar, indexOfFirstNonZeroDigit, maxAndMinUtil, svgPath } from '../utils';
29
+ import { getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getLineConfigForBarChart, getMaxValue, getMostNegativeValue, getNoOfSections, getXForLineInBar, getYForLineInBar, indexOfFirstNonZeroDigit, maxAndMinUtil, svgPath } from '../utils';
30
30
  import { AxesAndRulesDefaults, BarDefaults, chartTypes, defaultLineConfig, defaultPointerConfig } from '../utils/constants';
31
31
  export var useBarChart = function (props) {
32
- 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, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48;
32
+ 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, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54;
33
33
  var heightValue = props.heightValue, widthValue = props.widthValue, opacityValue = props.opacityValue, yAxisOffset = props.yAxisOffset, adjustToWidth = props.adjustToWidth, parentWidth = props.parentWidth, labelsDistanceFromXaxis = props.labelsDistanceFromXaxis, autoShiftLabelsForNegativeStacks = props.autoShiftLabelsForNegativeStacks, focusedBarIndex = props.focusedBarIndex, negativeStepValue = props.negativeStepValue, autoCenterTooltip = props.autoCenterTooltip;
34
- var _49 = __read(useState(''), 2), points = _49[0], setPoints = _49[1];
35
- var _50 = __read(useState(''), 2), points2 = _50[0], setPoints2 = _50[1];
36
- var _51 = __read(useState(''), 2), arrowPoints = _51[0], setArrowPoints = _51[1];
37
- var _52 = __read(useState(focusedBarIndex !== null && focusedBarIndex !== void 0 ? focusedBarIndex : -1), 2), selectedIndex = _52[0], setSelectedIndex = _52[1];
34
+ var _55 = __read(useState(''), 2), points = _55[0], setPoints = _55[1];
35
+ var _56 = __read(useState(''), 2), points2 = _56[0], setPoints2 = _56[1];
36
+ var _57 = __read(useState(''), 2), arrowPoints = _57[0], setArrowPoints = _57[1];
37
+ var _58 = __read(useState(focusedBarIndex !== null && focusedBarIndex !== void 0 ? focusedBarIndex : -1), 2), selectedIndex = _58[0], setSelectedIndex = _58[1];
38
38
  var showLine = (_a = props.showLine) !== null && _a !== void 0 ? _a : BarDefaults.showLine;
39
39
  useEffect(function () {
40
40
  setSelectedIndex(focusedBarIndex !== null && focusedBarIndex !== void 0 ? focusedBarIndex : -1);
@@ -74,7 +74,10 @@ export var useBarChart = function (props) {
74
74
  var widthFromProps = horizontal ? props.height : props.width;
75
75
  var isAnimated = (_l = props.isAnimated) !== null && _l !== void 0 ? _l : BarDefaults.isAnimated;
76
76
  var animationDuration = (_m = props.animationDuration) !== null && _m !== void 0 ? _m : BarDefaults.animationDuration;
77
- var secondaryData = getSecondaryDataWithOffsetIncluded(props.secondaryData, props.secondaryYAxis);
77
+ // const secondaryData = getSecondaryDataWithOffsetIncluded(
78
+ // props.secondaryData,
79
+ // props.secondaryYAxis
80
+ // )
78
81
  var lineData = useMemo(function () {
79
82
  var _a;
80
83
  if (!props.lineData) {
@@ -110,19 +113,47 @@ export var useBarChart = function (props) {
110
113
  var scrollAnimation = (_s = props.scrollAnimation) !== null && _s !== void 0 ? _s : BarDefaults.scrollAnimation;
111
114
  var scrollEventThrottle = (_t = props.scrollEventThrottle) !== null && _t !== void 0 ? _t : BarDefaults.scrollEventThrottle;
112
115
  var labelsExtraHeight = (_u = props.labelsExtraHeight) !== null && _u !== void 0 ? _u : AxesAndRulesDefaults.labelsExtraHeight;
116
+ var secondaryMaxItem = 0;
117
+ var secondaryMinItem = 0;
118
+ if (lineConfig.isSecondary) {
119
+ lineData.forEach(function (item) {
120
+ var _a, _b, _c, _d;
121
+ if (((_a = item.value) !== null && _a !== void 0 ? _a : 0) > secondaryMaxItem) {
122
+ secondaryMaxItem = (_b = item.value) !== null && _b !== void 0 ? _b : 0;
123
+ }
124
+ if (((_c = item.value) !== null && _c !== void 0 ? _c : 0) < secondaryMinItem) {
125
+ secondaryMinItem = (_d = item.value) !== null && _d !== void 0 ? _d : 0;
126
+ }
127
+ });
128
+ }
113
129
  var totalWidth = initialSpacing + endSpacing;
114
130
  var maxItem = 0;
115
131
  var minItem = 0;
132
+ var minPositiveItem = 0;
133
+ var secondaryMinPositiveItem = 0;
116
134
  if (props.stackData) {
117
135
  props.stackData.forEach(function (stackItem, index) {
118
136
  var _a, _b, _c;
119
137
  var stackSumMax = stackItem.stacks.reduce(function (acc, stack) { return acc + (stack.value >= 0 ? stack.value : 0); }, 0);
120
138
  var stackSumMin = stackItem.stacks.reduce(function (acc, stack) { return acc + (stack.value < 0 ? stack.value : 0); }, 0);
121
- if (stackSumMax > maxItem) {
122
- maxItem = stackSumMax;
139
+ if (stackItem.isSecondary) {
140
+ if (stackSumMax > secondaryMaxItem) {
141
+ secondaryMaxItem = stackSumMax;
142
+ }
143
+ if (stackSumMin < secondaryMinItem) {
144
+ secondaryMinItem = stackSumMin;
145
+ secondaryMinPositiveItem =
146
+ secondaryMinItem > 0 ? secondaryMinItem : secondaryMinPositiveItem;
147
+ }
123
148
  }
124
- if (stackSumMin < minItem) {
125
- minItem = stackSumMin;
149
+ else {
150
+ if (stackSumMax > maxItem) {
151
+ maxItem = stackSumMax;
152
+ }
153
+ if (stackSumMin < minItem) {
154
+ minItem = stackSumMin;
155
+ minPositiveItem = minItem > 0 ? minItem : minPositiveItem;
156
+ }
126
157
  }
127
158
  totalWidth +=
128
159
  ((_b = (_a = stackItem.stacks[0].barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
@@ -132,107 +163,119 @@ export var useBarChart = function (props) {
132
163
  else {
133
164
  data.forEach(function (item, index) {
134
165
  var _a, _b, _c;
135
- if (item.value > maxItem) {
136
- maxItem = item.value;
166
+ if (item.isSecondary) {
167
+ if (item.value > secondaryMaxItem) {
168
+ secondaryMaxItem = item.value;
169
+ }
170
+ if (item.value < secondaryMinItem) {
171
+ secondaryMinItem = item.value;
172
+ secondaryMinPositiveItem =
173
+ secondaryMinItem > 0 ? secondaryMinItem : secondaryMinPositiveItem;
174
+ }
137
175
  }
138
- if (item.value < minItem) {
139
- minItem = item.value;
176
+ else {
177
+ if (item.value > maxItem) {
178
+ maxItem = item.value;
179
+ }
180
+ if (item.value < minItem) {
181
+ minItem = item.value;
182
+ minPositiveItem = minItem > 0 ? minItem : minPositiveItem;
183
+ }
140
184
  }
141
185
  totalWidth +=
142
186
  ((_b = (_a = item.barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
143
187
  (index === data.length - 1 ? spacing : (_c = item.spacing) !== null && _c !== void 0 ? _c : spacing);
144
188
  });
145
189
  }
146
- var secondaryMaxItem = 0;
147
- var secondaryMinItem = 0;
148
- if (lineConfig.isSecondary) {
149
- lineData.forEach(function (item) {
150
- var _a, _b, _c, _d;
151
- if (((_a = item.value) !== null && _a !== void 0 ? _a : 0) > secondaryMaxItem) {
152
- secondaryMaxItem = (_b = item.value) !== null && _b !== void 0 ? _b : 0;
153
- }
154
- if (((_c = item.value) !== null && _c !== void 0 ? _c : 0) < secondaryMinItem) {
155
- secondaryMinItem = (_d = item.value) !== null && _d !== void 0 ? _d : 0;
156
- }
157
- });
158
- }
159
- var valuesRange = maxItem - minItem;
190
+ var valuesRange = maxItem - minPositiveItem; // Diff bw largest & smallest +ve values
160
191
  var showFractionalValues = (_v = props.showFractionalValues) !== null && _v !== void 0 ? _v : valuesRange <= 1;
161
192
  var roundToDigits = (_w = props.roundToDigits) !== null && _w !== void 0 ? _w : (showFractionalValues ? indexOfFirstNonZeroDigit(valuesRange) + 1 : 0);
162
193
  var maxAndMin = maxAndMinUtil(maxItem, minItem, roundToDigits, showFractionalValues);
163
- var secondaryMaxAndMin = maxAndMinUtil(secondaryMaxItem, secondaryMinItem, roundToDigits, showFractionalValues);
164
194
  var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxAndMin.maxItem);
165
- var secondaryMaxValue = lineConfig.isSecondary
166
- ? typeof props.secondaryYAxis !== 'boolean'
167
- ? (_x = props.secondaryYAxis.maxValue) !== null && _x !== void 0 ? _x : secondaryMaxAndMin.maxItem
168
- : secondaryMaxAndMin.maxItem
169
- : maxValue;
195
+ var secondaryRange = secondaryMaxItem - secondaryMinPositiveItem; // Diff bw largest & smallest +ve values
196
+ var showSecondaryFractionalValues = (_y = (_x = props.secondaryYAxis) === null || _x === void 0 ? void 0 : _x.showFractionalValues) !== null && _y !== void 0 ? _y : secondaryRange <= 1;
197
+ var secondaryRoundToDigits = (_0 = (_z = props.secondaryYAxis) === null || _z === void 0 ? void 0 : _z.roundToDigits) !== null && _0 !== void 0 ? _0 : (showSecondaryFractionalValues
198
+ ? indexOfFirstNonZeroDigit(secondaryRange) + 1
199
+ : 0);
200
+ var secondaryMaxAndMin = maxAndMinUtil(secondaryMaxItem, secondaryMinItem, secondaryRoundToDigits, showSecondaryFractionalValues);
201
+ // const secondaryMaxValue = lineConfig.isSecondary
202
+ // ? typeof props.secondaryYAxis !== 'boolean'
203
+ // ? (props.secondaryYAxis as secondaryYAxisType).maxValue ??
204
+ // secondaryMaxAndMin.maxItem
205
+ // : secondaryMaxAndMin.maxItem
206
+ // : maxValue
207
+ var secondaryMaxValue = (_2 = (_1 = props.secondaryYAxis) === null || _1 === void 0 ? void 0 : _1.maxValue) !== null && _2 !== void 0 ? _2 : secondaryMaxAndMin.maxItem;
170
208
  var mostNegativeValue = getMostNegativeValue(props.mostNegativeValue, props.negativeStepValue, props.noOfSectionsBelowXAxis, maxAndMin.minItem);
171
- var stepValue = (_y = props.stepValue) !== null && _y !== void 0 ? _y : maxValue / noOfSections;
172
- var noOfSectionsBelowXAxis = (_z = props.noOfSectionsBelowXAxis) !== null && _z !== void 0 ? _z : Math.round(Math.ceil(-mostNegativeValue / (negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue)));
173
- var showScrollIndicator = (_0 = props.showScrollIndicator) !== null && _0 !== void 0 ? _0 : BarDefaults.showScrollIndicator;
174
- var side = (_1 = props.side) !== null && _1 !== void 0 ? _1 : BarDefaults.side;
175
- var rotateLabel = (_2 = props.rotateLabel) !== null && _2 !== void 0 ? _2 : AxesAndRulesDefaults.rotateLabel;
176
- var opacity = (_3 = props.opacity) !== null && _3 !== void 0 ? _3 : BarDefaults.opacity;
177
- var isThreeD = (_4 = props.isThreeD) !== null && _4 !== void 0 ? _4 : BarDefaults.isThreeD;
178
- var showXAxisIndices = (_5 = props.showXAxisIndices) !== null && _5 !== void 0 ? _5 : AxesAndRulesDefaults.showXAxisIndices;
179
- var xAxisIndicesHeight = (_6 = props.xAxisIndicesHeight) !== null && _6 !== void 0 ? _6 : AxesAndRulesDefaults.xAxisIndicesHeight;
180
- var xAxisIndicesWidth = (_7 = props.xAxisIndicesWidth) !== null && _7 !== void 0 ? _7 : AxesAndRulesDefaults.xAxisIndicesWidth;
181
- var xAxisIndicesColor = (_8 = props.xAxisIndicesColor) !== null && _8 !== void 0 ? _8 : AxesAndRulesDefaults.xAxisIndicesColor;
182
- var xAxisThickness = (_9 = props.xAxisThickness) !== null && _9 !== void 0 ? _9 : AxesAndRulesDefaults.xAxisThickness;
183
- var xAxisTextNumberOfLines = (_10 = props.xAxisTextNumberOfLines) !== null && _10 !== void 0 ? _10 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
184
- var xAxisLabelsVerticalShift = (_11 = props.xAxisLabelsVerticalShift) !== null && _11 !== void 0 ? _11 : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
209
+ var stepValue = (_3 = props.stepValue) !== null && _3 !== void 0 ? _3 : maxValue / noOfSections;
210
+ var noOfSectionsBelowXAxis = (_4 = props.noOfSectionsBelowXAxis) !== null && _4 !== void 0 ? _4 : Math.round(Math.ceil(-mostNegativeValue / (negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue)));
211
+ var showScrollIndicator = (_5 = props.showScrollIndicator) !== null && _5 !== void 0 ? _5 : BarDefaults.showScrollIndicator;
212
+ var side = (_6 = props.side) !== null && _6 !== void 0 ? _6 : BarDefaults.side;
213
+ var rotateLabel = (_7 = props.rotateLabel) !== null && _7 !== void 0 ? _7 : AxesAndRulesDefaults.rotateLabel;
214
+ var opacity = (_8 = props.opacity) !== null && _8 !== void 0 ? _8 : BarDefaults.opacity;
215
+ var isThreeD = (_9 = props.isThreeD) !== null && _9 !== void 0 ? _9 : BarDefaults.isThreeD;
216
+ var showXAxisIndices = (_10 = props.showXAxisIndices) !== null && _10 !== void 0 ? _10 : AxesAndRulesDefaults.showXAxisIndices;
217
+ var xAxisIndicesHeight = (_11 = props.xAxisIndicesHeight) !== null && _11 !== void 0 ? _11 : AxesAndRulesDefaults.xAxisIndicesHeight;
218
+ var xAxisIndicesWidth = (_12 = props.xAxisIndicesWidth) !== null && _12 !== void 0 ? _12 : AxesAndRulesDefaults.xAxisIndicesWidth;
219
+ var xAxisIndicesColor = (_13 = props.xAxisIndicesColor) !== null && _13 !== void 0 ? _13 : AxesAndRulesDefaults.xAxisIndicesColor;
220
+ var xAxisThickness = (_14 = props.xAxisThickness) !== null && _14 !== void 0 ? _14 : AxesAndRulesDefaults.xAxisThickness;
221
+ var xAxisTextNumberOfLines = (_15 = props.xAxisTextNumberOfLines) !== null && _15 !== void 0 ? _15 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
222
+ var xAxisLabelsVerticalShift = (_16 = props.xAxisLabelsVerticalShift) !== null && _16 !== void 0 ? _16 : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
185
223
  var horizontalRulesStyle = props.horizontalRulesStyle;
186
- var autoShiftLabels = (_12 = props.autoShiftLabels) !== null && _12 !== void 0 ? _12 : false;
187
- var barBorderColor = (_13 = props.barBorderColor) !== null && _13 !== void 0 ? _13 : BarDefaults.barBorderColor;
224
+ var autoShiftLabels = (_17 = props.autoShiftLabels) !== null && _17 !== void 0 ? _17 : false;
225
+ var barBorderColor = (_18 = props.barBorderColor) !== null && _18 !== void 0 ? _18 : BarDefaults.barBorderColor;
188
226
  var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
189
- var containerHeightIncludingBelowXAxis = extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
190
- var _53 = __read(useState(-1), 2), pointerIndex = _53[0], setPointerIndex = _53[1];
191
- var _54 = __read(useState(0), 2), pointerX = _54[0], setPointerX = _54[1];
192
- var _55 = __read(useState(0), 2), pointerY = _55[0], setPointerY = _55[1];
193
- var _56 = __read(useState(), 2), pointerItem = _56[0], setPointerItem = _56[1];
194
- var _57 = __read(useState(0), 2), responderStartTime = _57[0], setResponderStartTime = _57[1];
195
- var _58 = __read(useState(false), 2), responderActive = _58[0], setResponderActive = _58[1];
227
+ var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
228
+ var _59 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepHeight = _59.stepHeight, secondaryStepValue = _59.stepValue, secondaryNegativeStepHeight = _59.negativeStepHeight, secondaryNegativeStepValue = _59.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _59.noOfSectionsBelowXAxis;
229
+ var primary4thQuadrantHeight = noOfSectionsBelowXAxis * ((_19 = props.negativeStepHeight) !== null && _19 !== void 0 ? _19 : stepHeight);
230
+ var secondary4thQuadrantHeight = secondaryNoOfSectionsBelowXAxis * secondaryNegativeStepHeight;
231
+ var containerHeightIncludingBelowXAxis = extendedContainerHeight +
232
+ Math.max(primary4thQuadrantHeight, secondary4thQuadrantHeight);
233
+ var _60 = __read(useState(-1), 2), pointerIndex = _60[0], setPointerIndex = _60[1];
234
+ var _61 = __read(useState(0), 2), pointerX = _61[0], setPointerX = _61[1];
235
+ var _62 = __read(useState(0), 2), pointerY = _62[0], setPointerY = _62[1];
236
+ var _63 = __read(useState(), 2), pointerItem = _63[0], setPointerItem = _63[1];
237
+ var _64 = __read(useState(0), 2), responderStartTime = _64[0], setResponderStartTime = _64[1];
238
+ var _65 = __read(useState(false), 2), responderActive = _65[0], setResponderActive = _65[1];
196
239
  var pointerConfig = props.pointerConfig;
197
- var getPointerProps = (_14 = props.getPointerProps) !== null && _14 !== void 0 ? _14 : null;
198
- var pointerHeight = (_15 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _15 !== void 0 ? _15 : defaultPointerConfig.height;
199
- var pointerWidth = (_16 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.width) !== null && _16 !== void 0 ? _16 : defaultPointerConfig.width;
200
- var pointerRadius = (_17 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.radius) !== null && _17 !== void 0 ? _17 : defaultPointerConfig.radius;
201
- var pointerColor = (_18 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColor) !== null && _18 !== void 0 ? _18 : defaultPointerConfig.pointerColor;
202
- var pointerComponent = (_19 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerComponent) !== null && _19 !== void 0 ? _19 : defaultPointerConfig.pointerComponent;
240
+ var getPointerProps = (_20 = props.getPointerProps) !== null && _20 !== void 0 ? _20 : null;
241
+ var pointerHeight = (_21 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _21 !== void 0 ? _21 : defaultPointerConfig.height;
242
+ var pointerWidth = (_22 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.width) !== null && _22 !== void 0 ? _22 : defaultPointerConfig.width;
243
+ var pointerRadius = (_23 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.radius) !== null && _23 !== void 0 ? _23 : defaultPointerConfig.radius;
244
+ var pointerColor = (_24 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColor) !== null && _24 !== void 0 ? _24 : defaultPointerConfig.pointerColor;
245
+ var pointerComponent = (_25 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerComponent) !== null && _25 !== void 0 ? _25 : defaultPointerConfig.pointerComponent;
203
246
  var showPointerStrip = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.showPointerStrip) === false
204
247
  ? false
205
248
  : defaultPointerConfig.showPointerStrip;
206
- var pointerStripHeight = (_20 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripHeight) !== null && _20 !== void 0 ? _20 : defaultPointerConfig.pointerStripHeight;
207
- var pointerStripWidth = (_21 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripWidth) !== null && _21 !== void 0 ? _21 : defaultPointerConfig.pointerStripWidth;
208
- var pointerStripColor = (_22 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripColor) !== null && _22 !== void 0 ? _22 : defaultPointerConfig.pointerStripColor;
209
- var pointerStripUptoDataPoint = (_23 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripUptoDataPoint) !== null && _23 !== void 0 ? _23 : defaultPointerConfig.pointerStripUptoDataPoint;
210
- var pointerLabelComponent = (_24 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelComponent) !== null && _24 !== void 0 ? _24 : defaultPointerConfig.pointerLabelComponent;
211
- var stripOverPointer = (_25 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripOverPointer) !== null && _25 !== void 0 ? _25 : defaultPointerConfig.stripOverPointer;
212
- var shiftPointerLabelX = (_26 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelX) !== null && _26 !== void 0 ? _26 : defaultPointerConfig.shiftPointerLabelX;
213
- var shiftPointerLabelY = (_27 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelY) !== null && _27 !== void 0 ? _27 : defaultPointerConfig.shiftPointerLabelY;
214
- var pointerLabelWidth = (_28 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelWidth) !== null && _28 !== void 0 ? _28 : defaultPointerConfig.pointerLabelWidth;
215
- var pointerLabelHeight = (_29 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelHeight) !== null && _29 !== void 0 ? _29 : defaultPointerConfig.pointerLabelHeight;
216
- var autoAdjustPointerLabelPosition = (_30 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.autoAdjustPointerLabelPosition) !== null && _30 !== void 0 ? _30 : defaultPointerConfig.autoAdjustPointerLabelPosition;
217
- var pointerVanishDelay = (_31 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerVanishDelay) !== null && _31 !== void 0 ? _31 : defaultPointerConfig.pointerVanishDelay;
218
- var activatePointersOnLongPress = (_32 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersOnLongPress) !== null && _32 !== void 0 ? _32 : defaultPointerConfig.activatePointersOnLongPress;
219
- var activatePointersDelay = (_33 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersDelay) !== null && _33 !== void 0 ? _33 : defaultPointerConfig.activatePointersDelay;
220
- var initialPointerIndex = (_34 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerIndex) !== null && _34 !== void 0 ? _34 : defaultPointerConfig.initialPointerIndex;
221
- var initialPointerAppearDelay = (_35 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerAppearDelay) !== null && _35 !== void 0 ? _35 : (isAnimated
249
+ var pointerStripHeight = (_26 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripHeight) !== null && _26 !== void 0 ? _26 : defaultPointerConfig.pointerStripHeight;
250
+ var pointerStripWidth = (_27 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripWidth) !== null && _27 !== void 0 ? _27 : defaultPointerConfig.pointerStripWidth;
251
+ var pointerStripColor = (_28 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripColor) !== null && _28 !== void 0 ? _28 : defaultPointerConfig.pointerStripColor;
252
+ var pointerStripUptoDataPoint = (_29 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripUptoDataPoint) !== null && _29 !== void 0 ? _29 : defaultPointerConfig.pointerStripUptoDataPoint;
253
+ var pointerLabelComponent = (_30 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelComponent) !== null && _30 !== void 0 ? _30 : defaultPointerConfig.pointerLabelComponent;
254
+ var stripOverPointer = (_31 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripOverPointer) !== null && _31 !== void 0 ? _31 : defaultPointerConfig.stripOverPointer;
255
+ var shiftPointerLabelX = (_32 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelX) !== null && _32 !== void 0 ? _32 : defaultPointerConfig.shiftPointerLabelX;
256
+ var shiftPointerLabelY = (_33 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelY) !== null && _33 !== void 0 ? _33 : defaultPointerConfig.shiftPointerLabelY;
257
+ var pointerLabelWidth = (_34 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelWidth) !== null && _34 !== void 0 ? _34 : defaultPointerConfig.pointerLabelWidth;
258
+ var pointerLabelHeight = (_35 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelHeight) !== null && _35 !== void 0 ? _35 : defaultPointerConfig.pointerLabelHeight;
259
+ var autoAdjustPointerLabelPosition = (_36 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.autoAdjustPointerLabelPosition) !== null && _36 !== void 0 ? _36 : defaultPointerConfig.autoAdjustPointerLabelPosition;
260
+ var pointerVanishDelay = (_37 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerVanishDelay) !== null && _37 !== void 0 ? _37 : defaultPointerConfig.pointerVanishDelay;
261
+ var activatePointersOnLongPress = (_38 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersOnLongPress) !== null && _38 !== void 0 ? _38 : defaultPointerConfig.activatePointersOnLongPress;
262
+ var activatePointersDelay = (_39 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersDelay) !== null && _39 !== void 0 ? _39 : defaultPointerConfig.activatePointersDelay;
263
+ var initialPointerIndex = (_40 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerIndex) !== null && _40 !== void 0 ? _40 : defaultPointerConfig.initialPointerIndex;
264
+ var initialPointerAppearDelay = (_41 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerAppearDelay) !== null && _41 !== void 0 ? _41 : (isAnimated
222
265
  ? animationDuration
223
266
  : defaultPointerConfig.initialPointerAppearDelay);
224
- var persistPointer = (_36 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.persistPointer) !== null && _36 !== void 0 ? _36 : defaultPointerConfig.persistPointer;
225
- var hidePointer1 = (_37 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointer1) !== null && _37 !== void 0 ? _37 : defaultPointerConfig.hidePointer1;
267
+ var persistPointer = (_42 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.persistPointer) !== null && _42 !== void 0 ? _42 : defaultPointerConfig.persistPointer;
268
+ var hidePointer1 = (_43 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointer1) !== null && _43 !== void 0 ? _43 : defaultPointerConfig.hidePointer1;
226
269
  var pointerEvents = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerEvents;
227
- var stripBehindBars = (_38 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripBehindBars) !== null && _38 !== void 0 ? _38 : defaultPointerConfig.stripBehindBars;
228
- var disableScroll = (_39 = props.disableScroll) !== null && _39 !== void 0 ? _39 : (pointerConfig
270
+ var stripBehindBars = (_44 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripBehindBars) !== null && _44 !== void 0 ? _44 : defaultPointerConfig.stripBehindBars;
271
+ var disableScroll = (_45 = props.disableScroll) !== null && _45 !== void 0 ? _45 : (pointerConfig
229
272
  ? activatePointersOnLongPress
230
273
  ? !!responderActive
231
274
  : true
232
275
  : false);
233
276
  var yAxisExtraHeightAtTop = props.trimYAxisAtTop
234
277
  ? 0
235
- : (_40 = props.yAxisExtraHeight) !== null && _40 !== void 0 ? _40 : containerHeight / 20;
278
+ : (_46 = props.yAxisExtraHeight) !== null && _46 !== void 0 ? _46 : containerHeight / 20;
236
279
  var barInnerComponent = props.barInnerComponent;
237
280
  useEffect(function () {
238
281
  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;
@@ -348,9 +391,9 @@ export var useBarChart = function (props) {
348
391
  spacing,
349
392
  yAxisLabelWidth,
350
393
  lineConfig.showArrow,
351
- (_41 = lineConfig.arrowConfig) === null || _41 === void 0 ? void 0 : _41.length,
352
- (_42 = lineConfig.arrowConfig) === null || _42 === void 0 ? void 0 : _42.width,
353
- (_43 = lineConfig.arrowConfig) === null || _43 === void 0 ? void 0 : _43.showArrowBase
394
+ (_47 = lineConfig.arrowConfig) === null || _47 === void 0 ? void 0 : _47.length,
395
+ (_48 = lineConfig.arrowConfig) === null || _48 === void 0 ? void 0 : _48.width,
396
+ (_49 = lineConfig.arrowConfig) === null || _49 === void 0 ? void 0 : _49.showArrowBase
354
397
  ]);
355
398
  useEffect(function () {
356
399
  var _a, _b, _c, _d;
@@ -465,7 +508,13 @@ export var useBarChart = function (props) {
465
508
  stepValue: stepValue,
466
509
  negativeStepHeight: (_u = props.negativeStepHeight) !== null && _u !== void 0 ? _u : stepHeight,
467
510
  negativeStepValue: (_v = props.negativeStepValue) !== null && _v !== void 0 ? _v : stepValue,
468
- secondaryXAxis: props.secondaryXAxis
511
+ secondaryXAxis: props.secondaryXAxis,
512
+ secondaryYAxis: props.secondaryYAxis,
513
+ secondaryStepHeight: secondaryStepHeight,
514
+ secondaryStepValue: secondaryStepValue,
515
+ secondaryNegativeStepHeight: secondaryNegativeStepHeight,
516
+ secondaryNegativeStepValue: secondaryNegativeStepValue,
517
+ secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis
469
518
  };
470
519
  };
471
520
  var barAndLineChartsWrapperProps = {
@@ -473,19 +522,19 @@ export var useBarChart = function (props) {
473
522
  containerHeight: containerHeight,
474
523
  noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
475
524
  stepHeight: stepHeight,
476
- negativeStepHeight: (_44 = props.negativeStepHeight) !== null && _44 !== void 0 ? _44 : stepHeight,
525
+ negativeStepHeight: (_50 = props.negativeStepHeight) !== null && _50 !== void 0 ? _50 : stepHeight,
477
526
  labelsExtraHeight: labelsExtraHeight,
478
527
  yAxisLabelWidth: yAxisLabelWidth,
479
528
  horizontal: horizontal,
480
529
  rtl: rtl,
481
- shiftX: (_45 = props.shiftX) !== null && _45 !== void 0 ? _45 : 0,
482
- shiftY: (_46 = props.shiftY) !== null && _46 !== void 0 ? _46 : 0,
530
+ shiftX: (_51 = props.shiftX) !== null && _51 !== void 0 ? _51 : 0,
531
+ shiftY: (_52 = props.shiftY) !== null && _52 !== void 0 ? _52 : 0,
483
532
  yAxisAtTop: yAxisAtTop,
484
533
  initialSpacing: initialSpacing,
485
534
  data: data,
486
535
  stackData: props.stackData,
487
- secondaryData: secondaryData,
488
- barWidth: (_47 = props.barWidth) !== null && _47 !== void 0 ? _47 : defaultBarWidth,
536
+ // secondaryData,
537
+ barWidth: (_53 = props.barWidth) !== null && _53 !== void 0 ? _53 : defaultBarWidth,
489
538
  xAxisThickness: xAxisThickness,
490
539
  totalWidth: totalWidth,
491
540
  disableScroll: disableScroll,
@@ -517,7 +566,7 @@ export var useBarChart = function (props) {
517
566
  noOfSections: noOfSections,
518
567
  sectionColors: props.sectionColors,
519
568
  showFractionalValues: showFractionalValues,
520
- axesAndRulesProps: getAxesAndRulesProps(props, stepValue, roundToDigits, negativeStepValue, secondaryMaxValue),
569
+ axesAndRulesProps: axesAndRulesProps,
521
570
  yAxisLabelTexts: props.yAxisLabelTexts,
522
571
  yAxisOffset: yAxisOffset,
523
572
  rotateYAxisTexts: props.rotateYAxisTexts,
@@ -534,7 +583,7 @@ export var useBarChart = function (props) {
534
583
  pointerY: pointerY,
535
584
  onEndReached: props.onEndReached,
536
585
  onStartReached: props.onStartReached,
537
- endReachedOffset: (_48 = props.endReachedOffset) !== null && _48 !== void 0 ? _48 : BarDefaults.endReachedOffset,
586
+ endReachedOffset: (_54 = props.endReachedOffset) !== null && _54 !== void 0 ? _54 : BarDefaults.endReachedOffset,
538
587
  onMomentumScrollEnd: props.onMomentumScrollEnd
539
588
  };
540
589
  return {
@@ -615,7 +664,7 @@ export var useBarChart = function (props) {
615
664
  appearingOpacity: appearingOpacity,
616
665
  autoShiftLabels: autoShiftLabels,
617
666
  yAxisAtTop: yAxisAtTop,
618
- secondaryData: secondaryData,
667
+ // secondaryData,
619
668
  disableScroll: disableScroll,
620
669
  showScrollIndicator: showScrollIndicator,
621
670
  scrollToEnd: scrollToEnd,
@@ -56,6 +56,7 @@ export interface stackDataItem {
56
56
  onContextMenu?: Function;
57
57
  onMouseEnter?: Function;
58
58
  onMouseLeave?: Function;
59
+ isSecondary?: boolean;
59
60
  }
60
61
  export interface StackedBarChartPropsType {
61
62
  style?: any;
@@ -125,6 +126,15 @@ export interface StackedBarChartPropsType {
125
126
  pointerConfig?: Pointer;
126
127
  showValuesAsTopLabel?: boolean;
127
128
  yAxisOffset: number;
129
+ stepHeight: number;
130
+ stepValue: number;
131
+ negativeStepHeight: number;
132
+ negativeStepValue: number;
133
+ secondaryStepHeight: number;
134
+ secondaryStepValue: number;
135
+ secondaryNegativeStepHeight: number;
136
+ secondaryNegativeStepValue: number;
137
+ secondaryNoOfSectionsBelowXAxis: number;
128
138
  }
129
139
  export interface BarChartPropsType {
130
140
  width?: number;
@@ -287,7 +297,6 @@ export interface BarChartPropsType {
287
297
  leftShiftForLastIndexTooltip?: number;
288
298
  barStyle?: object;
289
299
  barInnerComponent?: (item?: stackDataItem | barDataItem, index?: number) => ReactNode;
290
- secondaryData?: barDataItem[];
291
300
  secondaryYAxis?: secondaryYAxisType | boolean;
292
301
  pointerConfig?: Pointer;
293
302
  getPointerProps?: Function;
@@ -565,6 +574,7 @@ export interface RenderBarsPropsType {
565
574
  setSelectedIndex: Function;
566
575
  barStyle?: object;
567
576
  xAxisThickness?: number;
577
+ secondaryXAxis?: XAxisConfig;
568
578
  pointerConfig?: Pointer;
569
579
  focusBarOnPress?: boolean;
570
580
  focusedBarIndex?: number;
@@ -574,7 +584,11 @@ export interface RenderBarsPropsType {
574
584
  stepValue: number;
575
585
  negativeStepHeight: number;
576
586
  negativeStepValue: number;
577
- secondaryXAxis?: XAxisConfig;
587
+ secondaryStepHeight: number;
588
+ secondaryStepValue: number;
589
+ secondaryNegativeStepHeight: number;
590
+ secondaryNegativeStepValue: number;
591
+ secondaryNoOfSectionsBelowXAxis: number;
578
592
  }
579
593
  export interface trianglePropTypes {
580
594
  style: any;
@@ -419,7 +419,7 @@ export var useLineChartBiColor = function (props) {
419
419
  horizontalRulesStyle: horizontalRulesStyle,
420
420
  noOfSections: noOfSections,
421
421
  showFractionalValues: showFractionalValues,
422
- axesAndRulesProps: getAxesAndRulesProps(props, stepValue, (_50 = props.roundToDigits) !== null && _50 !== void 0 ? _50 : 0, undefined),
422
+ axesAndRulesProps: getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, (_50 = props.roundToDigits) !== null && _50 !== void 0 ? _50 : 0, 0, 0, 0, false, 0),
423
423
  yAxisLabelTexts: props.yAxisLabelTexts,
424
424
  yAxisOffset: props.yAxisOffset,
425
425
  rotateYAxisTexts: 0,