2011-12-13 46 views
1

Iam試圖用js和php實現圖。如何在java腳本中實現z索引高圖

我已經創建了圖表。現在它顯示用戶點擊圖形點時的y軸值和x軸值。我想在用戶點擊圖形點時顯示另一個值(除x和y之外)。我已經從ajax文件中返回了所有這些x,y和z值。但是不能實現z索引。 Plz幫助我。

$("document").ready(function(event){ 
    var pickerOpts = { 
      dateFormat:"d/m/yy" 

      }; 

    $('.date').datepicker(pickerOpts); 
    function loadGraph(d1,d2){ 


    $.ajax({ 

      dataType:'json', 
      type:'POST', 
      url:'../ajaxtaskAnalytics', 
      data:{ 
       date1:d1, 
       date2:d2 
      }, 
      success:function(result){ 


      $.parseJSON(result); 

      var gval=[]; 
      for(var i=0;i<result['tasks'].length;i++){ 

       gval.push([ 

          Date.parse(result['tasks'][i].dt+' UTC') 
          , 
          result['tasks'][i].number, 
          result['tasks'][i].usercount 
         ]); 

      } 

      var options = { 

       chart: { 
        renderTo: 'container' 
       }, 

       title: { 
        text: 'Task Analytics' 
       }, 

       subtitle: { 
        text: 'Machbee' 
       }, 

       xAxis: { 
        type: 'datetime', 
        tickInterval: 1 * 24 * 3600 * 1000, // one week 
        tickWidth: 0, 
        gridLineWidth: 1, 
        labels: { 
         align: 'left', 
         x: 3, 
         y: -3 
        } 
       }, 

       yAxis: [{ // left y axis 
        title: { 
         text: null 
        }, 
        labels: { 
         align: 'left', 
         x: 3, 
         y: 16, 
         formatter: function() { 
          return Highcharts.numberFormat(this.value, 0); 
         } 
        }, 
        showFirstLabel: false 
       }, { // right y axis 
        linkedTo: 0, 
        gridLineWidth: 0, 
        opposite: true, 
        title: { 
         text: null 
        }, 
        labels: { 
         align: 'right', 
         x: -3, 
         y: 16, 
         formatter: function() { 

          return Highcharts.numberFormat(this.value, 0); 
         } 
        }, 
        showFirstLabel: false 
       }], 

       legend: { 
        align: 'left', 
        verticalAlign: 'top', 
        y: 20, 
        floating: true, 
        borderWidth: 0 
       }, 

       tooltip: { 
        shared: true, 
        crosshairs: true 
       }, 

       plotOptions: { 
        series: { 
         cursor: 'pointer', 
         point: { 
          events: { 
           click: function() { 

            hs.htmlExpand(null, { 
             pageOrigin: { 
              x: this.pageX, 
              y: this.pageY 
             }, 
             headingText: Highcharts.dateFormat('%Y %b %e', this.x), 
             maincontentText: ' Total Tasks :'+this.y , 
             width: 200 
            }); 
           } 
          } 
         }, 
         marker: { 
          lineWidth: 1 
         } 
        } 
       }, 

       series: [{ 
        name: 'Task Info', 
        lineWidth: 4, 
        marker: { 
         radius: 4 
        } 
       }] 
      }; 
      options.series[0].data = gval; 
      //options.series[1].data = gval; 

      chart = new Highcharts.Chart(options); 


      $("#analyticsTaskCount").html("No Of Tasks in this WorkSpace is"+result['total']);   


      $("#analyticsUser").html(""); 
      for(var k=0;k<result['users'].length;k++){ 

       $("#analyticsUser").append("<br>"+result['users'][k].name+"="+result['users'][k].taskcount); 

      } 

      } 
      }); 
      } 
      loadGraph($("#sdate").val(),$("#ddate").val()); 


      var okay=true; 

      $("#sdate").live('click',function(){ 

        $("#err_startdate").html("");    

      }); 

      $("#ddate").live('click',function(){ 

       if($("#sdate").val().length<8){ 

        $("#err_startdate").html("Please select the first date"); 
        okay= false; 
       } 


      }); 
      $("#ddate").live('blur',function(){ 
       $("#err_enddate").html(""); 
       if($("#sdate").val().length<8){ 

        $("#err_startdate").html("Please select the first date"); 
        okay=false; 
       } 
       if($("#ddate").val().length<8){ 

        $("#err_enddate").html("Please select the second date"); 
        okay=false; 
       } 

      }); 
      $("#ddate").live('change',function(){ 
       loadGraph($("#sdate").val(),$("#ddate").val());    
      }); 

}); 

===================================從AJAX文件中輸出=== ====

(
[tasks] => Array 
    (
     [0] => Array 
      (
       [added_on] => 1322629212 
       [dt] => 2011/11/30 
       [number] => 3 
       [usercount] => 1 
      ) 

     [1] => Array 
      (
       [added_on] => 1323071708 
       [dt] => 2011/12/05 
       [number] => 2 
       [usercount] => 1 
      ) 

     [2] => Array 
      (
       [added_on] => 1323424536 
       [dt] => 2011/12/09 
       [number] => 1 
       [usercount] => 1 
      ) 

     [3] => Array 
      (
       [added_on] => 1323754243 
       [dt] => 2011/12/13 
       [number] => 2 
       [usercount] => 1 
      ) 

    ) 

[users] => Array 
    (
     [0] => Array 
      (
       [name] => God 
       [taskcount] => 7 
      ) 

     [1] => Array 
      (
       [name] => Veela 
       [taskcount] => 1 
      ) 

    ) 

[total] => 8 

+1

顯示您的標記和CSS – albert

+1

請只包括那些與該問題有關您的JavaScript的位,而不是整個腳本。另外,相關的PHP和CSS也會有用。 – GordonM

回答