Perspecrive XY CHART Question

I use xy chart and I want to specify the number of y-axis grids. What should I do?

You can play with yAxes.appearance.grid.minDistance.

I did it the way you told me

Even if minDistance is 0.5, it becomes this detailed, but I want to make only 5 grids.

Try make a number bigger, try 1, 5, 10, 50, 100, etc. until it looks like you want

Setting it to 0.5 isn't going to produce 5 gridlines, even if there weren't smarts to work out how many will actually fit on the graph; you would get 100s of 1000s of gridlines (600k)

If you want 5 gridlines dynamically, then you will need to:

  1. set the min/max y range statically (props.yAxes[x].value.range.min/max and set useStrict to true)
  2. set props.yAxes[x].appearance.grid.minDistance = expression binding:
({this.props.yAxes[x].value.range.max}-{this.props.yAxes[x].value.range.min})/5

where x = the array item index of your yAxis.
right click on this prop and turn on the "persistent" option so that the value is saved with the view (not technically required, but it's better if you do)

However, it looks like there is some logic to make these numbers logical, so depending what this evaluates to, you might see 5 or less gridlines.

1 Like