morrisjs / morris.js

Pretty time-series line graphs
http://morrisjs.github.com/morris.js/
6.92k stars 1.23k forks source link

Update morris.js #765

Open schirrel opened 6 years ago

schirrel commented 6 years ago

Hi everyone Something i missed and thus i tried to make it possible with morris was to format the number as is being shown in the chart. Ex as a brazilian we use offten comma instead of dot to separate numbers. This way i ca leave my chart to 'organize' the data with the normal number, ex: 1146.4 and when i need the user to see, it sees 1.146,40;

It just add a option called valueFormatter, that formatter onli the Y value(in my case i just needed it) so i use add:

...
  parseTime: false,
  smooth: false,
  valueFormatter: function(value) {
       var negative = value < 0;                            
       var valor = Math.abs(value);
       var final = valor.toFixed(2).replace('.', ',').replace(/(\d)(?=(\d{3})+\,)/g, "$1.");
      final = negative ? '-'+final:final;
       return final;
}
...

and the my value show as: exemplo

schirrel commented 6 years ago

Removed unsed for and 'formatted values' and add some animatino to the chart initi and hover