Save them on the main page (no need to download Google charts in partial):
<script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); </script>
In your partial part, you need to do something like below (if you are using jQuery). The point is to execute the js code after which the dom loads, which is what $ (function () {....}) is:
<div id="chart_div"></div> <script type="text/javascript"> $(function() { drawChart(); }); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Year'); data.addColumn('number', 'Sales'); data.addColumn('number', 'Expenses'); data.addRows([ ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] ]); var options = { width: 400, height: 240, title: 'Company Performance', vAxis: {title: 'Year', titleTextStyle: {color: 'red'}} }; var chart = new google.visualization.AreaChart(document.getElementById('chart_div')); chart.draw(data, options); } </script>
Using a library such as jQuery will save you many hours of browser inconsistency, knowing when dom is loaded correctly.
source share