Victory-native: How to display x-Axis partly?

Created on 5 Dec 2017  路  3Comments  路  Source: FormidableLabs/victory-native

Hi, I have a problem with VictoryLine. Because there are a lot of data, it is impossible to show all the label for x-Axis. Only need to show 3 labels: '9:40', '14:40', '20:40'.

How to implement the result? thanks very much.
Code as follows:
const data= [
{x: '9:40', y: 100}
{x: '10:40', y: 100}
{x: '11:40', y: 100}

....
{x: '20:40', y: 100}
]
<VictoryChart height={200}> <VictoryLine data={data} /> </VictoryChart>

Otherwise, chart will show as follows:

screen shot 2017-12-05 at 10 01 48 pm

Most helpful comment

Now, change code as follows:
<VictoryChart height={200}> <VictoryLine data={data} /> <VictoryAxis fixLabelOverlap={true}/> <VictoryAxis dependentAxis/> </VictoryChart>

Chart will show as follows:
screen shot 2017-12-05 at 11 23 13 pm

Maybe better now. One more question: If I want to show the day, not day+time, then several datas in one day will show only one. How to solve the problem?

screen shot 2017-12-05 at 11 29 06 pm

Thanks

All 3 comments

Now, change code as follows:
<VictoryChart height={200}> <VictoryLine data={data} /> <VictoryAxis fixLabelOverlap={true}/> <VictoryAxis dependentAxis/> </VictoryChart>

Chart will show as follows:
screen shot 2017-12-05 at 11 23 13 pm

Maybe better now. One more question: If I want to show the day, not day+time, then several datas in one day will show only one. How to solve the problem?

screen shot 2017-12-05 at 11 29 06 pm

Thanks

@jzhw0130 You want to use the tickFormat prop to control how your labels are displayed. More information here: https://formidable.com/open-source/victory/docs/victory-axis#tickformat

@boygirl Thanks a lot.

For the 'data' property, x is a key, must be unique. Be default, x will show directly.
So I need to format x to whatever I want. Empty string if do not show.

Was this page helpful?
0 / 5 - 0 ratings