React-vis: How to add integer number in YAxis

Created on 29 Jan 2019  路  3Comments  路  Source: uber/react-vis

Hi
I need set step on YAxis if i have max is 2-3 in domain, number on YAxis will be float, but i need only integer.

i need so
image

I did this

(max <= 5)
  ? <YAxis tickTotal={max} tickFormat={YTickFormat} />
  : <YAxis tickFormat={YTickFormat} />

if i don't do this i get float number
image

Is there another way to do this?

question

All 3 comments

You can either use tickFormat (as you do above) or you could provide tickValues, which might look like tickValues={[1, 2, 3, 5]}

I can't use tickFormat because what i should do if i get 0.2 or 0.4 number.
tickValues is some how set tickTotal={max} and i don't like.
I want set property like setIntegerYAxis and step will be only integer .
there is no such property?

Use tickFormat to conditionally display integer values:

<YAxis>
  tickFormat={val => Math.round(val) === val ? val : ""}
/>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cang-afero picture cang-afero  路  4Comments

basilaiman picture basilaiman  路  3Comments

martoncsikos picture martoncsikos  路  4Comments

yennycheung picture yennycheung  路  4Comments

cvalmonte picture cvalmonte  路  4Comments