给出这个堆积的柱形图数据:
var chartData = [
<?php
foreach($emptyArray as $key => $arrInternal){
if($key>0){
?>, <?php
}
?>
{
"position": <?php echo json_encode($emptyArray[$key][0][2]); ?>,
"demand": parseInt(<?php echo "'".$emptyArray[$key][0][4]."'"; ?>),
"crewplanned": parseInt(<?php echo "'".$emptyArray[$key][1][4]."'"; ?>),
"CrewplannedLineup": parseInt(<?php echo "'".$emptyArray[$key][2][4]."'"; ?>),
"replacement1": parseInt(<?php echo "'".$emptyArray[$key][3][4]."'"; ?>),
"demandsubdata": <?php echo json_encode($emptyArray[$key][0][5]); ?>,
"crewplannedsubdata": <?php echo json_encode($emptyArray[$key][1][5]); ?>,
"CrewplannedLineupsubdata": <?php echo json_encode($emptyArray[$key][2][5]); ?>,
"replacement1subdata": <?php echo json_encode($emptyArray[$key][3][5]); ?>
}
<?php
}
?>
];
我想在这样的条件下处理警报(请注意/ 点击后的条件在这里 /):
// this method handles chart data click
function handleClick(event)
{
if (event.item.dataContext.demand /*when-clicked condition goes here*/) {
alert(event.item.category + ": " + event.item.values.value + "|"+ event.item.dataContext.demandsubdata );
}
else if(event.item.dataContext.crewplanned /*when-clicked condition goes here*/){
alert(event.item.category + ": " + event.item.values.value + "|"+ event.item.dataContext.crewplannedsubdata );
}
else if(event.item.dataContext.CrewplannedLineup /*when-clicked condition goes here*/){
alert(event.item.category + ": " + event.item.values.value + "|"+ event.item.dataContext.CrewplannedLineupsubdata );
}
else if(event.item.dataContext.replacement1 /*when-clicked condition goes here*/){
alert(event.item.category + ": " + event.item.values.value + "|"+ event.item.dataContext.replacement1subdata );
}
}
条件的语法是什么?
答案 0 :(得分:1)
条件是这样的:
if(event.graph.valueField=="demand")
等等。或使用开关
// this method handles chart data click
function handleClick(event)
{
var subdata="";
switch (event.graph.valueField){
case "demand": subdata=event.item.dataContext.demandsubdata; break;
case "crewplanned": subdata=event.item.dataContext.crewplannedsubdata; break;
case "CrewplannedLineup": subdata=event.item.dataContext.CrewplannedLineupsubdata; break;
case "replacement1": subdata=event.item.dataContext.replacement1subdata; break;
}
alert("Find out who are these "+ event.item.values.value +" "+ event.item.category+". Click OK. \n("+ subdata+")" );
}