2016-05-04 60 views
0

我有highchart一個問題,這是我的代碼:獲取父單擊時,兒童Highcharts

   categories = ['Position', 'Ages', 'Salary'], 
        data = [{ 
         y: 120, 
         color: colors[0], 
         drilldown: { 
          name: 'Position', 
          categories: dataemp, 
          data: percent,       
          color: colors[1] 
         } 
        }, { 
         y: 120, 
         color: colors[4], 
         drilldown: { 
          name: 'Ages', 
          categories: ['10-20', '20-30', '30-40', '40-50', '50-60'], 
          data: [parseFloat(age[0]['percentA']), parseFloat(age[0]['percentB']), parseFloat(age[0]['percentC']), parseFloat(age[0]['percentD']), parseFloat(age[0]['percentE'])], 
          color: colors[2] 
         } 
        } 

我想告訴父母的名字,當我點擊這個孩子,比如孩子的名字是10-20。而輸出,我需要是這樣的:
This 10-20 has parent : Ages
幫助我謝謝。

回答

1
series: [{ 
      name: 'Items', 
      colorByPoint: true, 
      data: [{ 
       name: 'Position', 
       y: 5, 
       drilldown: 'position' 
      }, { 
       name: 'Ages', 
       y: 2, 
       drilldown: 'ages' 
      }, { 
       name: 'Salary', 
       y: 4, 
       drilldown: 'salary' 
      }] 
     }], 
     drilldown: { 
      series: [{ 
       id: 'position', 
       data: [ 
        ['position1', 50], 
        ['position2', 60], 
        ['position3', 25] 
       ] 
      }, { 
       id: 'ages', 
       data: [ 
        ['10-20', 20], 
        ['20-30', 30], 
        ['30-40', 50], 
        ['40-50', 60], 
        ['50-60', 25] 
       ] 
      }, { 
       id: 'salary', 
       data: [ 
        ['salary1', 50000], 
        ['salary2', 20000], 
        ['salary3',10000] 
       ] 
      }] 

檢查這個小提琴,http://jsfiddle.net/6fLhxy00/

+0

對不起,我編輯我的問題,我希望得到父母的名字,當我點擊的孩子。 –

+0

對不起,我沒有理解你的問題。默認情況下,它會顯示父 - >點擊父母.i.e。職位或年齡或薪水,您將得到適當的深入分析。在點擊孩子再次鑽取時,您需要獲得父級或深入查看是否要顯示父級名稱? – Raki

+0

我想要顯示父母名稱,當我點擊孩子... –