gpt4 book ai didi

reactjs - 有没有一种方法可以在胜利折线图的最后一个数据点上绘制一个点以进行 native react

转载 作者:行者123 更新时间:2023-12-04 17:12:06 28 4
gpt4 key购买 nike

所以目前我有这个作为胜利线聊天的代码

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { VictoryLine, VictoryChart } from 'victory-native'

let data = [
{
x: 1,
y: 0
},
{
x: 2,
y: 0
},
{
x: 3,
y: 0
},
{
x: 4,
y: 70
},
{
x: 5,
y: 73
},
{
x: 5,
y: 73
},
{
x: 5,
y: 73
},
{
x: 5,
y: 73
}
]

export default function Graph() {
return (

<VictoryLine style={styles.graph} height={150} width={350} data={data} style={{data: {stroke: 'orange', strokeWidth: 2.5}}} />

)
}

const styles = StyleSheet.create({
graph: {
marginRight: 0
}
})

这给了我一个看起来像 this 的折线图.有没有办法:

A) 为每个数据点绘制线上的虚点

B) 只需在数据列表中点上最后一个数据点。这里的示例图片是什么 I want to achieve

最佳答案

您可以用 VictroyChart 包装您的 VictoryLine 并隐藏轴,像这样 sample

  <View>
<VictoryChart polar={this.state.polar} height={390}>
<VictoryAxis style={{
axis: {stroke: "transparent"},
ticks: {stroke: "transparent"},
tickLabels: { fill:"transparent"}
}} />
<VictoryLine
interpolation={this.state.interpolation} data={data}
style={{ data: { stroke: "#c43a31" } }}
/>
<VictoryScatter data={[data[data.length-1]]}
size={5}
style={{ data: { fill: "#c43a31" } }}
/>
</VictoryChart>
</View>

关于reactjs - 有没有一种方法可以在胜利折线图的最后一个数据点上绘制一个点以进行 native react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69233762/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com