【问题标题】:react-native-chart-kit issue check the render methodreact-native-chart-kit 问题检查渲染方法
【发布时间】:2021-02-11 03:31:34
【问题描述】:

我正在测试包 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>
  );
}

【问题讨论】:

    标签: react-native charts render


    【解决方案1】:

    只需在大括号内导入即可。

    import { LineChart } from 'react-native-chart-kit';
    

    每当您看到此错误消息时,最好先怀疑存在错误的导入语句。

    【讨论】:

    • 非常感谢...很抱歉错过了...很简单...非常感谢。
    猜你喜欢
    • 2020-05-31
    • 1970-01-01
    • 2021-10-31
    • 2021-08-17
    • 2021-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多