react-native-chart-kit 问题检查渲染方法
react-native-chart-kit issue check the render method
我正在测试包 react-native-chart-kit,我按照教程只是为了看看它的样子,但我无法让它正常工作。我也试过饼图和条形图,但仍然是同样的错误。你能指导我检查一下有什么问题吗:
import React from 'react'
import { Text, View, TouchableOpacity, Dimensions } from 'react-native'
import LineChart from 'react-native-chart-kit'
const screenWidth = Dimensions.get("window").width;
const linedata = {
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
datasets: [
{
data: [20, 45, 28, 80, 99, 43],
strokeWidth: 2, // optional
},
],
};
export default function Linechart() {
return (
<View>
<Text>
Bezier Line Chart
</Text>
<LineChart
data={linedata}
width={Dimensions.get('window').width} // from react-native
height={220}
yAxisLabel={'$'}
chartConfig={{
backgroundColor: '#e26a00',
backgroundGradientFrom: '#fb8c00',
backgroundGradientTo: '#ffa726',
decimalPlaces: 2, // optional, defaults to 2dp
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
style: {
borderRadius: 16
}
}}
bezier
style={{
marginVertical: 8,
borderRadius: 16
}}
/>
</View>
);
}
只需将其导入大括号内即可。
import { LineChart } from 'react-native-chart-kit';
无论何时看到此错误消息,最好首先怀疑是否存在错误的导入语句。
我正在测试包 react-native-chart-kit,我按照教程只是为了看看它的样子,但我无法让它正常工作。我也试过饼图和条形图,但仍然是同样的错误。你能指导我检查一下有什么问题吗:
import React from 'react'
import { Text, View, TouchableOpacity, Dimensions } from 'react-native'
import LineChart from 'react-native-chart-kit'
const screenWidth = Dimensions.get("window").width;
const linedata = {
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
datasets: [
{
data: [20, 45, 28, 80, 99, 43],
strokeWidth: 2, // optional
},
],
};
export default function Linechart() {
return (
<View>
<Text>
Bezier Line Chart
</Text>
<LineChart
data={linedata}
width={Dimensions.get('window').width} // from react-native
height={220}
yAxisLabel={'$'}
chartConfig={{
backgroundColor: '#e26a00',
backgroundGradientFrom: '#fb8c00',
backgroundGradientTo: '#ffa726',
decimalPlaces: 2, // optional, defaults to 2dp
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
style: {
borderRadius: 16
}
}}
bezier
style={{
marginVertical: 8,
borderRadius: 16
}}
/>
</View>
);
}
只需将其导入大括号内即可。
import { LineChart } from 'react-native-chart-kit';
无论何时看到此错误消息,最好首先怀疑是否存在错误的导入语句。