不知道如何更改我的“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轴上的标签样式。

相关内容

热门资讯

透视操作!德扑之心免费透视,德... 透视操作!德扑之心免费透视,德普之星有辅助软件吗(透视)本来存在有透视教程(哔哩哔哩)1、德普之星有...
透视手筋!wepoker能不能... 透视手筋!wepoker能不能透视,wepoker提高好牌率(透视)真是是有挂(哔哩哔哩)1、wep...
透视积累!wepoker软件靠... 透视积累!wepoker软件靠谱么,wepoker数据分析工具(透视)切实有透视工具(哔哩哔哩)1、...
透视机巧!wepoker脚本,... 透视机巧!wepoker脚本,hhpoker可以控制吗(透视)都是是真的挂(哔哩哔哩)1、每一步都需...
透视办法!aapoker怎么设... 透视办法!aapoker怎么设置提高好牌几率,aapoker万能辅助器(透视)其实真的有脚本软件(哔...
透视操作!wepoker有没有... 透视操作!wepoker有没有透视方法,aapoker如何设置胜率(透视)确实有挂(哔哩哔哩)1、操...
透视绝活!约局吧辅助器,德州透... 透视绝活!约局吧辅助器,德州透视脚本(透视)真是存在有脚本工具(哔哩哔哩)1.约局吧辅助器 选牌创建...
透视绝活儿!wepoker怎么... 透视绝活儿!wepoker怎么挂底牌,wpk刷入池率脚本(透视)确实存在有挂(哔哩哔哩)1.wepo...
透视手筋!德州局透视,wepo... 透视手筋!德州局透视,wepoker安装教程(透视)本来是有透视教程(哔哩哔哩)暗藏猫腻,小编详细说...
透视窍门!hhpoker有后台... 透视窍门!hhpoker有后台操控吗,werplan脚本(透视)确实真的是有挂(哔哩哔哩)hhpok...