Skip to content
Advertisement

how to give string value on y axis in rechart

I am working on Recat.js and using rechart library for chart implementation. I want to give string value on the y axis as label and workout on some numbers included in the json data in x axis. here Iam giving my code I don’t why its not working properly. the value key pair has to gone through x axis and label values on the y axis. but its not working . please help me to solve this issue. iam giving my code

JavaScript

Advertisement

Answer

In your data array, I assumed that the values with

  • 2 will always have the "up" label,
  • 1 the "connection_recovered" label and
  • -2 the "down" label.

In order to have the label on a fixed tick in your graph on the YAxis, you can use the tickFormatter prop, where you can pass a function, which could return the label you want according to the value.

It would give the following:

JavaScript

Used in the YAxis just like so:

JavaScript

Which would give out a graph like the following enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement