gifted-charts-core 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/BarChart/Animated2DWithGradient.ts +4 -4
- package/src/BarChart/index.ts +2 -0
- package/src/BarChart/types.ts +7 -0
- package/src/LineChart/index.ts +1 -1
- package/src/LineChart/types.ts +2 -0
- package/src/PieChart/index.ts +13 -0
- package/src/PieChart/main.ts +12 -3
- package/src/PieChart/types.ts +5 -0
- package/src/utils/index.tsx +5 -0
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ export const getPropsForAnimated2DWithGradient = (props) => {
|
|
|
13
13
|
barBorderBottomLeftRadius,
|
|
14
14
|
barBorderBottomRightRadius,
|
|
15
15
|
barWidth,
|
|
16
|
-
|
|
16
|
+
barInnerComponent,
|
|
17
17
|
barStyle,
|
|
18
18
|
index,
|
|
19
19
|
opacity,
|
|
@@ -54,7 +54,7 @@ export const getPropsForAnimated2DWithGradient = (props) => {
|
|
|
54
54
|
focusedBarConfig,
|
|
55
55
|
item.frontColor,
|
|
56
56
|
frontColor,
|
|
57
|
-
isThreeD
|
|
57
|
+
isThreeD
|
|
58
58
|
);
|
|
59
59
|
const localGradientColor = item.gradientColor || gradientColor;
|
|
60
60
|
const localOpacity = opacity || 1;
|
|
@@ -118,8 +118,8 @@ export const getPropsForAnimated2DWithGradient = (props) => {
|
|
|
118
118
|
const commonPropsFor2Dand3Dbars: CommonPropsFor2Dand3DbarsType = {
|
|
119
119
|
barBackgroundPattern: item.barBackgroundPattern || barBackgroundPattern,
|
|
120
120
|
barInnerComponent: isFocused
|
|
121
|
-
? focusedBarConfig?.barInnerComponent ??
|
|
122
|
-
:
|
|
121
|
+
? focusedBarConfig?.barInnerComponent ?? barInnerComponent
|
|
122
|
+
: barInnerComponent,
|
|
123
123
|
patternId: item.patternId || patternId,
|
|
124
124
|
barWidth: localBarWidth,
|
|
125
125
|
barStyle: barStyle,
|
package/src/BarChart/index.ts
CHANGED
|
@@ -602,6 +602,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
602
602
|
patternId: props.patternId,
|
|
603
603
|
onPress: props.onPress,
|
|
604
604
|
onLongPress: props.onLongPress,
|
|
605
|
+
onPressOut: props.onPressOut,
|
|
605
606
|
focusBarOnPress: props.focusBarOnPress,
|
|
606
607
|
focusedBarConfig: props.focusedBarConfig,
|
|
607
608
|
xAxisTextNumberOfLines: xAxisTextNumberOfLines,
|
|
@@ -613,6 +614,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
613
614
|
selectedIndex: selectedIndex,
|
|
614
615
|
setSelectedIndex: setSelectedIndex,
|
|
615
616
|
activeOpacity: props.activeOpacity || 0.2,
|
|
617
|
+
noOfSectionsBelowXAxis,
|
|
616
618
|
|
|
617
619
|
leftShiftForLastIndexTooltip: props.leftShiftForLastIndexTooltip || 0,
|
|
618
620
|
label:
|
package/src/BarChart/types.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { Component, ReactNode } from "react";
|
|
|
13
13
|
export type stackDataItem = {
|
|
14
14
|
onPress?: any;
|
|
15
15
|
onLongPress?: any;
|
|
16
|
+
onPressOut?: any;
|
|
16
17
|
label?: String;
|
|
17
18
|
barWidth?: number;
|
|
18
19
|
spacing?: number;
|
|
@@ -77,6 +78,7 @@ export type StackedBarChartPropsType = {
|
|
|
77
78
|
barWidth?: number;
|
|
78
79
|
onPress?: Function;
|
|
79
80
|
onLongPress?: Function;
|
|
81
|
+
onPressOut?: Function;
|
|
80
82
|
|
|
81
83
|
rotateLabel?: boolean;
|
|
82
84
|
showXAxisIndices: boolean;
|
|
@@ -280,6 +282,7 @@ export type BarChartPropsType = {
|
|
|
280
282
|
barMarginBottom?: number;
|
|
281
283
|
onPress?: Function;
|
|
282
284
|
onLongPress?: Function;
|
|
285
|
+
onPressOut?: Function;
|
|
283
286
|
renderTooltip?: Function;
|
|
284
287
|
leftShiftForTooltip?: number;
|
|
285
288
|
leftShiftForLastIndexTooltip?: number;
|
|
@@ -298,6 +301,7 @@ export type BarChartPropsType = {
|
|
|
298
301
|
onEndReached?: () => void;
|
|
299
302
|
onStartReached?: () => void;
|
|
300
303
|
endReachedOffset?: number;
|
|
304
|
+
onScroll?: Function;
|
|
301
305
|
|
|
302
306
|
focusBarOnPress?: boolean;
|
|
303
307
|
focusedBarConfig?: FocusedBarConfig;
|
|
@@ -392,6 +396,7 @@ export type barDataItem = {
|
|
|
392
396
|
value: number;
|
|
393
397
|
onPress?: any;
|
|
394
398
|
onLongPress?: any;
|
|
399
|
+
onPressOut?: any;
|
|
395
400
|
frontColor?: ColorValue;
|
|
396
401
|
sideColor?: ColorValue;
|
|
397
402
|
topColor?: ColorValue;
|
|
@@ -532,6 +537,7 @@ export type RenderBarsPropsType = {
|
|
|
532
537
|
barMarginBottom?: number;
|
|
533
538
|
onPress?: Function;
|
|
534
539
|
onLongPress?: Function;
|
|
540
|
+
onPressOut?: Function;
|
|
535
541
|
xAxisTextNumberOfLines: number;
|
|
536
542
|
xAxisLabelsHeight?: number;
|
|
537
543
|
xAxisLabelsVerticalShift: number;
|
|
@@ -545,6 +551,7 @@ export type RenderBarsPropsType = {
|
|
|
545
551
|
xAxisThickness?: number;
|
|
546
552
|
pointerConfig?: Pointer;
|
|
547
553
|
focusBarOnPress?: boolean;
|
|
554
|
+
noOfSectionsBelowXAxis?: number;
|
|
548
555
|
};
|
|
549
556
|
|
|
550
557
|
export type trianglePropTypes = {
|
package/src/LineChart/index.ts
CHANGED
|
@@ -1571,7 +1571,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1571
1571
|
const stepHeight = props.stepHeight || containerHeight / noOfSections;
|
|
1572
1572
|
const stepValue = props.stepValue || maxValue / noOfSections;
|
|
1573
1573
|
const noOfSectionsBelowXAxis =
|
|
1574
|
-
props.noOfSectionsBelowXAxis
|
|
1574
|
+
props.noOfSectionsBelowXAxis ?? -mostNegativeValue / (stepValue || 1);
|
|
1575
1575
|
|
|
1576
1576
|
const showXAxisIndices =
|
|
1577
1577
|
props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices;
|
package/src/LineChart/types.ts
CHANGED
|
@@ -319,6 +319,7 @@ export type LineChartPropsType = {
|
|
|
319
319
|
onEndReached?: () => void;
|
|
320
320
|
onStartReached?: () => void;
|
|
321
321
|
endReachedOffset?: number;
|
|
322
|
+
onScroll?: Function;
|
|
322
323
|
|
|
323
324
|
showDataPointsForMissingValues?: boolean;
|
|
324
325
|
interpolateMissingValues?: boolean;
|
|
@@ -580,4 +581,5 @@ export type LineChartBicolorPropsType = {
|
|
|
580
581
|
adjustToWidth?: boolean;
|
|
581
582
|
getPointerProps?: Function;
|
|
582
583
|
formatYLabel?: (label: string) => string;
|
|
584
|
+
onScroll?: Function;
|
|
583
585
|
};
|
package/src/PieChart/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import { PieChartPropsType } from "./types";
|
|
3
|
+
import { getTextSizeForPieLabels } from "../utils";
|
|
3
4
|
|
|
4
5
|
export const usePieChart = (props: PieChartPropsType) => {
|
|
5
6
|
const radius = props.radius || 120;
|
|
@@ -88,6 +89,16 @@ export const usePieChart = (props: PieChartPropsType) => {
|
|
|
88
89
|
isDataShifted = true;
|
|
89
90
|
}
|
|
90
91
|
});
|
|
92
|
+
const textSize = getTextSizeForPieLabels(props.textSize ?? 0, radius);
|
|
93
|
+
|
|
94
|
+
const paddingHorizontal =
|
|
95
|
+
props.paddingHorizontal ?? props.labelsPosition === "onBorder"
|
|
96
|
+
? (props.textBackgroundRadius ?? textSize) * 2 + 6
|
|
97
|
+
: 0;
|
|
98
|
+
const paddingVertical =
|
|
99
|
+
props.paddingVertical ?? props.labelsPosition === "onBorder"
|
|
100
|
+
? (props.textBackgroundRadius ?? textSize) * 2 + 6
|
|
101
|
+
: 0;
|
|
91
102
|
|
|
92
103
|
return {
|
|
93
104
|
radius,
|
|
@@ -115,5 +126,7 @@ export const usePieChart = (props: PieChartPropsType) => {
|
|
|
115
126
|
shiftInnerCenterY,
|
|
116
127
|
tiltAngle,
|
|
117
128
|
isDataShifted,
|
|
129
|
+
paddingHorizontal,
|
|
130
|
+
paddingVertical,
|
|
118
131
|
};
|
|
119
132
|
};
|
package/src/PieChart/main.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { getTextSizeForPieLabels } from "../utils";
|
|
1
2
|
import { PieChartMainProps, pieDataItem } from "./types";
|
|
2
3
|
|
|
3
4
|
export const getPieChartMainProps = (props: PieChartMainProps) => {
|
|
4
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
isThreeD,
|
|
7
|
+
isBiggerPie,
|
|
8
|
+
paddingHorizontal,
|
|
9
|
+
paddingVertical,
|
|
10
|
+
extraRadiusForFocused,
|
|
11
|
+
} = props;
|
|
5
12
|
const propData = props.data;
|
|
6
13
|
const data: Array<pieDataItem> = [];
|
|
7
14
|
let itemHasInnerComponent = false;
|
|
@@ -41,8 +48,7 @@ export const getPieChartMainProps = (props: PieChartMainProps) => {
|
|
|
41
48
|
|
|
42
49
|
const showText = props.showText || false;
|
|
43
50
|
const textColor = props.textColor || "";
|
|
44
|
-
const textSize = props.textSize
|
|
45
|
-
|
|
51
|
+
const textSize = getTextSizeForPieLabels(props.textSize ?? 0, radius);
|
|
46
52
|
let tiltAngle = props.tiltAngle || "55deg";
|
|
47
53
|
if (
|
|
48
54
|
tiltAngle &&
|
|
@@ -160,5 +166,8 @@ export const getPieChartMainProps = (props: PieChartMainProps) => {
|
|
|
160
166
|
pData,
|
|
161
167
|
mData,
|
|
162
168
|
acc,
|
|
169
|
+
paddingHorizontal,
|
|
170
|
+
paddingVertical,
|
|
171
|
+
extraRadiusForFocused,
|
|
163
172
|
};
|
|
164
173
|
};
|
package/src/PieChart/types.ts
CHANGED
|
@@ -49,6 +49,8 @@ export type PieChartPropsType = {
|
|
|
49
49
|
pieInnerComponent?: (item?: pieDataItem, index?: number) => any;
|
|
50
50
|
pieInnerComponentHeight?: number;
|
|
51
51
|
pieInnerComponentWidth?: number;
|
|
52
|
+
paddingHorizontal?: number;
|
|
53
|
+
paddingVertical?: number;
|
|
52
54
|
};
|
|
53
55
|
export type pieDataItem = {
|
|
54
56
|
value: number;
|
|
@@ -79,4 +81,7 @@ export type pieDataItem = {
|
|
|
79
81
|
export interface PieChartMainProps extends PieChartPropsType {
|
|
80
82
|
setSelectedIndex: Function;
|
|
81
83
|
isBiggerPie?: boolean;
|
|
84
|
+
paddingHorizontal: number;
|
|
85
|
+
paddingVertical: number;
|
|
86
|
+
extraRadiusForFocused: number;
|
|
82
87
|
}
|
package/src/utils/index.tsx
CHANGED