I am having issue with Google line chart API. When I reload the div, the line chart does not load again.
This is the code for line chart
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addRows(4);
<?php
//gets line chart data
echo $join;?>
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, {width: 320, height: 250, title: ''});
}
</script>
<h3>Sales History</h3>
<table border="5" style="border-color: #3b6aa8;" >
<tr>
<td>
<div id="chart_div" style="border: 1;border-color: green;"></div>
</td>
</tr>
</table>
code used to reload the div
<script type="text/javascript">
$(document).ready(function() {
$('#sliderform').submit(function() {
bodyContent = $.ajax({
url: "dashboardreload.php",
global: false,
type: "POST",
data: ({year : $("#yearval").val(), month: $("#monthval").val(),day : $("#dayval").val(),
year1 : $("#year1val").val(), month1: $("#month1val").val(),day1 : $("#day1val").val()
}),
dataType: "html",
async:false,
success: function(msg){
//alert('test');
}
}
).responseText;
$('#dash').html(bodyContent);
//confirm(bodyContent);
return false;
});
});
</script>
so this might be the problem
even tho you are reloading this content the page still has these references loaded
and there might not ever be a call to drawChart on the second time around because
the google script isn’t loading any new content
to get around this you might want to call the drawChart function yourself after having loaded the new content
maybe this will help. gl