More fixes to work with KH 3.3
This commit is contained in:
@@ -19,7 +19,7 @@ abstract class GoogleChart implements Iterator,Countable {
|
||||
// Chart title
|
||||
protected $_title = '';
|
||||
protected $_dataurl = '';
|
||||
protected $_divname = '';
|
||||
protected $_divname = 'gchart';
|
||||
// Default chart size.
|
||||
protected $_height = '200';
|
||||
protected $_width = '700';
|
||||
|
@@ -99,36 +99,51 @@ class GoogleChart_ComboChart extends GoogleChart {
|
||||
Script::add(array(
|
||||
'type'=>'stdin',
|
||||
'data'=>"
|
||||
function drawChart".$this->_divname."() {
|
||||
var jsonData = $.ajax({
|
||||
url: '".$this->_dataurl."',
|
||||
dataType:'json',
|
||||
async: false,
|
||||
}).responseText;
|
||||
function drawChart_".$this->_divname."() {
|
||||
div = document.getElementById('".$this->_divname."');
|
||||
|
||||
var x = JSON.parse(jsonData);
|
||||
for(var key in x) {
|
||||
if (key == 'data')
|
||||
data = x[key];
|
||||
else if (key == 'options')
|
||||
options = x[key];
|
||||
else
|
||||
alert('UNKNOWN Key: '+key);
|
||||
if (! div) {
|
||||
alert(\"Unable to render chart, DIV ['".$this->_divname."'] doesnt exist.\");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create our data table out of JSON data loaded from server.
|
||||
var data = new google.visualization.DataTable(data);
|
||||
$.ajax({
|
||||
url: '".$this->_dataurl."',
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
success: function(jsonData) {
|
||||
for(var key in jsonData) {
|
||||
if (key == 'data')
|
||||
data = jsonData[key];
|
||||
else if (key == 'options')
|
||||
options = jsonData[key];
|
||||
else
|
||||
alert('UNKNOWN Key: '+key);
|
||||
}
|
||||
|
||||
// Instantiate and draw our chart, passing in some options.
|
||||
var chart = new google.visualization.ComboChart(document.getElementById('".$this->_divname."'));
|
||||
chart.draw(data, options);
|
||||
// Create our data table out of JSON data loaded from server.
|
||||
var x = new google.visualization.DataTable(data);
|
||||
|
||||
// Instantiate and draw our chart, passing in some options.
|
||||
var chart = new google.visualization.ComboChart(document.getElementById('".$this->_divname."'));
|
||||
chart.draw(x, options);
|
||||
},
|
||||
error: function(x, t, m) {
|
||||
if (t==='timeout') {
|
||||
alert('got timeout');
|
||||
} else {
|
||||
alert('t is: '+t+', X: '+x+', M: '+m);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
",
|
||||
));
|
||||
|
||||
Script::add(array(
|
||||
'type'=>'stdin',
|
||||
'data'=>'google.setOnLoadCallback(drawChart'.$this->_divname.');',
|
||||
'data'=>'$(document).ready(function() {google.setOnLoadCallback(drawChart_'.$this->_divname.'); });',
|
||||
));
|
||||
|
||||
return sprintf('<div id="%s" style="width: %spx; height: %spx;"></div>',$this->_divname,$this->_width,$this->_height);
|
||||
|
Reference in New Issue
Block a user