【问题标题】:Recharts wordwrap x-axis labelRecharts 自动换行 x 轴标签
【发布时间】:2017-10-22 15:25:57
【问题描述】:

我想像demo 那样对长标签进行自动换行。 据说this PR 支持它,但我无法使用它

<XAxis dataKey="name" interval={0} width={30} label={<Text width={30} />} />

【问题讨论】:

    标签: reactjs recharts


    【解决方案1】:

    有一个例子herelisamartin00完成

    她使用了自定义轴刻度:

    const CustomizedAxisTick = React.createClass({
      render () {
        const {x, y, payload} = this.props;
    
        return <Text x={x} y={y} width={75} textAnchor="middle" verticalAnchor="start">{payload.value}</Text>
      }
    });
    

    【讨论】:

    • 有什么方法可以实现省略号...对于太长的文本?
    猜你喜欢
    • 1970-01-01
    • 2021-12-13
    • 1970-01-01
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多