3

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

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
    }
})

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

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

B) 只需点在数据列表中的最后一个数据点。我想要实现的示例图片

4

1 回答 1

1

您可以用 VictroyChart 包装您的 VictoryLine 并隐藏轴,就像这个示例

  <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>
于 2021-09-18T13:22:29.153 回答