react原生图表套件responsible不起作用



我试图使response的图表成为原生的,根据那里的文档,如果你想响应图表,你必须把代码放在下面。我检查了其他人的代码,但他们的代码有效。我试了很多,但我解决不了

import { Dimensions } from "react-native";
const screenWidth = Dimensions.get("window").width;
<LineChart
data={data}
width={screenWidth}
height={220}
chartConfig={chartConfig}
/>

但我试过和这个一样

const screenWidth = Dimensions.get("window").width;
<LineChart
data={{
labels: ["January", "February", "March", "April", "May", "June"],
datasets: [
{
data: [
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
],
},
],
}}
width={screenWidth} // from react-native
height={220}
/>
```
Can anyone help me why it is not working....

尝试使用useWindowDimensions

import { useWindowDimensions } from 'react-native';
const windowWidth = useWindowDimensions().width;
const windowHeight = useWindowDimensions().height;

相关内容

  • 没有找到相关文章

最新更新