I'm showing the results of a face emotion detection program as a google bar 
chart. The problem is that for every result set that is returned, the chart 
draws double the number of rows. 

[image: bargraph.png]


This is the script tag of the javascript.



<script>
document.getElementById("result").innerHTML;
google.charts.load('current', {packages: ['corechart', 'bar']});
</script>
<button onclick="stopTextColor();">Stop</button> 
<img id="bg" width=1200px height=900px src="{{ url_for('calc') }}">
<div id="chart"></div>
</body>
<script type="text/javascript">

var intervalID = setInterval(update_values,1000);
  function update_values() {
  
        $.getJSON($SCRIPT_ROOT + '/result',
               
      function(data) {
        $('#result').text(data.result);
        console.log(data); 
drawMultSeries(); 

function drawMultSeries() {

var tdata = google.visualization.arrayToDataTable(data.result, true);
  
tdata.addRows(data.result);


var options = {

    height: 500,
                            width:  500,
                            
chartArea:{left:100,top:100,right:100,bottom:100},
                            hAxis: { ticks: [25,50,75,100] }, 
                            isStacked: false,
                            bar: {groupWidth: '10'},
                            vAxis:{ textStyle:{color: '#000000',fontSize: 
'12', paddingRight: '0',marginRight: '0'}},
                            colors: ['green','#ffff99','#ffbf0c','red'],
                         };
var chart1 = new 
google.visualization.BarChart(document.getElementById('chart'));
                    chart1.draw(tdata, options);
    } 
      });
      
    };
    function stopTextColor() {
      clearInterval(intervalID);
    }
    
</script>



When I inspect the array that is returned, there are only 7, but the graph 
as you can see shows 14. The next 7 rows are a replica of the first 7. I'm 
not sure where I'm going wrong here. Can someone please help me out with 
this?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/7830fe85-b237-4db1-a6b9-55e76f1940f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to