react-native-gifted-charts 1.4.19 → 1.4.20
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
CHANGED
|
@@ -23,6 +23,8 @@ The exact same piece of code that you write to render charts in react-native, ca
|
|
|
23
23
|
|
|
24
24
|
## [Release notes 🎉](release-notes/release-notes.md)
|
|
25
25
|
|
|
26
|
+
See the **[release changes by version here.](release-notes/release-notes.md)**
|
|
27
|
+
|
|
26
28
|
|
|
27
29
|
<img src='/demos/bars.png' alt=''/>
|
|
28
30
|
<img src='/demos/lineArea.png' alt=''/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.20",
|
|
4
4
|
"description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Population Pyramid charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"files": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"registry": "https://registry.npmjs.org/"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"gifted-charts-core": "^0.1.
|
|
28
|
+
"gifted-charts-core": "^0.1.19"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/core": "^7.22.5",
|
|
@@ -4,8 +4,10 @@ import Svg, {Path} from 'react-native-svg';
|
|
|
4
4
|
import {renderSpecificVerticalLines} from './renderSpecificVerticalLines';
|
|
5
5
|
import {renderDataPoints} from './renderDataPoints';
|
|
6
6
|
import {renderSpecificDataPoints} from './renderSpecificDataPoints';
|
|
7
|
+
import {LineInBarChartPropsType} from 'gifted-charts-core';
|
|
8
|
+
import {DataPointProps} from 'gifted-charts-core';
|
|
7
9
|
|
|
8
|
-
const RenderLineInBarChart = (props:
|
|
10
|
+
const RenderLineInBarChart = (props: LineInBarChartPropsType) => {
|
|
9
11
|
const {
|
|
10
12
|
yAxisLabelWidth,
|
|
11
13
|
initialSpacing,
|
|
@@ -22,11 +24,12 @@ const RenderLineInBarChart = (props: any) => {
|
|
|
22
24
|
barWidth,
|
|
23
25
|
labelsExtraHeight,
|
|
24
26
|
xAxisLabelsVerticalShift,
|
|
27
|
+
selectedIndex,
|
|
25
28
|
} = props;
|
|
26
29
|
|
|
27
30
|
const firstBarWidth = data[0].barWidth ?? barWidth;
|
|
28
31
|
|
|
29
|
-
const dataPointsProps = {
|
|
32
|
+
const dataPointsProps: DataPointProps = {
|
|
30
33
|
data,
|
|
31
34
|
lineConfig,
|
|
32
35
|
barWidth,
|
|
@@ -35,6 +38,7 @@ const RenderLineInBarChart = (props: any) => {
|
|
|
35
38
|
firstBarWidth,
|
|
36
39
|
yAxisLabelWidth,
|
|
37
40
|
spacing,
|
|
41
|
+
selectedIndex,
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
const specificVerticalLinesProps = {
|
|
@@ -89,9 +93,9 @@ const RenderLineInBarChart = (props: any) => {
|
|
|
89
93
|
{lineConfig.showArrow && (
|
|
90
94
|
<Path
|
|
91
95
|
d={arrowPoints}
|
|
92
|
-
fill={lineConfig.arrowConfig
|
|
93
|
-
stroke={lineConfig.arrowConfig
|
|
94
|
-
strokeWidth={lineConfig.arrowConfig
|
|
96
|
+
fill={lineConfig.arrowConfig?.fillColor}
|
|
97
|
+
stroke={lineConfig.arrowConfig?.strokeColor}
|
|
98
|
+
strokeWidth={lineConfig.arrowConfig?.strokeWidth}
|
|
95
99
|
/>
|
|
96
100
|
)}
|
|
97
101
|
</Svg>
|
|
@@ -127,9 +131,9 @@ const RenderLineInBarChart = (props: any) => {
|
|
|
127
131
|
{lineConfig.showArrow && (
|
|
128
132
|
<Path
|
|
129
133
|
d={arrowPoints}
|
|
130
|
-
fill={lineConfig.arrowConfig
|
|
131
|
-
stroke={lineConfig.arrowConfig
|
|
132
|
-
strokeWidth={lineConfig.arrowConfig
|
|
134
|
+
fill={lineConfig.arrowConfig?.fillColor}
|
|
135
|
+
stroke={lineConfig.arrowConfig?.strokeColor}
|
|
136
|
+
strokeWidth={lineConfig.arrowConfig?.strokeWidth}
|
|
133
137
|
/>
|
|
134
138
|
)}
|
|
135
139
|
</Svg>
|
|
@@ -3,8 +3,9 @@ import {styles} from '../../../BarChart/styles';
|
|
|
3
3
|
import {View} from 'react-native';
|
|
4
4
|
import {getXForLineInBar, getYForLineInBar} from 'gifted-charts-core';
|
|
5
5
|
import {Rect, Text as CanvasText, Circle} from 'react-native-svg';
|
|
6
|
+
import {DataPointProps} from 'gifted-charts-core';
|
|
6
7
|
|
|
7
|
-
export const renderDataPoints = (props:
|
|
8
|
+
export const renderDataPoints = (props: DataPointProps) => {
|
|
8
9
|
const {
|
|
9
10
|
data,
|
|
10
11
|
lineConfig,
|
|
@@ -14,13 +15,29 @@ export const renderDataPoints = (props: any) => {
|
|
|
14
15
|
firstBarWidth,
|
|
15
16
|
yAxisLabelWidth,
|
|
16
17
|
spacing,
|
|
18
|
+
selectedIndex,
|
|
17
19
|
} = props;
|
|
18
20
|
return data.map((item: any, index: number) => {
|
|
19
|
-
if (
|
|
21
|
+
if (
|
|
22
|
+
index < lineConfig.startIndex ||
|
|
23
|
+
index > lineConfig.endIndex ||
|
|
24
|
+
item.hideDataPoint
|
|
25
|
+
) {
|
|
20
26
|
return null;
|
|
21
27
|
}
|
|
22
28
|
const currentBarWidth = item.barWidth || barWidth || 30;
|
|
23
29
|
const customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
|
|
30
|
+
const dataPointColor =
|
|
31
|
+
lineConfig.focusEnabled &&
|
|
32
|
+
index === (lineConfig.focusedDataPointIndex ?? selectedIndex)
|
|
33
|
+
? lineConfig.focusedDataPointColor
|
|
34
|
+
: lineConfig.dataPointsColor;
|
|
35
|
+
|
|
36
|
+
const dataPointRadius =
|
|
37
|
+
lineConfig.focusEnabled &&
|
|
38
|
+
index === (lineConfig.focusedDataPointIndex ?? selectedIndex)
|
|
39
|
+
? lineConfig.focusedDataPointRadius
|
|
40
|
+
: lineConfig.dataPointsRadius;
|
|
24
41
|
const value =
|
|
25
42
|
item.value ??
|
|
26
43
|
item.stacks.reduce((total: number, item: any) => total + item.value, 0);
|
|
@@ -73,7 +90,7 @@ export const renderDataPoints = (props: any) => {
|
|
|
73
90
|
}
|
|
74
91
|
width={lineConfig.dataPointsWidth}
|
|
75
92
|
height={lineConfig.dataPointsHeight}
|
|
76
|
-
fill={
|
|
93
|
+
fill={dataPointColor}
|
|
77
94
|
/>
|
|
78
95
|
{item.dataPointText && (
|
|
79
96
|
<CanvasText
|
|
@@ -122,8 +139,8 @@ export const renderDataPoints = (props: any) => {
|
|
|
122
139
|
containerHeight,
|
|
123
140
|
maxValue,
|
|
124
141
|
)}
|
|
125
|
-
r={
|
|
126
|
-
fill={
|
|
142
|
+
r={dataPointRadius}
|
|
143
|
+
fill={dataPointColor}
|
|
127
144
|
/>
|
|
128
145
|
{item.dataPointText && (
|
|
129
146
|
<CanvasText
|
package/src/LineChart/index.tsx
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
useLineChart,
|
|
35
35
|
adjustToOffset,
|
|
36
36
|
LineProperties,
|
|
37
|
+
LineDefaults,
|
|
37
38
|
} from 'gifted-charts-core';
|
|
38
39
|
import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
|
|
39
40
|
import {StripAndLabel} from '../Components/common/StripAndLabel';
|
|
@@ -626,7 +627,9 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
626
627
|
item.dataPointHeight ||
|
|
627
628
|
dataPtsHeight;
|
|
628
629
|
dataPointsColor =
|
|
629
|
-
item.focusedDataPointColor ||
|
|
630
|
+
item.focusedDataPointColor ||
|
|
631
|
+
props.focusedDataPointColor ||
|
|
632
|
+
LineDefaults.focusedDataPointColor;
|
|
630
633
|
dataPointsRadius =
|
|
631
634
|
item.focusedDataPointRadius ||
|
|
632
635
|
props.focusedDataPointRadius ||
|
|
@@ -1217,7 +1220,7 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
1217
1220
|
set.textFontSize ?? textFontSize1,
|
|
1218
1221
|
set.startIndex ?? 0,
|
|
1219
1222
|
set.endIndex ?? set.data.length - 1,
|
|
1220
|
-
|
|
1223
|
+
set.isSecondary,
|
|
1221
1224
|
showValuesAsDataPointsText,
|
|
1222
1225
|
);
|
|
1223
1226
|
}) ?? null}
|