I recently upgraded one of my sites to the latest GL1.8.
What I want to do is integrate some charts using the Google Chart API:
https://developers.google.com/chart/
In the past this has worked fine because using their older tools I could just build the chart as a call to an image in html which GL had no problem allowing - all I was doing was loading an external image.
Text Formatted Code
echo '<img align="left" src="https://chart.googleapis.com/chart?';
echo 'various options and call data out of my other databases to build my graph....
This is being deprecated by Google now though, and they want you to use the new format (which has lots of cool bells and whistles). The new method is javascript-based. I have done a certain amount of reading about the $_SCRIPTS class, but I'm still not sure how I should be approaching this. Here's an example. As a test in a PHP page outside of geeklog the following works fine:
Text Formatted Code
echo "<script type='text/javascript' src='https://www.google.com/jsapi'></script>";
echo "<script type='text/javascript'>";
echo "google.load('visualization', '1', {packages:['corechart']});";
echo "google.setOnLoadCallback(drawChart);";
echo "function drawChart() {";
echo "var data = google.visualization.arrayToDataTable([";
// grab the data from above
echo $result;
// end getting data
echo " ]);";
echo "var options = {";
echo "title: 'My Graph',";
echo "};";
echo "var chart = new google.visualization.PieChart(document.getElementById('backlog_chart_div'))";
echo "chart.draw(data, options);";
echo "}";
echo "</script>";
I believe I need the script to be in the header, but I really only need the script in the header on a certain static page, it seems it would be a performance hit to load it all the time. The data is dynamically generated by a call to another database I run.
What is the best way to go about loading externally hosted javascript like this in a Geeklog static page? I am not a developer, though I have been using Geeklog for a long time and have managed to hack together whatever I've needed up to this point. I'm starting to get into things over my head here with javascript so please be gentle.