不知道如何更改我的“react-native-svg-charts”中的x和y轴标签
创始人
2025-01-12 04:30:11
0

可以通过在组件中设置xAxisProps和yAxisProps来更改x和y轴标签。

例如:

import React from 'react'; import { View } from 'react-native'; import { LineChart, XAxis, YAxis } from 'react-native-svg-charts';

class Chart extends React.PureComponent {

render() {

    const data = [ 10, 15, 25, 20, 35, 25, 40, 50, 30, 45 ]

    const xAxisLabels = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct' ]
    const yAxisLabels = [ '$0', '$50', '$100', '$150', '$200' ]

    const axesSvg = { fontSize: 12, fill: 'grey' };
    const verticalContentInset = { top: 10, bottom: 10 };
    const xAxisHeight = 30;

    return (
        
             `$${value}`}
                {...this.props.yAxisProps}
            />
            
                
                     xAxisLabels[index]}
                        style={{ marginHorizontal: -10, height: xAxisHeight }}
                        contentInset={{ left: 10, right: 10 }}
                        svg={axesSvg}
                        {...this.props.xAxisProps}
                    />
                
            
        
    )
}

}

然后在调用图表时,可以传递xAxisProps和yAxisProps来设置标签。

例如:

这将设置x轴上的标签样式和y轴上的标签样式。

相关内容

热门资讯

透视资料!智星德州辅助译码插件... 透视资料!智星德州辅助译码插件靠谱吗(透视)pokemomo辅助工具(辅助)原来真的有方法(哔哩哔哩...
透视教程书!来玩app破解版(... 透视教程书!来玩app破解版(透视)sohoo竞技联盟辅助器(辅助)其实真的是有app(哔哩哔哩)1...
透视绝活儿!德州局怎么透视(透... 透视绝活儿!德州局怎么透视(透视)菠萝德州透视脚本(辅助)其实真的有攻略(哔哩哔哩)1、很好的工具软...
透视手册!聚星ai辅助工具收费... 透视手册!聚星ai辅助工具收费多少(透视)哈糖大菠萝免费辅助器(辅助)原来真的是有方法(哔哩哔哩)1...
透视模块!德州局透视脚本下载安... 透视模块!德州局透视脚本下载安装最新版本(透视)菠萝辅助器免费版的特点(辅助)都是一直都是有技巧(哔...
透视操作!werplan怎么作... 透视操作!werplan怎么作必弊(透视)werplan怎么作必弊(辅助)都是一直总是有攻略(哔哩哔...
透视阶段!werplan免费挂... 透视阶段!werplan免费挂下载(透视)poker world辅助器(辅助)一直有神器(哔哩哔哩)...
透视模块!pokemmo手机版... 透视模块!pokemmo手机版透视脚本(透视)pokemmo辅助器脚本下载(辅助)本来一直总是有攻略...
透视法门!拱趴大菠萝十三水作必... 透视法门!拱趴大菠萝十三水作必弊(透视)xpoker辅助工具(辅助)一直存在有神器(哔哩哔哩)1、拱...
透视秘籍!哈糖大菠萝软件下载(... 透视秘籍!哈糖大菠萝软件下载(透视)xpoker怎么作必弊(辅助)总是有神器(哔哩哔哩)1、每一步都...