in Education by
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. BarGraphWithDuplicates document.getElementById("result").innerHTML; google.charts.load('current', {packages: ['corechart', 'bar']}); image
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); } Run code snippetExpand snippet 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? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
remove this statement... tdata.addRows(data.result); the rows are already being added here... var tdata = google.visualization.arrayToDataTable(data.result, true);

Related questions

0 votes
    WHICH TYPE OF CHART IS USED FOR REPRESENTING HUGE AMOUNT OF DATA. (i) BAR (ii) LINE (iii) SCATTER Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    What is a Stacked Bar chart in Tableau?...
asked Nov 1, 2020 in Technology by JackTerrance
0 votes
    What is the Bar Chart in Tableau?...
asked Nov 1, 2020 in Technology by JackTerrance
0 votes
    Suppose, without using a line/bar chart, I want to design a view to show the region-wise profit and sales. How should I go about doing it? Explain...
asked Oct 30, 2020 in Technology by JackTerrance
0 votes
    How can we delete duplicate rows from flat files?...
asked Mar 26, 2021 in Technology by JackTerrance
0 votes
    How to delete duplicate rows in SQL Server?...
asked Nov 9, 2020 in Technology by Editorial Staff
0 votes
    I am trying to figure out how to pull only specific rows and columns using Google apps script. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I am new to python and cloud vision.I need to label ~20k images.My code although does the work, ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Which of the following is used to limit the number of rows returned? (a) setMaxRows(int i) (b) setMinRows(int ... Beans & JDBC of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    in split cell window we can specify the number of (i) Rows and cells (ii) Rows and Columns (iii) Columns and ... (iv) Tables and Cells Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    in split cell window we can specify the number of (i) Rows and cells (ii) Rows and Columns (iii) Columns and ... (iv) Tables and Cells Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    in split cell window we can specify the number of (i) Rows and cells (ii) Rows and Columns (iii) Columns and ... (iv) Tables and Cells Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    Which of the following is used to limit the number of rows returned? (a) setMaxRows(int i) (b) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    Which option controls the number of rows returned in each block of paginated results? (1)threshold (2)PagingSpec (3)pagingIdentifiers...
asked Aug 20, 2021 in Technology by JackTerrance
...