Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recharts wordwrap x-axis label

I want to word-wrap long labels like in this demo. Supposedly this PR supports it, but I couldn't get it to work with

<XAxis dataKey="name" interval={0} width={30} label={<Text width={30} />} />
like image 378
Avery235 Avatar asked Oct 22 '17 15:10

Avery235


1 Answers

There is an example here done by lisamartin00

She used a custom axis tick:

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>
  }
});
like image 96
Jöcker Avatar answered Oct 27 '22 21:10

Jöcker