gifted-charts-core 0.1.10 → 0.1.11
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/package.json +1 -1
- package/src/BarChart/index.d.ts +4 -0
- package/src/BarChart/index.js +58 -52
- package/src/BarChart/index.ts +18 -4
- package/src/BarChart/types.d.ts +7 -0
- package/src/BarChart/types.ts +7 -0
- package/src/LineChart/LineChartBiColor.js +1 -0
- package/src/LineChart/LineChartBiColor.ts +1 -0
- package/src/LineChart/index.js +7 -5
- package/src/LineChart/index.ts +4 -2
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +4 -2
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.ts +9 -2
- package/src/components/BarAndLineChartsWrapper/index.js +5 -1
- package/src/components/BarAndLineChartsWrapper/index.ts +6 -0
- package/src/utils/index.d.ts +16 -2
- package/src/utils/index.js +7 -1
- package/src/utils/index.ts +28 -2
- package/src/utils/types.d.ts +7 -0
- package/src/utils/types.ts +7 -0
package/package.json
CHANGED
package/src/BarChart/index.d.ts
CHANGED
|
@@ -177,6 +177,10 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
177
177
|
yAxisExtraHeightAtTop: number;
|
|
178
178
|
yAxisOffset: number;
|
|
179
179
|
focusedBarIndex: number | undefined;
|
|
180
|
+
stepHeight: number;
|
|
181
|
+
stepValue: number;
|
|
182
|
+
negativeStepHeight: number;
|
|
183
|
+
negativeStepValue: number;
|
|
180
184
|
};
|
|
181
185
|
barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes;
|
|
182
186
|
yAxisExtraHeightAtTop: number;
|
package/src/BarChart/index.js
CHANGED
|
@@ -26,11 +26,11 @@ 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, getNoOfSections, getSecondaryDataWithOffsetIncluded, getXForLineInBar, getYForLineInBar, maxAndMinUtil, svgPath } from '../utils';
|
|
29
|
+
import { getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getLineConfigForBarChart, getMaxValue, getMostNegativeValue, getNoOfSections, getSecondaryDataWithOffsetIncluded, getXForLineInBar, getYForLineInBar, maxAndMinUtil, svgPath } from '../utils';
|
|
30
30
|
import { AxesAndRulesDefaults, BarDefaults, chartTypes, defaultLineConfig, defaultPointerConfig } from '../utils/constants';
|
|
31
31
|
export var useBarChart = function (props) {
|
|
32
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;
|
|
33
|
-
var heightValue = props.heightValue, widthValue = props.widthValue, opacValue = props.opacValue, yAxisOffset = props.yAxisOffset, adjustToWidth = props.adjustToWidth, parentWidth = props.parentWidth, labelsDistanceFromXaxis = props.labelsDistanceFromXaxis, autoShiftLabelsForNegativeStacks = props.autoShiftLabelsForNegativeStacks, focusedBarIndex = props.focusedBarIndex;
|
|
33
|
+
var heightValue = props.heightValue, widthValue = props.widthValue, opacValue = props.opacValue, yAxisOffset = props.yAxisOffset, adjustToWidth = props.adjustToWidth, parentWidth = props.parentWidth, labelsDistanceFromXaxis = props.labelsDistanceFromXaxis, autoShiftLabelsForNegativeStacks = props.autoShiftLabelsForNegativeStacks, focusedBarIndex = props.focusedBarIndex, negativeStepValue = props.negativeStepValue;
|
|
34
34
|
var _48 = __read(useState(''), 2), points = _48[0], setPoints = _48[1];
|
|
35
35
|
var _49 = __read(useState(''), 2), points2 = _49[0], setPoints2 = _49[1];
|
|
36
36
|
var _50 = __read(useState(''), 2), arrowPoints = _50[0], setArrowPoints = _50[1];
|
|
@@ -165,24 +165,24 @@ export var useBarChart = function (props) {
|
|
|
165
165
|
? (_w = props.secondaryYAxis.maxValue) !== null && _w !== void 0 ? _w : secondaryMaxAndMin.maxItem
|
|
166
166
|
: secondaryMaxAndMin.maxItem
|
|
167
167
|
: maxValue;
|
|
168
|
-
var mostNegativeValue = (
|
|
169
|
-
var stepValue = (
|
|
170
|
-
var noOfSectionsBelowXAxis = (
|
|
171
|
-
var showScrollIndicator = (
|
|
172
|
-
var side = (
|
|
173
|
-
var rotateLabel = (
|
|
174
|
-
var opacity = (
|
|
175
|
-
var isThreeD = (
|
|
176
|
-
var showXAxisIndices = (
|
|
177
|
-
var xAxisIndicesHeight = (
|
|
178
|
-
var xAxisIndicesWidth = (
|
|
179
|
-
var xAxisIndicesColor = (
|
|
180
|
-
var xAxisThickness = (
|
|
181
|
-
var xAxisTextNumberOfLines = (
|
|
182
|
-
var xAxisLabelsVerticalShift = (
|
|
168
|
+
var mostNegativeValue = getMostNegativeValue(props.mostNegativeValue, props.negativeStepValue, props.noOfSectionsBelowXAxis, maxAndMin.minItem);
|
|
169
|
+
var stepValue = (_x = props.stepValue) !== null && _x !== void 0 ? _x : maxValue / noOfSections;
|
|
170
|
+
var noOfSectionsBelowXAxis = (_y = props.noOfSectionsBelowXAxis) !== null && _y !== void 0 ? _y : Math.round(Math.ceil(-mostNegativeValue / (negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue)));
|
|
171
|
+
var showScrollIndicator = (_z = props.showScrollIndicator) !== null && _z !== void 0 ? _z : BarDefaults.showScrollIndicator;
|
|
172
|
+
var side = (_0 = props.side) !== null && _0 !== void 0 ? _0 : BarDefaults.side;
|
|
173
|
+
var rotateLabel = (_1 = props.rotateLabel) !== null && _1 !== void 0 ? _1 : AxesAndRulesDefaults.rotateLabel;
|
|
174
|
+
var opacity = (_2 = props.opacity) !== null && _2 !== void 0 ? _2 : BarDefaults.opacity;
|
|
175
|
+
var isThreeD = (_3 = props.isThreeD) !== null && _3 !== void 0 ? _3 : BarDefaults.isThreeD;
|
|
176
|
+
var showXAxisIndices = (_4 = props.showXAxisIndices) !== null && _4 !== void 0 ? _4 : AxesAndRulesDefaults.showXAxisIndices;
|
|
177
|
+
var xAxisIndicesHeight = (_5 = props.xAxisIndicesHeight) !== null && _5 !== void 0 ? _5 : AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
178
|
+
var xAxisIndicesWidth = (_6 = props.xAxisIndicesWidth) !== null && _6 !== void 0 ? _6 : AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
179
|
+
var xAxisIndicesColor = (_7 = props.xAxisIndicesColor) !== null && _7 !== void 0 ? _7 : AxesAndRulesDefaults.xAxisIndicesColor;
|
|
180
|
+
var xAxisThickness = (_8 = props.xAxisThickness) !== null && _8 !== void 0 ? _8 : AxesAndRulesDefaults.xAxisThickness;
|
|
181
|
+
var xAxisTextNumberOfLines = (_9 = props.xAxisTextNumberOfLines) !== null && _9 !== void 0 ? _9 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
|
|
182
|
+
var xAxisLabelsVerticalShift = (_10 = props.xAxisLabelsVerticalShift) !== null && _10 !== void 0 ? _10 : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
|
|
183
183
|
var horizontalRulesStyle = props.horizontalRulesStyle;
|
|
184
|
-
var autoShiftLabels = (
|
|
185
|
-
var barBorderColor = (
|
|
184
|
+
var autoShiftLabels = (_11 = props.autoShiftLabels) !== null && _11 !== void 0 ? _11 : false;
|
|
185
|
+
var barBorderColor = (_12 = props.barBorderColor) !== null && _12 !== void 0 ? _12 : BarDefaults.barBorderColor;
|
|
186
186
|
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
|
|
187
187
|
var containerHeightIncludingBelowXAxis = extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
188
188
|
var _52 = __read(useState(-1), 2), pointerIndex = _52[0], setPointerIndex = _52[1];
|
|
@@ -192,45 +192,45 @@ export var useBarChart = function (props) {
|
|
|
192
192
|
var _56 = __read(useState(0), 2), responderStartTime = _56[0], setResponderStartTime = _56[1];
|
|
193
193
|
var _57 = __read(useState(false), 2), responderActive = _57[0], setResponderActive = _57[1];
|
|
194
194
|
var pointerConfig = props.pointerConfig;
|
|
195
|
-
var getPointerProps = (
|
|
196
|
-
var pointerHeight = (
|
|
197
|
-
var pointerWidth = (
|
|
198
|
-
var pointerRadius = (
|
|
199
|
-
var pointerColor = (
|
|
200
|
-
var pointerComponent = (
|
|
195
|
+
var getPointerProps = (_13 = props.getPointerProps) !== null && _13 !== void 0 ? _13 : null;
|
|
196
|
+
var pointerHeight = (_14 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _14 !== void 0 ? _14 : defaultPointerConfig.height;
|
|
197
|
+
var pointerWidth = (_15 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.width) !== null && _15 !== void 0 ? _15 : defaultPointerConfig.width;
|
|
198
|
+
var pointerRadius = (_16 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.radius) !== null && _16 !== void 0 ? _16 : defaultPointerConfig.radius;
|
|
199
|
+
var pointerColor = (_17 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColor) !== null && _17 !== void 0 ? _17 : defaultPointerConfig.pointerColor;
|
|
200
|
+
var pointerComponent = (_18 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerComponent) !== null && _18 !== void 0 ? _18 : defaultPointerConfig.pointerComponent;
|
|
201
201
|
var showPointerStrip = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.showPointerStrip) === false
|
|
202
202
|
? false
|
|
203
203
|
: defaultPointerConfig.showPointerStrip;
|
|
204
|
-
var pointerStripHeight = (
|
|
205
|
-
var pointerStripWidth = (
|
|
206
|
-
var pointerStripColor = (
|
|
207
|
-
var pointerStripUptoDataPoint = (
|
|
208
|
-
var pointerLabelComponent = (
|
|
209
|
-
var stripOverPointer = (
|
|
210
|
-
var shiftPointerLabelX = (
|
|
211
|
-
var shiftPointerLabelY = (
|
|
212
|
-
var pointerLabelWidth = (
|
|
213
|
-
var pointerLabelHeight = (
|
|
214
|
-
var autoAdjustPointerLabelPosition = (
|
|
215
|
-
var pointerVanishDelay = (
|
|
216
|
-
var activatePointersOnLongPress = (
|
|
217
|
-
var activatePointersDelay = (
|
|
218
|
-
var initialPointerIndex = (
|
|
219
|
-
var initialPointerAppearDelay = (
|
|
204
|
+
var pointerStripHeight = (_19 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripHeight) !== null && _19 !== void 0 ? _19 : defaultPointerConfig.pointerStripHeight;
|
|
205
|
+
var pointerStripWidth = (_20 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripWidth) !== null && _20 !== void 0 ? _20 : defaultPointerConfig.pointerStripWidth;
|
|
206
|
+
var pointerStripColor = (_21 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripColor) !== null && _21 !== void 0 ? _21 : defaultPointerConfig.pointerStripColor;
|
|
207
|
+
var pointerStripUptoDataPoint = (_22 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripUptoDataPoint) !== null && _22 !== void 0 ? _22 : defaultPointerConfig.pointerStripUptoDataPoint;
|
|
208
|
+
var pointerLabelComponent = (_23 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelComponent) !== null && _23 !== void 0 ? _23 : defaultPointerConfig.pointerLabelComponent;
|
|
209
|
+
var stripOverPointer = (_24 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripOverPointer) !== null && _24 !== void 0 ? _24 : defaultPointerConfig.stripOverPointer;
|
|
210
|
+
var shiftPointerLabelX = (_25 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelX) !== null && _25 !== void 0 ? _25 : defaultPointerConfig.shiftPointerLabelX;
|
|
211
|
+
var shiftPointerLabelY = (_26 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelY) !== null && _26 !== void 0 ? _26 : defaultPointerConfig.shiftPointerLabelY;
|
|
212
|
+
var pointerLabelWidth = (_27 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelWidth) !== null && _27 !== void 0 ? _27 : defaultPointerConfig.pointerLabelWidth;
|
|
213
|
+
var pointerLabelHeight = (_28 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelHeight) !== null && _28 !== void 0 ? _28 : defaultPointerConfig.pointerLabelHeight;
|
|
214
|
+
var autoAdjustPointerLabelPosition = (_29 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.autoAdjustPointerLabelPosition) !== null && _29 !== void 0 ? _29 : defaultPointerConfig.autoAdjustPointerLabelPosition;
|
|
215
|
+
var pointerVanishDelay = (_30 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerVanishDelay) !== null && _30 !== void 0 ? _30 : defaultPointerConfig.pointerVanishDelay;
|
|
216
|
+
var activatePointersOnLongPress = (_31 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersOnLongPress) !== null && _31 !== void 0 ? _31 : defaultPointerConfig.activatePointersOnLongPress;
|
|
217
|
+
var activatePointersDelay = (_32 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersDelay) !== null && _32 !== void 0 ? _32 : defaultPointerConfig.activatePointersDelay;
|
|
218
|
+
var initialPointerIndex = (_33 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerIndex) !== null && _33 !== void 0 ? _33 : defaultPointerConfig.initialPointerIndex;
|
|
219
|
+
var initialPointerAppearDelay = (_34 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerAppearDelay) !== null && _34 !== void 0 ? _34 : (isAnimated
|
|
220
220
|
? animationDuration
|
|
221
221
|
: defaultPointerConfig.initialPointerAppearDelay);
|
|
222
|
-
var persistPointer = (
|
|
223
|
-
var hidePointer1 = (
|
|
222
|
+
var persistPointer = (_35 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.persistPointer) !== null && _35 !== void 0 ? _35 : defaultPointerConfig.persistPointer;
|
|
223
|
+
var hidePointer1 = (_36 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointer1) !== null && _36 !== void 0 ? _36 : defaultPointerConfig.hidePointer1;
|
|
224
224
|
var pointerEvents = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerEvents;
|
|
225
|
-
var stripBehindBars = (
|
|
226
|
-
var disableScroll = (
|
|
225
|
+
var stripBehindBars = (_37 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripBehindBars) !== null && _37 !== void 0 ? _37 : defaultPointerConfig.stripBehindBars;
|
|
226
|
+
var disableScroll = (_38 = props.disableScroll) !== null && _38 !== void 0 ? _38 : (pointerConfig
|
|
227
227
|
? activatePointersOnLongPress
|
|
228
228
|
? !!responderActive
|
|
229
229
|
: true
|
|
230
230
|
: false);
|
|
231
231
|
var yAxisExtraHeightAtTop = props.trimYAxisAtTop
|
|
232
232
|
? 0
|
|
233
|
-
: (
|
|
233
|
+
: (_39 = props.yAxisExtraHeight) !== null && _39 !== void 0 ? _39 : containerHeight / 20;
|
|
234
234
|
var barInnerComponent = props.barInnerComponent;
|
|
235
235
|
useEffect(function () {
|
|
236
236
|
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;
|
|
@@ -346,9 +346,9 @@ export var useBarChart = function (props) {
|
|
|
346
346
|
spacing,
|
|
347
347
|
yAxisLabelWidth,
|
|
348
348
|
lineConfig.showArrow,
|
|
349
|
-
(
|
|
350
|
-
(
|
|
351
|
-
(
|
|
349
|
+
(_40 = lineConfig.arrowConfig) === null || _40 === void 0 ? void 0 : _40.length,
|
|
350
|
+
(_41 = lineConfig.arrowConfig) === null || _41 === void 0 ? void 0 : _41.width,
|
|
351
|
+
(_42 = lineConfig.arrowConfig) === null || _42 === void 0 ? void 0 : _42.showArrowBase
|
|
352
352
|
]);
|
|
353
353
|
useEffect(function () {
|
|
354
354
|
var _a, _b, _c, _d;
|
|
@@ -394,7 +394,7 @@ export var useBarChart = function (props) {
|
|
|
394
394
|
outputRange: [0, initialSpacing + totalWidth + endSpacing]
|
|
395
395
|
});
|
|
396
396
|
var getPropsCommonForBarAndStack = function (item, index) {
|
|
397
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
397
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
398
398
|
return {
|
|
399
399
|
key: index,
|
|
400
400
|
item: item,
|
|
@@ -453,7 +453,11 @@ export var useBarChart = function (props) {
|
|
|
453
453
|
pointerConfig: pointerConfig,
|
|
454
454
|
yAxisExtraHeightAtTop: yAxisExtraHeightAtTop,
|
|
455
455
|
yAxisOffset: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0,
|
|
456
|
-
focusedBarIndex: focusedBarIndex
|
|
456
|
+
focusedBarIndex: focusedBarIndex,
|
|
457
|
+
stepHeight: stepHeight,
|
|
458
|
+
stepValue: stepValue,
|
|
459
|
+
negativeStepHeight: (_l = props.negativeStepHeight) !== null && _l !== void 0 ? _l : stepHeight,
|
|
460
|
+
negativeStepValue: (_m = props.negativeStepValue) !== null && _m !== void 0 ? _m : stepValue
|
|
457
461
|
};
|
|
458
462
|
};
|
|
459
463
|
var barAndLineChartsWrapperProps = {
|
|
@@ -461,6 +465,7 @@ export var useBarChart = function (props) {
|
|
|
461
465
|
containerHeight: containerHeight,
|
|
462
466
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
463
467
|
stepHeight: stepHeight,
|
|
468
|
+
negativeStepHeight: (_43 = props.negativeStepHeight) !== null && _43 !== void 0 ? _43 : stepHeight,
|
|
464
469
|
labelsExtraHeight: labelsExtraHeight,
|
|
465
470
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
466
471
|
horizontal: horizontal,
|
|
@@ -501,8 +506,9 @@ export var useBarChart = function (props) {
|
|
|
501
506
|
endSpacing: endSpacing,
|
|
502
507
|
horizontalRulesStyle: horizontalRulesStyle,
|
|
503
508
|
noOfSections: noOfSections,
|
|
509
|
+
sectionColors: props.sectionColors,
|
|
504
510
|
showFractionalValues: showFractionalValues,
|
|
505
|
-
axesAndRulesProps: getAxesAndRulesProps(props, stepValue, secondaryMaxValue),
|
|
511
|
+
axesAndRulesProps: getAxesAndRulesProps(props, stepValue, negativeStepValue, secondaryMaxValue),
|
|
506
512
|
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
507
513
|
yAxisOffset: yAxisOffset,
|
|
508
514
|
rotateYAxisTexts: props.rotateYAxisTexts,
|
package/src/BarChart/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getExtendedContainerHeightWithPadding,
|
|
12
12
|
getLineConfigForBarChart,
|
|
13
13
|
getMaxValue,
|
|
14
|
+
getMostNegativeValue,
|
|
14
15
|
getNoOfSections,
|
|
15
16
|
getSecondaryDataWithOffsetIncluded,
|
|
16
17
|
getXForLineInBar,
|
|
@@ -50,7 +51,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
50
51
|
parentWidth,
|
|
51
52
|
labelsDistanceFromXaxis,
|
|
52
53
|
autoShiftLabelsForNegativeStacks,
|
|
53
|
-
focusedBarIndex
|
|
54
|
+
focusedBarIndex,
|
|
55
|
+
negativeStepValue
|
|
54
56
|
} = props
|
|
55
57
|
const [points, setPoints] = useState('')
|
|
56
58
|
const [points2, setPoints2] = useState('')
|
|
@@ -244,12 +246,17 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
244
246
|
secondaryMaxAndMin.maxItem
|
|
245
247
|
: secondaryMaxAndMin.maxItem
|
|
246
248
|
: maxValue
|
|
247
|
-
const mostNegativeValue =
|
|
249
|
+
const mostNegativeValue = getMostNegativeValue(
|
|
250
|
+
props.mostNegativeValue,
|
|
251
|
+
props.negativeStepValue,
|
|
252
|
+
props.noOfSectionsBelowXAxis,
|
|
253
|
+
maxAndMin.minItem
|
|
254
|
+
)
|
|
248
255
|
|
|
249
256
|
const stepValue = props.stepValue ?? maxValue / noOfSections
|
|
250
257
|
const noOfSectionsBelowXAxis =
|
|
251
258
|
props.noOfSectionsBelowXAxis ??
|
|
252
|
-
Math.round(Math.ceil(-mostNegativeValue / stepValue))
|
|
259
|
+
Math.round(Math.ceil(-mostNegativeValue / (negativeStepValue ?? stepValue)))
|
|
253
260
|
const showScrollIndicator =
|
|
254
261
|
props.showScrollIndicator ?? BarDefaults.showScrollIndicator
|
|
255
262
|
const side = props.side ?? BarDefaults.side
|
|
@@ -691,7 +698,11 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
691
698
|
pointerConfig,
|
|
692
699
|
yAxisExtraHeightAtTop,
|
|
693
700
|
yAxisOffset: yAxisOffset ?? 0,
|
|
694
|
-
focusedBarIndex
|
|
701
|
+
focusedBarIndex,
|
|
702
|
+
stepHeight,
|
|
703
|
+
stepValue,
|
|
704
|
+
negativeStepHeight: props.negativeStepHeight ?? stepHeight,
|
|
705
|
+
negativeStepValue: props.negativeStepValue ?? stepValue
|
|
695
706
|
}
|
|
696
707
|
}
|
|
697
708
|
|
|
@@ -700,6 +711,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
700
711
|
containerHeight,
|
|
701
712
|
noOfSectionsBelowXAxis,
|
|
702
713
|
stepHeight,
|
|
714
|
+
negativeStepHeight: props.negativeStepHeight ?? stepHeight,
|
|
703
715
|
labelsExtraHeight,
|
|
704
716
|
yAxisLabelWidth,
|
|
705
717
|
horizontal,
|
|
@@ -741,11 +753,13 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
741
753
|
endSpacing,
|
|
742
754
|
horizontalRulesStyle,
|
|
743
755
|
noOfSections,
|
|
756
|
+
sectionColors: props.sectionColors,
|
|
744
757
|
showFractionalValues,
|
|
745
758
|
|
|
746
759
|
axesAndRulesProps: getAxesAndRulesProps(
|
|
747
760
|
props,
|
|
748
761
|
stepValue,
|
|
762
|
+
negativeStepValue,
|
|
749
763
|
secondaryMaxValue
|
|
750
764
|
),
|
|
751
765
|
|
package/src/BarChart/types.d.ts
CHANGED
|
@@ -122,11 +122,14 @@ export interface BarChartPropsType {
|
|
|
122
122
|
overflowTop?: number;
|
|
123
123
|
minHeight?: number;
|
|
124
124
|
noOfSections?: number;
|
|
125
|
+
sectionColors?: ColorValue[];
|
|
125
126
|
noOfSectionsBelowXAxis?: number;
|
|
126
127
|
maxValue?: number;
|
|
127
128
|
mostNegativeValue?: number;
|
|
128
129
|
stepHeight?: number;
|
|
129
130
|
stepValue?: number;
|
|
131
|
+
negativeStepHeight?: number;
|
|
132
|
+
negativeStepValue?: number;
|
|
130
133
|
spacing?: number;
|
|
131
134
|
data?: barDataItem[];
|
|
132
135
|
stackData?: stackDataItem[];
|
|
@@ -530,6 +533,10 @@ export interface RenderBarsPropsType {
|
|
|
530
533
|
focusedBarIndex?: number;
|
|
531
534
|
noOfSectionsBelowXAxis?: number;
|
|
532
535
|
yAxisOffset: number;
|
|
536
|
+
stepHeight: number;
|
|
537
|
+
stepValue: number;
|
|
538
|
+
negativeStepHeight: number;
|
|
539
|
+
negativeStepValue: number;
|
|
533
540
|
}
|
|
534
541
|
export interface trianglePropTypes {
|
|
535
542
|
style: any;
|
package/src/BarChart/types.ts
CHANGED
|
@@ -141,11 +141,14 @@ export interface BarChartPropsType {
|
|
|
141
141
|
overflowTop?: number
|
|
142
142
|
minHeight?: number
|
|
143
143
|
noOfSections?: number
|
|
144
|
+
sectionColors?: ColorValue[]
|
|
144
145
|
noOfSectionsBelowXAxis?: number
|
|
145
146
|
maxValue?: number
|
|
146
147
|
mostNegativeValue?: number
|
|
147
148
|
stepHeight?: number
|
|
148
149
|
stepValue?: number
|
|
150
|
+
negativeStepHeight?: number
|
|
151
|
+
negativeStepValue?: number
|
|
149
152
|
spacing?: number
|
|
150
153
|
data?: barDataItem[]
|
|
151
154
|
stackData?: stackDataItem[]
|
|
@@ -577,6 +580,10 @@ export interface RenderBarsPropsType {
|
|
|
577
580
|
focusedBarIndex?: number
|
|
578
581
|
noOfSectionsBelowXAxis?: number
|
|
579
582
|
yAxisOffset: number
|
|
583
|
+
stepHeight: number
|
|
584
|
+
stepValue: number
|
|
585
|
+
negativeStepHeight: number
|
|
586
|
+
negativeStepValue: number
|
|
580
587
|
}
|
|
581
588
|
|
|
582
589
|
export interface trianglePropTypes {
|
|
@@ -376,6 +376,7 @@ export var useLineChartBiColor = function (props) {
|
|
|
376
376
|
containerHeight: containerHeight,
|
|
377
377
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
378
378
|
stepHeight: stepHeight,
|
|
379
|
+
negativeStepHeight: stepHeight,
|
|
379
380
|
labelsExtraHeight: labelsExtraHeight,
|
|
380
381
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
381
382
|
horizontal: horizontal,
|
package/src/LineChart/index.js
CHANGED
|
@@ -252,16 +252,17 @@ export var useLineChart = function (props) {
|
|
|
252
252
|
if (animateOnDataChange && animations) {
|
|
253
253
|
animations.forEach(function (item, index) {
|
|
254
254
|
item.addListener(function (val) {
|
|
255
|
-
var _a, _b, _c, _d, _e;
|
|
255
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
256
256
|
var temp = (_b = (_a = data[index]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
257
|
-
data[index].value = val.value;
|
|
257
|
+
data[index].value = (_c = val === null || val === void 0 ? void 0 : val.value) !== null && _c !== void 0 ? _c : 0;
|
|
258
258
|
var pp = '';
|
|
259
259
|
var ppp = '';
|
|
260
|
-
if (!((
|
|
260
|
+
if (!((_d = dataSet === null || dataSet === void 0 ? void 0 : dataSet[0].curved) !== null && _d !== void 0 ? _d : props.curved)) {
|
|
261
261
|
for (var i = 0; i < (data0 !== null && data0 !== void 0 ? data0 : data).length; i++) {
|
|
262
|
-
pp +=
|
|
262
|
+
pp +=
|
|
263
|
+
'L' + getX(i) + ' ' + getY((_f = (_e = (data0 !== null && data0 !== void 0 ? data0 : data)[i]) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : 0) + ' ';
|
|
263
264
|
}
|
|
264
|
-
if ((
|
|
265
|
+
if ((_h = (_g = dataSet === null || dataSet === void 0 ? void 0 : dataSet[0]) === null || _g === void 0 ? void 0 : _g.areaChart) !== null && _h !== void 0 ? _h : areaChart) {
|
|
265
266
|
ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
266
267
|
ppp += pp;
|
|
267
268
|
ppp +=
|
|
@@ -1052,6 +1053,7 @@ export var useLineChart = function (props) {
|
|
|
1052
1053
|
containerHeight: containerHeight,
|
|
1053
1054
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
1054
1055
|
stepHeight: stepHeight,
|
|
1056
|
+
negativeStepHeight: stepHeight,
|
|
1055
1057
|
labelsExtraHeight: labelsExtraHeight,
|
|
1056
1058
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
1057
1059
|
horizontal: horizontal,
|
package/src/LineChart/index.ts
CHANGED
|
@@ -470,12 +470,13 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
470
470
|
animations.forEach((item, index) => {
|
|
471
471
|
item.addListener((val) => {
|
|
472
472
|
const temp = data[index]?.value ?? 0
|
|
473
|
-
data[index].value = val
|
|
473
|
+
data[index].value = val?.value ?? 0
|
|
474
474
|
let pp = ''
|
|
475
475
|
let ppp = ''
|
|
476
476
|
if (!(dataSet?.[0].curved ?? props.curved)) {
|
|
477
477
|
for (let i = 0; i < (data0 ?? data).length; i++) {
|
|
478
|
-
pp +=
|
|
478
|
+
pp +=
|
|
479
|
+
'L' + getX(i) + ' ' + getY((data0 ?? data)[i]?.value ?? 0) + ' '
|
|
479
480
|
}
|
|
480
481
|
if (dataSet?.[0]?.areaChart ?? areaChart) {
|
|
481
482
|
ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
@@ -1775,6 +1776,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1775
1776
|
containerHeight,
|
|
1776
1777
|
noOfSectionsBelowXAxis,
|
|
1777
1778
|
stepHeight,
|
|
1779
|
+
negativeStepHeight: stepHeight,
|
|
1778
1780
|
labelsExtraHeight,
|
|
1779
1781
|
yAxisLabelWidth,
|
|
1780
1782
|
horizontal,
|
|
@@ -2,7 +2,7 @@ import { AxesAndRulesDefaults } from '../../utils/constants';
|
|
|
2
2
|
import { computeMaxAndMinItems, getLabelTextUtil } from '../../utils';
|
|
3
3
|
export var getHorizSectionVals = function (props) {
|
|
4
4
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
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, roundToDigits = props.roundToDigits, yAxisOffset = props.yAxisOffset, formatYLabel = props.formatYLabel, secondaryData = props.secondaryData, secondaryYAxis = props.secondaryYAxis;
|
|
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, secondaryData = props.secondaryData, secondaryYAxis = props.secondaryYAxis;
|
|
6
6
|
var yAxisExtraHeightAtTop = trimYAxisAtTop ? 0 : yAxisExtraHeight;
|
|
7
7
|
/***********************************************************************************************************************************
|
|
8
8
|
* *
|
|
@@ -15,6 +15,8 @@ export var getHorizSectionVals = function (props) {
|
|
|
15
15
|
mostNegativeValue: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue,
|
|
16
16
|
stepValue: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepValue,
|
|
17
17
|
stepHeight: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight,
|
|
18
|
+
negativeStepValue: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepValue,
|
|
19
|
+
negativeStepHeight: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight,
|
|
18
20
|
showFractionalValues: (_b = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showFractionalValues) !== null && _b !== void 0 ? _b : showFractionalValues,
|
|
19
21
|
roundToDigits: (_c = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.roundToDigits) !== null && _c !== void 0 ? _c : roundToDigits,
|
|
20
22
|
noOfSectionsBelowXAxis: (_d = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSectionsBelowXAxis) !== null && _d !== void 0 ? _d : noOfSectionsBelowXAxis,
|
|
@@ -63,7 +65,7 @@ export var getHorizSectionVals = function (props) {
|
|
|
63
65
|
var horizSectionsBelow = [];
|
|
64
66
|
if (noOfSectionsBelowXAxis) {
|
|
65
67
|
for (var i = 1; i <= noOfSectionsBelowXAxis; i++) {
|
|
66
|
-
var value =
|
|
68
|
+
var value = negativeStepValue * -i;
|
|
67
69
|
if (showFractionalValues || roundToDigits) {
|
|
68
70
|
value = parseFloat(value.toFixed(roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : AxesAndRulesDefaults.roundToDigits));
|
|
69
71
|
}
|
|
@@ -45,6 +45,7 @@ export const getHorizSectionVals = (props: horizSectionPropTypes) => {
|
|
|
45
45
|
yAxisLabelTexts,
|
|
46
46
|
|
|
47
47
|
stepValue,
|
|
48
|
+
negativeStepValue,
|
|
48
49
|
roundToDigits,
|
|
49
50
|
|
|
50
51
|
yAxisOffset,
|
|
@@ -69,6 +70,9 @@ export const getHorizSectionVals = (props: horizSectionPropTypes) => {
|
|
|
69
70
|
stepValue: secondaryYAxis?.stepValue,
|
|
70
71
|
stepHeight: secondaryYAxis?.stepHeight,
|
|
71
72
|
|
|
73
|
+
negativeStepValue: secondaryYAxis?.stepValue,
|
|
74
|
+
negativeStepHeight: secondaryYAxis?.stepHeight,
|
|
75
|
+
|
|
72
76
|
showFractionalValues:
|
|
73
77
|
secondaryYAxis?.showFractionalValues ?? showFractionalValues,
|
|
74
78
|
roundToDigits: secondaryYAxis?.roundToDigits ?? roundToDigits,
|
|
@@ -136,7 +140,7 @@ export const getHorizSectionVals = (props: horizSectionPropTypes) => {
|
|
|
136
140
|
const horizSectionsBelow: HorizSectionsType = []
|
|
137
141
|
if (noOfSectionsBelowXAxis) {
|
|
138
142
|
for (let i = 1; i <= noOfSectionsBelowXAxis; i++) {
|
|
139
|
-
let value =
|
|
143
|
+
let value = negativeStepValue * -i
|
|
140
144
|
if (showFractionalValues || roundToDigits) {
|
|
141
145
|
value = parseFloat(
|
|
142
146
|
value.toFixed(roundToDigits ?? AxesAndRulesDefaults.roundToDigits)
|
|
@@ -356,7 +360,10 @@ export const getHorizSectionVals = (props: horizSectionPropTypes) => {
|
|
|
356
360
|
)
|
|
357
361
|
}
|
|
358
362
|
|
|
359
|
-
const getLabelTextsForSecondaryYAxis = (
|
|
363
|
+
const getLabelTextsForSecondaryYAxis = (
|
|
364
|
+
val: string,
|
|
365
|
+
index: number
|
|
366
|
+
): string => {
|
|
360
367
|
const {
|
|
361
368
|
showFractionalValues,
|
|
362
369
|
yAxisLabelTexts,
|
|
@@ -38,7 +38,7 @@ import { useEffect, useState } from 'react';
|
|
|
38
38
|
import { AxesAndRulesDefaults, BarDefaults } from '../../utils/constants';
|
|
39
39
|
export var useBarAndLineChartsWrapper = function (props) {
|
|
40
40
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
|
|
41
|
-
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, stepHeight = props.stepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL;
|
|
41
|
+
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL;
|
|
42
42
|
var yAxisAtTop = rtl ? !props.yAxisAtTop : props.yAxisAtTop;
|
|
43
43
|
var hideOrigin = (_a = axesAndRulesProps.hideOrigin) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.hideOrigin;
|
|
44
44
|
var yAxisSide = (_b = axesAndRulesProps.yAxisSide) !== null && _b !== void 0 ? _b : AxesAndRulesDefaults.yAxisSide;
|
|
@@ -74,6 +74,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
74
74
|
var yAxisTextStyle = axesAndRulesProps.yAxisTextStyle;
|
|
75
75
|
var secondaryYAxis = axesAndRulesProps.secondaryYAxis;
|
|
76
76
|
var stepValue = axesAndRulesProps.stepValue;
|
|
77
|
+
var negativeStepValue = axesAndRulesProps.negativeStepValue;
|
|
77
78
|
var roundToDigits = axesAndRulesProps.roundToDigits;
|
|
78
79
|
var referenceLinesConfig = axesAndRulesProps.referenceLinesConfig;
|
|
79
80
|
var referenceLinesOverChartContent = (_2 = referenceLinesConfig.referenceLinesOverChartContent) !== null && _2 !== void 0 ? _2 : AxesAndRulesDefaults.referenceLinesOverChartContent;
|
|
@@ -98,7 +99,9 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
98
99
|
yAxisSide: yAxisSide,
|
|
99
100
|
horizontalRulesStyle: horizontalRulesStyle,
|
|
100
101
|
noOfSections: noOfSections,
|
|
102
|
+
sectionColors: sectionColors,
|
|
101
103
|
stepHeight: stepHeight,
|
|
104
|
+
negativeStepHeight: negativeStepHeight,
|
|
102
105
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
103
106
|
yAxisLabelContainerStyle: yAxisLabelContainerStyle,
|
|
104
107
|
yAxisThickness: yAxisThickness,
|
|
@@ -141,6 +144,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
141
144
|
horizontal: horizontal,
|
|
142
145
|
yAxisAtTop: yAxisAtTop,
|
|
143
146
|
stepValue: stepValue,
|
|
147
|
+
negativeStepValue: negativeStepValue,
|
|
144
148
|
roundToDigits: roundToDigits,
|
|
145
149
|
secondaryData: secondaryData,
|
|
146
150
|
secondaryYAxis: secondaryYAxis,
|
|
@@ -13,7 +13,9 @@ export const useBarAndLineChartsWrapper = (
|
|
|
13
13
|
chartType,
|
|
14
14
|
containerHeight,
|
|
15
15
|
noOfSectionsBelowXAxis,
|
|
16
|
+
sectionColors,
|
|
16
17
|
stepHeight,
|
|
18
|
+
negativeStepHeight,
|
|
17
19
|
labelsExtraHeight,
|
|
18
20
|
yAxisLabelWidth,
|
|
19
21
|
horizontal,
|
|
@@ -126,6 +128,7 @@ export const useBarAndLineChartsWrapper = (
|
|
|
126
128
|
const yAxisTextStyle = axesAndRulesProps.yAxisTextStyle
|
|
127
129
|
const secondaryYAxis = axesAndRulesProps.secondaryYAxis
|
|
128
130
|
const stepValue = axesAndRulesProps.stepValue
|
|
131
|
+
const negativeStepValue = axesAndRulesProps.negativeStepValue
|
|
129
132
|
const roundToDigits = axesAndRulesProps.roundToDigits
|
|
130
133
|
|
|
131
134
|
const referenceLinesConfig = axesAndRulesProps.referenceLinesConfig
|
|
@@ -173,7 +176,9 @@ export const useBarAndLineChartsWrapper = (
|
|
|
173
176
|
yAxisSide,
|
|
174
177
|
horizontalRulesStyle,
|
|
175
178
|
noOfSections,
|
|
179
|
+
sectionColors,
|
|
176
180
|
stepHeight,
|
|
181
|
+
negativeStepHeight,
|
|
177
182
|
yAxisLabelWidth,
|
|
178
183
|
yAxisLabelContainerStyle,
|
|
179
184
|
yAxisThickness,
|
|
@@ -222,6 +227,7 @@ export const useBarAndLineChartsWrapper = (
|
|
|
222
227
|
yAxisAtTop,
|
|
223
228
|
|
|
224
229
|
stepValue,
|
|
230
|
+
negativeStepValue,
|
|
225
231
|
roundToDigits,
|
|
226
232
|
|
|
227
233
|
secondaryData,
|
package/src/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 } from './types';
|
|
3
|
+
import { type arrowConfigType, CurveType, type HighlightedRange, type LineProperties, type LineSegment, Framework, referenceConfigType } 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';
|
|
@@ -16,10 +16,23 @@ export declare const getPathWithHighlight: (data: lineDataItem[], i: number, hig
|
|
|
16
16
|
export declare const getRegionPathObjects: (points: string, color: ColorValue, currentLineThickness: number, thickness: number, strokeDashArray: number[], isCurved: boolean, startDelimeter: string, stop: string, endDelimeter: string) => LineProperties[];
|
|
17
17
|
export declare const getSegmentedPathObjects: (points: string, color: ColorValue, currentLineThickness: number, thickness: number, strokeDashArray: number[], isCurved: boolean, startDelimeter: string, endDelimeter: string) => LineProperties[];
|
|
18
18
|
export declare const getArrowPoints: (arrowTipX: number, arrowTipY: number, x1: number, y1: number, arrowLength?: number, arrowWidth?: number, showArrowBase?: boolean) => string;
|
|
19
|
+
interface ReferenceLinesConfig {
|
|
20
|
+
showReferenceLine1?: boolean;
|
|
21
|
+
referenceLine1Position?: number;
|
|
22
|
+
referenceLine1Config?: referenceConfigType;
|
|
23
|
+
showReferenceLine2?: boolean;
|
|
24
|
+
referenceLine2Position?: number;
|
|
25
|
+
referenceLine2Config?: referenceConfigType;
|
|
26
|
+
showReferenceLine3?: boolean;
|
|
27
|
+
referenceLine3Position?: number;
|
|
28
|
+
referenceLine3Config?: referenceConfigType;
|
|
29
|
+
referenceLinesOverChartContent?: boolean;
|
|
30
|
+
}
|
|
19
31
|
interface IgetAxesAndRulesProps extends BarChartPropsType {
|
|
20
32
|
verticalLinesUptoDataPoint?: boolean;
|
|
33
|
+
referenceLinesConfig: ReferenceLinesConfig;
|
|
21
34
|
}
|
|
22
|
-
export declare const getAxesAndRulesProps: (props: extendedBarChartPropsType, stepValue: number, maxValue?: number) => IgetAxesAndRulesProps;
|
|
35
|
+
export declare const getAxesAndRulesProps: (props: extendedBarChartPropsType, stepValue: number, negativeStepValue?: number, maxValue?: number) => IgetAxesAndRulesProps;
|
|
23
36
|
export declare const getExtendedContainerHeightWithPadding: (containerHeight: number, overflowTop?: number) => number;
|
|
24
37
|
export declare const getSecondaryDataWithOffsetIncluded: (secondaryData?: barDataItem[] | lineDataItem[], secondaryYAxis?: any | undefined, showDataPointsForMissingValues?: boolean, interpolateMissingValues?: boolean, onlyPositive?: boolean) => barDataItem[] | lineDataItem[] | undefined;
|
|
25
38
|
export declare const getArrowProperty: (property: string, count: number, props: extendedLineChartPropsType, defaultArrowConfig: arrowConfigType) => any;
|
|
@@ -75,6 +88,7 @@ export declare const clone: (obj: any) => any;
|
|
|
75
88
|
export declare const getLineConfigForBarChart: (lineConfig: lineConfigType, barInitialSpacing: number) => lineConfigType;
|
|
76
89
|
export declare const getNoOfSections: (noOfSections: number | undefined, maxValue: number | undefined, stepValue: number | undefined) => number;
|
|
77
90
|
export declare const getMaxValue: (maxValue: number | undefined, stepValue: number | undefined, noOfSections: number, maxItem: number) => number;
|
|
91
|
+
export declare const getMostNegativeValue: (minValue: number | undefined, stepValue: number | undefined, noOfSections: number | undefined, minItem: number) => number;
|
|
78
92
|
export declare const getBarFrontColor: (isFocused?: boolean, focusedBarConfig?: FocusedBarConfig, itemFrontColor?: ColorValue, frontColor?: ColorValue, isThreeD?: boolean) => ColorValue;
|
|
79
93
|
export declare const getBarSideColor: (isFocused?: boolean, focusedBarConfig?: FocusedBarConfig, itemSideColor?: ColorValue, sideColor?: ColorValue) => ColorValue | undefined;
|
|
80
94
|
export declare const getBarTopColor: (isFocused?: boolean, focusedBarConfig?: FocusedBarConfig, itemTopColor?: ColorValue, topColor?: ColorValue) => ColorValue | undefined;
|
package/src/utils/index.js
CHANGED
|
@@ -475,7 +475,7 @@ export var getArrowPoints = function (arrowTipX, arrowTipY, x1, y1, arrowLength,
|
|
|
475
475
|
arrowPoints += " L".concat(arrowTipX, " ").concat(arrowTipY);
|
|
476
476
|
return arrowPoints;
|
|
477
477
|
};
|
|
478
|
-
export var getAxesAndRulesProps = function (props, stepValue, maxValue) {
|
|
478
|
+
export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue, maxValue) {
|
|
479
479
|
var _a, _b, _c, _d;
|
|
480
480
|
var secondaryYAxis = !props.secondaryYAxis || props.secondaryYAxis === true
|
|
481
481
|
? {}
|
|
@@ -539,6 +539,7 @@ export var getAxesAndRulesProps = function (props, stepValue, maxValue) {
|
|
|
539
539
|
verticalLinesUptoDataPoint: props.verticalLinesUptoDataPoint,
|
|
540
540
|
roundToDigits: props.roundToDigits,
|
|
541
541
|
stepValue: stepValue,
|
|
542
|
+
negativeStepValue: negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue,
|
|
542
543
|
secondaryYAxis: props.secondaryYAxis,
|
|
543
544
|
formatYLabel: props.formatYLabel
|
|
544
545
|
};
|
|
@@ -660,7 +661,9 @@ export var maxAndMinUtil = function (maxItem, minItem, roundToDigits, showFracti
|
|
|
660
661
|
else {
|
|
661
662
|
maxItem = maxItem + (10 - (maxItem % 10));
|
|
662
663
|
if (minItem !== 0) {
|
|
664
|
+
minItem *= 10;
|
|
663
665
|
minItem = minItem - (10 + (minItem % 10));
|
|
666
|
+
minItem /= 10;
|
|
664
667
|
}
|
|
665
668
|
}
|
|
666
669
|
return { maxItem: maxItem, minItem: minItem };
|
|
@@ -788,6 +791,9 @@ export var getNoOfSections = function (noOfSections, maxValue, stepValue) {
|
|
|
788
791
|
: noOfSections !== null && noOfSections !== void 0 ? noOfSections : AxesAndRulesDefaults.noOfSections;
|
|
789
792
|
};
|
|
790
793
|
export var getMaxValue = function (maxValue, stepValue, noOfSections, maxItem) { return maxValue !== null && maxValue !== void 0 ? maxValue : (stepValue ? stepValue * noOfSections : maxItem); };
|
|
794
|
+
export var getMostNegativeValue = function (minValue, stepValue, noOfSections, minItem) {
|
|
795
|
+
return minValue !== null && minValue !== void 0 ? minValue : (stepValue && noOfSections ? stepValue * noOfSections : minItem);
|
|
796
|
+
};
|
|
791
797
|
export var getBarFrontColor = function (isFocused, focusedBarConfig, itemFrontColor, frontColor, isThreeD) {
|
|
792
798
|
var _a, _b;
|
|
793
799
|
if (isFocused) {
|
package/src/utils/index.ts
CHANGED
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
type HighlightedRange,
|
|
20
20
|
type LineProperties,
|
|
21
21
|
type LineSegment,
|
|
22
|
-
Framework
|
|
22
|
+
Framework,
|
|
23
|
+
referenceConfigType
|
|
23
24
|
} from './types'
|
|
24
25
|
import {
|
|
25
26
|
type lineConfigType,
|
|
@@ -645,20 +646,34 @@ export const getArrowPoints = (
|
|
|
645
646
|
return arrowPoints
|
|
646
647
|
}
|
|
647
648
|
|
|
649
|
+
interface ReferenceLinesConfig {
|
|
650
|
+
showReferenceLine1?: boolean
|
|
651
|
+
referenceLine1Position?: number
|
|
652
|
+
referenceLine1Config?: referenceConfigType
|
|
653
|
+
showReferenceLine2?: boolean
|
|
654
|
+
referenceLine2Position?: number
|
|
655
|
+
referenceLine2Config?: referenceConfigType
|
|
656
|
+
showReferenceLine3?: boolean
|
|
657
|
+
referenceLine3Position?: number
|
|
658
|
+
referenceLine3Config?: referenceConfigType
|
|
659
|
+
referenceLinesOverChartContent?: boolean
|
|
660
|
+
}
|
|
648
661
|
interface IgetAxesAndRulesProps extends BarChartPropsType {
|
|
649
662
|
verticalLinesUptoDataPoint?: boolean
|
|
663
|
+
referenceLinesConfig: ReferenceLinesConfig
|
|
650
664
|
}
|
|
651
665
|
|
|
652
666
|
export const getAxesAndRulesProps = (
|
|
653
667
|
props: extendedBarChartPropsType,
|
|
654
668
|
stepValue: number,
|
|
669
|
+
negativeStepValue?: number,
|
|
655
670
|
maxValue?: number
|
|
656
671
|
): IgetAxesAndRulesProps => {
|
|
657
672
|
const secondaryYAxis =
|
|
658
673
|
!props.secondaryYAxis || props.secondaryYAxis === true
|
|
659
674
|
? {}
|
|
660
675
|
: props.secondaryYAxis
|
|
661
|
-
const axesAndRulesProps = {
|
|
676
|
+
const axesAndRulesProps: IgetAxesAndRulesProps = {
|
|
662
677
|
yAxisSide: props.yAxisSide,
|
|
663
678
|
yAxisLabelContainerStyle: props.yAxisLabelContainerStyle,
|
|
664
679
|
yAxisColor: props.yAxisColor,
|
|
@@ -721,6 +736,7 @@ export const getAxesAndRulesProps = (
|
|
|
721
736
|
|
|
722
737
|
roundToDigits: props.roundToDigits,
|
|
723
738
|
stepValue,
|
|
739
|
+
negativeStepValue: negativeStepValue ?? stepValue,
|
|
724
740
|
|
|
725
741
|
secondaryYAxis: props.secondaryYAxis,
|
|
726
742
|
formatYLabel: props.formatYLabel
|
|
@@ -1040,7 +1056,9 @@ export const maxAndMinUtil = (
|
|
|
1040
1056
|
} else {
|
|
1041
1057
|
maxItem = maxItem + (10 - (maxItem % 10))
|
|
1042
1058
|
if (minItem !== 0) {
|
|
1059
|
+
minItem *= 10
|
|
1043
1060
|
minItem = minItem - (10 + (minItem % 10))
|
|
1061
|
+
minItem /= 10
|
|
1044
1062
|
}
|
|
1045
1063
|
}
|
|
1046
1064
|
|
|
@@ -1237,6 +1255,14 @@ export const getMaxValue = (
|
|
|
1237
1255
|
maxItem: number
|
|
1238
1256
|
): number => maxValue ?? (stepValue ? stepValue * noOfSections : maxItem)
|
|
1239
1257
|
|
|
1258
|
+
export const getMostNegativeValue = (
|
|
1259
|
+
minValue: number | undefined,
|
|
1260
|
+
stepValue: number | undefined,
|
|
1261
|
+
noOfSections: number | undefined,
|
|
1262
|
+
minItem: number
|
|
1263
|
+
): number =>
|
|
1264
|
+
minValue ?? (stepValue && noOfSections ? stepValue * noOfSections : minItem)
|
|
1265
|
+
|
|
1240
1266
|
export const getBarFrontColor = (
|
|
1241
1267
|
isFocused?: boolean,
|
|
1242
1268
|
focusedBarConfig?: FocusedBarConfig,
|
package/src/utils/types.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface secondaryYAxisType {
|
|
|
37
37
|
mostNegativeValue?: number;
|
|
38
38
|
stepValue?: number;
|
|
39
39
|
stepHeight?: number;
|
|
40
|
+
negativeStepValue?: number;
|
|
41
|
+
negativeStepHeight?: number;
|
|
40
42
|
showFractionalValues?: boolean;
|
|
41
43
|
roundToDigits?: number;
|
|
42
44
|
noOfSectionsBelowXAxis?: number;
|
|
@@ -116,7 +118,9 @@ export interface horizSectionPropTypes {
|
|
|
116
118
|
yAxisSide: yAxisSides;
|
|
117
119
|
horizontalRulesStyle: any;
|
|
118
120
|
noOfSections: number;
|
|
121
|
+
sectionColors?: ColorValue[];
|
|
119
122
|
stepHeight: number;
|
|
123
|
+
negativeStepHeight: number;
|
|
120
124
|
yAxisLabelWidth: number;
|
|
121
125
|
yAxisLabelContainerStyle: any;
|
|
122
126
|
yAxisThickness: number;
|
|
@@ -159,6 +163,7 @@ export interface horizSectionPropTypes {
|
|
|
159
163
|
horizontal: boolean;
|
|
160
164
|
yAxisAtTop: boolean;
|
|
161
165
|
stepValue: number;
|
|
166
|
+
negativeStepValue: number;
|
|
162
167
|
roundToDigits: number | undefined;
|
|
163
168
|
secondaryData: any[] | undefined;
|
|
164
169
|
secondaryYAxis: secondaryYAxisType | null;
|
|
@@ -174,7 +179,9 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
174
179
|
chartType: chartTypes;
|
|
175
180
|
containerHeight: number;
|
|
176
181
|
noOfSectionsBelowXAxis: number;
|
|
182
|
+
sectionColors?: ColorValue[];
|
|
177
183
|
stepHeight: number;
|
|
184
|
+
negativeStepHeight: number;
|
|
178
185
|
labelsExtraHeight: number;
|
|
179
186
|
yAxisLabelWidth: number;
|
|
180
187
|
horizontal: boolean;
|
package/src/utils/types.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface secondaryYAxisType {
|
|
|
46
46
|
mostNegativeValue?: number
|
|
47
47
|
stepValue?: number
|
|
48
48
|
stepHeight?: number
|
|
49
|
+
negativeStepValue?: number
|
|
50
|
+
negativeStepHeight?: number
|
|
49
51
|
showFractionalValues?: boolean
|
|
50
52
|
roundToDigits?: number
|
|
51
53
|
noOfSectionsBelowXAxis?: number
|
|
@@ -131,7 +133,9 @@ export interface horizSectionPropTypes {
|
|
|
131
133
|
yAxisSide: yAxisSides
|
|
132
134
|
horizontalRulesStyle: any
|
|
133
135
|
noOfSections: number
|
|
136
|
+
sectionColors?: ColorValue[]
|
|
134
137
|
stepHeight: number
|
|
138
|
+
negativeStepHeight: number
|
|
135
139
|
yAxisLabelWidth: number
|
|
136
140
|
yAxisLabelContainerStyle: any
|
|
137
141
|
yAxisThickness: number
|
|
@@ -180,6 +184,7 @@ export interface horizSectionPropTypes {
|
|
|
180
184
|
yAxisAtTop: boolean
|
|
181
185
|
|
|
182
186
|
stepValue: number
|
|
187
|
+
negativeStepValue: number
|
|
183
188
|
roundToDigits: number | undefined
|
|
184
189
|
|
|
185
190
|
secondaryData: any[] | undefined
|
|
@@ -199,7 +204,9 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
199
204
|
chartType: chartTypes
|
|
200
205
|
containerHeight: number
|
|
201
206
|
noOfSectionsBelowXAxis: number
|
|
207
|
+
sectionColors?: ColorValue[]
|
|
202
208
|
stepHeight: number
|
|
209
|
+
negativeStepHeight: number
|
|
203
210
|
labelsExtraHeight: number
|
|
204
211
|
yAxisLabelWidth: number
|
|
205
212
|
horizontal: boolean
|