Correction of graphic counter

Asked

Viewed 30 times

0

I have a graph and my system I need it to report the exact value of the searched results.

Due to a lot of data, the results come out like this 1.1K.

printescreen de um gráfico

In the place that this 1.1K wanted it to show the exact amount it would be 1057.

Here below is the graph function on JS:

function ChartConstructor(title, dados, totalText) {
    window.google.charts.load('current', { 'packages': ['bar'] });
    window.google.charts.setOnLoadCallback(drawStuff);

    function drawStuff() {
        var table = JSON.parse(dados);
        var rows = "";

        var array = [["", "Total"]];

        for (var i = 0; i < table.length; i++) {
            array.push([table[i].Title, table[i].Count]);
        }

        var data = new google.visualization.arrayToDataTable(array);

        var options = {
            width: '100%',
            height: 400,            
            chart: {
                title: title,
            },
            bar: { groupWidth: '95%' },
            bars: 'horizontal',
            series: {
                0: { axis: 'distance' }, 
            }
        };

        var chart = new google.charts.Bar(document.getElementById("chart-content"));
        chart.draw(data, options);

        $("#chart-type").val("");
    }
}

1 answer

0

Oops, try to take the value and multiply it according to the string.

Would look this way:

function getVal (val) { 
   multiplier = val.substr(-1).toLowerCase(); 

   if (multiplier == "k") 
      return parseFloat(val) * 1000; 
  else if (multiplier == "m") 
      return parseFloat(val) * 1000000; 
}
  • Or this site can also help http://numeraljs.com/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.