Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update morris.js #765

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Update morris.js #765

wants to merge 4 commits into from

Conversation

schirrel
Copy link

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

Add support for valueFormatter to show in Line and Bar mouse hover tooltip the value formated
@schirrel
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants