Doubt with Google charts API

I have a bar chart on my system using the Google charts API. It is working already, but I am having the following problem. I present in the charts the amounts received and spent monthly from January to December. It is presenting all the values, however, the problem is in presenting the numbers. When I have the value of R$ 1500,00 it presents the value 1.5. I wonder if it is possible to change to the national currency format?


<script type="text/javascript">
        google.charts.load('current', {'packages':['bar']});
        google.charts.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = google.visualization.arrayToDataTable([
                ['Mês', 'Receitas', 'Custos e Despesas'],
                ['Janeiro', <?php echo $recebimentoJan; ?>, <?php echo $pagamentoJan; ?>],
                ['Fevereiro', <?php echo $recebimentoFev; ?>, <?php echo $pagamentoFev; ?>],
                ['Março', <?php echo $recebimentoMar; ?>, <?php echo $pagamentoMar; ?>],
                ['Abril', <?php echo $recebimentoAbr; ?>, <?php echo $pagamentoAbr; ?>],
                ['Maio', <?php echo $recebimentoMai; ?>, <?php echo $pagamentoMai; ?>],
                ['Junho', <?php echo $recebimentoJun; ?>, <?php echo $pagamentoJun; ?>],
                ['Julho', <?php echo $recebimentoJul; ?>, <?php echo $pagamentoJul; ?>],
                ['Agosto', <?php echo $recebimentoAgo; ?>, <?php echo $pagamentoAgo; ?>],
                ['Setembro', <?php echo $recebimentoSet; ?>, <?php echo $pagamentoSet; ?>],
                ['Outubro', <?php echo $recebimentoOut; ?>, <?php echo $pagamentoOut; ?>],
                ['Novembro', <?php echo $recebimentoNov; ?>, <?php echo $pagamentoNov; ?>],
                ['Dezembro', <?php echo $recebimentoDez; ?>, <?php echo $pagamentoDez; ?>]
            ]);

            var options = {
                chart: {
                    title: 'Evolução mensal do ano de '+<?php echo $ano; ?>+''
                },
                bars: 'vertical'            
            };

            var chart = new google.charts.Bar(document.getElementById('barchart'));         
            chart.draw(data, options);
        }
    </script>
Author: rray, 2017-10-09

2 answers

In line:

google.charts.load('current', {packages: ['corechart']});

Add:

'language': 'pt'

Looks like this:

google.charts.load('current', {packages: ['corechart'],'language': 'pt'})

In the hAxix Property, add format: 'currency',

 1
Author: cassiano, 2018-07-18 19:39:47

Unfortunately the Google API does not convert the currency to Real. But what can be done is the conversion through the code itself. Thus you print the converted value accompanied by the symbol of the national currency R$. ex in PHP:

// repare que o padrão é no formato americano

echo 'R$' . number_format($num, 2); // retorna R$100,000.50


// nosso formato

echo 'R$' . number_format($num, 2, ',', '.'); // retorna R$100.000,50
 0
Author: Gabriel Lucchese, 2017-10-09 19:58:12