gifted-charts-core 0.1.43 → 0.1.44
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.js +51 -30
- package/dist/LineChart/index.d.ts +11 -4
- package/dist/LineChart/index.js +326 -226
- package/dist/LineChart/types.d.ts +6 -0
- package/dist/PieChart/main.d.ts +17 -0
- package/dist/PieChart/main.js +45 -6
- package/dist/PieChart/types.d.ts +13 -0
- package/dist/utils/constants.d.ts +9 -0
- package/dist/utils/constants.js +10 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -20,6 +20,11 @@ export interface LineChartPropsType {
|
|
|
20
20
|
data3?: lineDataItem[];
|
|
21
21
|
data4?: lineDataItem[];
|
|
22
22
|
data5?: lineDataItem[];
|
|
23
|
+
spacing1?: number;
|
|
24
|
+
spacing2?: number;
|
|
25
|
+
spacing3?: number;
|
|
26
|
+
spacing4?: number;
|
|
27
|
+
spacing5?: number;
|
|
23
28
|
dataSet?: DataSet[];
|
|
24
29
|
zIndex1?: number;
|
|
25
30
|
zIndex2?: number;
|
|
@@ -320,6 +325,7 @@ export interface lineDataItem {
|
|
|
320
325
|
textShiftY?: number;
|
|
321
326
|
textColor?: string;
|
|
322
327
|
textFontSize?: number;
|
|
328
|
+
spacing?: number;
|
|
323
329
|
hideDataPoint?: boolean;
|
|
324
330
|
dataPointHeight?: number;
|
|
325
331
|
dataPointWidth?: number;
|
package/dist/PieChart/main.d.ts
CHANGED
|
@@ -20,6 +20,20 @@ export declare const getPieChartMainProps: (props: PieChartMainProps) => {
|
|
|
20
20
|
strokeWidth: number;
|
|
21
21
|
strokeColor: string;
|
|
22
22
|
innerRadius: number;
|
|
23
|
+
showTooltip: boolean | undefined;
|
|
24
|
+
tooltipWidth: number | undefined;
|
|
25
|
+
persistTooltip: boolean | undefined;
|
|
26
|
+
tooltipDuration: number;
|
|
27
|
+
tooltipComponent: Function | undefined;
|
|
28
|
+
tooltipVerticalShift: number;
|
|
29
|
+
tooltipHorizontalShift: number;
|
|
30
|
+
showValuesAsTooltipText: boolean;
|
|
31
|
+
tooltipTextNoOfLines: number;
|
|
32
|
+
tooltipBackgroundColor: import("react-native").ColorValue;
|
|
33
|
+
tooltipBorderRadius: number;
|
|
34
|
+
tooltipSelectedIndex: number;
|
|
35
|
+
setTooltipSelectedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
36
|
+
getTooltipText: (index: number) => string;
|
|
23
37
|
showText: boolean;
|
|
24
38
|
textColor: string;
|
|
25
39
|
textSize: number;
|
|
@@ -87,4 +101,7 @@ export declare const getPieChartMainProps: (props: PieChartMainProps) => {
|
|
|
87
101
|
};
|
|
88
102
|
coordinates: any[];
|
|
89
103
|
onPressed: (item: pieDataItem, index: number) => void;
|
|
104
|
+
font: string | undefined;
|
|
105
|
+
fontWeight: string | undefined;
|
|
106
|
+
fontStyle: import("react-native-svg").FontStyle | undefined;
|
|
90
107
|
};
|
package/dist/PieChart/main.js
CHANGED
|
@@ -34,12 +34,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
34
34
|
}
|
|
35
35
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
36
|
};
|
|
37
|
+
import { useRef, useState } from 'react';
|
|
37
38
|
import { defaultLabelLineConfig, emptyExternaLabelProperties, getTextSizeForPieLabels } from '../utils';
|
|
39
|
+
import { PieTooltipDefaults } from '../utils/constants';
|
|
38
40
|
export var getPieChartMainProps = function (props) {
|
|
39
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;
|
|
40
|
-
var isThreeD = props.isThreeD, isBiggerPie = props.isBiggerPie, paddingHorizontal = props.paddingHorizontal, paddingVertical = props.paddingVertical, extraRadius = props.extraRadius, showExternalLabels = props.showExternalLabels, externalLabelComponent = props.externalLabelComponent;
|
|
42
|
+
var isThreeD = props.isThreeD, isBiggerPie = props.isBiggerPie, paddingHorizontal = props.paddingHorizontal, paddingVertical = props.paddingVertical, extraRadius = props.extraRadius, showExternalLabels = props.showExternalLabels, externalLabelComponent = props.externalLabelComponent, showTooltip = props.showTooltip, tooltipWidth = props.tooltipWidth, persistTooltip = props.persistTooltip, tooltipComponent = props.tooltipComponent, _13 = props.tooltipDuration, tooltipDuration = _13 === void 0 ? PieTooltipDefaults.tooltipDuration : _13, _14 = props.tooltipVerticalShift, tooltipVerticalShift = _14 === void 0 ? PieTooltipDefaults.tooltipVerticalShift : _14, _15 = props.tooltipHorizontalShift, tooltipHorizontalShift = _15 === void 0 ? PieTooltipDefaults.tooltipHorizontalShift : _15, _16 = props.showValuesAsTooltipText, showValuesAsTooltipText = _16 === void 0 ? PieTooltipDefaults.showValuesAsTooltipText : _16, _17 = props.tooltipTextNoOfLines, tooltipTextNoOfLines = _17 === void 0 ? PieTooltipDefaults.tooltipTextNoOfLines : _17, _18 = props.tooltipBackgroundColor, tooltipBackgroundColor = _18 === void 0 ? PieTooltipDefaults.tooltipBackgroundColor : _18, _19 = props.tooltipBorderRadius, tooltipBorderRadius = _19 === void 0 ? PieTooltipDefaults.tooltipBorderRadius : _19, font = props.font, fontWeight = props.fontWeight, fontStyle = props.fontStyle;
|
|
41
43
|
var propData = props.data;
|
|
42
44
|
var data = [];
|
|
45
|
+
var _20 = __read(useState(-1), 2), tooltipSelectedIndex = _20[0], setTooltipSelectedIndex = _20[1];
|
|
43
46
|
var itemHasInnerComponent = false;
|
|
44
47
|
if (propData) {
|
|
45
48
|
for (var i = 0; i < propData.length; i++) {
|
|
@@ -220,12 +223,11 @@ export var getPieChartMainProps = function (props) {
|
|
|
220
223
|
(item.shiftX || 0);
|
|
221
224
|
var sy = cy * (1 - Math.cos(2 * pi * pData[index] + initialAngle)) +
|
|
222
225
|
(item.shiftY || 0);
|
|
223
|
-
var ax = cx * (1 + Math.sin(2 * pi * nextItem + initialAngle)) +
|
|
224
|
-
|
|
225
|
-
var ay = cy * (1 - Math.cos(2 * pi * nextItem + initialAngle)) +
|
|
226
|
-
(item.shiftY || 0);
|
|
226
|
+
var ax = cx * (1 + Math.sin(2 * pi * nextItem + initialAngle)) + (item.shiftX || 0);
|
|
227
|
+
var ay = cy * (1 - Math.cos(2 * pi * nextItem + initialAngle)) + (item.shiftY || 0);
|
|
227
228
|
coordinates[index] = { sx: sx, sy: sy, ax: ax, ay: ay };
|
|
228
229
|
});
|
|
230
|
+
var timer = useRef(setTimeout(function () { })); // timer for tooltip
|
|
229
231
|
var onPressed = function (item, index) {
|
|
230
232
|
if (item.onPress) {
|
|
231
233
|
item.onPress();
|
|
@@ -243,6 +245,26 @@ export var getPieChartMainProps = function (props) {
|
|
|
243
245
|
props.setSelectedIndex(index);
|
|
244
246
|
}
|
|
245
247
|
}
|
|
248
|
+
if (showTooltip) {
|
|
249
|
+
if (tooltipSelectedIndex === index) {
|
|
250
|
+
setTooltipSelectedIndex(-1);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
setTooltipSelectedIndex(index);
|
|
254
|
+
if (!persistTooltip) {
|
|
255
|
+
clearTimeout(timer.current);
|
|
256
|
+
timer.current = setTimeout(function () {
|
|
257
|
+
setTooltipSelectedIndex(-1);
|
|
258
|
+
}, tooltipDuration);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var getTooltipText = function (index) {
|
|
264
|
+
var _a, _b;
|
|
265
|
+
var item = data[index];
|
|
266
|
+
var tooltipText = (_b = (_a = item.tooltipText) !== null && _a !== void 0 ? _a : item.text) !== null && _b !== void 0 ? _b : (showValuesAsTooltipText ? item.value.toString() : '');
|
|
267
|
+
return tooltipText;
|
|
246
268
|
};
|
|
247
269
|
return {
|
|
248
270
|
isThreeD: isThreeD,
|
|
@@ -265,6 +287,20 @@ export var getPieChartMainProps = function (props) {
|
|
|
265
287
|
strokeWidth: strokeWidth,
|
|
266
288
|
strokeColor: strokeColor,
|
|
267
289
|
innerRadius: innerRadius,
|
|
290
|
+
showTooltip: showTooltip,
|
|
291
|
+
tooltipWidth: tooltipWidth,
|
|
292
|
+
persistTooltip: persistTooltip,
|
|
293
|
+
tooltipDuration: tooltipDuration,
|
|
294
|
+
tooltipComponent: tooltipComponent,
|
|
295
|
+
tooltipVerticalShift: tooltipVerticalShift,
|
|
296
|
+
tooltipHorizontalShift: tooltipHorizontalShift,
|
|
297
|
+
showValuesAsTooltipText: showValuesAsTooltipText,
|
|
298
|
+
tooltipTextNoOfLines: tooltipTextNoOfLines,
|
|
299
|
+
tooltipBackgroundColor: tooltipBackgroundColor,
|
|
300
|
+
tooltipBorderRadius: tooltipBorderRadius,
|
|
301
|
+
tooltipSelectedIndex: tooltipSelectedIndex,
|
|
302
|
+
setTooltipSelectedIndex: setTooltipSelectedIndex,
|
|
303
|
+
getTooltipText: getTooltipText,
|
|
268
304
|
showText: showText,
|
|
269
305
|
textColor: textColor,
|
|
270
306
|
textSize: textSize,
|
|
@@ -296,6 +332,9 @@ export var getPieChartMainProps = function (props) {
|
|
|
296
332
|
externalLabelComponent: externalLabelComponent,
|
|
297
333
|
getExternaLabelProperties: getExternaLabelProperties,
|
|
298
334
|
coordinates: coordinates,
|
|
299
|
-
onPressed: onPressed
|
|
335
|
+
onPressed: onPressed,
|
|
336
|
+
font: font,
|
|
337
|
+
fontWeight: fontWeight,
|
|
338
|
+
fontStyle: fontStyle
|
|
300
339
|
};
|
|
301
340
|
};
|
package/dist/PieChart/types.d.ts
CHANGED
|
@@ -31,6 +31,17 @@ export interface PieChartPropsType {
|
|
|
31
31
|
textBackgroundColor?: string;
|
|
32
32
|
textBackgroundRadius?: number;
|
|
33
33
|
showValuesAsLabels?: boolean;
|
|
34
|
+
showTooltip?: boolean;
|
|
35
|
+
tooltipWidth?: number;
|
|
36
|
+
tooltipComponent?: Function;
|
|
37
|
+
persistTooltip?: boolean;
|
|
38
|
+
tooltipDuration?: number;
|
|
39
|
+
tooltipVerticalShift?: number;
|
|
40
|
+
tooltipHorizontalShift?: number;
|
|
41
|
+
showValuesAsTooltipText?: boolean;
|
|
42
|
+
tooltipTextNoOfLines?: number;
|
|
43
|
+
tooltipBackgroundColor?: ColorValue;
|
|
44
|
+
tooltipBorderRadius?: number;
|
|
34
45
|
centerLabelComponent?: Function;
|
|
35
46
|
tiltAngle?: string;
|
|
36
47
|
initialAngle?: number;
|
|
@@ -69,6 +80,8 @@ export interface pieDataItem {
|
|
|
69
80
|
shiftY?: number;
|
|
70
81
|
color?: string;
|
|
71
82
|
gradientCenterColor?: string;
|
|
83
|
+
tooltipText?: string;
|
|
84
|
+
tooltipComponent?: Function;
|
|
72
85
|
text?: string;
|
|
73
86
|
textColor?: string;
|
|
74
87
|
textSize?: number;
|
|
@@ -253,3 +253,12 @@ export declare const populationDefaults: {
|
|
|
253
253
|
prefix: string;
|
|
254
254
|
suffix: string;
|
|
255
255
|
};
|
|
256
|
+
export declare const PieTooltipDefaults: {
|
|
257
|
+
tooltipDuration: number;
|
|
258
|
+
tooltipVerticalShift: number;
|
|
259
|
+
tooltipHorizontalShift: number;
|
|
260
|
+
showValuesAsTooltipText: boolean;
|
|
261
|
+
tooltipTextNoOfLines: number;
|
|
262
|
+
tooltipBackgroundColor: string;
|
|
263
|
+
tooltipBorderRadius: number;
|
|
264
|
+
};
|
package/dist/utils/constants.js
CHANGED
|
@@ -207,7 +207,7 @@ export var defaultLineConfig = {
|
|
|
207
207
|
isSecondary: false,
|
|
208
208
|
focusEnabled: false,
|
|
209
209
|
focusedDataPointColor: LineDefaults.focusedDataPointColor,
|
|
210
|
-
focusedDataPointRadius: LineDefaults.dataPointsRadius
|
|
210
|
+
focusedDataPointRadius: LineDefaults.dataPointsRadius
|
|
211
211
|
};
|
|
212
212
|
export var defaultPointerConfig = {
|
|
213
213
|
height: 0,
|
|
@@ -306,3 +306,12 @@ export var populationDefaults = {
|
|
|
306
306
|
prefix: '',
|
|
307
307
|
suffix: ''
|
|
308
308
|
};
|
|
309
|
+
export var PieTooltipDefaults = {
|
|
310
|
+
tooltipDuration: 1000,
|
|
311
|
+
tooltipVerticalShift: 30,
|
|
312
|
+
tooltipHorizontalShift: 20,
|
|
313
|
+
showValuesAsTooltipText: true,
|
|
314
|
+
tooltipTextNoOfLines: 3,
|
|
315
|
+
tooltipBackgroundColor: 'rgba(20,20,20,0.8)',
|
|
316
|
+
tooltipBorderRadius: 4
|
|
317
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const bezierCommand: (point: number[], i: number, a: number[][],
|
|
|
12
12
|
export declare const getSegmentString: (lineSegment: LineSegment[] | undefined, index: number, startDelimeter: string, endDelimeter: string) => string;
|
|
13
13
|
export declare const getCurvePathWithSegments: (path: string, lineSegment: LineSegment[] | undefined, startDelimeter: string, endDelimeter: string, curveType: CurveType) => string;
|
|
14
14
|
export declare const getPreviousSegmentsLastPoint: (isCurved: boolean, previousSegment: string) => string;
|
|
15
|
-
export declare const getPathWithHighlight: (data: lineDataItem[], i: number, highlightedRange: HighlightedRange, startIndex: number, endIndex: number, getX: (i: number) => number, getY: (value: number) => number) => string;
|
|
15
|
+
export declare const getPathWithHighlight: (data: lineDataItem[], i: number, highlightedRange: HighlightedRange, startIndex: number, endIndex: number, spacingArray: number[], getX: (spacingArray: number[], i: number) => number, getY: (value: number) => number) => string;
|
|
16
16
|
export declare const getRegionPathObjects: (points: string, color: ColorValue, currentLineThickness: number, thickness: number, strokeDashArray: number[], isCurved: boolean, startDelimeter: string, stop: string, endDelimeter: string, curveType: CurveType) => LineProperties[];
|
|
17
17
|
export declare const getSegmentedPathObjects: (points: string, color: ColorValue, currentLineThickness: number, thickness: number, strokeDashArray: number[], isCurved: boolean, startDelimeter: string, endDelimeter: string, curveType: CurveType) => LineProperties[];
|
|
18
18
|
export declare const getArrowPoints: (arrowTipX: number, arrowTipY: number, x1: number, y1: number, arrowLength?: number, arrowWidth?: number, showArrowBase?: boolean) => string;
|
package/dist/utils/index.js
CHANGED
|
@@ -183,7 +183,7 @@ export var getPreviousSegmentsLastPoint = function (isCurved, previousSegment) {
|
|
|
183
183
|
.replace('L', 'M');
|
|
184
184
|
return ((prevSegmentLastPoint.trim()[0] === 'M' ? '' : 'M') + prevSegmentLastPoint);
|
|
185
185
|
};
|
|
186
|
-
export var getPathWithHighlight = function (data, i, highlightedRange, startIndex, endIndex, getX, getY) {
|
|
186
|
+
export var getPathWithHighlight = function (data, i, highlightedRange, startIndex, endIndex, spacingArray, getX, getY) {
|
|
187
187
|
var path = '';
|
|
188
188
|
var from = highlightedRange.from, to = highlightedRange.to;
|
|
189
189
|
var currentPointRegion = data[i].value < from ? loc.DOWN : data[i].value > to ? loc.UP : loc.IN;
|
|
@@ -195,9 +195,9 @@ export var getPathWithHighlight = function (data, i, highlightedRange, startInde
|
|
|
195
195
|
: loc.IN;
|
|
196
196
|
if (currentPointRegion !== nextPointRegion ||
|
|
197
197
|
(i === startIndex && currentPointRegion === loc.IN)) {
|
|
198
|
-
var x1 = getX(i);
|
|
198
|
+
var x1 = getX(spacingArray, i);
|
|
199
199
|
var y1 = getY(data[i].value);
|
|
200
|
-
var x2 = getX(i + 1);
|
|
200
|
+
var x2 = getX(spacingArray, i + 1);
|
|
201
201
|
var y2 = getY(data[i + 1].value);
|
|
202
202
|
var m = (y2 - y1) / (x2 - x1);
|
|
203
203
|
var x = 0;
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ export interface secondaryLineConfigType {
|
|
|
98
98
|
showArrow?: boolean;
|
|
99
99
|
arrowConfig?: arrowConfigType;
|
|
100
100
|
isSecondary?: boolean;
|
|
101
|
+
spacing?: number;
|
|
101
102
|
}
|
|
102
103
|
export interface ExtendedLineConfigType extends lineConfigType {
|
|
103
104
|
startIndex: number;
|
|
@@ -410,6 +411,7 @@ export interface DataSet {
|
|
|
410
411
|
lineSegments?: LineSegment[];
|
|
411
412
|
isSecondary?: boolean;
|
|
412
413
|
hidePointers?: boolean;
|
|
414
|
+
spacing?: number;
|
|
413
415
|
}
|
|
414
416
|
export interface IntersectionAreaConfig {
|
|
415
417
|
fillColor?: ColorValue;
|