문제

이 쌓인 열 차트 데이터가 주어졌습니다.

        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
        }
        ?>
        ];
.

나는 이와 같은 조건을 주어주는 경고를 처리하고 싶다 (클릭 된 조건은 여기에있는 경우 / em> / /) :

        // 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 );
                }
            }
.

조건에 대한 구문이 될 수 있습니까?

도움이 되었습니까?

해결책

조건은 다음과 같습니다.

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+")" );               
        }
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top