大家好,这里是我正在使用的 Google 分散图表代码:
require '/lib/GoogleChart.php';
require '/lib/markers/GoogleChartShapeMarker.php';
require '/lib/markers/GoogleChartTextMarker.php';
$Variance=array();
$Emp_RecFactor=array();
$Emp_Id=array();
//$Emp_FirstName=array();
$EquityGraph=new EquityGraph();
$EquityGraph->Graph();
$DrawGraph=$EquityGraph->DrawGraph;
foreach($DrawGraph as $key=>$value)
{
$Variance[]=$value["Variance"];//for multiple values ,array
$Emp_RecFactor[]=$value["Emp_RecFactor"];//single value
$Emp_Id[]=$value["Emp_Id"];//single value
}
$_GET['Variance']=$Variance;
$_GET['Emp_RecFactor']=$Emp_RecFactor;
print_r($Emp_RecFactor);
$chart = new GoogleChart('lc', 500, 200);
// manually forcing the scale to [0,100]
$chart->setScale(0,100);
// add one line
$data = new GoogleChartData($Variance);
$chart->addData($data);
// customize y axis
$y_axis = new GoogleChartAxis('y');
$y_axis->setDrawTickMarks(false)->setLabels(array(-5,0,5));
$chart->addAxis($y_axis);
// customize x axis
$x_axis = new GoogleChartAxis('x');
$x_axis->setTickMarks(5);
$chart->addAxis($x_axis);
// add a shape marker with a border
$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
$shape_marker->setSize(6);
$shape_marker->setBorder(2);
$shape_marker->setData($data);
$chart->addMarker($shape_marker);
// add a value marker
$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
$value_marker->setData($data);
$chart->addMarker($value_marker);
//~ header('Content-Type: image/png');
echo $chart->toHtml();
正如您在代码中看到的那样,我使用了$Variance
数组传递到$data
现在我需要再使用一个数组$Emp_RecFactor
,并且我需要在这两个数组之间绘制一个图形......
我还想为此添加鼠标悬停功能,以便如果有人将鼠标悬停在所选点上,它应该为不同的所选点显示不同的内容 - 我该怎么做?