Home How to assign values after the program finished drawing Google Charts?
 I know that sounds a bit weird but I got a piece of code in here: let globalResult = []; let defaultData = ["None", 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200]; $(document).ready(() => { // set a listener on the textbox$('#input').on("change", (evt) => { let text = $('#input').val(); // the {text: text} sends a parameter named text with the // value of what was typed in the textbox$.get("/display", {text: text}) .done((data) => { globalResult = data['result']; $('#input').val(''); // reset the textbox //Draw Graph google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { //Chart stuff.... Doesn't matter //It's programmed to Draw Line with defaultData and globalResult }; var chart = new google.visualization.LineChart(document.getElementById('curve_chart')); chart.draw(data, options); //Swap Value here: defaultData = globalResult; } })  I tried to swap defaultData and globalResult after the Chart is drawn, But some how it always drawing a new chart when swapping data, thus it causes interruption on the graph (like another line just died in the middle of the drawing, left half of the line hanging out there). If I trying to put these outside of the function drawChart, it will draw 2 same line with another dies in the middle. And I also cannot place this outside of $.get() scope cause that the chart won't be drawn. How do I fix that?