首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用react-native-svg-charts的多折线图

使用react-native-svg-charts的多折线图
EN

Stack Overflow用户
提问于 2019-11-28 06:10:34
回答 1查看 4.1K关注 0票数 6

我正在尝试将多个折线图放在一个图中显示不同的数据,但无法在使用react-native-svg-charts的react-native中执行此操作。

代码语言:javascript
复制
<View style= {{height: 200}}>
      <LineChart 
        style={{ flex:1 }}
                data={this.state.data}
                svg={{ stroke: 'rgb(134, 65, 244)' }}
                contentInset={{ top: 20, bottom: 20 }}
            >
            <Grid/>
      </LineChart>
      <LineChart 
        style={{position: 'absolute'}}
                data={this.state.data1}
                svg={{ stroke: 'rgb(168, 155, 50)' }}
                contentInset={{ top: 20, bottom: 20 }}
            >
            <Grid/>
      </LineChart>
      </View>

上面的代码是我正在尝试的,但我无法获得正确的设计,因为我只获得了第一个数据的折线图。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2019-12-06 14:27:40

代码语言:javascript
复制
render() {

    const data1 = [ 50, 10, 40, 95, -4, -24, 85, 91, 35, 53, -53, 24, 50, -20, -80 ]
    const data2 = [ -87, 66, -69, 92, -40, -61, 16, 62, 20, -93, -54, 47, -89, -44, 18 ]

    const data = [
        {
            data: data1,
            svg: { stroke: '#8800cc' },
        },
        {
            data: data2,
            svg: { stroke: 'green' },
        },
    ]

    return (
        <LineChart
            style={{ height: 200 }}
            data={ data }
            contentInset={{ top: 20, bottom: 20 }}
        >
            <Grid />
        </LineChart>
    )
}
票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59079119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档