I am using JpGraph and CodeIgniter. In JpGraph, you can define a Callback function to add some properties.
In my tests, everything was correct, I used :
for( $i=0; $i < $n; ++$i )
{
$datax[$i] = $data[$i][0];
$datay[$i] = -$data[$i][1];
$format[strval($datax[$i])][strval($datay[$i])] = array($data[$i][2],$data[$i][3]);
}
Then I specify the callback :
$sp1->mark->SetCallbackYX("FCallback");
And my function :
function FCallback($aYVal,$aXVal)
{
global $format;
return array($format[strval($aXVal)][strval($aYVal)][0],'',
$format[strval($aXVal)][strval($aYVal)][1],'','');
}
But, with CodeIgniter, I build my graph in a Class, so I can't use global var $format. There is a way to access the var $format outside the class ? Tha开发者_如何学运维nks.
Best to find a way to pass the $format variable into the FCallback function rather than using the global scope. But, if you need to you could try using the $GLOBALS array.
Pass the $format function into the $GLOBALS array within your controller class
$GLOBALS['format'] = $format;
Then within the FCallback function you would grab the variable using the reverse.
$format = $GLOBALS['format'];
精彩评论