react-native-gifted-charts 1.0.9 → 1.0.12
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/README.md +2 -2
- package/package.json +2 -2
- package/src/BarChart/index.tsx +3 -0
- package/src/LineChart/index.tsx +90 -20
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# react-native-gifted-charts [](https://openbase.com/js/react-native-gifted-charts?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)
|
|
2
2
|
|
|
3
|
-
The most complete library for Bar, Line, Area, Pie, and
|
|
3
|
+
The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.
|
|
4
4
|
|
|
5
5
|
### Yet another chart library? Why?
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ The most complete library for Bar, Line, Area, Pie, and Donut charts in React Na
|
|
|
22
22
|
<img src='/demos/animatedDataLine.gif' alt='' width=300/>
|
|
23
23
|
<img src='/demos/pielabbelled.svg' alt='' height=280 width=270/>
|
|
24
24
|
<img src='/demos/movingBars.gif' alt='' width=300/>
|
|
25
|
-
<img src='/demos/
|
|
25
|
+
<img src='/demos/stacks.png' alt='' height=360 width=320/>
|
|
26
26
|

|
|
27
27
|
<img src='/demos/cappedCombined.png' alt='' height=280 width=280/>
|
|
28
28
|
<img src='/demos/line.gif' alt='' height=300 width=290/>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "The most complete library for Bar, Line, Area, Pie and
|
|
3
|
+
"version": "1.0.12",
|
|
4
|
+
"description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"files": [
|
|
7
7
|
"src"
|
package/src/BarChart/index.tsx
CHANGED
|
@@ -44,6 +44,7 @@ type PropTypes = {
|
|
|
44
44
|
xAxisColor?: ColorValue;
|
|
45
45
|
yAxisThickness?: number;
|
|
46
46
|
yAxisColor?: ColorValue;
|
|
47
|
+
yAxisLabelContainerStyle?: any;
|
|
47
48
|
yAxisTextStyle?: any;
|
|
48
49
|
yAxisLabelWidth?: number;
|
|
49
50
|
hideYAxisText?: Boolean;
|
|
@@ -360,6 +361,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
360
361
|
: props.yAxisThickness || 1;
|
|
361
362
|
const yAxisColor = props.yAxisColor || 'black';
|
|
362
363
|
const yAxisTextStyle = props.yAxisTextStyle;
|
|
364
|
+
const yAxisLabelContainerStyle = props.yAxisLabelContainerStyle;
|
|
363
365
|
const showFractionalValues = props.showFractionalValues || false;
|
|
364
366
|
const yAxisLabelWidth = props.yAxisLabelWidth || 35;
|
|
365
367
|
const hideYAxisText = props.hideYAxisText || false;
|
|
@@ -647,6 +649,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
647
649
|
index === noOfSections ? stepHeight / 2 : stepHeight,
|
|
648
650
|
width: yAxisLabelWidth,
|
|
649
651
|
},
|
|
652
|
+
yAxisLabelContainerStyle,
|
|
650
653
|
]}>
|
|
651
654
|
{!hideYAxisText ? (
|
|
652
655
|
<Text
|
package/src/LineChart/index.tsx
CHANGED
|
@@ -49,6 +49,12 @@ type propTypes = {
|
|
|
49
49
|
thickness3?: number;
|
|
50
50
|
thickness4?: number;
|
|
51
51
|
thickness5?: number;
|
|
52
|
+
strokeDashArray?: Array<number>;
|
|
53
|
+
strokeDashArray1?: Array<number>;
|
|
54
|
+
strokeDashArray2?: Array<number>;
|
|
55
|
+
strokeDashArray3?: Array<number>;
|
|
56
|
+
strokeDashArray4?: Array<number>;
|
|
57
|
+
strokeDashArray5?: Array<number>;
|
|
52
58
|
rotateLabel?: Boolean;
|
|
53
59
|
isAnimated?: Boolean;
|
|
54
60
|
animateOnDataChange?: Boolean;
|
|
@@ -93,6 +99,7 @@ type propTypes = {
|
|
|
93
99
|
referenceLine5Position?: number;
|
|
94
100
|
|
|
95
101
|
showVerticalLines?: Boolean;
|
|
102
|
+
verticalLinesUptoDataPoint?: Boolean;
|
|
96
103
|
verticalLinesThickness?: number;
|
|
97
104
|
verticalLinesColor?: ColorValue;
|
|
98
105
|
verticalLinesZIndex?: number;
|
|
@@ -135,6 +142,7 @@ type propTypes = {
|
|
|
135
142
|
color5?: string;
|
|
136
143
|
yAxisThickness?: number;
|
|
137
144
|
yAxisColor?: ColorValue;
|
|
145
|
+
yAxisLabelContainerStyle?: any;
|
|
138
146
|
yAxisTextStyle?: any;
|
|
139
147
|
showFractionalValues?: Boolean;
|
|
140
148
|
roundToDigits?: number;
|
|
@@ -291,6 +299,7 @@ type itemType = {
|
|
|
291
299
|
showStrip?: Boolean;
|
|
292
300
|
|
|
293
301
|
showVerticalLine?: Boolean;
|
|
302
|
+
verticalLineUptoDataPoint?: Boolean;
|
|
294
303
|
verticalLineColor?: string;
|
|
295
304
|
verticalLineThickness?: number;
|
|
296
305
|
};
|
|
@@ -1114,11 +1123,18 @@ export const LineChart = (props: propTypes) => {
|
|
|
1114
1123
|
const stepValue = props.stepValue || maxValue / noOfSections;
|
|
1115
1124
|
const noOfSectionsBelowXAxis =
|
|
1116
1125
|
props.noOfSectionsBelowXAxis || -minValue / stepValue;
|
|
1117
|
-
const thickness1 = props.thickness1;
|
|
1118
|
-
const thickness2 = props.thickness2;
|
|
1119
|
-
const thickness3 = props.thickness3;
|
|
1120
|
-
const thickness4 = props.thickness4;
|
|
1121
|
-
const thickness5 = props.thickness5;
|
|
1126
|
+
const thickness1 = props.thickness1 === 0 ? 0 : props.thickness || 1;
|
|
1127
|
+
const thickness2 = props.thickness2 === 0 ? 0 : props.thickness || 1;
|
|
1128
|
+
const thickness3 = props.thickness3 === 0 ? 0 : props.thickness || 1;
|
|
1129
|
+
const thickness4 = props.thickness4 === 0 ? 0 : props.thickness || 1;
|
|
1130
|
+
const thickness5 = props.thickness5 === 0 ? 0 : props.thickness || 1;
|
|
1131
|
+
|
|
1132
|
+
const strokeDashArray1 = props.strokeDashArray1 || props.strokeDashArray;
|
|
1133
|
+
const strokeDashArray2 = props.strokeDashArray2 || props.strokeDashArray;
|
|
1134
|
+
const strokeDashArray3 = props.strokeDashArray3 || props.strokeDashArray;
|
|
1135
|
+
const strokeDashArray4 = props.strokeDashArray4 || props.strokeDashArray;
|
|
1136
|
+
const strokeDashArray5 = props.strokeDashArray5 || props.strokeDashArray;
|
|
1137
|
+
|
|
1122
1138
|
const rotateLabel = props.rotateLabel || false;
|
|
1123
1139
|
const isAnimated = props.isAnimated || false;
|
|
1124
1140
|
const hideDataPoints1 =
|
|
@@ -1182,6 +1198,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1182
1198
|
|
|
1183
1199
|
const hideRules = props.hideRules || false;
|
|
1184
1200
|
const showVerticalLines = props.showVerticalLines || false;
|
|
1201
|
+
const verticalLinesUptoDataPoint = props.verticalLinesUptoDataPoint || false;
|
|
1185
1202
|
|
|
1186
1203
|
const showYAxisIndices = props.showYAxisIndices || false;
|
|
1187
1204
|
const showXAxisIndices = props.showXAxisIndices || false;
|
|
@@ -1195,6 +1212,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1195
1212
|
const yAxisThickness = props.yAxisThickness || 1;
|
|
1196
1213
|
const yAxisColor = props.yAxisColor || 'black';
|
|
1197
1214
|
const yAxisTextStyle = props.yAxisTextStyle;
|
|
1215
|
+
const yAxisLabelContainerStyle = props.yAxisLabelContainerStyle;
|
|
1198
1216
|
const showFractionalValues = props.showFractionalValues || false;
|
|
1199
1217
|
const yAxisLabelWidth = props.yAxisLabelWidth || 35;
|
|
1200
1218
|
const hideYAxisText = props.hideYAxisText || false;
|
|
@@ -1467,6 +1485,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1467
1485
|
index === noOfSections ? stepHeight / 2 : stepHeight,
|
|
1468
1486
|
width: yAxisLabelWidth,
|
|
1469
1487
|
},
|
|
1488
|
+
yAxisLabelContainerStyle,
|
|
1470
1489
|
]}>
|
|
1471
1490
|
{!hideYAxisText ? (
|
|
1472
1491
|
<Text
|
|
@@ -1904,9 +1923,19 @@ export const LineChart = (props: propTypes) => {
|
|
|
1904
1923
|
1 +
|
|
1905
1924
|
spacing * index
|
|
1906
1925
|
}
|
|
1907
|
-
y={
|
|
1926
|
+
y={
|
|
1927
|
+
item.verticalLineUptoDataPoint
|
|
1928
|
+
? containerHeight -
|
|
1929
|
+
(item.value * containerHeight) / maxValue +
|
|
1930
|
+
10
|
|
1931
|
+
: -xAxisThickness
|
|
1932
|
+
}
|
|
1908
1933
|
width={item.verticalLineThickness || 1}
|
|
1909
|
-
height={
|
|
1934
|
+
height={
|
|
1935
|
+
item.verticalLineUptoDataPoint
|
|
1936
|
+
? (item.value * containerHeight) / maxValue - xAxisThickness
|
|
1937
|
+
: containerHeight + 10 - xAxisThickness
|
|
1938
|
+
}
|
|
1910
1939
|
fill={item.verticalLineColor || 'lightgray'}
|
|
1911
1940
|
/>
|
|
1912
1941
|
);
|
|
@@ -1924,6 +1953,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1924
1953
|
endFillColor: string,
|
|
1925
1954
|
startOpacity: number,
|
|
1926
1955
|
endOpacity: number,
|
|
1956
|
+
strokeDashArray: Array<number> | undefined | null,
|
|
1927
1957
|
) => {
|
|
1928
1958
|
return (
|
|
1929
1959
|
<View
|
|
@@ -1936,12 +1966,25 @@ export const LineChart = (props: propTypes) => {
|
|
|
1936
1966
|
// backgroundColor: 'rgba(200,150,150,0.6)'
|
|
1937
1967
|
}}>
|
|
1938
1968
|
<Svg>
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1969
|
+
{strokeDashArray &&
|
|
1970
|
+
strokeDashArray.length === 2 &&
|
|
1971
|
+
typeof strokeDashArray[0] === 'number' &&
|
|
1972
|
+
typeof strokeDashArray[1] === 'number' ? (
|
|
1973
|
+
<Path
|
|
1974
|
+
d={points}
|
|
1975
|
+
fill="none"
|
|
1976
|
+
stroke={color}
|
|
1977
|
+
strokeWidth={currentLineThickness || thickness}
|
|
1978
|
+
strokeDasharray={strokeDashArray}
|
|
1979
|
+
/>
|
|
1980
|
+
) : (
|
|
1981
|
+
<Path
|
|
1982
|
+
d={points}
|
|
1983
|
+
fill="none"
|
|
1984
|
+
stroke={color}
|
|
1985
|
+
strokeWidth={currentLineThickness || thickness}
|
|
1986
|
+
/>
|
|
1987
|
+
)}
|
|
1945
1988
|
|
|
1946
1989
|
{/*********************** For Area Chart ************/}
|
|
1947
1990
|
|
|
@@ -2067,6 +2110,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2067
2110
|
endFillColor: string,
|
|
2068
2111
|
startOpacity: number,
|
|
2069
2112
|
endOpacity: number,
|
|
2113
|
+
strokeDashArray: Array<number> | undefined | null,
|
|
2070
2114
|
) => {
|
|
2071
2115
|
// console.log('animatedWidth is-------->', animatedWidth);
|
|
2072
2116
|
return (
|
|
@@ -2080,12 +2124,25 @@ export const LineChart = (props: propTypes) => {
|
|
|
2080
2124
|
// backgroundColor: 'wheat',
|
|
2081
2125
|
}}>
|
|
2082
2126
|
<Svg>
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2127
|
+
{strokeDashArray &&
|
|
2128
|
+
strokeDashArray.length === 2 &&
|
|
2129
|
+
typeof strokeDashArray[0] === 'number' &&
|
|
2130
|
+
typeof strokeDashArray[1] === 'number' ? (
|
|
2131
|
+
<Path
|
|
2132
|
+
d={points}
|
|
2133
|
+
fill="none"
|
|
2134
|
+
stroke={color}
|
|
2135
|
+
strokeWidth={currentLineThickness || thickness}
|
|
2136
|
+
strokeDasharray={strokeDashArray}
|
|
2137
|
+
/>
|
|
2138
|
+
) : (
|
|
2139
|
+
<Path
|
|
2140
|
+
d={points}
|
|
2141
|
+
fill="none"
|
|
2142
|
+
stroke={color}
|
|
2143
|
+
strokeWidth={currentLineThickness || thickness}
|
|
2144
|
+
/>
|
|
2145
|
+
)}
|
|
2089
2146
|
|
|
2090
2147
|
{/*********************** For Area Chart ************/}
|
|
2091
2148
|
|
|
@@ -2250,7 +2307,10 @@ export const LineChart = (props: propTypes) => {
|
|
|
2250
2307
|
style={{
|
|
2251
2308
|
position: 'absolute',
|
|
2252
2309
|
zIndex: verticalLinesZIndex || -1,
|
|
2253
|
-
|
|
2310
|
+
marginBottom: xAxisThickness,
|
|
2311
|
+
height: verticalLinesUptoDataPoint
|
|
2312
|
+
? (item.value * containerHeight) / maxValue - xAxisThickness
|
|
2313
|
+
: containerHeight + 15 - xAxisThickness,
|
|
2254
2314
|
width: verticalLinesThickness,
|
|
2255
2315
|
backgroundColor: verticalLinesColor,
|
|
2256
2316
|
bottom: 60,
|
|
@@ -2292,6 +2352,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2292
2352
|
endFillColor1,
|
|
2293
2353
|
startOpacity1,
|
|
2294
2354
|
endOpacity1,
|
|
2355
|
+
strokeDashArray1,
|
|
2295
2356
|
)
|
|
2296
2357
|
: renderLine(
|
|
2297
2358
|
points,
|
|
@@ -2302,6 +2363,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2302
2363
|
endFillColor1,
|
|
2303
2364
|
startOpacity1,
|
|
2304
2365
|
endOpacity1,
|
|
2366
|
+
strokeDashArray1,
|
|
2305
2367
|
)}
|
|
2306
2368
|
{points2
|
|
2307
2369
|
? isAnimated
|
|
@@ -2315,6 +2377,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2315
2377
|
endFillColor2,
|
|
2316
2378
|
startOpacity2,
|
|
2317
2379
|
endOpacity2,
|
|
2380
|
+
strokeDashArray2,
|
|
2318
2381
|
)
|
|
2319
2382
|
: renderLine(
|
|
2320
2383
|
points2,
|
|
@@ -2325,6 +2388,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2325
2388
|
endFillColor2,
|
|
2326
2389
|
startOpacity2,
|
|
2327
2390
|
endOpacity2,
|
|
2391
|
+
strokeDashArray2,
|
|
2328
2392
|
)
|
|
2329
2393
|
: null}
|
|
2330
2394
|
{points3
|
|
@@ -2339,6 +2403,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2339
2403
|
endFillColor3,
|
|
2340
2404
|
startOpacity3,
|
|
2341
2405
|
endOpacity3,
|
|
2406
|
+
strokeDashArray3,
|
|
2342
2407
|
)
|
|
2343
2408
|
: renderLine(
|
|
2344
2409
|
points3,
|
|
@@ -2349,6 +2414,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2349
2414
|
endFillColor3,
|
|
2350
2415
|
startOpacity3,
|
|
2351
2416
|
endOpacity3,
|
|
2417
|
+
strokeDashArray3,
|
|
2352
2418
|
)
|
|
2353
2419
|
: null}
|
|
2354
2420
|
{points4
|
|
@@ -2363,6 +2429,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2363
2429
|
endFillColor4,
|
|
2364
2430
|
startOpacity4,
|
|
2365
2431
|
endOpacity4,
|
|
2432
|
+
strokeDashArray4,
|
|
2366
2433
|
)
|
|
2367
2434
|
: renderLine(
|
|
2368
2435
|
points4,
|
|
@@ -2373,6 +2440,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2373
2440
|
endFillColor4,
|
|
2374
2441
|
startOpacity4,
|
|
2375
2442
|
endOpacity4,
|
|
2443
|
+
strokeDashArray4,
|
|
2376
2444
|
)
|
|
2377
2445
|
: null}
|
|
2378
2446
|
{points5
|
|
@@ -2387,6 +2455,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2387
2455
|
endFillColor5,
|
|
2388
2456
|
startOpacity5,
|
|
2389
2457
|
endOpacity5,
|
|
2458
|
+
strokeDashArray5,
|
|
2390
2459
|
)
|
|
2391
2460
|
: renderLine(
|
|
2392
2461
|
points5,
|
|
@@ -2397,6 +2466,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2397
2466
|
endFillColor5,
|
|
2398
2467
|
startOpacity5,
|
|
2399
2468
|
endOpacity5,
|
|
2469
|
+
strokeDashArray5,
|
|
2400
2470
|
)
|
|
2401
2471
|
: null}
|
|
2402
2472
|
{data.map((item: itemType, index: number) => {
|