Y-axis integers in line chart morris.js

I started using the morris.js chart line in my html page. Is there any way to establish that the y axis contains only integers? Now it displays decimal numbers, but my dataset contains only integers.

+7
jquery html
source share
3 answers

This feature was added by this pull request about 25 days ago in the Github repository. He added the gridIntegers option, which is set to false by default. It is still not merged with the main repository. Therefore, if you want to use it right now, you need to download this version and configure it as follows:

  Morris.Line({ element: "mydiv", data: mydata, xkey: 'time', ykeys: ['value'], labels: ['Requisiรงรตes'], gridIntegers: true, ymin: 0 }); 

Have you seen the ymin parameter set to 0 ? This is a warning! The y axis will only work with integers if and only if you have set your custom borders y-min and / or y-max. In my case, this is doable, because I know that my data will not contain values โ€‹โ€‹less than 0. Therefore, it works like a charm.

Below you can see the difference when using and when using the patch:

Without the patchenter image description here

+9
source share

Here is the actual code I used ....

 new Morris.Bar({ ... yLabelFormat: function(y){return y != Math.round(y)?'':y;}, ... }); 
+3
source share

I am using BAR / LINE and I have a problem:

enter image description here

Using "ymin: 0" I do not have integers

0
source share

All Articles