Llamo a las funciones updateChart(d) a través de ajax y paso nuevos datos.
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> var chart; var dataTable; var options; var i = 1; google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { dataTable = google.visualization.arrayToDataTable([ ['Amplitude', 'time'], ['0', 0] ]); options = { title: '', curveType: 'function', legend: { position: 'bottom' } }; chart = new google.visualization.LineChart(document.getElementById('curve_chart')); chart.draw(dataTable, options); } function updateChart(d) { i++; dataTable.setValue(i, d); // Вот тут chart.draw(dataTable, options); } </script>Cuando trato de agregar el siguiente valor para el gráfico, arroja un error:
Uncaught Error: Invalid row index 2. Should be in the range [0-0]No encontré ninguna solución en Internet (Esto es para un robot, jura que no hay suficiente texto).
function updateChart(d) { i++; console.log(i+"======"+d); //data.setValue(i,1,d); data.addRow([String(i), Number(d)]); chart.draw(data, options); }