gifted-charts-core 0.1.71 → 0.1.72
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 +3 -3
- package/dist/BarChart/index.js +85 -82
- package/dist/BarChart/types.d.ts +4 -0
- package/dist/PieChart/index.d.ts +1 -0
- package/dist/PieChart/index.js +26 -25
- package/dist/PieChart/pro.js +5 -5
- package/dist/PieChart/types.d.ts +1 -1
- package/dist/utils/constants.js +10 -9
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +3 -2
- package/dist/utils/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/BarChart/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type barDataItem, type stackDataItem, BarChartPropsTypeForWeb, barDataItemNullSafe, lineConfigWithSetFocusedDataPointIndexType } from './types';
|
|
2
2
|
import { type BarAndLineChartsWrapperTypes, type secondaryYAxisType } from '../utils/types';
|
|
3
3
|
import { type Animated } from 'react-native';
|
|
4
4
|
export interface extendedBarChartPropsType extends BarChartPropsTypeForWeb {
|
|
@@ -10,7 +10,7 @@ export interface extendedBarChartPropsType extends BarChartPropsTypeForWeb {
|
|
|
10
10
|
secondaryYAxis?: secondaryYAxisType | boolean;
|
|
11
11
|
}
|
|
12
12
|
export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
13
|
-
lineConfig:
|
|
13
|
+
lineConfig: lineConfigWithSetFocusedDataPointIndexType;
|
|
14
14
|
hidePointer1: boolean;
|
|
15
15
|
pointerItem: barDataItem | stackDataItem | undefined;
|
|
16
16
|
pointerY: number;
|
|
@@ -94,7 +94,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
94
94
|
scrollAnimation: boolean;
|
|
95
95
|
scrollEventThrottle: number;
|
|
96
96
|
showLine: boolean;
|
|
97
|
-
lineConfig2:
|
|
97
|
+
lineConfig2: lineConfigWithSetFocusedDataPointIndexType;
|
|
98
98
|
lineData: (import("..").lineDataItem | barDataItem | stackDataItem)[];
|
|
99
99
|
lineData2: (import("..").lineDataItem | barDataItem | stackDataItem)[] | undefined;
|
|
100
100
|
animatedWidth: Animated.AnimatedInterpolation<string | number> | undefined;
|
package/dist/BarChart/index.js
CHANGED
|
@@ -29,20 +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, _69;
|
|
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, _70, _71, _72, _73, _74, _75, _76, _77;
|
|
33
33
|
var heightValue = props.heightValue, widthValue = props.widthValue, opacityValue = props.opacityValue, yAxisOffset = props.yAxisOffset, adjustToWidth = props.adjustToWidth, parentWidth = props.parentWidth, labelsDistanceFromXaxis = props.labelsDistanceFromXaxis, autoShiftLabelsForNegativeStacks = props.autoShiftLabelsForNegativeStacks, focusedBarIndex = props.focusedBarIndex, nsv = props.negativeStepValue, autoCenterTooltip = props.autoCenterTooltip, floatingYAxisLabels = props.floatingYAxisLabels;
|
|
34
34
|
var negativeStepValue = nsv ? Math.abs(nsv) : undefined;
|
|
35
35
|
var allowFontScaling = (_a = props.allowFontScaling) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.allowFontScaling;
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
36
|
+
var _78 = __read(useState(''), 2), points = _78[0], setPoints = _78[1];
|
|
37
|
+
var _79 = __read(useState(''), 2), points2 = _79[0], setPoints2 = _79[1];
|
|
38
|
+
var _80 = __read(useState(''), 2), arrowPoints = _80[0], setArrowPoints = _80[1];
|
|
39
|
+
var _81 = __read(useState(function () {
|
|
40
40
|
if (Array.isArray(focusedBarIndex)) {
|
|
41
41
|
return focusedBarIndex;
|
|
42
42
|
}
|
|
43
43
|
return [focusedBarIndex !== null && focusedBarIndex !== void 0 ? focusedBarIndex : -1];
|
|
44
|
-
}), 2), selectedIndex =
|
|
45
|
-
var
|
|
44
|
+
}), 2), selectedIndex = _81[0], setSelectedIndex = _81[1];
|
|
45
|
+
var _82 = __read(useState((_b = props.highlightedStackIndex) !== null && _b !== void 0 ? _b : -1), 2), selectedStackIndex = _82[0], setSelectedStackIndex = _82[1];
|
|
46
46
|
var showLine = (_c = props.showLine) !== null && _c !== void 0 ? _c : BarDefaults.showLine;
|
|
47
47
|
useEffect(function () {
|
|
48
48
|
var newIndex = Array.isArray(focusedBarIndex)
|
|
@@ -141,23 +141,26 @@ export var useBarChart = function (props) {
|
|
|
141
141
|
defaultLineConfig.initialSpacing = initialSpacing;
|
|
142
142
|
defaultLineConfig.endIndex = lineData.length - 1;
|
|
143
143
|
defaultLineConfig.animationDuration = animationDuration;
|
|
144
|
+
var _83 = __read(useState((_0 = (_z = props.lineConfig) === null || _z === void 0 ? void 0 : _z.focusedDataPointIndex) !== null && _0 !== void 0 ? _0 : -1), 2), focusedDataPointIndex = _83[0], setFocusedDataPointIndex = _83[1];
|
|
145
|
+
var _84 = __read(useState((_2 = (_1 = props.lineConfig2) === null || _1 === void 0 ? void 0 : _1.focusedDataPointIndex) !== null && _2 !== void 0 ? _2 : -1), 2), focusedDataPointIndex2 = _84[0], setFocusedDataPointIndex2 = _84[1];
|
|
144
146
|
var lineConfig = props.lineConfig
|
|
145
|
-
? getLineConfigForBarChart(props.lineConfig, initialSpacing)
|
|
147
|
+
? getLineConfigForBarChart(props.lineConfig, initialSpacing, focusedDataPointIndex, setFocusedDataPointIndex)
|
|
146
148
|
: defaultLineConfig;
|
|
147
149
|
var lineConfig2 = props.lineConfig2
|
|
148
|
-
? getLineConfigForBarChart(props.lineConfig2, initialSpacing)
|
|
150
|
+
? getLineConfigForBarChart(props.lineConfig2, initialSpacing, focusedDataPointIndex2, setFocusedDataPointIndex2)
|
|
149
151
|
: defaultLineConfig;
|
|
150
152
|
var noOfSections = getNoOfSections(props.noOfSections, props.maxValue, props.stepValue);
|
|
153
|
+
var secondaryNoOfSections = getNoOfSections((_4 = (_3 = props.secondaryYAxis) === null || _3 === void 0 ? void 0 : _3.noOfSections) !== null && _4 !== void 0 ? _4 : noOfSections, (_5 = props.secondaryYAxis) === null || _5 === void 0 ? void 0 : _5.maxValue, (_6 = props.secondaryYAxis) === null || _6 === void 0 ? void 0 : _6.stepValue);
|
|
151
154
|
var containerHeight = heightFromProps !== null && heightFromProps !== void 0 ? heightFromProps : (props.stepHeight
|
|
152
155
|
? props.stepHeight * noOfSections
|
|
153
156
|
: AxesAndRulesDefaults.containerHeight);
|
|
154
157
|
var horizSections = [{ value: '0' }];
|
|
155
|
-
var stepHeight = (
|
|
156
|
-
var labelWidth = (
|
|
157
|
-
var scrollToEnd = (
|
|
158
|
-
var scrollAnimation = (
|
|
159
|
-
var scrollEventThrottle = (
|
|
160
|
-
var labelsExtraHeight = (
|
|
158
|
+
var stepHeight = (_7 = props.stepHeight) !== null && _7 !== void 0 ? _7 : containerHeight / noOfSections;
|
|
159
|
+
var labelWidth = (_8 = props.labelWidth) !== null && _8 !== void 0 ? _8 : AxesAndRulesDefaults.labelWidth;
|
|
160
|
+
var scrollToEnd = (_9 = props.scrollToEnd) !== null && _9 !== void 0 ? _9 : BarDefaults.scrollToEnd;
|
|
161
|
+
var scrollAnimation = (_10 = props.scrollAnimation) !== null && _10 !== void 0 ? _10 : BarDefaults.scrollAnimation;
|
|
162
|
+
var scrollEventThrottle = (_11 = props.scrollEventThrottle) !== null && _11 !== void 0 ? _11 : BarDefaults.scrollEventThrottle;
|
|
163
|
+
var labelsExtraHeight = (_12 = props.labelsExtraHeight) !== null && _12 !== void 0 ? _12 : AxesAndRulesDefaults.labelsExtraHeight;
|
|
161
164
|
var secondaryMaxItem = 0;
|
|
162
165
|
var secondaryMinItem = 0;
|
|
163
166
|
if (lineConfig.isSecondary) {
|
|
@@ -233,13 +236,13 @@ export var useBarChart = function (props) {
|
|
|
233
236
|
});
|
|
234
237
|
}
|
|
235
238
|
var valuesRange = maxItem - minPositiveItem; // Diff bw largest & smallest +ve values
|
|
236
|
-
var showFractionalValues = (
|
|
237
|
-
var roundToDigits = (
|
|
239
|
+
var showFractionalValues = (_13 = props.showFractionalValues) !== null && _13 !== void 0 ? _13 : valuesRange <= 1;
|
|
240
|
+
var roundToDigits = (_14 = props.roundToDigits) !== null && _14 !== void 0 ? _14 : (showFractionalValues ? indexOfFirstNonZeroDigit(valuesRange) + 1 : 0);
|
|
238
241
|
var maxAndMin = maxAndMinUtil(maxItem, minItem, roundToDigits, showFractionalValues);
|
|
239
242
|
var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxAndMin.maxItem) || 10;
|
|
240
243
|
var secondaryRange = secondaryMaxItem - secondaryMinPositiveItem; // Diff bw largest & smallest +ve values
|
|
241
|
-
var showSecondaryFractionalValues = (
|
|
242
|
-
var secondaryRoundToDigits = (
|
|
244
|
+
var showSecondaryFractionalValues = (_16 = (_15 = props.secondaryYAxis) === null || _15 === void 0 ? void 0 : _15.showFractionalValues) !== null && _16 !== void 0 ? _16 : secondaryRange <= 1;
|
|
245
|
+
var secondaryRoundToDigits = (_18 = (_17 = props.secondaryYAxis) === null || _17 === void 0 ? void 0 : _17.roundToDigits) !== null && _18 !== void 0 ? _18 : (showSecondaryFractionalValues
|
|
243
246
|
? indexOfFirstNonZeroDigit(secondaryRange) + 1
|
|
244
247
|
: 0);
|
|
245
248
|
var secondaryMaxAndMin = maxAndMinUtil(secondaryMaxItem, secondaryMinItem, secondaryRoundToDigits, showSecondaryFractionalValues);
|
|
@@ -249,88 +252,88 @@ export var useBarChart = function (props) {
|
|
|
249
252
|
// secondaryMaxAndMin.maxItem
|
|
250
253
|
// : secondaryMaxAndMin.maxItem
|
|
251
254
|
// : maxValue
|
|
252
|
-
var secondaryMaxValue = (
|
|
255
|
+
var secondaryMaxValue = getMaxValue((_19 = props.secondaryYAxis) === null || _19 === void 0 ? void 0 : _19.maxValue, (_20 = props.secondaryYAxis) === null || _20 === void 0 ? void 0 : _20.stepValue, secondaryNoOfSections, secondaryMaxAndMin.maxItem);
|
|
253
256
|
var mostNegativeValue = getMostNegativeValue(props.mostNegativeValue, props.negativeStepValue, props.noOfSectionsBelowXAxis, maxAndMin.minItem);
|
|
254
|
-
var stepValue = (
|
|
257
|
+
var stepValue = (_21 = props.stepValue) !== null && _21 !== void 0 ? _21 : maxValue / noOfSections;
|
|
255
258
|
var effectiveNegativeStepValue = negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue;
|
|
256
|
-
var noOfSectionsBelowXAxis = (
|
|
259
|
+
var noOfSectionsBelowXAxis = (_22 = props.noOfSectionsBelowXAxis) !== null && _22 !== void 0 ? _22 : (effectiveNegativeStepValue
|
|
257
260
|
? Math.round(Math.ceil(-mostNegativeValue / effectiveNegativeStepValue))
|
|
258
261
|
: 0);
|
|
259
|
-
var showScrollIndicator = (
|
|
260
|
-
var side = (
|
|
261
|
-
var rotateLabel = (
|
|
262
|
-
var opacity = (
|
|
263
|
-
var isThreeD = (
|
|
264
|
-
var showXAxisIndices = (
|
|
265
|
-
var xAxisIndicesHeight = (
|
|
266
|
-
var xAxisIndicesWidth = (
|
|
267
|
-
var xAxisIndicesColor = (
|
|
268
|
-
var xAxisThickness = (
|
|
269
|
-
var xAxisTextNumberOfLines = (
|
|
270
|
-
var xAxisLabelsVerticalShift = (
|
|
271
|
-
var xAxisLabelsAtBottom = (
|
|
262
|
+
var showScrollIndicator = (_23 = props.showScrollIndicator) !== null && _23 !== void 0 ? _23 : BarDefaults.showScrollIndicator;
|
|
263
|
+
var side = (_24 = props.side) !== null && _24 !== void 0 ? _24 : BarDefaults.side;
|
|
264
|
+
var rotateLabel = (_25 = props.rotateLabel) !== null && _25 !== void 0 ? _25 : AxesAndRulesDefaults.rotateLabel;
|
|
265
|
+
var opacity = (_26 = props.opacity) !== null && _26 !== void 0 ? _26 : BarDefaults.opacity;
|
|
266
|
+
var isThreeD = (_27 = props.isThreeD) !== null && _27 !== void 0 ? _27 : BarDefaults.isThreeD;
|
|
267
|
+
var showXAxisIndices = (_28 = props.showXAxisIndices) !== null && _28 !== void 0 ? _28 : AxesAndRulesDefaults.showXAxisIndices;
|
|
268
|
+
var xAxisIndicesHeight = (_29 = props.xAxisIndicesHeight) !== null && _29 !== void 0 ? _29 : AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
269
|
+
var xAxisIndicesWidth = (_30 = props.xAxisIndicesWidth) !== null && _30 !== void 0 ? _30 : AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
270
|
+
var xAxisIndicesColor = (_31 = props.xAxisIndicesColor) !== null && _31 !== void 0 ? _31 : AxesAndRulesDefaults.xAxisIndicesColor;
|
|
271
|
+
var xAxisThickness = (_32 = props.xAxisThickness) !== null && _32 !== void 0 ? _32 : AxesAndRulesDefaults.xAxisThickness;
|
|
272
|
+
var xAxisTextNumberOfLines = (_33 = props.xAxisTextNumberOfLines) !== null && _33 !== void 0 ? _33 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
|
|
273
|
+
var xAxisLabelsVerticalShift = (_34 = props.xAxisLabelsVerticalShift) !== null && _34 !== void 0 ? _34 : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
|
|
274
|
+
var xAxisLabelsAtBottom = (_35 = props.xAxisLabelsAtBottom) !== null && _35 !== void 0 ? _35 : false;
|
|
272
275
|
var horizontalRulesStyle = props.horizontalRulesStyle;
|
|
273
|
-
var autoShiftLabels = (
|
|
274
|
-
var barBorderColor = (
|
|
276
|
+
var autoShiftLabels = (_36 = props.autoShiftLabels) !== null && _36 !== void 0 ? _36 : false;
|
|
277
|
+
var barBorderColor = (_37 = props.barBorderColor) !== null && _37 !== void 0 ? _37 : BarDefaults.barBorderColor;
|
|
275
278
|
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
|
|
276
279
|
var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
|
|
277
|
-
var
|
|
278
|
-
var primary4thQuadrantHeight = noOfSectionsBelowXAxis * ((
|
|
280
|
+
var _85 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepHeight = _85.stepHeight, secondaryStepValue = _85.stepValue, secondaryNegativeStepHeight = _85.negativeStepHeight, secondaryNegativeStepValue = _85.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _85.noOfSectionsBelowXAxis;
|
|
281
|
+
var primary4thQuadrantHeight = noOfSectionsBelowXAxis * ((_38 = props.negativeStepHeight) !== null && _38 !== void 0 ? _38 : stepHeight);
|
|
279
282
|
var secondary4thQuadrantHeight = secondaryNoOfSectionsBelowXAxis * secondaryNegativeStepHeight;
|
|
280
283
|
var fourthQuadrantHeight = Math.max(primary4thQuadrantHeight, secondary4thQuadrantHeight);
|
|
281
284
|
var containerHeightIncludingBelowXAxis = extendedContainerHeight + fourthQuadrantHeight;
|
|
282
|
-
var
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
var
|
|
286
|
-
var
|
|
287
|
-
var
|
|
285
|
+
var _86 = __read(useState(-1), 2), pointerIndex = _86[0], setPointerIndex = _86[1];
|
|
286
|
+
var _87 = __read(useState(0), 2), pointerX = _87[0], setPointerX = _87[1];
|
|
287
|
+
var _88 = __read(useState(0), 2), pointerY = _88[0], setPointerY = _88[1];
|
|
288
|
+
var _89 = __read(useState(), 2), pointerItem = _89[0], setPointerItem = _89[1];
|
|
289
|
+
var _90 = __read(useState(0), 2), responderStartTime = _90[0], setResponderStartTime = _90[1];
|
|
290
|
+
var _91 = __read(useState(false), 2), responderActive = _91[0], setResponderActive = _91[1];
|
|
288
291
|
var pointerConfig = props.pointerConfig;
|
|
289
|
-
var getPointerProps = (
|
|
290
|
-
var pointerHeight = (
|
|
291
|
-
var pointerWidth = (
|
|
292
|
-
var pointerRadius = (
|
|
293
|
-
var pointerColor = (
|
|
294
|
-
var pointerComponent = (
|
|
292
|
+
var getPointerProps = (_39 = props.getPointerProps) !== null && _39 !== void 0 ? _39 : null;
|
|
293
|
+
var pointerHeight = (_40 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _40 !== void 0 ? _40 : defaultPointerConfig.height;
|
|
294
|
+
var pointerWidth = (_41 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.width) !== null && _41 !== void 0 ? _41 : defaultPointerConfig.width;
|
|
295
|
+
var pointerRadius = (_42 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.radius) !== null && _42 !== void 0 ? _42 : defaultPointerConfig.radius;
|
|
296
|
+
var pointerColor = (_43 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColor) !== null && _43 !== void 0 ? _43 : defaultPointerConfig.pointerColor;
|
|
297
|
+
var pointerComponent = (_44 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerComponent) !== null && _44 !== void 0 ? _44 : defaultPointerConfig.pointerComponent;
|
|
295
298
|
var showPointerStrip = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.showPointerStrip) === false
|
|
296
299
|
? false
|
|
297
300
|
: defaultPointerConfig.showPointerStrip;
|
|
298
|
-
var pointerStripHeight = (
|
|
299
|
-
var pointerStripWidth = (
|
|
300
|
-
var pointerStripColor = (
|
|
301
|
-
var pointerStripUptoDataPoint = (
|
|
302
|
-
var pointerLabelComponent = (
|
|
303
|
-
var stripOverPointer = (
|
|
304
|
-
var shiftPointerLabelX = (
|
|
305
|
-
var shiftPointerLabelY = (
|
|
306
|
-
var pointerLabelWidth = (
|
|
307
|
-
var pointerLabelHeight = (
|
|
308
|
-
var autoAdjustPointerLabelPosition = (
|
|
309
|
-
var pointerVanishDelay = (
|
|
310
|
-
var activatePointersOnLongPress = (
|
|
311
|
-
var activatePointersDelay = (
|
|
312
|
-
var initialPointerIndex = (
|
|
313
|
-
var initialPointerAppearDelay = (
|
|
301
|
+
var pointerStripHeight = (_45 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripHeight) !== null && _45 !== void 0 ? _45 : defaultPointerConfig.pointerStripHeight;
|
|
302
|
+
var pointerStripWidth = (_46 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripWidth) !== null && _46 !== void 0 ? _46 : defaultPointerConfig.pointerStripWidth;
|
|
303
|
+
var pointerStripColor = (_47 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripColor) !== null && _47 !== void 0 ? _47 : defaultPointerConfig.pointerStripColor;
|
|
304
|
+
var pointerStripUptoDataPoint = (_48 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripUptoDataPoint) !== null && _48 !== void 0 ? _48 : defaultPointerConfig.pointerStripUptoDataPoint;
|
|
305
|
+
var pointerLabelComponent = (_49 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelComponent) !== null && _49 !== void 0 ? _49 : defaultPointerConfig.pointerLabelComponent;
|
|
306
|
+
var stripOverPointer = (_50 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripOverPointer) !== null && _50 !== void 0 ? _50 : defaultPointerConfig.stripOverPointer;
|
|
307
|
+
var shiftPointerLabelX = (_51 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelX) !== null && _51 !== void 0 ? _51 : defaultPointerConfig.shiftPointerLabelX;
|
|
308
|
+
var shiftPointerLabelY = (_52 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelY) !== null && _52 !== void 0 ? _52 : defaultPointerConfig.shiftPointerLabelY;
|
|
309
|
+
var pointerLabelWidth = (_53 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelWidth) !== null && _53 !== void 0 ? _53 : defaultPointerConfig.pointerLabelWidth;
|
|
310
|
+
var pointerLabelHeight = (_54 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelHeight) !== null && _54 !== void 0 ? _54 : defaultPointerConfig.pointerLabelHeight;
|
|
311
|
+
var autoAdjustPointerLabelPosition = (_55 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.autoAdjustPointerLabelPosition) !== null && _55 !== void 0 ? _55 : defaultPointerConfig.autoAdjustPointerLabelPosition;
|
|
312
|
+
var pointerVanishDelay = (_56 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerVanishDelay) !== null && _56 !== void 0 ? _56 : defaultPointerConfig.pointerVanishDelay;
|
|
313
|
+
var activatePointersOnLongPress = (_57 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersOnLongPress) !== null && _57 !== void 0 ? _57 : defaultPointerConfig.activatePointersOnLongPress;
|
|
314
|
+
var activatePointersDelay = (_58 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersDelay) !== null && _58 !== void 0 ? _58 : defaultPointerConfig.activatePointersDelay;
|
|
315
|
+
var initialPointerIndex = (_59 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerIndex) !== null && _59 !== void 0 ? _59 : defaultPointerConfig.initialPointerIndex;
|
|
316
|
+
var initialPointerAppearDelay = (_60 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerAppearDelay) !== null && _60 !== void 0 ? _60 : (isAnimated
|
|
314
317
|
? animationDuration
|
|
315
318
|
: defaultPointerConfig.initialPointerAppearDelay);
|
|
316
|
-
var persistPointer = (
|
|
317
|
-
var hidePointer1 = (
|
|
319
|
+
var persistPointer = (_61 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.persistPointer) !== null && _61 !== void 0 ? _61 : defaultPointerConfig.persistPointer;
|
|
320
|
+
var hidePointer1 = (_62 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointer1) !== null && _62 !== void 0 ? _62 : defaultPointerConfig.hidePointer1;
|
|
318
321
|
var pointerEvents = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerEvents;
|
|
319
|
-
var stripBehindBars = (
|
|
320
|
-
var disableScroll = (
|
|
322
|
+
var stripBehindBars = (_63 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripBehindBars) !== null && _63 !== void 0 ? _63 : defaultPointerConfig.stripBehindBars;
|
|
323
|
+
var disableScroll = (_64 = props.disableScroll) !== null && _64 !== void 0 ? _64 : (pointerConfig
|
|
321
324
|
? activatePointersOnLongPress
|
|
322
325
|
? !!responderActive
|
|
323
326
|
: true
|
|
324
327
|
: false);
|
|
325
328
|
var yAxisExtraHeightAtTop = props.trimYAxisAtTop
|
|
326
329
|
? 0
|
|
327
|
-
: (
|
|
330
|
+
: (_65 = props.yAxisExtraHeight) !== null && _65 !== void 0 ? _65 : containerHeight / 20;
|
|
328
331
|
var barInnerComponent = props.barInnerComponent;
|
|
329
332
|
var localYAxisOffset1 = lineConfig.isSecondary
|
|
330
|
-
? (
|
|
333
|
+
? (_67 = (_66 = props.secondaryYAxis) === null || _66 === void 0 ? void 0 : _66.yAxisOffset) !== null && _67 !== void 0 ? _67 : 0
|
|
331
334
|
: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0;
|
|
332
335
|
var localYAxisOffset2 = lineConfig2.isSecondary
|
|
333
|
-
? (
|
|
336
|
+
? (_69 = (_68 = props.secondaryYAxis) === null || _68 === void 0 ? void 0 : _68.yAxisOffset) !== null && _69 !== void 0 ? _69 : 0
|
|
334
337
|
: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0;
|
|
335
338
|
useEffect(function () {
|
|
336
339
|
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;
|
|
@@ -446,9 +449,9 @@ export var useBarChart = function (props) {
|
|
|
446
449
|
spacing,
|
|
447
450
|
yAxisLabelWidth,
|
|
448
451
|
lineConfig.showArrow,
|
|
449
|
-
(
|
|
450
|
-
(
|
|
451
|
-
(
|
|
452
|
+
(_70 = lineConfig.arrowConfig) === null || _70 === void 0 ? void 0 : _70.length,
|
|
453
|
+
(_71 = lineConfig.arrowConfig) === null || _71 === void 0 ? void 0 : _71.width,
|
|
454
|
+
(_72 = lineConfig.arrowConfig) === null || _72 === void 0 ? void 0 : _72.showArrowBase
|
|
452
455
|
]);
|
|
453
456
|
useEffect(function () {
|
|
454
457
|
var _a, _b;
|
|
@@ -585,19 +588,19 @@ export var useBarChart = function (props) {
|
|
|
585
588
|
containerHeight: containerHeight,
|
|
586
589
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
587
590
|
stepHeight: stepHeight,
|
|
588
|
-
negativeStepHeight: (
|
|
591
|
+
negativeStepHeight: (_73 = props.negativeStepHeight) !== null && _73 !== void 0 ? _73 : stepHeight,
|
|
589
592
|
labelsExtraHeight: labelsExtraHeight,
|
|
590
593
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
591
594
|
horizontal: horizontal,
|
|
592
595
|
rtl: rtl,
|
|
593
|
-
shiftX: (
|
|
594
|
-
shiftY: (
|
|
596
|
+
shiftX: (_74 = props.shiftX) !== null && _74 !== void 0 ? _74 : 0,
|
|
597
|
+
shiftY: (_75 = props.shiftY) !== null && _75 !== void 0 ? _75 : 0,
|
|
595
598
|
yAxisAtTop: yAxisAtTop,
|
|
596
599
|
initialSpacing: initialSpacing,
|
|
597
600
|
data: data,
|
|
598
601
|
stackData: stackData,
|
|
599
602
|
// secondaryData,
|
|
600
|
-
barWidth: (
|
|
603
|
+
barWidth: (_76 = props.barWidth) !== null && _76 !== void 0 ? _76 : defaultBarWidth,
|
|
601
604
|
xAxisThickness: xAxisThickness,
|
|
602
605
|
totalWidth: totalWidth,
|
|
603
606
|
disableScroll: disableScroll,
|
|
@@ -646,7 +649,7 @@ export var useBarChart = function (props) {
|
|
|
646
649
|
pointerY: pointerY,
|
|
647
650
|
onEndReached: props.onEndReached,
|
|
648
651
|
onStartReached: props.onStartReached,
|
|
649
|
-
endReachedOffset: (
|
|
652
|
+
endReachedOffset: (_77 = props.endReachedOffset) !== null && _77 !== void 0 ? _77 : BarDefaults.endReachedOffset,
|
|
650
653
|
onMomentumScrollEnd: props.onMomentumScrollEnd,
|
|
651
654
|
customBackground: props.customBackground,
|
|
652
655
|
highlightEnabled: highlightEnabled,
|
package/dist/BarChart/types.d.ts
CHANGED
|
@@ -403,6 +403,9 @@ export interface lineConfigType {
|
|
|
403
403
|
focusedDataPointIndex?: number;
|
|
404
404
|
showDataPointLabelOnFocus?: boolean;
|
|
405
405
|
}
|
|
406
|
+
export type lineConfigWithSetFocusedDataPointIndexType = lineConfigType & {
|
|
407
|
+
setFocusedDataPointIndex: (i: number) => void;
|
|
408
|
+
};
|
|
406
409
|
export interface defaultLineConfigType {
|
|
407
410
|
initialSpacing: number;
|
|
408
411
|
curved: boolean;
|
|
@@ -436,6 +439,7 @@ export interface defaultLineConfigType {
|
|
|
436
439
|
focusedDataPointColor: ColorValue;
|
|
437
440
|
focusedDataPointRadius: number;
|
|
438
441
|
showDataPointLabelOnFocus: boolean;
|
|
442
|
+
setFocusedDataPointIndex: (i: number) => void;
|
|
439
443
|
}
|
|
440
444
|
interface arrowType {
|
|
441
445
|
length?: number;
|
package/dist/PieChart/index.d.ts
CHANGED
package/dist/PieChart/index.js
CHANGED
|
@@ -18,10 +18,10 @@ import { useEffect, useState } from 'react';
|
|
|
18
18
|
import { getTextSizeForPieLabels } from '../utils';
|
|
19
19
|
import { PieTooltipDefaults } from '../utils/constants';
|
|
20
20
|
export var usePieChart = function (props) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u
|
|
22
|
-
var showTooltip = props.showTooltip, tooltipWidth = props.tooltipWidth, tooltipComponent = props.tooltipComponent,
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
22
|
+
var showTooltip = props.showTooltip, tooltipWidth = props.tooltipWidth, tooltipComponent = props.tooltipComponent, _v = props.tooltipVerticalShift, tooltipVerticalShift = _v === void 0 ? PieTooltipDefaults.tooltipVerticalShift : _v, _w = props.tooltipHorizontalShift, tooltipHorizontalShift = _w === void 0 ? PieTooltipDefaults.tooltipHorizontalShift : _w, _x = props.showValuesAsTooltipText, showValuesAsTooltipText = _x === void 0 ? PieTooltipDefaults.showValuesAsTooltipText : _x, _y = props.tooltipTextNoOfLines, tooltipTextNoOfLines = _y === void 0 ? PieTooltipDefaults.tooltipTextNoOfLines : _y, _z = props.tooltipBackgroundColor, tooltipBackgroundColor = _z === void 0 ? PieTooltipDefaults.tooltipBackgroundColor : _z, _0 = props.tooltipBorderRadius, tooltipBorderRadius = _0 === void 0 ? PieTooltipDefaults.tooltipBorderRadius : _0, textColor = props.textColor,
|
|
23
23
|
// textSize,
|
|
24
|
-
font = props.font, fontWeight = props.fontWeight, fontStyle = props.fontStyle;
|
|
24
|
+
font = props.font, fontWeight = props.fontWeight, fontStyle = props.fontStyle, initialAngle = props.initialAngle, _1 = props.rotatable, rotatable = _1 === void 0 ? false : _1;
|
|
25
25
|
var _2 = __read(useState(-1), 2), tooltipSelectedIndex = _2[0], setTooltipSelectedIndex = _2[1];
|
|
26
26
|
var radius = (_a = props.radius) !== null && _a !== void 0 ? _a : 120;
|
|
27
27
|
var extraRadius = (_b = props.extraRadius) !== null && _b !== void 0 ? _b : (props.showExternalLabels
|
|
@@ -32,25 +32,26 @@ export var usePieChart = function (props) {
|
|
|
32
32
|
var pi = props.semiCircle ? Math.PI / 2 : Math.PI;
|
|
33
33
|
var _3 = __read(useState((_d = props.focusedPieIndex) !== null && _d !== void 0 ? _d : -1), 2), selectedIndex = _3[0], setSelectedIndex = _3[1]; // at the start, nothing is selected
|
|
34
34
|
// because we're going to use a useEffect, we need startAngle and total to be state variables
|
|
35
|
-
var _4 = __read(useState(
|
|
35
|
+
var _4 = __read(useState(initialAngle !== null && initialAngle !== void 0 ? initialAngle : (props.semiCircle ? -pi : 0)), 2), startAngle = _4[0], setStartAngle = _4[1];
|
|
36
36
|
var _5 = __read(useState(0), 2), total = _5[0], setTotal = _5[1];
|
|
37
37
|
useEffect(function () {
|
|
38
38
|
var _a;
|
|
39
39
|
setSelectedIndex((_a = props.focusedPieIndex) !== null && _a !== void 0 ? _a : -1);
|
|
40
40
|
}, [props.focusedPieIndex]);
|
|
41
41
|
useEffect(function () {
|
|
42
|
-
var _a;
|
|
43
42
|
// Update the total, this could be use to replace the forEach : const newTotal = props.data.reduce((acc, item) => acc + item.value, 0);
|
|
44
43
|
var newTotal = 0;
|
|
45
|
-
props.data.forEach(function (item) {
|
|
44
|
+
props.data.forEach(function (item, index) {
|
|
46
45
|
newTotal += item.value;
|
|
46
|
+
if (index === props.focusedPieIndex)
|
|
47
|
+
item.focused = true;
|
|
47
48
|
});
|
|
48
49
|
setTotal(newTotal);
|
|
49
50
|
// Update selectedIndex based on focused item
|
|
50
51
|
var newSelectedIndex = props.data.findIndex(function (item) { return item.focused === true; });
|
|
51
52
|
setSelectedIndex(newSelectedIndex);
|
|
52
53
|
// Calculate the new start angle
|
|
53
|
-
var newStartAngle =
|
|
54
|
+
var newStartAngle = initialAngle !== null && initialAngle !== void 0 ? initialAngle : (props.semiCircle ? -pi : 0);
|
|
54
55
|
if (newSelectedIndex !== -1) {
|
|
55
56
|
// it was !== 0 here before, which would not work, it's either !==-1 or >=0
|
|
56
57
|
// This could be used to replace the for loop that was used before
|
|
@@ -62,11 +63,10 @@ export var usePieChart = function (props) {
|
|
|
62
63
|
else {
|
|
63
64
|
setStartAngle(newStartAngle);
|
|
64
65
|
}
|
|
65
|
-
}, [props.data,
|
|
66
|
+
}, [props.data, initialAngle, props.semiCircle]);
|
|
66
67
|
useEffect(function () {
|
|
67
|
-
var _a;
|
|
68
68
|
if (selectedIndex !== -1) {
|
|
69
|
-
var newStartAngle =
|
|
69
|
+
var newStartAngle = initialAngle !== null && initialAngle !== void 0 ? initialAngle : (props.semiCircle ? -pi : 0);
|
|
70
70
|
var start = 0;
|
|
71
71
|
for (var i = 0; i < selectedIndex; i++) {
|
|
72
72
|
start += props.data[i].value;
|
|
@@ -77,29 +77,29 @@ export var usePieChart = function (props) {
|
|
|
77
77
|
}
|
|
78
78
|
}, [selectedIndex]);
|
|
79
79
|
var pro = props.pro, data = props.data, donut = props.donut, isThreeD = props.isThreeD, semiCircle = props.semiCircle, _6 = props.inwardExtraLengthForFocused, inwardExtraLengthForFocused = _6 === void 0 ? 0 : _6, _7 = props.isAnimated, isAnimated = _7 === void 0 ? false : _7, edgesRadius = props.edgesRadius;
|
|
80
|
-
var endAngle = (
|
|
80
|
+
var endAngle = (_e = props.endAngle) !== null && _e !== void 0 ? _e : startAngle + Math.PI * (semiCircle ? 1 : 2);
|
|
81
81
|
var canvasWidth = radius * 2;
|
|
82
82
|
var canvasHeight = isThreeD ? radius * 2.3 : radius * 2;
|
|
83
|
-
var strokeWidth = (
|
|
84
|
-
var innerRadius = (
|
|
85
|
-
var innerCircleColor = (
|
|
86
|
-
var innerCircleBorderWidth = (
|
|
87
|
-
var innerCircleBorderColor = (
|
|
88
|
-
var shiftInnerCenterX = (
|
|
89
|
-
var shiftInnerCenterY = (
|
|
90
|
-
var tiltAngle = (
|
|
83
|
+
var strokeWidth = (_f = props.strokeWidth) !== null && _f !== void 0 ? _f : 0;
|
|
84
|
+
var innerRadius = (_g = props.innerRadius) !== null && _g !== void 0 ? _g : radius / 2.5;
|
|
85
|
+
var innerCircleColor = (_j = (_h = props.innerCircleColor) !== null && _h !== void 0 ? _h : props.backgroundColor) !== null && _j !== void 0 ? _j : 'white';
|
|
86
|
+
var innerCircleBorderWidth = (_k = props.innerCircleBorderWidth) !== null && _k !== void 0 ? _k : (props.innerCircleBorderColor ? strokeWidth || 2 : 0);
|
|
87
|
+
var innerCircleBorderColor = (_l = props.innerCircleBorderColor) !== null && _l !== void 0 ? _l : 'lightgray';
|
|
88
|
+
var shiftInnerCenterX = (_m = props.shiftInnerCenterX) !== null && _m !== void 0 ? _m : 0;
|
|
89
|
+
var shiftInnerCenterY = (_o = props.shiftInnerCenterY) !== null && _o !== void 0 ? _o : 0;
|
|
90
|
+
var tiltAngle = (_p = props.tiltAngle) !== null && _p !== void 0 ? _p : '55deg';
|
|
91
91
|
var isDataShifted = false;
|
|
92
92
|
data.forEach(function (item) {
|
|
93
93
|
if (item.shiftX || item.shiftY) {
|
|
94
94
|
isDataShifted = true;
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
|
-
var textSize = getTextSizeForPieLabels((
|
|
98
|
-
var paddingHorizontal = ((
|
|
99
|
-
? ((
|
|
97
|
+
var textSize = getTextSizeForPieLabels((_q = props.textSize) !== null && _q !== void 0 ? _q : 0, radius);
|
|
98
|
+
var paddingHorizontal = ((_r = props.paddingHorizontal) !== null && _r !== void 0 ? _r : props.labelsPosition === 'onBorder')
|
|
99
|
+
? ((_s = props.textBackgroundRadius) !== null && _s !== void 0 ? _s : textSize) * 2 + 6
|
|
100
100
|
: 0;
|
|
101
|
-
var paddingVertical = ((
|
|
102
|
-
? ((
|
|
101
|
+
var paddingVertical = ((_t = props.paddingVertical) !== null && _t !== void 0 ? _t : props.labelsPosition === 'onBorder')
|
|
102
|
+
? ((_u = props.textBackgroundRadius) !== null && _u !== void 0 ? _u : textSize) * 2 + 6
|
|
103
103
|
: 0;
|
|
104
104
|
var getTooltipText = function (index) {
|
|
105
105
|
var _a, _b;
|
|
@@ -151,6 +151,7 @@ export var usePieChart = function (props) {
|
|
|
151
151
|
fontWeight: fontWeight,
|
|
152
152
|
fontStyle: fontStyle,
|
|
153
153
|
tooltipSelectedIndex: tooltipSelectedIndex,
|
|
154
|
-
setTooltipSelectedIndex: setTooltipSelectedIndex
|
|
154
|
+
setTooltipSelectedIndex: setTooltipSelectedIndex,
|
|
155
|
+
rotatable: rotatable
|
|
155
156
|
};
|
|
156
157
|
};
|
package/dist/PieChart/pro.js
CHANGED
|
@@ -26,8 +26,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
26
26
|
import { defaultAnimationDuration } from '../utils/constants';
|
|
27
27
|
export var usePiePro = function (props) {
|
|
28
28
|
var _a, _b;
|
|
29
|
-
var data = props.data, isAnimated = props.isAnimated, donut = props.donut, semiCircle = props.semiCircle, _c = props.radius, radius = _c === void 0 ? 120 : _c, _d = props.innerRadius, innerRadius = _d === void 0 ? donut ? radius / 2.5 : 0 : _d, _e = props.strokeWidth, strokeWidth = _e === void 0 ? props.ring ? 10 : 0 : _e, _f = props.edgesRadius, edgesRadius = _f === void 0 ? 0 : _f, _g = props.
|
|
30
|
-
var endAngle = (_a = props.endAngle) !== null && _a !== void 0 ? _a :
|
|
29
|
+
var data = props.data, isAnimated = props.isAnimated, donut = props.donut, semiCircle = props.semiCircle, _c = props.radius, radius = _c === void 0 ? 120 : _c, _d = props.innerRadius, innerRadius = _d === void 0 ? donut ? radius / 2.5 : 0 : _d, _e = props.strokeWidth, strokeWidth = _e === void 0 ? props.ring ? 10 : 0 : _e, _f = props.edgesRadius, edgesRadius = _f === void 0 ? 0 : _f, _g = props.initialAngle, initialAngle = _g === void 0 ? 0 : _g, ring = props.ring;
|
|
30
|
+
var endAngle = (_a = props.endAngle) !== null && _a !== void 0 ? _a : initialAngle + Math.PI * (semiCircle ? 1 : 2);
|
|
31
31
|
var total = data.reduce(function (acc, item) { return acc + (item === null || item === void 0 ? void 0 : item.value); }, 0);
|
|
32
32
|
var animationDuration = (_b = props.animationDuration) !== null && _b !== void 0 ? _b : defaultAnimationDuration;
|
|
33
33
|
var maxStrokeWidth = Math.max.apply(Math, __spreadArray(__spreadArray([], __read(data.map(function (item) { var _a; return (_a = item.strokeWidth) !== null && _a !== void 0 ? _a : 0; })), false), [strokeWidth], false));
|
|
@@ -56,7 +56,7 @@ export var usePiePro = function (props) {
|
|
|
56
56
|
var getCoordinates = function (index, additionalValue, addInOnlyStart, addInOnlyEnd, totalParam) {
|
|
57
57
|
var _a;
|
|
58
58
|
var addedValue = addValues(index - 1) + (addInOnlyEnd ? 0 : additionalValue !== null && additionalValue !== void 0 ? additionalValue : 0);
|
|
59
|
-
var angle = (addedValue / (totalParam !== null && totalParam !== void 0 ? totalParam : total)) * endAngle +
|
|
59
|
+
var angle = (addedValue / (totalParam !== null && totalParam !== void 0 ? totalParam : total)) * endAngle + initialAngle;
|
|
60
60
|
var startInnerX = radius + Math.cos(angle) * innerRadius;
|
|
61
61
|
var startInnerY = radius - Math.sin(angle) * innerRadius;
|
|
62
62
|
var startOuterX = radius + Math.cos(angle) * radius;
|
|
@@ -64,7 +64,7 @@ export var usePiePro = function (props) {
|
|
|
64
64
|
var value = addValues(index - 1) +
|
|
65
65
|
((_a = data[index]) === null || _a === void 0 ? void 0 : _a.value) +
|
|
66
66
|
(addInOnlyStart ? 0 : additionalValue !== null && additionalValue !== void 0 ? additionalValue : 0);
|
|
67
|
-
angle = (value / (totalParam !== null && totalParam !== void 0 ? totalParam : total)) * endAngle +
|
|
67
|
+
angle = (value / (totalParam !== null && totalParam !== void 0 ? totalParam : total)) * endAngle + initialAngle;
|
|
68
68
|
var endOuterX = radius + Math.cos(angle) * radius;
|
|
69
69
|
var endOuterY = radius - Math.sin(angle) * radius;
|
|
70
70
|
var endInnerX = radius + Math.cos(angle) * innerRadius;
|
|
@@ -83,7 +83,7 @@ export var usePiePro = function (props) {
|
|
|
83
83
|
var getTextCoordinates = function (index, labelPos) {
|
|
84
84
|
var _a;
|
|
85
85
|
var value = addValues(index - 1) + ((_a = data[index]) === null || _a === void 0 ? void 0 : _a.value) / 2;
|
|
86
|
-
var angle = (value / total) * endAngle +
|
|
86
|
+
var angle = (value / total) * endAngle + initialAngle;
|
|
87
87
|
var labelPosition = labelPos || labelsPosition;
|
|
88
88
|
var x = radius +
|
|
89
89
|
Math.cos(angle) *
|
package/dist/PieChart/types.d.ts
CHANGED
|
@@ -62,7 +62,6 @@ export interface PieChartPropsType {
|
|
|
62
62
|
pieInnerComponentWidth?: number;
|
|
63
63
|
paddingHorizontal?: number;
|
|
64
64
|
paddingVertical?: number;
|
|
65
|
-
startAngle?: number;
|
|
66
65
|
endAngle?: number;
|
|
67
66
|
curvedStartEdges?: boolean;
|
|
68
67
|
curvedEndEdges?: boolean;
|
|
@@ -77,6 +76,7 @@ export interface PieChartPropsType {
|
|
|
77
76
|
* @description If true, the edges of the pie will be pressable, but you may need to press twice for focus- once for unfocusing the already focused pie and then for focusing the new pie
|
|
78
77
|
*/
|
|
79
78
|
edgesPressable?: boolean;
|
|
79
|
+
rotatable?: boolean;
|
|
80
80
|
}
|
|
81
81
|
export interface pieDataItem {
|
|
82
82
|
value: number;
|
package/dist/utils/constants.js
CHANGED
|
@@ -217,7 +217,8 @@ export var defaultLineConfig = {
|
|
|
217
217
|
focusEnabled: false,
|
|
218
218
|
focusedDataPointColor: LineDefaults.focusedDataPointColor,
|
|
219
219
|
focusedDataPointRadius: LineDefaults.dataPointsRadius,
|
|
220
|
-
showDataPointLabelOnFocus: LineDefaults.showDataPointLabelOnFocus
|
|
220
|
+
showDataPointLabelOnFocus: LineDefaults.showDataPointLabelOnFocus,
|
|
221
|
+
setFocusedDataPointIndex: function () { }
|
|
221
222
|
};
|
|
222
223
|
export var defaultPointerConfig = {
|
|
223
224
|
height: 0,
|
|
@@ -259,14 +260,14 @@ export var defaultPointerConfig = {
|
|
|
259
260
|
};
|
|
260
261
|
// Pie chart specific
|
|
261
262
|
export var pieColors = [
|
|
262
|
-
'
|
|
263
|
-
'
|
|
264
|
-
'
|
|
265
|
-
'
|
|
266
|
-
'#
|
|
267
|
-
'
|
|
268
|
-
'
|
|
269
|
-
'
|
|
263
|
+
'#ccc',
|
|
264
|
+
'#888',
|
|
265
|
+
'#bbb',
|
|
266
|
+
'#777',
|
|
267
|
+
'#aaa',
|
|
268
|
+
'#666',
|
|
269
|
+
'#999',
|
|
270
|
+
'#555'
|
|
270
271
|
];
|
|
271
272
|
export var populationDefaults = {
|
|
272
273
|
height: 200,
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ColorValue } from 'react-native';
|
|
2
2
|
import { lineDataItemNullSafe, type IDataSanitisationProps, type lineDataItem } from '../LineChart/types';
|
|
3
3
|
import { type arrowConfigType, CurveType, type HighlightedRange, type LineProperties, type LineSegment, Framework, referenceConfigType, secondaryYAxisType } from './types';
|
|
4
|
-
import { type lineConfigType, type BarChartPropsType, type FocusedBarConfig, type barDataItem, barDataItemNullSafe } from '../BarChart/types';
|
|
4
|
+
import { type lineConfigType, type BarChartPropsType, type FocusedBarConfig, type barDataItem, barDataItemNullSafe, lineConfigWithSetFocusedDataPointIndexType } from '../BarChart/types';
|
|
5
5
|
import { type extendedLineChartPropsType } from '../LineChart';
|
|
6
6
|
import { type extendedBarChartPropsType } from '../BarChart';
|
|
7
7
|
export declare const getCumulativeWidth: (data: any, index: number, spacing: number) => number;
|
|
@@ -93,7 +93,7 @@ export declare const getLabelTextUtil: (val: string, index: number, showFraction
|
|
|
93
93
|
export declare const getXForLineInBar: (index: number, firstBarWidth: number, currentBarWidth: number, yAxisLabelWidth: number, lineConfig: any, spacing: number) => number;
|
|
94
94
|
export declare const getYForLineInBar: (value: number | undefined, shiftY: number | undefined, containerHeight: number, maxValue: number, yAxisOffset: number) => number;
|
|
95
95
|
export declare const clone: (obj: any) => any;
|
|
96
|
-
export declare const getLineConfigForBarChart: (lineConfig: lineConfigType, barInitialSpacing: number) =>
|
|
96
|
+
export declare const getLineConfigForBarChart: (lineConfig: lineConfigType, barInitialSpacing: number, focusedDataPointIndex: number, setFocusedDataPointIndex: (i: number) => void) => lineConfigWithSetFocusedDataPointIndexType;
|
|
97
97
|
export declare const getNoOfSections: (noOfSections: number | undefined, maxValue: number | undefined, stepValue: number | undefined) => number;
|
|
98
98
|
export declare const getMaxValue: (maxValue: number | undefined, stepValue: number | undefined, noOfSections: number, maxItem: number) => number;
|
|
99
99
|
export declare const getMostNegativeValue: (minValue: number | undefined, stepValue: number | undefined, noOfSections: number | undefined, minItem: number) => number;
|
package/dist/utils/index.js
CHANGED
|
@@ -795,7 +795,7 @@ export var clone = function (obj) {
|
|
|
795
795
|
}
|
|
796
796
|
return temp;
|
|
797
797
|
};
|
|
798
|
-
export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
|
|
798
|
+
export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing, focusedDataPointIndex, setFocusedDataPointIndex) {
|
|
799
799
|
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;
|
|
800
800
|
return {
|
|
801
801
|
initialSpacing: (_b = (_a = lineConfig.initialSpacing) !== null && _a !== void 0 ? _a : barInitialSpacing) !== null && _b !== void 0 ? _b : defaultLineConfig.initialSpacing,
|
|
@@ -840,7 +840,8 @@ export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
|
|
|
840
840
|
focusEnabled: (_21 = lineConfig.focusEnabled) !== null && _21 !== void 0 ? _21 : defaultLineConfig.focusEnabled,
|
|
841
841
|
focusedDataPointColor: (_22 = lineConfig.focusedDataPointColor) !== null && _22 !== void 0 ? _22 : defaultLineConfig.focusedDataPointColor,
|
|
842
842
|
focusedDataPointRadius: (_23 = lineConfig.focusedDataPointRadius) !== null && _23 !== void 0 ? _23 : defaultLineConfig.focusedDataPointRadius,
|
|
843
|
-
focusedDataPointIndex:
|
|
843
|
+
focusedDataPointIndex: focusedDataPointIndex,
|
|
844
|
+
setFocusedDataPointIndex: setFocusedDataPointIndex,
|
|
844
845
|
showDataPointLabelOnFocus: (_24 = lineConfig.showDataPointLabelOnFocus) !== null && _24 !== void 0 ? _24 : defaultLineConfig.showDataPointLabelOnFocus
|
|
845
846
|
};
|
|
846
847
|
};
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ export interface ExtendedLineConfigType extends lineConfigType {
|
|
|
132
132
|
startIndex: number;
|
|
133
133
|
endIndex: number;
|
|
134
134
|
dataPointsHeight: number;
|
|
135
|
+
setFocusedDataPointIndex: (i: number) => void;
|
|
135
136
|
}
|
|
136
137
|
export interface LineInBarChartPropsType {
|
|
137
138
|
yAxisLabelWidth: number;
|