gifted-charts-core 0.1.66 → 0.1.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BarChart/index.d.ts +1 -0
- package/dist/BarChart/index.js +105 -101
- package/dist/BarChart/types.d.ts +3 -0
- package/dist/LineChart/LineChartBiColor.d.ts +1 -0
- package/dist/LineChart/LineChartBiColor.js +86 -82
- package/dist/LineChart/index.d.ts +3 -2
- package/dist/LineChart/index.js +30 -26
- package/dist/LineChart/types.d.ts +4 -0
- package/dist/PopulationPyramid/index.js +1 -1
- package/dist/RadarChart/index.d.ts +1 -0
- package/dist/RadarChart/index.js +32 -31
- package/dist/RadarChart/types.d.ts +2 -0
- package/dist/components/BarAndLineChartsWrapper/index.js +7 -3
- package/dist/utils/constants.d.ts +3 -0
- package/dist/utils/constants.js +5 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/types.d.ts +5 -0
- package/package.json +1 -1
package/dist/BarChart/index.d.ts
CHANGED
|
@@ -205,4 +205,5 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
205
205
|
yAxisExtraHeightAtTop: number;
|
|
206
206
|
selectedStackIndex: number;
|
|
207
207
|
setSelectedStackIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
208
|
+
allowFontScaling: boolean;
|
|
208
209
|
};
|
package/dist/BarChart/index.js
CHANGED
|
@@ -29,19 +29,20 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
29
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, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68;
|
|
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
|
|
35
|
-
var _70 = __read(useState(''), 2),
|
|
36
|
-
var _71 = __read(useState(''), 2),
|
|
37
|
-
var _72 = __read(useState(
|
|
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, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69;
|
|
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, floatingYAxisLabels = props.floatingYAxisLabels;
|
|
34
|
+
var allowFontScaling = (_a = props.allowFontScaling) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.allowFontScaling;
|
|
35
|
+
var _70 = __read(useState(''), 2), points = _70[0], setPoints = _70[1];
|
|
36
|
+
var _71 = __read(useState(''), 2), points2 = _71[0], setPoints2 = _71[1];
|
|
37
|
+
var _72 = __read(useState(''), 2), arrowPoints = _72[0], setArrowPoints = _72[1];
|
|
38
|
+
var _73 = __read(useState(function () {
|
|
38
39
|
if (Array.isArray(focusedBarIndex)) {
|
|
39
40
|
return focusedBarIndex;
|
|
40
41
|
}
|
|
41
42
|
return [focusedBarIndex !== null && focusedBarIndex !== void 0 ? focusedBarIndex : -1];
|
|
42
|
-
}), 2), selectedIndex =
|
|
43
|
-
var
|
|
44
|
-
var showLine = (
|
|
43
|
+
}), 2), selectedIndex = _73[0], setSelectedIndex = _73[1];
|
|
44
|
+
var _74 = __read(useState((_b = props.highlightedStackIndex) !== null && _b !== void 0 ? _b : -1), 2), selectedStackIndex = _74[0], setSelectedStackIndex = _74[1];
|
|
45
|
+
var showLine = (_c = props.showLine) !== null && _c !== void 0 ? _c : BarDefaults.showLine;
|
|
45
46
|
useEffect(function () {
|
|
46
47
|
var newIndex = Array.isArray(focusedBarIndex)
|
|
47
48
|
? focusedBarIndex
|
|
@@ -52,10 +53,10 @@ export var useBarChart = function (props) {
|
|
|
52
53
|
var _a;
|
|
53
54
|
setSelectedStackIndex((_a = props.highlightedStackIndex) !== null && _a !== void 0 ? _a : -1);
|
|
54
55
|
}, [props.highlightedStackIndex]);
|
|
55
|
-
var highlightEnabled = (
|
|
56
|
-
var highlightedBarIndex = (
|
|
57
|
-
var lowlightOpacity = (
|
|
58
|
-
var stackHighlightEnabled = (
|
|
56
|
+
var highlightEnabled = (_d = props.highlightEnabled) !== null && _d !== void 0 ? _d : BarDefaults.highlightEnabled;
|
|
57
|
+
var highlightedBarIndex = (_e = props.highlightedBarIndex) !== null && _e !== void 0 ? _e : selectedIndex;
|
|
58
|
+
var lowlightOpacity = (_f = props.lowlightOpacity) !== null && _f !== void 0 ? _f : BarDefaults.lowlightOpacity;
|
|
59
|
+
var stackHighlightEnabled = (_g = props.stackHighlightEnabled) !== null && _g !== void 0 ? _g : BarDefaults.stackHighlightEnabled;
|
|
59
60
|
var data = useMemo(function () {
|
|
60
61
|
if (!props.data) {
|
|
61
62
|
return [];
|
|
@@ -94,8 +95,8 @@ export var useBarChart = function (props) {
|
|
|
94
95
|
return props.stackData;
|
|
95
96
|
}, [yAxisOffset, props.stackData]);
|
|
96
97
|
// adjustToWidth should work for data or stacked data
|
|
97
|
-
var dataLength = (
|
|
98
|
-
var yAxisLabelWidth = (
|
|
98
|
+
var dataLength = (_l = (_j = (_h = props.data) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : (_k = props.stackData) === null || _k === void 0 ? void 0 : _k.length) !== null && _l !== void 0 ? _l : 0;
|
|
99
|
+
var yAxisLabelWidth = (_m = props.yAxisLabelWidth) !== null && _m !== void 0 ? _m : (props.hideYAxisText
|
|
99
100
|
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
100
101
|
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
101
102
|
var autoComputedSectionWidth = props.initialSpacing !== undefined
|
|
@@ -105,19 +106,19 @@ export var useBarChart = function (props) {
|
|
|
105
106
|
var defaultBarWidth = adjustToWidth
|
|
106
107
|
? autoComputedBarWidth
|
|
107
108
|
: BarDefaults.barWidth;
|
|
108
|
-
var barWidth = (
|
|
109
|
+
var barWidth = (_o = props.barWidth) !== null && _o !== void 0 ? _o : defaultBarWidth;
|
|
109
110
|
var autoComputedSpacing = autoComputedSectionWidth * 0.4;
|
|
110
|
-
var spacing = (
|
|
111
|
-
var initialSpacing = (
|
|
112
|
-
var endSpacing = (
|
|
113
|
-
var horizontal = (
|
|
114
|
-
var rtl = (
|
|
115
|
-
var yAxisAtTop = (
|
|
116
|
-
var intactTopLabel = (
|
|
111
|
+
var spacing = (_p = props.spacing) !== null && _p !== void 0 ? _p : (adjustToWidth ? autoComputedSpacing : BarDefaults.spacing);
|
|
112
|
+
var initialSpacing = (_q = props.initialSpacing) !== null && _q !== void 0 ? _q : spacing;
|
|
113
|
+
var endSpacing = (_r = props.endSpacing) !== null && _r !== void 0 ? _r : spacing;
|
|
114
|
+
var horizontal = (_s = props.horizontal) !== null && _s !== void 0 ? _s : BarDefaults.horizontal;
|
|
115
|
+
var rtl = (_t = props.rtl) !== null && _t !== void 0 ? _t : BarDefaults.rtl;
|
|
116
|
+
var yAxisAtTop = (_u = props.yAxisAtTop) !== null && _u !== void 0 ? _u : BarDefaults.yAxisAtTop;
|
|
117
|
+
var intactTopLabel = (_v = props.intactTopLabel) !== null && _v !== void 0 ? _v : BarDefaults.intactTopLabel;
|
|
117
118
|
var heightFromProps = horizontal ? props.width : props.height;
|
|
118
119
|
var widthFromProps = horizontal ? props.height : props.width;
|
|
119
|
-
var isAnimated = (
|
|
120
|
-
var animationDuration = (
|
|
120
|
+
var isAnimated = (_w = props.isAnimated) !== null && _w !== void 0 ? _w : BarDefaults.isAnimated;
|
|
121
|
+
var animationDuration = (_x = props.animationDuration) !== null && _x !== void 0 ? _x : BarDefaults.animationDuration;
|
|
121
122
|
// const secondaryData = getSecondaryDataWithOffsetIncluded(
|
|
122
123
|
// props.secondaryData,
|
|
123
124
|
// props.secondaryYAxis
|
|
@@ -135,7 +136,7 @@ export var useBarChart = function (props) {
|
|
|
135
136
|
return props.lineData;
|
|
136
137
|
}, [yAxisOffset, props.lineData, data, stackData]);
|
|
137
138
|
var lineData2 = props.lineData2;
|
|
138
|
-
var lineBehindBars = (
|
|
139
|
+
var lineBehindBars = (_y = props.lineBehindBars) !== null && _y !== void 0 ? _y : BarDefaults.lineBehindBars;
|
|
139
140
|
defaultLineConfig.initialSpacing = initialSpacing;
|
|
140
141
|
defaultLineConfig.endIndex = lineData.length - 1;
|
|
141
142
|
defaultLineConfig.animationDuration = animationDuration;
|
|
@@ -150,12 +151,12 @@ export var useBarChart = function (props) {
|
|
|
150
151
|
? props.stepHeight * noOfSections
|
|
151
152
|
: AxesAndRulesDefaults.containerHeight);
|
|
152
153
|
var horizSections = [{ value: '0' }];
|
|
153
|
-
var stepHeight = (
|
|
154
|
-
var labelWidth = (
|
|
155
|
-
var scrollToEnd = (
|
|
156
|
-
var scrollAnimation = (
|
|
157
|
-
var scrollEventThrottle = (
|
|
158
|
-
var labelsExtraHeight = (
|
|
154
|
+
var stepHeight = (_z = props.stepHeight) !== null && _z !== void 0 ? _z : containerHeight / noOfSections;
|
|
155
|
+
var labelWidth = (_0 = props.labelWidth) !== null && _0 !== void 0 ? _0 : AxesAndRulesDefaults.labelWidth;
|
|
156
|
+
var scrollToEnd = (_1 = props.scrollToEnd) !== null && _1 !== void 0 ? _1 : BarDefaults.scrollToEnd;
|
|
157
|
+
var scrollAnimation = (_2 = props.scrollAnimation) !== null && _2 !== void 0 ? _2 : BarDefaults.scrollAnimation;
|
|
158
|
+
var scrollEventThrottle = (_3 = props.scrollEventThrottle) !== null && _3 !== void 0 ? _3 : BarDefaults.scrollEventThrottle;
|
|
159
|
+
var labelsExtraHeight = (_4 = props.labelsExtraHeight) !== null && _4 !== void 0 ? _4 : AxesAndRulesDefaults.labelsExtraHeight;
|
|
159
160
|
var secondaryMaxItem = 0;
|
|
160
161
|
var secondaryMinItem = 0;
|
|
161
162
|
if (lineConfig.isSecondary) {
|
|
@@ -231,13 +232,13 @@ export var useBarChart = function (props) {
|
|
|
231
232
|
});
|
|
232
233
|
}
|
|
233
234
|
var valuesRange = maxItem - minPositiveItem; // Diff bw largest & smallest +ve values
|
|
234
|
-
var showFractionalValues = (
|
|
235
|
-
var roundToDigits = (
|
|
235
|
+
var showFractionalValues = (_5 = props.showFractionalValues) !== null && _5 !== void 0 ? _5 : valuesRange <= 1;
|
|
236
|
+
var roundToDigits = (_6 = props.roundToDigits) !== null && _6 !== void 0 ? _6 : (showFractionalValues ? indexOfFirstNonZeroDigit(valuesRange) + 1 : 0);
|
|
236
237
|
var maxAndMin = maxAndMinUtil(maxItem, minItem, roundToDigits, showFractionalValues);
|
|
237
238
|
var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxAndMin.maxItem) || 10;
|
|
238
239
|
var secondaryRange = secondaryMaxItem - secondaryMinPositiveItem; // Diff bw largest & smallest +ve values
|
|
239
|
-
var showSecondaryFractionalValues = (
|
|
240
|
-
var secondaryRoundToDigits = (
|
|
240
|
+
var showSecondaryFractionalValues = (_8 = (_7 = props.secondaryYAxis) === null || _7 === void 0 ? void 0 : _7.showFractionalValues) !== null && _8 !== void 0 ? _8 : secondaryRange <= 1;
|
|
241
|
+
var secondaryRoundToDigits = (_10 = (_9 = props.secondaryYAxis) === null || _9 === void 0 ? void 0 : _9.roundToDigits) !== null && _10 !== void 0 ? _10 : (showSecondaryFractionalValues
|
|
241
242
|
? indexOfFirstNonZeroDigit(secondaryRange) + 1
|
|
242
243
|
: 0);
|
|
243
244
|
var secondaryMaxAndMin = maxAndMinUtil(secondaryMaxItem, secondaryMinItem, secondaryRoundToDigits, showSecondaryFractionalValues);
|
|
@@ -247,88 +248,88 @@ export var useBarChart = function (props) {
|
|
|
247
248
|
// secondaryMaxAndMin.maxItem
|
|
248
249
|
// : secondaryMaxAndMin.maxItem
|
|
249
250
|
// : maxValue
|
|
250
|
-
var secondaryMaxValue = (
|
|
251
|
+
var secondaryMaxValue = (_12 = (_11 = props.secondaryYAxis) === null || _11 === void 0 ? void 0 : _11.maxValue) !== null && _12 !== void 0 ? _12 : secondaryMaxAndMin.maxItem;
|
|
251
252
|
var mostNegativeValue = getMostNegativeValue(props.mostNegativeValue, props.negativeStepValue, props.noOfSectionsBelowXAxis, maxAndMin.minItem);
|
|
252
|
-
var stepValue = (
|
|
253
|
+
var stepValue = (_13 = props.stepValue) !== null && _13 !== void 0 ? _13 : maxValue / noOfSections;
|
|
253
254
|
var effectiveNegativeStepValue = negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue;
|
|
254
|
-
var noOfSectionsBelowXAxis = (
|
|
255
|
+
var noOfSectionsBelowXAxis = (_14 = props.noOfSectionsBelowXAxis) !== null && _14 !== void 0 ? _14 : (effectiveNegativeStepValue
|
|
255
256
|
? Math.round(Math.ceil(-mostNegativeValue / effectiveNegativeStepValue))
|
|
256
257
|
: 0);
|
|
257
|
-
var showScrollIndicator = (
|
|
258
|
-
var side = (
|
|
259
|
-
var rotateLabel = (
|
|
260
|
-
var opacity = (
|
|
261
|
-
var isThreeD = (
|
|
262
|
-
var showXAxisIndices = (
|
|
263
|
-
var xAxisIndicesHeight = (
|
|
264
|
-
var xAxisIndicesWidth = (
|
|
265
|
-
var xAxisIndicesColor = (
|
|
266
|
-
var xAxisThickness = (
|
|
267
|
-
var xAxisTextNumberOfLines = (
|
|
268
|
-
var xAxisLabelsVerticalShift = (
|
|
269
|
-
var xAxisLabelsAtBottom = (
|
|
258
|
+
var showScrollIndicator = (_15 = props.showScrollIndicator) !== null && _15 !== void 0 ? _15 : BarDefaults.showScrollIndicator;
|
|
259
|
+
var side = (_16 = props.side) !== null && _16 !== void 0 ? _16 : BarDefaults.side;
|
|
260
|
+
var rotateLabel = (_17 = props.rotateLabel) !== null && _17 !== void 0 ? _17 : AxesAndRulesDefaults.rotateLabel;
|
|
261
|
+
var opacity = (_18 = props.opacity) !== null && _18 !== void 0 ? _18 : BarDefaults.opacity;
|
|
262
|
+
var isThreeD = (_19 = props.isThreeD) !== null && _19 !== void 0 ? _19 : BarDefaults.isThreeD;
|
|
263
|
+
var showXAxisIndices = (_20 = props.showXAxisIndices) !== null && _20 !== void 0 ? _20 : AxesAndRulesDefaults.showXAxisIndices;
|
|
264
|
+
var xAxisIndicesHeight = (_21 = props.xAxisIndicesHeight) !== null && _21 !== void 0 ? _21 : AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
265
|
+
var xAxisIndicesWidth = (_22 = props.xAxisIndicesWidth) !== null && _22 !== void 0 ? _22 : AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
266
|
+
var xAxisIndicesColor = (_23 = props.xAxisIndicesColor) !== null && _23 !== void 0 ? _23 : AxesAndRulesDefaults.xAxisIndicesColor;
|
|
267
|
+
var xAxisThickness = (_24 = props.xAxisThickness) !== null && _24 !== void 0 ? _24 : AxesAndRulesDefaults.xAxisThickness;
|
|
268
|
+
var xAxisTextNumberOfLines = (_25 = props.xAxisTextNumberOfLines) !== null && _25 !== void 0 ? _25 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
|
|
269
|
+
var xAxisLabelsVerticalShift = (_26 = props.xAxisLabelsVerticalShift) !== null && _26 !== void 0 ? _26 : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
|
|
270
|
+
var xAxisLabelsAtBottom = (_27 = props.xAxisLabelsAtBottom) !== null && _27 !== void 0 ? _27 : false;
|
|
270
271
|
var horizontalRulesStyle = props.horizontalRulesStyle;
|
|
271
|
-
var autoShiftLabels = (
|
|
272
|
-
var barBorderColor = (
|
|
272
|
+
var autoShiftLabels = (_28 = props.autoShiftLabels) !== null && _28 !== void 0 ? _28 : false;
|
|
273
|
+
var barBorderColor = (_29 = props.barBorderColor) !== null && _29 !== void 0 ? _29 : BarDefaults.barBorderColor;
|
|
273
274
|
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
|
|
274
275
|
var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
|
|
275
|
-
var
|
|
276
|
-
var primary4thQuadrantHeight = noOfSectionsBelowXAxis * ((
|
|
276
|
+
var _75 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepHeight = _75.stepHeight, secondaryStepValue = _75.stepValue, secondaryNegativeStepHeight = _75.negativeStepHeight, secondaryNegativeStepValue = _75.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _75.noOfSectionsBelowXAxis;
|
|
277
|
+
var primary4thQuadrantHeight = noOfSectionsBelowXAxis * ((_30 = props.negativeStepHeight) !== null && _30 !== void 0 ? _30 : stepHeight);
|
|
277
278
|
var secondary4thQuadrantHeight = secondaryNoOfSectionsBelowXAxis * secondaryNegativeStepHeight;
|
|
278
279
|
var fourthQuadrantHeight = Math.max(primary4thQuadrantHeight, secondary4thQuadrantHeight);
|
|
279
280
|
var containerHeightIncludingBelowXAxis = extendedContainerHeight + fourthQuadrantHeight;
|
|
280
|
-
var
|
|
281
|
-
var
|
|
282
|
-
var
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
var
|
|
281
|
+
var _76 = __read(useState(-1), 2), pointerIndex = _76[0], setPointerIndex = _76[1];
|
|
282
|
+
var _77 = __read(useState(0), 2), pointerX = _77[0], setPointerX = _77[1];
|
|
283
|
+
var _78 = __read(useState(0), 2), pointerY = _78[0], setPointerY = _78[1];
|
|
284
|
+
var _79 = __read(useState(), 2), pointerItem = _79[0], setPointerItem = _79[1];
|
|
285
|
+
var _80 = __read(useState(0), 2), responderStartTime = _80[0], setResponderStartTime = _80[1];
|
|
286
|
+
var _81 = __read(useState(false), 2), responderActive = _81[0], setResponderActive = _81[1];
|
|
286
287
|
var pointerConfig = props.pointerConfig;
|
|
287
|
-
var getPointerProps = (
|
|
288
|
-
var pointerHeight = (
|
|
289
|
-
var pointerWidth = (
|
|
290
|
-
var pointerRadius = (
|
|
291
|
-
var pointerColor = (
|
|
292
|
-
var pointerComponent = (
|
|
288
|
+
var getPointerProps = (_31 = props.getPointerProps) !== null && _31 !== void 0 ? _31 : null;
|
|
289
|
+
var pointerHeight = (_32 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _32 !== void 0 ? _32 : defaultPointerConfig.height;
|
|
290
|
+
var pointerWidth = (_33 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.width) !== null && _33 !== void 0 ? _33 : defaultPointerConfig.width;
|
|
291
|
+
var pointerRadius = (_34 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.radius) !== null && _34 !== void 0 ? _34 : defaultPointerConfig.radius;
|
|
292
|
+
var pointerColor = (_35 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColor) !== null && _35 !== void 0 ? _35 : defaultPointerConfig.pointerColor;
|
|
293
|
+
var pointerComponent = (_36 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerComponent) !== null && _36 !== void 0 ? _36 : defaultPointerConfig.pointerComponent;
|
|
293
294
|
var showPointerStrip = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.showPointerStrip) === false
|
|
294
295
|
? false
|
|
295
296
|
: defaultPointerConfig.showPointerStrip;
|
|
296
|
-
var pointerStripHeight = (
|
|
297
|
-
var pointerStripWidth = (
|
|
298
|
-
var pointerStripColor = (
|
|
299
|
-
var pointerStripUptoDataPoint = (
|
|
300
|
-
var pointerLabelComponent = (
|
|
301
|
-
var stripOverPointer = (
|
|
302
|
-
var shiftPointerLabelX = (
|
|
303
|
-
var shiftPointerLabelY = (
|
|
304
|
-
var pointerLabelWidth = (
|
|
305
|
-
var pointerLabelHeight = (
|
|
306
|
-
var autoAdjustPointerLabelPosition = (
|
|
307
|
-
var pointerVanishDelay = (
|
|
308
|
-
var activatePointersOnLongPress = (
|
|
309
|
-
var activatePointersDelay = (
|
|
310
|
-
var initialPointerIndex = (
|
|
311
|
-
var initialPointerAppearDelay = (
|
|
297
|
+
var pointerStripHeight = (_37 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripHeight) !== null && _37 !== void 0 ? _37 : defaultPointerConfig.pointerStripHeight;
|
|
298
|
+
var pointerStripWidth = (_38 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripWidth) !== null && _38 !== void 0 ? _38 : defaultPointerConfig.pointerStripWidth;
|
|
299
|
+
var pointerStripColor = (_39 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripColor) !== null && _39 !== void 0 ? _39 : defaultPointerConfig.pointerStripColor;
|
|
300
|
+
var pointerStripUptoDataPoint = (_40 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripUptoDataPoint) !== null && _40 !== void 0 ? _40 : defaultPointerConfig.pointerStripUptoDataPoint;
|
|
301
|
+
var pointerLabelComponent = (_41 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelComponent) !== null && _41 !== void 0 ? _41 : defaultPointerConfig.pointerLabelComponent;
|
|
302
|
+
var stripOverPointer = (_42 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripOverPointer) !== null && _42 !== void 0 ? _42 : defaultPointerConfig.stripOverPointer;
|
|
303
|
+
var shiftPointerLabelX = (_43 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelX) !== null && _43 !== void 0 ? _43 : defaultPointerConfig.shiftPointerLabelX;
|
|
304
|
+
var shiftPointerLabelY = (_44 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelY) !== null && _44 !== void 0 ? _44 : defaultPointerConfig.shiftPointerLabelY;
|
|
305
|
+
var pointerLabelWidth = (_45 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelWidth) !== null && _45 !== void 0 ? _45 : defaultPointerConfig.pointerLabelWidth;
|
|
306
|
+
var pointerLabelHeight = (_46 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelHeight) !== null && _46 !== void 0 ? _46 : defaultPointerConfig.pointerLabelHeight;
|
|
307
|
+
var autoAdjustPointerLabelPosition = (_47 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.autoAdjustPointerLabelPosition) !== null && _47 !== void 0 ? _47 : defaultPointerConfig.autoAdjustPointerLabelPosition;
|
|
308
|
+
var pointerVanishDelay = (_48 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerVanishDelay) !== null && _48 !== void 0 ? _48 : defaultPointerConfig.pointerVanishDelay;
|
|
309
|
+
var activatePointersOnLongPress = (_49 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersOnLongPress) !== null && _49 !== void 0 ? _49 : defaultPointerConfig.activatePointersOnLongPress;
|
|
310
|
+
var activatePointersDelay = (_50 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersDelay) !== null && _50 !== void 0 ? _50 : defaultPointerConfig.activatePointersDelay;
|
|
311
|
+
var initialPointerIndex = (_51 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerIndex) !== null && _51 !== void 0 ? _51 : defaultPointerConfig.initialPointerIndex;
|
|
312
|
+
var initialPointerAppearDelay = (_52 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerAppearDelay) !== null && _52 !== void 0 ? _52 : (isAnimated
|
|
312
313
|
? animationDuration
|
|
313
314
|
: defaultPointerConfig.initialPointerAppearDelay);
|
|
314
|
-
var persistPointer = (
|
|
315
|
-
var hidePointer1 = (
|
|
315
|
+
var persistPointer = (_53 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.persistPointer) !== null && _53 !== void 0 ? _53 : defaultPointerConfig.persistPointer;
|
|
316
|
+
var hidePointer1 = (_54 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointer1) !== null && _54 !== void 0 ? _54 : defaultPointerConfig.hidePointer1;
|
|
316
317
|
var pointerEvents = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerEvents;
|
|
317
|
-
var stripBehindBars = (
|
|
318
|
-
var disableScroll = (
|
|
318
|
+
var stripBehindBars = (_55 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripBehindBars) !== null && _55 !== void 0 ? _55 : defaultPointerConfig.stripBehindBars;
|
|
319
|
+
var disableScroll = (_56 = props.disableScroll) !== null && _56 !== void 0 ? _56 : (pointerConfig
|
|
319
320
|
? activatePointersOnLongPress
|
|
320
321
|
? !!responderActive
|
|
321
322
|
: true
|
|
322
323
|
: false);
|
|
323
324
|
var yAxisExtraHeightAtTop = props.trimYAxisAtTop
|
|
324
325
|
? 0
|
|
325
|
-
: (
|
|
326
|
+
: (_57 = props.yAxisExtraHeight) !== null && _57 !== void 0 ? _57 : containerHeight / 20;
|
|
326
327
|
var barInnerComponent = props.barInnerComponent;
|
|
327
328
|
var localYAxisOffset1 = lineConfig.isSecondary
|
|
328
|
-
? (
|
|
329
|
+
? (_59 = (_58 = props.secondaryYAxis) === null || _58 === void 0 ? void 0 : _58.yAxisOffset) !== null && _59 !== void 0 ? _59 : 0
|
|
329
330
|
: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0;
|
|
330
331
|
var localYAxisOffset2 = lineConfig2.isSecondary
|
|
331
|
-
? (
|
|
332
|
+
? (_61 = (_60 = props.secondaryYAxis) === null || _60 === void 0 ? void 0 : _60.yAxisOffset) !== null && _61 !== void 0 ? _61 : 0
|
|
332
333
|
: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0;
|
|
333
334
|
useEffect(function () {
|
|
334
335
|
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;
|
|
@@ -444,9 +445,9 @@ export var useBarChart = function (props) {
|
|
|
444
445
|
spacing,
|
|
445
446
|
yAxisLabelWidth,
|
|
446
447
|
lineConfig.showArrow,
|
|
447
|
-
(
|
|
448
|
-
(
|
|
449
|
-
(
|
|
448
|
+
(_62 = lineConfig.arrowConfig) === null || _62 === void 0 ? void 0 : _62.length,
|
|
449
|
+
(_63 = lineConfig.arrowConfig) === null || _63 === void 0 ? void 0 : _63.width,
|
|
450
|
+
(_64 = lineConfig.arrowConfig) === null || _64 === void 0 ? void 0 : _64.showArrowBase
|
|
450
451
|
]);
|
|
451
452
|
useEffect(function () {
|
|
452
453
|
var _a, _b;
|
|
@@ -583,19 +584,19 @@ export var useBarChart = function (props) {
|
|
|
583
584
|
containerHeight: containerHeight,
|
|
584
585
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
585
586
|
stepHeight: stepHeight,
|
|
586
|
-
negativeStepHeight: (
|
|
587
|
+
negativeStepHeight: (_65 = props.negativeStepHeight) !== null && _65 !== void 0 ? _65 : stepHeight,
|
|
587
588
|
labelsExtraHeight: labelsExtraHeight,
|
|
588
589
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
589
590
|
horizontal: horizontal,
|
|
590
591
|
rtl: rtl,
|
|
591
|
-
shiftX: (
|
|
592
|
-
shiftY: (
|
|
592
|
+
shiftX: (_66 = props.shiftX) !== null && _66 !== void 0 ? _66 : 0,
|
|
593
|
+
shiftY: (_67 = props.shiftY) !== null && _67 !== void 0 ? _67 : 0,
|
|
593
594
|
yAxisAtTop: yAxisAtTop,
|
|
594
595
|
initialSpacing: initialSpacing,
|
|
595
596
|
data: data,
|
|
596
597
|
stackData: stackData,
|
|
597
598
|
// secondaryData,
|
|
598
|
-
barWidth: (
|
|
599
|
+
barWidth: (_68 = props.barWidth) !== null && _68 !== void 0 ? _68 : defaultBarWidth,
|
|
599
600
|
xAxisThickness: xAxisThickness,
|
|
600
601
|
totalWidth: totalWidth,
|
|
601
602
|
disableScroll: disableScroll,
|
|
@@ -644,13 +645,15 @@ export var useBarChart = function (props) {
|
|
|
644
645
|
pointerY: pointerY,
|
|
645
646
|
onEndReached: props.onEndReached,
|
|
646
647
|
onStartReached: props.onStartReached,
|
|
647
|
-
endReachedOffset: (
|
|
648
|
+
endReachedOffset: (_69 = props.endReachedOffset) !== null && _69 !== void 0 ? _69 : BarDefaults.endReachedOffset,
|
|
648
649
|
onMomentumScrollEnd: props.onMomentumScrollEnd,
|
|
649
650
|
customBackground: props.customBackground,
|
|
650
651
|
highlightEnabled: highlightEnabled,
|
|
651
652
|
lowlightOpacity: lowlightOpacity,
|
|
652
653
|
xAxisLabelsAtBottom: xAxisLabelsAtBottom,
|
|
653
|
-
onScrollEndDrag: props.onScrollEndDrag
|
|
654
|
+
onScrollEndDrag: props.onScrollEndDrag,
|
|
655
|
+
floatingYAxisLabels: floatingYAxisLabels,
|
|
656
|
+
allowFontScaling: allowFontScaling
|
|
654
657
|
};
|
|
655
658
|
return {
|
|
656
659
|
lineConfig: lineConfig,
|
|
@@ -763,6 +766,7 @@ export var useBarChart = function (props) {
|
|
|
763
766
|
barAndLineChartsWrapperProps: barAndLineChartsWrapperProps,
|
|
764
767
|
yAxisExtraHeightAtTop: yAxisExtraHeightAtTop,
|
|
765
768
|
selectedStackIndex: selectedStackIndex,
|
|
766
|
-
setSelectedStackIndex: setSelectedStackIndex
|
|
769
|
+
setSelectedStackIndex: setSelectedStackIndex,
|
|
770
|
+
allowFontScaling: allowFontScaling
|
|
767
771
|
};
|
|
768
772
|
};
|
package/dist/BarChart/types.d.ts
CHANGED
|
@@ -195,6 +195,8 @@ export interface BarChartPropsType {
|
|
|
195
195
|
xAxisLabelsVerticalShift?: number;
|
|
196
196
|
xAxisLabelsAtBottom?: boolean;
|
|
197
197
|
yAxisLabelWidth?: number;
|
|
198
|
+
floatingYAxisLabels?: boolean;
|
|
199
|
+
allowFontScaling?: boolean;
|
|
198
200
|
hideYAxisText?: boolean;
|
|
199
201
|
rotateYAxisTexts?: number;
|
|
200
202
|
yAxisSide?: yAxisSides;
|
|
@@ -663,6 +665,7 @@ export interface animatedBarPropTypes {
|
|
|
663
665
|
selectedIndex: number[];
|
|
664
666
|
focusBarOnPress?: boolean;
|
|
665
667
|
focusedBarConfig?: FocusedBarConfig;
|
|
668
|
+
containerHeight: number;
|
|
666
669
|
}
|
|
667
670
|
export interface CommonPropsFor2dand3dBarsType {
|
|
668
671
|
barBackgroundPattern?: () => ReactNode;
|
|
@@ -28,11 +28,11 @@ import { AxesAndRulesDefaults, LineDefaults, chartTypes } from '../utils/constan
|
|
|
28
28
|
import { getAxesAndRulesProps, getExtendedContainerHeightWithPadding } from '../utils';
|
|
29
29
|
var initialData = null;
|
|
30
30
|
export var useLineChartBiColor = function (props) {
|
|
31
|
-
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;
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
31
|
+
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;
|
|
32
|
+
var _54 = __read(useState(false), 2), toggle = _54[0], setToggle = _54[1];
|
|
33
|
+
var _55 = __read(useState([]), 2), pointsArray = _55[0], setPointsArray = _55[1];
|
|
34
|
+
var _56 = __read(useState([]), 2), fillPointsArray = _56[0], setFillPointsArray = _56[1];
|
|
35
|
+
var _57 = __read(useState(-1), 2), selectedIndex = _57[0], setSelectedIndex = _57[1];
|
|
36
36
|
var containerHeight = (_a = props.height) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.containerHeight;
|
|
37
37
|
var noOfSections = (_b = props.noOfSections) !== null && _b !== void 0 ? _b : AxesAndRulesDefaults.noOfSections;
|
|
38
38
|
var data = useMemo(function () {
|
|
@@ -48,12 +48,13 @@ export var useLineChartBiColor = function (props) {
|
|
|
48
48
|
}
|
|
49
49
|
return props.data;
|
|
50
50
|
}, [props.yAxisOffset, props.data]);
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
51
|
+
var allowFontScaling = (_c = props.allowFontScaling) !== null && _c !== void 0 ? _c : AxesAndRulesDefaults.allowFontScaling;
|
|
52
|
+
var scrollToEnd = (_d = props.scrollToEnd) !== null && _d !== void 0 ? _d : LineDefaults.scrollToEnd;
|
|
53
|
+
var scrollAnimation = (_e = props.scrollAnimation) !== null && _e !== void 0 ? _e : LineDefaults.scrollAnimation;
|
|
54
|
+
var scrollEventThrottle = (_f = props.scrollEventThrottle) !== null && _f !== void 0 ? _f : LineDefaults.scrollEventThrottle;
|
|
55
|
+
var labelsExtraHeight = (_g = props.labelsExtraHeight) !== null && _g !== void 0 ? _g : 0;
|
|
56
|
+
var animationDuration = (_h = props.animationDuration) !== null && _h !== void 0 ? _h : LineDefaults.animationDuration;
|
|
57
|
+
var startIndex1 = (_j = props.startIndex) !== null && _j !== void 0 ? _j : 0;
|
|
57
58
|
var endIndex1;
|
|
58
59
|
if (props.endIndex === undefined || props.endIndex === null) {
|
|
59
60
|
endIndex1 = data.length - 1;
|
|
@@ -64,23 +65,23 @@ export var useLineChartBiColor = function (props) {
|
|
|
64
65
|
if (!initialData) {
|
|
65
66
|
initialData = __spreadArray([], __read(data), false);
|
|
66
67
|
}
|
|
67
|
-
var adjustToWidth = (
|
|
68
|
-
var initialSpacing = (
|
|
69
|
-
var endSpacing = (
|
|
70
|
-
var thickness = (
|
|
71
|
-
var spacing = (
|
|
72
|
-
? (((
|
|
68
|
+
var adjustToWidth = (_k = props.adjustToWidth) !== null && _k !== void 0 ? _k : false;
|
|
69
|
+
var initialSpacing = (_l = props.initialSpacing) !== null && _l !== void 0 ? _l : LineDefaults.initialSpacing;
|
|
70
|
+
var endSpacing = (_m = props.endSpacing) !== null && _m !== void 0 ? _m : (adjustToWidth ? 0 : LineDefaults.endSpacing);
|
|
71
|
+
var thickness = (_o = props.thickness) !== null && _o !== void 0 ? _o : LineDefaults.thickness;
|
|
72
|
+
var spacing = (_p = props.spacing) !== null && _p !== void 0 ? _p : (adjustToWidth
|
|
73
|
+
? (((_q = props.width) !== null && _q !== void 0 ? _q : AxesAndRulesDefaults.width) - initialSpacing) /
|
|
73
74
|
data.length
|
|
74
75
|
: LineDefaults.spacing);
|
|
75
|
-
var xAxisThickness = (
|
|
76
|
-
var dataPointsHeight1 = (
|
|
77
|
-
var dataPointsWidth1 = (
|
|
78
|
-
var dataPointsRadius1 = (
|
|
79
|
-
var dataPointsColor1 = (
|
|
80
|
-
var dataPointsShape1 = (
|
|
81
|
-
var areaChart = (
|
|
82
|
-
var textFontSize1 = (
|
|
83
|
-
var textColor1 = (
|
|
76
|
+
var xAxisThickness = (_r = props.xAxisThickness) !== null && _r !== void 0 ? _r : AxesAndRulesDefaults.xAxisThickness;
|
|
77
|
+
var dataPointsHeight1 = (_s = props.dataPointsHeight) !== null && _s !== void 0 ? _s : LineDefaults.dataPointsHeight;
|
|
78
|
+
var dataPointsWidth1 = (_t = props.dataPointsWidth) !== null && _t !== void 0 ? _t : LineDefaults.dataPointsWidth;
|
|
79
|
+
var dataPointsRadius1 = (_u = props.dataPointsRadius) !== null && _u !== void 0 ? _u : LineDefaults.dataPointsRadius;
|
|
80
|
+
var dataPointsColor1 = (_v = props.dataPointsColor) !== null && _v !== void 0 ? _v : LineDefaults.dataPointsColor;
|
|
81
|
+
var dataPointsShape1 = (_w = props.dataPointsShape) !== null && _w !== void 0 ? _w : LineDefaults.dataPointsShape;
|
|
82
|
+
var areaChart = (_x = props.areaChart) !== null && _x !== void 0 ? _x : false;
|
|
83
|
+
var textFontSize1 = (_y = props.textFontSize) !== null && _y !== void 0 ? _y : LineDefaults.textFontSize;
|
|
84
|
+
var textColor1 = (_z = props.textColor) !== null && _z !== void 0 ? _z : LineDefaults.textColor;
|
|
84
85
|
var totalWidth = initialSpacing + endSpacing;
|
|
85
86
|
var maxItem = 0;
|
|
86
87
|
var minItem = 0;
|
|
@@ -93,16 +94,16 @@ export var useLineChartBiColor = function (props) {
|
|
|
93
94
|
}
|
|
94
95
|
totalWidth += index === data.length - 1 ? 0 : spacing;
|
|
95
96
|
});
|
|
96
|
-
if ((
|
|
97
|
-
maxItem *= 10 * ((
|
|
97
|
+
if ((_0 = props.showFractionalValues) !== null && _0 !== void 0 ? _0 : props.roundToDigits) {
|
|
98
|
+
maxItem *= 10 * ((_1 = props.roundToDigits) !== null && _1 !== void 0 ? _1 : 1);
|
|
98
99
|
maxItem = maxItem + (10 - (maxItem % 10));
|
|
99
|
-
maxItem /= 10 * ((
|
|
100
|
-
maxItem = parseFloat(maxItem.toFixed((
|
|
100
|
+
maxItem /= 10 * ((_2 = props.roundToDigits) !== null && _2 !== void 0 ? _2 : 1);
|
|
101
|
+
maxItem = parseFloat(maxItem.toFixed((_3 = props.roundToDigits) !== null && _3 !== void 0 ? _3 : 1));
|
|
101
102
|
if (minItem !== 0) {
|
|
102
|
-
minItem *= 10 * ((
|
|
103
|
+
minItem *= 10 * ((_4 = props.roundToDigits) !== null && _4 !== void 0 ? _4 : 1);
|
|
103
104
|
minItem = minItem - (10 + (minItem % 10));
|
|
104
|
-
minItem /= 10 * ((
|
|
105
|
-
minItem = parseFloat(minItem.toFixed((
|
|
105
|
+
minItem /= 10 * ((_5 = props.roundToDigits) !== null && _5 !== void 0 ? _5 : 1);
|
|
106
|
+
minItem = parseFloat(minItem.toFixed((_6 = props.roundToDigits) !== null && _6 !== void 0 ? _6 : 1));
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
else {
|
|
@@ -111,8 +112,8 @@ export var useLineChartBiColor = function (props) {
|
|
|
111
112
|
minItem = minItem - (10 + (minItem % 10));
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
|
-
var maxValue = (
|
|
115
|
-
var mostNegativeValue = (
|
|
115
|
+
var maxValue = (_7 = props.maxValue) !== null && _7 !== void 0 ? _7 : maxItem;
|
|
116
|
+
var mostNegativeValue = (_8 = props.mostNegativeValue) !== null && _8 !== void 0 ? _8 : minItem;
|
|
116
117
|
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, props.overflowTop);
|
|
117
118
|
var yAtxAxis = extendedContainerHeight - xAxisThickness / 2;
|
|
118
119
|
var getX = function (index) { return initialSpacing + spacing * index; };
|
|
@@ -310,67 +311,67 @@ export var useLineChartBiColor = function (props) {
|
|
|
310
311
|
maxValue
|
|
311
312
|
]);
|
|
312
313
|
var horizSections = [{ value: '0' }];
|
|
313
|
-
var stepHeight = (
|
|
314
|
-
var stepValue = (
|
|
315
|
-
var noOfSectionsBelowXAxis = (
|
|
316
|
-
var thickness1 = (
|
|
317
|
-
var zIndex = (
|
|
314
|
+
var stepHeight = (_9 = props.stepHeight) !== null && _9 !== void 0 ? _9 : containerHeight / noOfSections;
|
|
315
|
+
var stepValue = (_10 = props.stepValue) !== null && _10 !== void 0 ? _10 : maxValue / noOfSections;
|
|
316
|
+
var noOfSectionsBelowXAxis = (_11 = props.noOfSectionsBelowXAxis) !== null && _11 !== void 0 ? _11 : Math.round(Math.ceil(-mostNegativeValue / stepValue));
|
|
317
|
+
var thickness1 = (_12 = props.thickness) !== null && _12 !== void 0 ? _12 : LineDefaults.thickness;
|
|
318
|
+
var zIndex = (_13 = props.zIndex) !== null && _13 !== void 0 ? _13 : 0;
|
|
318
319
|
var strokeDashArray1 = props.strokeDashArray;
|
|
319
|
-
var rotateLabel = (
|
|
320
|
-
var isAnimated = (
|
|
321
|
-
var hideDataPoints1 = (
|
|
322
|
-
var color = (
|
|
323
|
-
var colorNegative = (
|
|
324
|
-
var startFillColor = (
|
|
325
|
-
var endFillColor = (
|
|
326
|
-
var startOpacity = (
|
|
327
|
-
var endOpacity = (
|
|
328
|
-
var startFillColorNegative = (
|
|
329
|
-
var endFillColorNegative = (
|
|
330
|
-
var startOpacityNegative = (
|
|
331
|
-
var endOpacityNegative = (
|
|
332
|
-
var gradientDirection = (
|
|
333
|
-
var showXAxisIndices = (
|
|
334
|
-
var xAxisIndicesHeight = (
|
|
335
|
-
var xAxisIndicesWidth = (
|
|
336
|
-
var xAxisIndicesColor = (
|
|
337
|
-
var xAxisTextNumberOfLines = (
|
|
320
|
+
var rotateLabel = (_14 = props.rotateLabel) !== null && _14 !== void 0 ? _14 : AxesAndRulesDefaults.rotateLabel;
|
|
321
|
+
var isAnimated = (_15 = props.isAnimated) !== null && _15 !== void 0 ? _15 : LineDefaults.isAnimated;
|
|
322
|
+
var hideDataPoints1 = (_16 = props.hideDataPoints) !== null && _16 !== void 0 ? _16 : LineDefaults.hideDataPoints;
|
|
323
|
+
var color = (_17 = props.color) !== null && _17 !== void 0 ? _17 : 'green';
|
|
324
|
+
var colorNegative = (_18 = props.colorNegative) !== null && _18 !== void 0 ? _18 : 'red';
|
|
325
|
+
var startFillColor = (_19 = props.startFillColor) !== null && _19 !== void 0 ? _19 : 'lightgreen';
|
|
326
|
+
var endFillColor = (_20 = props.endFillColor) !== null && _20 !== void 0 ? _20 : 'white';
|
|
327
|
+
var startOpacity = (_21 = props.startOpacity) !== null && _21 !== void 0 ? _21 : LineDefaults.startOpacity;
|
|
328
|
+
var endOpacity = (_22 = props.endOpacity) !== null && _22 !== void 0 ? _22 : LineDefaults.endOpacity;
|
|
329
|
+
var startFillColorNegative = (_23 = props.startFillColorNegative) !== null && _23 !== void 0 ? _23 : 'pink';
|
|
330
|
+
var endFillColorNegative = (_24 = props.endFillColorNegative) !== null && _24 !== void 0 ? _24 : 'white';
|
|
331
|
+
var startOpacityNegative = (_25 = props.startOpacityNegative) !== null && _25 !== void 0 ? _25 : LineDefaults.startOpacity;
|
|
332
|
+
var endOpacityNegative = (_26 = props.endOpacityNegative) !== null && _26 !== void 0 ? _26 : LineDefaults.endOpacity;
|
|
333
|
+
var gradientDirection = (_27 = props.gradientDirection) !== null && _27 !== void 0 ? _27 : 'vertical';
|
|
334
|
+
var showXAxisIndices = (_28 = props.showXAxisIndices) !== null && _28 !== void 0 ? _28 : AxesAndRulesDefaults.showXAxisIndices;
|
|
335
|
+
var xAxisIndicesHeight = (_29 = props.xAxisIndicesHeight) !== null && _29 !== void 0 ? _29 : AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
336
|
+
var xAxisIndicesWidth = (_30 = props.xAxisIndicesWidth) !== null && _30 !== void 0 ? _30 : AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
337
|
+
var xAxisIndicesColor = (_31 = props.xAxisIndicesColor) !== null && _31 !== void 0 ? _31 : AxesAndRulesDefaults.xAxisIndicesColor;
|
|
338
|
+
var xAxisTextNumberOfLines = (_32 = props.xAxisTextNumberOfLines) !== null && _32 !== void 0 ? _32 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
|
|
338
339
|
var horizontalRulesStyle = props.horizontalRulesStyle;
|
|
339
|
-
var showFractionalValues = (
|
|
340
|
-
var yAxisLabelWidth = (
|
|
340
|
+
var showFractionalValues = (_33 = props.showFractionalValues) !== null && _33 !== void 0 ? _33 : AxesAndRulesDefaults.showFractionalValues;
|
|
341
|
+
var yAxisLabelWidth = (_34 = props.yAxisLabelWidth) !== null && _34 !== void 0 ? _34 : (props.hideYAxisText
|
|
341
342
|
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
342
343
|
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
343
344
|
var yAxisExtraHeightAtTop = props.trimYAxisAtTop
|
|
344
345
|
? 0
|
|
345
|
-
: (
|
|
346
|
+
: (_35 = props.yAxisExtraHeight) !== null && _35 !== void 0 ? _35 : containerHeight / 20;
|
|
346
347
|
var horizontal = false;
|
|
347
348
|
var yAxisAtTop = false;
|
|
348
|
-
var disableScroll = (
|
|
349
|
-
var showScrollIndicator = (
|
|
350
|
-
var focusEnabled = (
|
|
351
|
-
var showDataPointOnFocus = (
|
|
352
|
-
var showStripOnFocus = (
|
|
353
|
-
var showTextOnFocus = (
|
|
349
|
+
var disableScroll = (_36 = props.disableScroll) !== null && _36 !== void 0 ? _36 : LineDefaults.disableScroll;
|
|
350
|
+
var showScrollIndicator = (_37 = props.showScrollIndicator) !== null && _37 !== void 0 ? _37 : LineDefaults.showScrollIndicator;
|
|
351
|
+
var focusEnabled = (_38 = props.focusEnabled) !== null && _38 !== void 0 ? _38 : LineDefaults.focusEnabled;
|
|
352
|
+
var showDataPointOnFocus = (_39 = props.showDataPointOnFocus) !== null && _39 !== void 0 ? _39 : LineDefaults.showDataPointOnFocus;
|
|
353
|
+
var showStripOnFocus = (_40 = props.showStripOnFocus) !== null && _40 !== void 0 ? _40 : LineDefaults.showStripOnFocus;
|
|
354
|
+
var showTextOnFocus = (_41 = props.showTextOnFocus) !== null && _41 !== void 0 ? _41 : LineDefaults.showTextOnFocus;
|
|
354
355
|
var stripHeight = props.stripHeight;
|
|
355
|
-
var stripWidth = (
|
|
356
|
-
var stripColor = (
|
|
357
|
-
var stripOpacity = (
|
|
358
|
-
var unFocusOnPressOut = (
|
|
359
|
-
var delayBeforeUnFocus = (
|
|
356
|
+
var stripWidth = (_42 = props.stripWidth) !== null && _42 !== void 0 ? _42 : LineDefaults.stripWidth;
|
|
357
|
+
var stripColor = (_43 = props.stripColor) !== null && _43 !== void 0 ? _43 : color;
|
|
358
|
+
var stripOpacity = (_44 = props.stripOpacity) !== null && _44 !== void 0 ? _44 : (startOpacity + endOpacity) / 2;
|
|
359
|
+
var unFocusOnPressOut = (_45 = props.unFocusOnPressOut) !== null && _45 !== void 0 ? _45 : LineDefaults.unFocusOnPressOut;
|
|
360
|
+
var delayBeforeUnFocus = (_46 = props.delayBeforeUnFocus) !== null && _46 !== void 0 ? _46 : LineDefaults.delayBeforeUnFocus;
|
|
360
361
|
horizSections.pop();
|
|
361
362
|
for (var i = 0; i <= noOfSections; i++) {
|
|
362
363
|
var value = maxValue - stepValue * i;
|
|
363
|
-
if ((
|
|
364
|
-
value = parseFloat(value.toFixed((
|
|
364
|
+
if ((_47 = props.showFractionalValues) !== null && _47 !== void 0 ? _47 : props.roundToDigits) {
|
|
365
|
+
value = parseFloat(value.toFixed((_48 = props.roundToDigits) !== null && _48 !== void 0 ? _48 : 1));
|
|
365
366
|
}
|
|
366
367
|
horizSections.push({
|
|
367
368
|
value: props.yAxisLabelTexts
|
|
368
|
-
? (
|
|
369
|
+
? (_49 = props.yAxisLabelTexts[noOfSections - i]) !== null && _49 !== void 0 ? _49 : value.toString()
|
|
369
370
|
: value.toString()
|
|
370
371
|
});
|
|
371
372
|
}
|
|
372
|
-
var dataPointsRadius = (
|
|
373
|
-
var dataPointsWidth = (
|
|
373
|
+
var dataPointsRadius = (_50 = props.dataPointsRadius) !== null && _50 !== void 0 ? _50 : LineDefaults.dataPointsRadius;
|
|
374
|
+
var dataPointsWidth = (_51 = props.dataPointsWidth) !== null && _51 !== void 0 ? _51 : LineDefaults.dataPointsWidth;
|
|
374
375
|
var extraWidthDueToDataPoint = props.hideDataPoints
|
|
375
376
|
? 0
|
|
376
377
|
: dataPointsRadius !== null && dataPointsRadius !== void 0 ? dataPointsRadius : dataPointsWidth;
|
|
@@ -422,7 +423,7 @@ export var useLineChartBiColor = function (props) {
|
|
|
422
423
|
horizontalRulesStyle: horizontalRulesStyle,
|
|
423
424
|
noOfSections: noOfSections,
|
|
424
425
|
showFractionalValues: showFractionalValues,
|
|
425
|
-
axesAndRulesProps: getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, (
|
|
426
|
+
axesAndRulesProps: getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, (_52 = props.roundToDigits) !== null && _52 !== void 0 ? _52 : 0, stepValue, 0, 0, false, 0),
|
|
426
427
|
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
427
428
|
yAxisOffset: props.yAxisOffset,
|
|
428
429
|
rotateYAxisTexts: 0,
|
|
@@ -437,12 +438,14 @@ export var useLineChartBiColor = function (props) {
|
|
|
437
438
|
pointerIndex: 0,
|
|
438
439
|
pointerX: 0,
|
|
439
440
|
pointerY: 0,
|
|
440
|
-
endReachedOffset: (
|
|
441
|
+
endReachedOffset: (_53 = props.endReachedOffset) !== null && _53 !== void 0 ? _53 : LineDefaults.endReachedOffset,
|
|
441
442
|
extraWidthDueToDataPoint: extraWidthDueToDataPoint,
|
|
442
443
|
highlightEnabled: LineDefaults.highlightEnabled,
|
|
443
444
|
lowlightOpacity: LineDefaults.lowlightOpacity,
|
|
444
445
|
xAxisLabelsAtBottom: false,
|
|
445
|
-
onScrollEndDrag: props.onScrollEndDrag
|
|
446
|
+
onScrollEndDrag: props.onScrollEndDrag,
|
|
447
|
+
floatingYAxisLabels: props.floatingYAxisLabels,
|
|
448
|
+
allowFontScaling: allowFontScaling
|
|
446
449
|
};
|
|
447
450
|
return {
|
|
448
451
|
toggle: toggle,
|
|
@@ -531,6 +534,7 @@ export var useLineChartBiColor = function (props) {
|
|
|
531
534
|
delayBeforeUnFocus: delayBeforeUnFocus,
|
|
532
535
|
horizSections: horizSections,
|
|
533
536
|
barAndLineChartsWrapperProps: barAndLineChartsWrapperProps,
|
|
534
|
-
yAxisExtraHeightAtTop: yAxisExtraHeightAtTop
|
|
537
|
+
yAxisExtraHeightAtTop: yAxisExtraHeightAtTop,
|
|
538
|
+
allowFontScaling: allowFontScaling
|
|
535
539
|
};
|
|
536
540
|
};
|
|
@@ -314,8 +314,8 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
|
|
|
314
314
|
arrowConfig: import("../utils/types").arrowConfigType | undefined;
|
|
315
315
|
};
|
|
316
316
|
addLeadingAndTrailingPathForAreaFill: (initialPath: string, value: number, dataLength: number) => string;
|
|
317
|
-
getNextPoint: (data: lineDataItemNullSafe[], index: number, around: boolean, before: boolean, spacingArray: number[]) => string;
|
|
318
|
-
getStepPath: (data: lineDataItemNullSafe[], i: number, spacingArray: number[], lineSegment: LineSegment[] | undefined) => string;
|
|
317
|
+
getNextPoint: (data: lineDataItemNullSafe[], index: number, around: boolean, before: boolean, spacingArray: number[], isSecondary?: boolean) => string;
|
|
318
|
+
getStepPath: (data: lineDataItemNullSafe[], i: number, spacingArray: number[], lineSegment: LineSegment[] | undefined, isSecondary?: boolean) => string;
|
|
319
319
|
getSegmentPath: (data: lineDataItemNullSafe[], i: number, lineSegment: LineSegment[] | undefined, startIndex: number, endIndex: number, spacingArray: number[], isSecondary?: boolean) => string;
|
|
320
320
|
gradientDirection: string;
|
|
321
321
|
horizSections: {
|
|
@@ -419,4 +419,5 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
|
|
|
419
419
|
renderTooltip5: Function | undefined;
|
|
420
420
|
renderTooltipSecondary: Function | undefined;
|
|
421
421
|
pointerItemLocal: any[];
|
|
422
|
+
allowFontScaling: boolean;
|
|
422
423
|
};
|
package/dist/LineChart/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
36
36
|
};
|
|
37
37
|
import { useEffect, useMemo, useState } from 'react';
|
|
38
38
|
import { AxesAndRulesDefaults, LineDefaults, SEGMENT_END, SEGMENT_START, chartTypes, defaultArrowConfig, defaultPointerConfig } from '../utils/constants';
|
|
39
|
-
import { computeMaxAndMinItems, getAllArrowProperties, getArrowPoints, getAxesAndRulesProps, getCurvePathWithSegments, getExtendedContainerHeightWithPadding, getLineSegmentsDueToNoExtrapolation, getLineSegmentsForMissingValues, getMaxValue, getNoOfSections, getPathWithHighlight, getSanitisedData, getSecondaryDataWithOffsetIncluded, getSegmentString, indexOfFirstNonZeroDigit, svgPath } from '../utils';
|
|
39
|
+
import { colorsToLowerCase, computeMaxAndMinItems, getAllArrowProperties, getArrowPoints, getAxesAndRulesProps, getCurvePathWithSegments, getExtendedContainerHeightWithPadding, getLineSegmentsDueToNoExtrapolation, getLineSegmentsForMissingValues, getMaxValue, getNoOfSections, getPathWithHighlight, getSanitisedData, getSecondaryDataWithOffsetIncluded, getSegmentString, indexOfFirstNonZeroDigit, svgPath } from '../utils';
|
|
40
40
|
import { EdgePosition } from '../utils/types';
|
|
41
41
|
export var useLineChart = function (props) {
|
|
42
42
|
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, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255, _256, _257, _258, _259, _260, _261, _262, _263, _264, _265, _266, _267, _268, _269, _270, _271, _272, _273, _274, _275, _276, _277, _278, _279, _280, _281, _282, _283, _284, _285, _286, _287, _288, _289, _290, _291, _292, _293, _294, _295, _296, _297, _298, _299, _300, _301, _302, _303, _304, _305, _306, _307, _308, _309, _310, _311, _312, _313, _314, _315, _316, _317, _318, _319, _320, _321, _322, _323, _324, _325, _326, _327, _328, _329, _330, _331, _332, _333, _334, _335, _336, _337, _338;
|
|
@@ -105,12 +105,13 @@ export var useLineChart = function (props) {
|
|
|
105
105
|
var _386 = __read(useState([]), 2), fillPointsFromSet = _386[0], setFillPointsFromSet = _386[1];
|
|
106
106
|
var _387 = __read(useState([]), 2), arrowPointsFromSet = _387[0], setArrowPointsFromSet = _387[1];
|
|
107
107
|
var _388 = __read(useState((_o = props.focusedDataPointIndex) !== null && _o !== void 0 ? _o : -1), 2), selectedIndex = _388[0], setSelectedIndex = _388[1];
|
|
108
|
+
var allowFontScaling = (_p = props.allowFontScaling) !== null && _p !== void 0 ? _p : AxesAndRulesDefaults.allowFontScaling;
|
|
108
109
|
useEffect(function () {
|
|
109
110
|
var _a;
|
|
110
111
|
setSelectedIndex((_a = props.focusedDataPointIndex) !== null && _a !== void 0 ? _a : -1);
|
|
111
112
|
}, [props.focusedDataPointIndex]);
|
|
112
113
|
var noOfSections = getNoOfSections(props.noOfSections, props.maxValue, props.stepValue);
|
|
113
|
-
var containerHeight = (
|
|
114
|
+
var containerHeight = (_q = props.height) !== null && _q !== void 0 ? _q : (((_r = props.stepHeight) !== null && _r !== void 0 ? _r : 0) * noOfSections ||
|
|
114
115
|
AxesAndRulesDefaults.containerHeight);
|
|
115
116
|
var dataSanitisationProps = {
|
|
116
117
|
showDataPointsForMissingValues: showDataPointsForMissingValues,
|
|
@@ -123,17 +124,16 @@ export var useLineChart = function (props) {
|
|
|
123
124
|
var data3 = useMemo(function () { return getSanitisedData(props.data3, dataSanitisationProps); }, [yAxisOffset, props.data3]);
|
|
124
125
|
var data4 = useMemo(function () { return getSanitisedData(props.data4, dataSanitisationProps); }, [yAxisOffset, props.data4]);
|
|
125
126
|
var data5 = useMemo(function () { return getSanitisedData(props.data5, dataSanitisationProps); }, [yAxisOffset, props.data5]);
|
|
126
|
-
var secondaryData = (
|
|
127
|
-
var dataSet =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
127
|
+
var secondaryData = (_s = getSecondaryDataWithOffsetIncluded(props.secondaryData, props.secondaryYAxis, showDataPointsForMissingValues, interpolateMissingValues, onlyPositive)) !== null && _s !== void 0 ? _s : [];
|
|
128
|
+
var dataSet = useMemo(function () {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
if (!((_a = props.dataSet) === null || _a === void 0 ? void 0 : _a.length))
|
|
131
|
+
return undefined;
|
|
132
|
+
return (_b = props.dataSet) === null || _b === void 0 ? void 0 : _b.map(function (dataSetItem) {
|
|
133
|
+
var sanitisedData = getSanitisedData(dataSetItem.data, dataSanitisationProps);
|
|
134
|
+
return __assign(__assign({}, dataSetItem), { data: sanitisedData });
|
|
135
|
+
});
|
|
136
|
+
}, [yAxisOffset, props.dataSet]);
|
|
137
137
|
var data0 = (_t = dataSet === null || dataSet === void 0 ? void 0 : dataSet[0]) === null || _t === void 0 ? void 0 : _t.data;
|
|
138
138
|
var scrollToEnd = (_u = props.scrollToEnd) !== null && _u !== void 0 ? _u : LineDefaults.scrollToEnd;
|
|
139
139
|
var scrollAnimation = (_v = props.scrollAnimation) !== null && _v !== void 0 ? _v : LineDefaults.scrollAnimation;
|
|
@@ -170,27 +170,27 @@ export var useLineChart = function (props) {
|
|
|
170
170
|
? getLineSegmentsForMissingValues(props.data)
|
|
171
171
|
: !extrapolateMissingValues
|
|
172
172
|
? getLineSegmentsDueToNoExtrapolation(props.data)
|
|
173
|
-
: props.lineSegments;
|
|
173
|
+
: colorsToLowerCase(props.lineSegments);
|
|
174
174
|
var lineSegments2 = !interpolateMissingValues
|
|
175
175
|
? getLineSegmentsForMissingValues(props.data2)
|
|
176
176
|
: !extrapolateMissingValues
|
|
177
177
|
? getLineSegmentsDueToNoExtrapolation(props.data2)
|
|
178
|
-
: props.lineSegments2;
|
|
178
|
+
: colorsToLowerCase(props.lineSegments2);
|
|
179
179
|
var lineSegments3 = !interpolateMissingValues
|
|
180
180
|
? getLineSegmentsForMissingValues(props.data3)
|
|
181
181
|
: !extrapolateMissingValues
|
|
182
182
|
? getLineSegmentsDueToNoExtrapolation(props.data3)
|
|
183
|
-
: props.lineSegments3;
|
|
183
|
+
: colorsToLowerCase(props.lineSegments3);
|
|
184
184
|
var lineSegments4 = !interpolateMissingValues
|
|
185
185
|
? getLineSegmentsForMissingValues(props.data4)
|
|
186
186
|
: !extrapolateMissingValues
|
|
187
187
|
? getLineSegmentsDueToNoExtrapolation(props.data4)
|
|
188
|
-
: props.lineSegments4;
|
|
188
|
+
: colorsToLowerCase(props.lineSegments4);
|
|
189
189
|
var lineSegments5 = !interpolateMissingValues
|
|
190
190
|
? getLineSegmentsForMissingValues(props.data5)
|
|
191
191
|
: !extrapolateMissingValues
|
|
192
192
|
? getLineSegmentsDueToNoExtrapolation(props.data5)
|
|
193
|
-
: props.lineSegments5;
|
|
193
|
+
: colorsToLowerCase(props.lineSegments5);
|
|
194
194
|
var highlightedRange = props.highlightedRange;
|
|
195
195
|
var adjustToWidth = (_13 = props.adjustToWidth) !== null && _13 !== void 0 ? _13 : false;
|
|
196
196
|
var initialSpacing = (_14 = props.initialSpacing) !== null && _14 !== void 0 ? _14 : LineDefaults.initialSpacing;
|
|
@@ -551,7 +551,7 @@ export var useLineChart = function (props) {
|
|
|
551
551
|
heightUptoXaxis +
|
|
552
552
|
' ');
|
|
553
553
|
};
|
|
554
|
-
var getNextPoint = function (data, index, around, before, spacingArray) {
|
|
554
|
+
var getNextPoint = function (data, index, around, before, spacingArray, isSecondary) {
|
|
555
555
|
var isLast = index === data.length - 1;
|
|
556
556
|
return isLast && !(around || before)
|
|
557
557
|
? ' '
|
|
@@ -559,10 +559,12 @@ export var useLineChart = function (props) {
|
|
|
559
559
|
(getX(spacingArray, index) +
|
|
560
560
|
(around ? (isLast ? 0 : spacing / 2) : before ? 0 : spacing)) +
|
|
561
561
|
' ' +
|
|
562
|
-
|
|
562
|
+
(isSecondary
|
|
563
|
+
? getSecondaryY(data[index].value)
|
|
564
|
+
: getY(data[index].value)) +
|
|
563
565
|
' ';
|
|
564
566
|
};
|
|
565
|
-
var getStepPath = function (data, i, spacingArray, lineSegment) {
|
|
567
|
+
var getStepPath = function (data, i, spacingArray, lineSegment, isSecondary) {
|
|
566
568
|
var around = edgePosition === EdgePosition.AROUND_DATA_POINT;
|
|
567
569
|
var before = edgePosition === EdgePosition.BEFORE_DATA_POINT;
|
|
568
570
|
var isSegment = lineSegment === null || lineSegment === void 0 ? void 0 : lineSegment.find(function (segment) { return segment.startIndex === i; });
|
|
@@ -570,11 +572,11 @@ export var useLineChart = function (props) {
|
|
|
570
572
|
(getX(spacingArray, i) -
|
|
571
573
|
(around && i > 0 ? spacing / 2 : before && i > 0 ? spacing : 0)) +
|
|
572
574
|
' ' +
|
|
573
|
-
getY(data[i].value) +
|
|
575
|
+
(isSecondary ? getSecondaryY(data[i].value) : getY(data[i].value)) + // handle isSecondary for dataSet
|
|
574
576
|
(isSegment
|
|
575
577
|
? getSegmentString(lineSegment, i, SEGMENT_START, SEGMENT_END, true)
|
|
576
578
|
: '') +
|
|
577
|
-
getNextPoint(data, i, around, before, spacingArray));
|
|
579
|
+
getNextPoint(data, i, around, before, spacingArray, isSecondary));
|
|
578
580
|
};
|
|
579
581
|
var getSegmentPath = function (data, i, lineSegment, startIndex, endIndex, spacingArray, isSecondary) {
|
|
580
582
|
var path = 'L' +
|
|
@@ -639,7 +641,7 @@ export var useLineChart = function (props) {
|
|
|
639
641
|
if (i >= ((_k = set.startIndex) !== null && _k !== void 0 ? _k : 0) &&
|
|
640
642
|
i <= ((_l = set.endIndex) !== null && _l !== void 0 ? _l : set.data.length - 1)) {
|
|
641
643
|
if ((_m = set.stepChart) !== null && _m !== void 0 ? _m : stepChart) {
|
|
642
|
-
pp += getStepPath(set.data, i, cumulativeSpacingForSet[index], setSegments);
|
|
644
|
+
pp += getStepPath(set.data, i, cumulativeSpacingForSet[index], setSegments, set.isSecondary);
|
|
643
645
|
}
|
|
644
646
|
else {
|
|
645
647
|
pp += getSegmentPath(set.data, i, setSegments, //set.lineSegments,
|
|
@@ -1396,7 +1398,8 @@ export var useLineChart = function (props) {
|
|
|
1396
1398
|
highlightEnabled: LineDefaults.highlightEnabled,
|
|
1397
1399
|
lowlightOpacity: LineDefaults.lowlightOpacity,
|
|
1398
1400
|
xAxisLabelsAtBottom: xAxisLabelsAtBottom,
|
|
1399
|
-
onScrollEndDrag: props.onScrollEndDrag
|
|
1401
|
+
onScrollEndDrag: props.onScrollEndDrag,
|
|
1402
|
+
allowFontScaling: allowFontScaling
|
|
1400
1403
|
};
|
|
1401
1404
|
var pointerItemLocal = [];
|
|
1402
1405
|
if (pointerConfig) {
|
|
@@ -1801,7 +1804,8 @@ export var useLineChart = function (props) {
|
|
|
1801
1804
|
renderTooltip4: renderTooltip4,
|
|
1802
1805
|
renderTooltip5: renderTooltip5,
|
|
1803
1806
|
renderTooltipSecondary: renderTooltipSecondary,
|
|
1804
|
-
pointerItemLocal: pointerItemLocal
|
|
1807
|
+
pointerItemLocal: pointerItemLocal,
|
|
1808
|
+
allowFontScaling: allowFontScaling
|
|
1805
1809
|
// oldPoints
|
|
1806
1810
|
};
|
|
1807
1811
|
};
|
|
@@ -167,6 +167,8 @@ export interface LineChartPropsType {
|
|
|
167
167
|
roundToDigits?: number;
|
|
168
168
|
yAxisLabelWidth?: number;
|
|
169
169
|
hideYAxisText?: boolean;
|
|
170
|
+
floatingYAxisLabels?: boolean;
|
|
171
|
+
allowFontScaling?: boolean;
|
|
170
172
|
backgroundColor?: ColorValue;
|
|
171
173
|
customBackground?: CustomBackground;
|
|
172
174
|
curved?: boolean;
|
|
@@ -595,6 +597,8 @@ export interface LineChartBicolorPropsType {
|
|
|
595
597
|
parentWidth?: number;
|
|
596
598
|
yAxisExtraHeight?: number;
|
|
597
599
|
trimYAxisAtTop?: boolean;
|
|
600
|
+
floatingYAxisLabels?: boolean;
|
|
601
|
+
allowFontScaling?: boolean;
|
|
598
602
|
}
|
|
599
603
|
export interface LineChartPropsTypeForWeb extends LineChartPropsType {
|
|
600
604
|
onContextMenu?: Function;
|
|
@@ -60,7 +60,7 @@ export var usePopulationPyramid = function (props) {
|
|
|
60
60
|
: height;
|
|
61
61
|
var stepHeight = (_s = props.stepHeight) !== null && _s !== void 0 ? _s : containerHeight / noOfSections;
|
|
62
62
|
var xAxisLabelsHeight = 30;
|
|
63
|
-
var containerHeightWithXaxisLabels = containerHeight + xAxisLabelsHeight;
|
|
63
|
+
var containerHeightWithXaxisLabels = containerHeight + xAxisLabelsHeight + Math.max(0, xAxisLabelShiftY);
|
|
64
64
|
var mid = (width + yAxisLabelWidth) / 2;
|
|
65
65
|
var leftMax = Math.max.apply(Math, __spreadArray([], __read(data.map(function (item) { return item.left; })), false));
|
|
66
66
|
var rightMax = Math.max.apply(Math, __spreadArray([], __read(data.map(function (item) { return item.right; })), false));
|
package/dist/RadarChart/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
37
37
|
import { radarChartDefaults } from '../utils/constants';
|
|
38
38
|
export var useRadarChart = function (props) {
|
|
39
39
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
40
|
-
var _u = props.circular, circular = _u === void 0 ? false : _u, _v = props.gridConfig, gridConfig = _v === void 0 ? {} : _v, _w = props.polygonConfig, polygonConfig = _w === void 0 ? {} : _w, _x = props.data, data = _x === void 0 ? [] : _x, dataSet = props.dataSet, _y = props.noOfSections, noOfSections = _y === void 0 ? radarChartDefaults.noOfSections : _y, _z = props.chartSize, chartSize = _z === void 0 ? radarChartDefaults.chartSize : _z, _0 = props.labelConfig, labelConfig = _0 === void 0 ? {} : _0, labelConfigArray = props.labelConfigArray, _1 = props.asterLinesConfig, asterLinesConfig = _1 === void 0 ? {} : _1, _2 = props.hideGrid, hideGrid = _2 === void 0 ? radarChartDefaults.hideGrid : _2, _3 = props.hideLabels, hideLabels = _3 === void 0 ? radarChartDefaults.hideLabels : _3, _4 = props.hideAsterLines, hideAsterLines = _4 === void 0 ? (_a = props.hideGrid) !== null && _a !== void 0 ? _a : radarChartDefaults.hideAsterLines : _4, _5 = props.dataLabelsConfig, dataLabelsConfig = _5 === void 0 ? {} : _5, _6 = props.labelsPositionOffset, labelsPositionOffset = _6 === void 0 ? radarChartDefaults.labelsPositionOffset : _6, _7 = props.dataLabelsPositionOffset, dataLabelsPositionOffset = _7 === void 0 ? radarChartDefaults.dataLabelsPositionOffset : _7, _8 = props.isAnimated, isAnimated = _8 === void 0 ? radarChartDefaults.isAnimated : _8, _9 = props.animationDuration, animationDuration = _9 === void 0 ? radarChartDefaults.animationDuration : _9, _10 = props.animateTogether, animateTogether = _10 === void 0 ? radarChartDefaults.animateTogether : _10;
|
|
40
|
+
var _u = props.circular, circular = _u === void 0 ? false : _u, _v = props.gridConfig, gridConfig = _v === void 0 ? {} : _v, _w = props.polygonConfig, polygonConfig = _w === void 0 ? {} : _w, _x = props.data, data = _x === void 0 ? [] : _x, dataSet = props.dataSet, _y = props.noOfSections, noOfSections = _y === void 0 ? radarChartDefaults.noOfSections : _y, _z = props.chartSize, chartSize = _z === void 0 ? radarChartDefaults.chartSize : _z, _0 = props.labelConfig, labelConfig = _0 === void 0 ? {} : _0, labelConfigArray = props.labelConfigArray, _1 = props.asterLinesConfig, asterLinesConfig = _1 === void 0 ? {} : _1, _2 = props.hideGrid, hideGrid = _2 === void 0 ? radarChartDefaults.hideGrid : _2, _3 = props.hideLabels, hideLabels = _3 === void 0 ? radarChartDefaults.hideLabels : _3, _4 = props.hideAsterLines, hideAsterLines = _4 === void 0 ? (_a = props.hideGrid) !== null && _a !== void 0 ? _a : radarChartDefaults.hideAsterLines : _4, _5 = props.dataLabelsConfig, dataLabelsConfig = _5 === void 0 ? {} : _5, _6 = props.labelsPositionOffset, labelsPositionOffset = _6 === void 0 ? radarChartDefaults.labelsPositionOffset : _6, _7 = props.dataLabelsPositionOffset, dataLabelsPositionOffset = _7 === void 0 ? radarChartDefaults.dataLabelsPositionOffset : _7, _8 = props.isAnimated, isAnimated = _8 === void 0 ? radarChartDefaults.isAnimated : _8, _9 = props.animationDuration, animationDuration = _9 === void 0 ? radarChartDefaults.animationDuration : _9, _10 = props.animateTogether, animateTogether = _10 === void 0 ? radarChartDefaults.animateTogether : _10, _11 = props.startAngle, startAngle = _11 === void 0 ? radarChartDefaults.startAngle : _11, _12 = props.isClockWise, isClockWise = _12 === void 0 ? radarChartDefaults.isClockWise : _12;
|
|
41
41
|
var labels = (_e = (_b = props.labels) !== null && _b !== void 0 ? _b : (_d = ((_c = dataSet === null || dataSet === void 0 ? void 0 : dataSet[0]) !== null && _c !== void 0 ? _c : data)) === null || _d === void 0 ? void 0 : _d.map(function (_, index) { return "Label".concat(index + 1); })) !== null && _e !== void 0 ? _e : [];
|
|
42
42
|
var getMax = function (dataSet) {
|
|
43
43
|
return dataSet.reduce(function (acc, set) {
|
|
@@ -58,31 +58,31 @@ export var useRadarChart = function (props) {
|
|
|
58
58
|
};
|
|
59
59
|
var center = chartSize / 2;
|
|
60
60
|
var radius = center * 0.8;
|
|
61
|
-
var
|
|
62
|
-
.strokeDashArray :
|
|
63
|
-
.gradientColor :
|
|
64
|
-
.showGradient :
|
|
65
|
-
.gradientOpacity :
|
|
61
|
+
var _13 = gridConfig.stroke, gridStroke = _13 === void 0 ? radarChartDefaults.gridSection.stroke : _13, _14 = gridConfig.strokeWidth, gridStrokeWidth = _14 === void 0 ? radarChartDefaults.gridSection.strokeWidth : _14, _15 = gridConfig.strokeDashArray, gridStrokeDashArray = _15 === void 0 ? radarChartDefaults.gridSection
|
|
62
|
+
.strokeDashArray : _15, _16 = gridConfig.fill, gridFill = _16 === void 0 ? radarChartDefaults.gridSection.fill : _16, _17 = gridConfig.gradientColor, gridGradientColor = _17 === void 0 ? radarChartDefaults.gridSection
|
|
63
|
+
.gradientColor : _17, _18 = gridConfig.showGradient, gridShowGradient = _18 === void 0 ? radarChartDefaults.gridSection
|
|
64
|
+
.showGradient : _18, _19 = gridConfig.opacity, gridOpacity = _19 === void 0 ? radarChartDefaults.gridSection.opacity : _19, _20 = gridConfig.gradientOpacity, gridGradientOpacity = _20 === void 0 ? radarChartDefaults.gridSection
|
|
65
|
+
.gradientOpacity : _20;
|
|
66
66
|
var gridSections = (_j = (_h = gridConfig.gridSections) === null || _h === void 0 ? void 0 : _h.map(function (i) { return (__assign(__assign({}, radarChartDefaults.gridSection), i)); })) !== null && _j !== void 0 ? _j : Array(noOfSections).fill({});
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
dataLabelsColor =
|
|
71
|
-
|
|
72
|
-
dataLabelsTextAnchor =
|
|
73
|
-
|
|
74
|
-
dataLabelsAlignmentBaseline =
|
|
75
|
-
|
|
76
|
-
dataLabelsFontWeight =
|
|
77
|
-
|
|
67
|
+
var _21 = labelConfig.fontSize, fontSize = _21 === void 0 ? radarChartDefaults.labelConfig.fontSize : _21, _22 = labelConfig.stroke, stroke = _22 === void 0 ? radarChartDefaults.labelConfig.stroke : _22, _23 = labelConfig.textAnchor, textAnchor = _23 === void 0 ? radarChartDefaults.labelConfig.textAnchor : _23, _24 = labelConfig.alignmentBaseline, alignmentBaseline = _24 === void 0 ? radarChartDefaults.labelConfig.alignmentBaseline : _24, _25 = labelConfig.fontWeight, fontWeight = _25 === void 0 ? radarChartDefaults.labelConfig.fontWeight : _25, _26 = labelConfig.fontFamily, fontFamily = _26 === void 0 ? radarChartDefaults.labelConfig.fontFamily : _26;
|
|
68
|
+
var _27 = dataLabelsConfig.fontSize, dataLabelsFontSize = _27 === void 0 ? fontSize : _27, // defaults to labelConfig (from above)
|
|
69
|
+
_28 = dataLabelsConfig.stroke, // defaults to labelConfig (from above)
|
|
70
|
+
dataLabelsColor = _28 === void 0 ? stroke : _28, // defaults to labelConfig (from above)
|
|
71
|
+
_29 = dataLabelsConfig.textAnchor, // defaults to labelConfig (from above)
|
|
72
|
+
dataLabelsTextAnchor = _29 === void 0 ? textAnchor : _29, // defaults to labelConfig (from above)
|
|
73
|
+
_30 = dataLabelsConfig.alignmentBaseline, // defaults to labelConfig (from above)
|
|
74
|
+
dataLabelsAlignmentBaseline = _30 === void 0 ? alignmentBaseline : _30, // defaults to labelConfig (from above)
|
|
75
|
+
_31 = dataLabelsConfig.fontWeight, // defaults to labelConfig (from above)
|
|
76
|
+
dataLabelsFontWeight = _31 === void 0 ? fontWeight : _31, // defaults to labelConfig (from above)
|
|
77
|
+
_32 = dataLabelsConfig.fontFamily // defaults to labelConfig (from above)
|
|
78
78
|
, // defaults to labelConfig (from above)
|
|
79
|
-
dataLabelsFontFamily =
|
|
79
|
+
dataLabelsFontFamily = _32 === void 0 ? fontFamily : _32 // defaults to labelConfig (from above)
|
|
80
80
|
;
|
|
81
|
-
var
|
|
82
|
-
.strokeWidth :
|
|
83
|
-
.strokeDashArray :
|
|
84
|
-
.gradientColor :
|
|
85
|
-
.showGradient :
|
|
81
|
+
var _33 = polygonConfig.stroke, polygonStroke = _33 === void 0 ? radarChartDefaults.polygonConfig.stroke : _33, _34 = polygonConfig.strokeWidth, polygonStrokeWidth = _34 === void 0 ? radarChartDefaults.polygonConfig
|
|
82
|
+
.strokeWidth : _34, _35 = polygonConfig.strokeDashArray, polygonStrokeDashArray = _35 === void 0 ? radarChartDefaults.polygonConfig
|
|
83
|
+
.strokeDashArray : _35, _36 = polygonConfig.fill, polygonFill = _36 === void 0 ? radarChartDefaults.polygonConfig.fill : _36, _37 = polygonConfig.gradientColor, polygonGradientColor = _37 === void 0 ? radarChartDefaults.polygonConfig
|
|
84
|
+
.gradientColor : _37, _38 = polygonConfig.showGradient, polygonShowGradient = _38 === void 0 ? radarChartDefaults.polygonConfig
|
|
85
|
+
.showGradient : _38, _39 = polygonConfig.opacity, polygonOpacity = _39 === void 0 ? radarChartDefaults.polygonConfig.opacity : _39, _40 = polygonConfig.gradientOpacity, polygonGradientOpacity = _40 === void 0 ? polygonOpacity : _40, showDataValuesAsLabels = polygonConfig.showDataValuesAsLabels, _41 = polygonConfig.isAnimated, polygonIsAnimated = _41 === void 0 ? isAnimated : _41, _42 = polygonConfig.animationDuration, polygonAnimationDuration = _42 === void 0 ? animationDuration : _42;
|
|
86
86
|
var polygonConfigArray = (_l = (_k = props.polygonConfigArray) === null || _k === void 0 ? void 0 : _k.map(function (set) {
|
|
87
87
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
88
88
|
return ({
|
|
@@ -147,27 +147,27 @@ export var useRadarChart = function (props) {
|
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
149
|
})) !== null && _r !== void 0 ? _r : (dataSet ? Array(dataSet.length).fill(dataLabelsConfigArray) : null);
|
|
150
|
-
var
|
|
150
|
+
var _43 = asterLinesConfig.stroke, asterLinesStroke = _43 === void 0 ? gridStroke : _43, _44 = asterLinesConfig.strokeWidth, asterLinesStrokeWidth = _44 === void 0 ? gridStrokeWidth : _44, _45 = asterLinesConfig.strokeDashArray, asterLinesStrokeDashArray = _45 === void 0 ? radarChartDefaults.asterLineStrokeDashArray : _45;
|
|
151
151
|
// Calculate angles for each category
|
|
152
|
-
var angleStep = 360 / labels.length;
|
|
152
|
+
var angleStep = (360 / labels.length) * (isClockWise ? -1 : 1);
|
|
153
153
|
// Generate coordinates for the data points
|
|
154
154
|
var points = data.map(function (value, index) {
|
|
155
|
-
var angle = index * angleStep;
|
|
155
|
+
var angle = index * angleStep + startAngle;
|
|
156
156
|
return polarToCartesian(angle, value);
|
|
157
157
|
});
|
|
158
158
|
var initialPoints = data.map(function (value, index) {
|
|
159
|
-
var angle = index * angleStep;
|
|
159
|
+
var angle = index * angleStep + startAngle;
|
|
160
160
|
return polarToCartesian(angle, 0);
|
|
161
161
|
});
|
|
162
162
|
var pointsArray = (_s = dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set) {
|
|
163
163
|
return set.map(function (value, index) {
|
|
164
|
-
var angle = index * angleStep;
|
|
164
|
+
var angle = index * angleStep + startAngle;
|
|
165
165
|
return polarToCartesian(angle, value);
|
|
166
166
|
});
|
|
167
167
|
})) !== null && _s !== void 0 ? _s : [];
|
|
168
168
|
var initialPointsArray = (_t = dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set) {
|
|
169
169
|
return set.map(function (value, index) {
|
|
170
|
-
var angle = index * angleStep;
|
|
170
|
+
var angle = index * angleStep + startAngle;
|
|
171
171
|
return polarToCartesian(angle, 0);
|
|
172
172
|
});
|
|
173
173
|
})) !== null && _t !== void 0 ? _t : [];
|
|
@@ -193,7 +193,7 @@ export var useRadarChart = function (props) {
|
|
|
193
193
|
var gridShowGradientLocal = gridItem.showGradient || gridShowGradient;
|
|
194
194
|
var gridStrokeDashArrayLocal = gridItem.strokeDashArray || gridStrokeDashArray;
|
|
195
195
|
var levelPoints = labels.map(function (_, index) {
|
|
196
|
-
var angle = index * angleStep;
|
|
196
|
+
var angle = index * angleStep + startAngle;
|
|
197
197
|
return polarToCartesian(angle, (level / noOfSections) * maxValue);
|
|
198
198
|
});
|
|
199
199
|
var levelPolygonPoints = levelPoints
|
|
@@ -279,6 +279,7 @@ export var useRadarChart = function (props) {
|
|
|
279
279
|
hideLabels: hideLabels,
|
|
280
280
|
hideAsterLines: hideAsterLines,
|
|
281
281
|
getGridLevelProps: getGridLevelProps,
|
|
282
|
-
animateTogether: animateTogether
|
|
282
|
+
animateTogether: animateTogether,
|
|
283
|
+
startAngle: startAngle
|
|
283
284
|
};
|
|
284
285
|
};
|
|
@@ -39,7 +39,7 @@ import { AxesAndRulesDefaults, BarDefaults, chartTypes } from '../../utils/const
|
|
|
39
39
|
import { computeMaxAndMinItems } from '../../utils';
|
|
40
40
|
export var useBarAndLineChartsWrapper = function (props) {
|
|
41
41
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
42
|
-
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, dataSet = props.dataSet, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL, selectedIndex = props.selectedIndex, onlyPositive = props.onlyPositive, highlightEnabled = props.highlightEnabled, lowlightOpacity = props.lowlightOpacity, xAxisLabelsAtBottom = props.xAxisLabelsAtBottom;
|
|
42
|
+
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, dataSet = props.dataSet, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL, selectedIndex = props.selectedIndex, onlyPositive = props.onlyPositive, highlightEnabled = props.highlightEnabled, lowlightOpacity = props.lowlightOpacity, xAxisLabelsAtBottom = props.xAxisLabelsAtBottom, floatingYAxisLabels = props.floatingYAxisLabels, allowFontScaling = props.allowFontScaling;
|
|
43
43
|
var _20 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepValue = _20.stepValue, secondaryNegativeStepValue = _20.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _20.noOfSectionsBelowXAxis, showSecondaryFractionalValues = _20.showFractionalValues, secondaryRoundToDigits = _20.roundToDigits, secondaryStepHeight = _20.stepHeight, secondaryNegativeStepHeight = _20.negativeStepHeight;
|
|
44
44
|
var primaryYAxisHeightBelowOrigin = noOfSectionsBelowXAxis * negativeStepHeight;
|
|
45
45
|
var secondaryYAxisHeightBelowOrigin = secondaryNoOfSectionsBelowXAxis * secondaryNegativeStepHeight;
|
|
@@ -182,7 +182,9 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
182
182
|
secondaryStepHeight: secondaryStepHeight,
|
|
183
183
|
secondaryNegativeStepHeight: secondaryNegativeStepHeight,
|
|
184
184
|
customBackground: props.customBackground,
|
|
185
|
-
onlyPositive: onlyPositive
|
|
185
|
+
onlyPositive: onlyPositive,
|
|
186
|
+
floatingYAxisLabels: floatingYAxisLabels,
|
|
187
|
+
allowFontScaling: allowFontScaling
|
|
186
188
|
};
|
|
187
189
|
var lineInBarChartProps = {
|
|
188
190
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
@@ -191,7 +193,9 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
191
193
|
containerHeight: containerHeight,
|
|
192
194
|
containerHeightIncludingBelowXAxis: containerHeightIncludingBelowXAxis,
|
|
193
195
|
lineConfig: lineConfig,
|
|
194
|
-
maxValue: (
|
|
196
|
+
maxValue: (lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.isSecondary)
|
|
197
|
+
? (_15 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _15 !== void 0 ? _15 : maxValue
|
|
198
|
+
: maxValue,
|
|
195
199
|
animatedWidth: animatedWidth,
|
|
196
200
|
lineBehindBars: lineBehindBars,
|
|
197
201
|
points: points,
|
|
@@ -75,6 +75,7 @@ export declare const AxesAndRulesDefaults: {
|
|
|
75
75
|
showFractionalValues: boolean;
|
|
76
76
|
roundToDigits: number;
|
|
77
77
|
referenceLinesOverChartContent: boolean;
|
|
78
|
+
allowFontScaling: boolean;
|
|
78
79
|
};
|
|
79
80
|
export declare const defaultArrowConfig: {
|
|
80
81
|
length: number;
|
|
@@ -312,4 +313,6 @@ export declare const radarChartDefaults: {
|
|
|
312
313
|
isAnimated: boolean;
|
|
313
314
|
animationDuration: number;
|
|
314
315
|
animateTogether: boolean;
|
|
316
|
+
startAngle: number;
|
|
317
|
+
isClockWise: boolean;
|
|
315
318
|
};
|
package/dist/utils/constants.js
CHANGED
|
@@ -84,7 +84,8 @@ export var AxesAndRulesDefaults = {
|
|
|
84
84
|
yAxisEmptyLabelWidth: 10,
|
|
85
85
|
showFractionalValues: false,
|
|
86
86
|
roundToDigits: 1,
|
|
87
|
-
referenceLinesOverChartContent: true
|
|
87
|
+
referenceLinesOverChartContent: true,
|
|
88
|
+
allowFontScaling: true
|
|
88
89
|
};
|
|
89
90
|
export var defaultArrowConfig = {
|
|
90
91
|
length: 10,
|
|
@@ -364,5 +365,7 @@ export var radarChartDefaults = {
|
|
|
364
365
|
asterLineStrokeDashArray: [4, 4],
|
|
365
366
|
isAnimated: false,
|
|
366
367
|
animationDuration: 800,
|
|
367
|
-
animateTogether: false
|
|
368
|
+
animateTogether: false,
|
|
369
|
+
startAngle: 0,
|
|
370
|
+
isClockWise: false
|
|
368
371
|
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -104,6 +104,7 @@ export declare const getBarWidth: (isFocused?: boolean, focusedBarConfig?: Focus
|
|
|
104
104
|
export declare const getInterpolatedData: (dataParam: lineDataItem[], showDataPointsForMissingValues?: boolean, interpolateMissingValues?: boolean, onlyPositive?: boolean) => lineDataItemNullSafe[];
|
|
105
105
|
export declare const getLineSegmentsDueToNoExtrapolation: (data?: lineDataItem[]) => LineSegment[] | undefined;
|
|
106
106
|
export declare const getLineSegmentsForMissingValues: (data?: lineDataItem[]) => LineSegment[] | undefined;
|
|
107
|
+
export declare const colorsToLowerCase: (lineSegments?: LineSegment[]) => LineSegment[] | undefined;
|
|
107
108
|
export declare const getTextSizeForPieLabels: (textSize: number, radius: number) => number;
|
|
108
109
|
export declare const adjustToOffset: (data: lineDataItemNullSafe[], yAxisOffset?: number) => lineDataItemNullSafe[];
|
|
109
110
|
export declare const getSanitisedData: (data: lineDataItem[] | undefined, dataSanitisationProps: IDataSanitisationProps) => lineDataItemNullSafe[];
|
package/dist/utils/index.js
CHANGED
|
@@ -1037,6 +1037,14 @@ export var getLineSegmentsForMissingValues = function (data) {
|
|
|
1037
1037
|
}
|
|
1038
1038
|
return segments;
|
|
1039
1039
|
};
|
|
1040
|
+
export var colorsToLowerCase = function (lineSegments) {
|
|
1041
|
+
return lineSegments === null || lineSegments === void 0 ? void 0 : lineSegments.map(function (segment) {
|
|
1042
|
+
if (segment.color && segment.color.toString().startsWith('#')) {
|
|
1043
|
+
segment.color = segment.color.toString().toLowerCase();
|
|
1044
|
+
}
|
|
1045
|
+
return segment;
|
|
1046
|
+
});
|
|
1047
|
+
};
|
|
1040
1048
|
export var getTextSizeForPieLabels = function (textSize, radius) { return (textSize ? Math.min(textSize, radius / 5) : 16); };
|
|
1041
1049
|
export var adjustToOffset = function (data, yAxisOffset) {
|
|
1042
1050
|
return data.map(function (item) { return (__assign(__assign({}, item), { value: item.value - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0) })); });
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -249,6 +249,7 @@ export interface horizSectionPropTypes {
|
|
|
249
249
|
secondaryYAxis: secondaryYAxisType | null;
|
|
250
250
|
formatYLabel?: (label: string) => string;
|
|
251
251
|
onlyReferenceLines?: boolean;
|
|
252
|
+
onlyLabels?: boolean;
|
|
252
253
|
renderReferenceLines?: boolean;
|
|
253
254
|
secondaryXAxis?: XAxisConfig;
|
|
254
255
|
secondaryMaxItem: number;
|
|
@@ -262,6 +263,8 @@ export interface horizSectionPropTypes {
|
|
|
262
263
|
secondaryNegativeStepHeight: number;
|
|
263
264
|
customBackground?: CustomBackground;
|
|
264
265
|
onlyPositive?: boolean;
|
|
266
|
+
floatingYAxisLabels?: boolean;
|
|
267
|
+
allowFontScaling: boolean;
|
|
265
268
|
}
|
|
266
269
|
interface HorizSectionObject {
|
|
267
270
|
value: string;
|
|
@@ -276,6 +279,8 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
276
279
|
negativeStepHeight: number;
|
|
277
280
|
labelsExtraHeight: number;
|
|
278
281
|
yAxisLabelWidth: number;
|
|
282
|
+
floatingYAxisLabels?: boolean;
|
|
283
|
+
allowFontScaling: boolean;
|
|
279
284
|
horizontal: boolean;
|
|
280
285
|
rtl: boolean;
|
|
281
286
|
shiftX: number;
|