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

Morris.js with format number in brazilian currency #801

Open
danilorago opened this issue Dec 16, 2020 · 1 comment
Open

Morris.js with format number in brazilian currency #801

danilorago opened this issue Dec 16, 2020 · 1 comment

Comments

@danilorago
Copy link

I'm trying to use Morris to create a graph, and it's almost everything working. My issue is that I have to use the brazilian format with number. Should be "1.234,00" instead "1,234.00". Someone knows how to change? I tried a lot of times but I couldn't find a way... I tried to use the function format_number with PHP, but when I change to the brazilian format the graph don't open.

<script>
Morris.Bar({
    element: 'mr-Volumetria',
    data: [
        {x: '12/2019', y: 60.72},
        {x: '9/2020', y: 249.46},
        {x: '10/2020', y: 275.54},
        {x: '11/2020', y: 3501.50},
        {x: '12/2020', y: 3739.24}
    ],
    xkey: 'x',
    ykeys: ['y'],
    labels: ['Valor do mês'],
    barColors: function (row, series, type) {
        if(type === 'bar'){
            var red = Math.ceil(255 * row.y / this.ymax);
            return 'rgb('+red+',0,0)';
        }else{
            return '#000000';
        }
    }
});
</script>
@pierresh
Copy link

Hello,

You can use the function yLabelFormat() to solve this problem.
The value provided to Morris would be the standard values as shown in your example, but then the function yLabelFormat() could format the value in the way you want. You can read more about this function in the help: http://morrisjs.github.io/morris.js/lines.html

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

No branches or pull requests

2 participants