react-native - react-native-svg-charts 没有动画
问题描述
我使用 react-native-svg-charts 动画不起作用。这里的代码
function AnimusScreen () {
const [lineChartData, setLineChartData] = useState([
{
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
svg: { stroke: Colors.cosmic, strokeWidth: 1, },
}
])
const changea = ()=>{
setLineChartData([
{
data: [50, 10, 40, 95, -4, -24, 85, 50, -20, -80],
svg: { stroke: Colors.cosmic, strokeWidth: 1, },
}
])
}
return (
<View
style={{
flex: 1,
flexDirection: "column",
justifyContent: "center",
alignItems: "center"
}}
>
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
alignSelf: "stretch"
}}
>
<LineChart
style={{
flex: 1,
alignSelf: "stretch",
borderWidth: 1,
borderColor: "rgba(255,255,255,0.5)",
margin: 10
}}
data={lineChartData}
svg={{
strokeWidth: 2,
stroke: Colors.cosmic
}}
animate
/>
</View>
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
alignSelf: "stretch"
}}
>
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
alignSelf: "stretch"
}}
>
<Text>My Chart :D x</Text>
</View>
</View>
<TouchableOpacity
onPress={() => changea()}
>
<Text>Press Here</Text>
</TouchableOpacity>
</View>
);
}
export default AnimusScreen;
解决方案
推荐阅读
- html - WooCommerce 热收据打印显示 HTML 标签
- reactjs - 在 React 中使用 If 语句
- amazon-web-services - ECS Fargate 在从 SQS 接收消息时如何在可用任务之间分配流量?
- php - 如何覆盖 function.php 中的 WooCommerce 总运费?
- javascript - 如何在 iframe 中提醒而不在 iframe 之外放置代码?
- java - findFragmentById 是否接受 FrameLayout 而不是 Fragment?
- javascript - 使用扩展运算符从 API 操作/过滤对象的道具
- lua - 如何防止 renderBlocks() 函数进入无限循环?
- c# - 执行 .net 方法登录某些服务器而不是其他服务器
- google-data-studio - 如何在 Data Studio 中使用嵌入式报表创建 RLS 过滤器