Search code examples
reactjsreact-chartjs

How to show an inverted line in reactjs charts 2?


Is there a way to show inverted line graphs in reactjs-charts-2 ?

For example, we are tracking number of complaints per month.

The more complaints there are, the lower we want the graph to go, with 0 complaints being at the top of the graph.

So the Y scaling should be reversed:

0
1
2
3
4
5

and so on...

The only way I know to do it currently is to multiply all values by -1. But then the Y axis values show the negative number. Not pretty.


Solution

  • I found the answer. You need to add this to the options object:

    scales: {
        yAxes: [{
                  ticks: {
                     reverse: true
               }
        }]
    }