2013-12-17 46 views
1
<div id="container" style="width:100%; height:400px;"></div> 
<div id="container_dialogue" style="width:100%; height:400px;"></div> 

    var chart1; 
function test(name, e){ 
alert(name); 

$("#container_dialogue").empty(); 
$("#container_dialogue").dialog({height: 500,modal: true}); 

$("#container_dialogue").append("<div id='dialogue_inner'></div><div   id='dialogue_inner1'></div>"); 
$("#dialogue_inner1").append(name); 

/** 
    on Clicking any chart based on this property or 'e' i need to identify  the    corresponsing series and to display in dialogue box. 
    As of now i hard coded the values and displays a single chart only 

    **/ 
    $('#dialogue_inner').highcharts({ 

    title: { 
     text: 'Energy Consumption' 
    }, 
    yAxis: { 
     title: { 
      text: 'Energy' 
     } 
    }, 
    series: [{ 
     name: name, 
     data: [1,0,4,5,6,9,3] //hardcoded values 
    }] 
}); 

} 


    $(function() { 
    chart1 = new Highcharts.Chart({ 
chart: { 
     renderTo: 'container', 
     type: 'line' 
    }, 

title: { 
     text: 'Energy Consumption' 
    }, 
    yAxis: { 
     title: { 
      text: 'Energy' 
     } 
    }, 
    plotOptions: { 
      line: { 
        events:{ 
          click: function(e){ 
        var name = this.name; 

        alert(this.name); 
           test(name, e); 
          }  
        } 
      } 
    }, 
    series: [{ 
     name: 'A', 
     data: [2,3,8,1,9,6,4,8] 
    }, { 
     name: 'B', 
     data: [5,6,3,8,4,1,6,0] 
    },{ 
     name: 'C', 
     data: [1,5,4,3,7,7,2,6] 
    },{ 
     name: 'D', 
     data: [9,10,2,4,5,8,3,8] 
    }] 
    });  

    }); 

上單擊基於此屬性或「e」我需要確定corresponsing系列,並顯示在對話框中特定的圖表任何線圖獲取所有系列的值時,點擊單線圖

回答

1

你可以使用series click然後打印所有點

http://jsfiddle.net/6gYLX/3/

click: function() { 
        console.log(this); 
         var series = this.data; 

        $.each(series,function(i,point){ 
         console.log(point.y); 
        }); 
       } 
+0

塞巴斯蒂安嗨,我想你的代碼和我在一個戒備一個獲取值太..但我需要的完整系列點在一起並在對話框中用這些值繪製一條線。你可以幫我嗎? – sush

+0

在funcion測試(名稱,e)我需要傳遞系列和系列點的名稱.. – sush

+0

嗨,最後我明白了..只需要創建一個數組.. – sush

相關問題