2017-04-03 59 views
0

這個小提琴在IE瀏覽器中無法使用,在此停留數小時。幫我解決這個問題。我不知道爲什麼會出錯。代碼在Mozilla和Chrome的Highcharts Drilldown在IE中無法正常工作

工作正常

Here is JSFiddle


var chart = new Highcharts.Chart({ 
 
    chart: { 
 
    renderTo: 'container', 
 
    type: 'column', 
 
    events: { 
 
     drilldown: function(e) { 
 
     var chart = this; 
 
     drilldowns = chart.userOptions.drilldown.series; 
 
     series = []; 
 
     e.preventDefault(); 
 
     Highcharts.each(drilldowns, function(p, i) { 
 
      if (p.id.includes(e.point.drilldown)) { 
 
      chart.addSingleSeriesAsDrilldown(e.point, p); 
 
      } 
 
     }); 
 
     chart.applyDrilldown(); 
 
     } 
 
    } 
 
    }, 
 
    title: { 
 
    text: 'Scores par paliers' 
 
    }, 
 
    xAxis: { 
 
    type: 'category', 
 
    labels: { 
 
     rotation: -45, 
 
     align: 'right', 
 
     style: { 
 
     fontFamily: 'Verdana, sans-serif' 
 
     } 
 
    }, 
 
    min: 0 
 
    }, 
 
    yAxis: { 
 
    title: { 
 
     text: 'Score' 
 
    }, 
 
    max: 100, 
 
    tickInterval: 10, 
 
    min: 0 
 
    }, 
 
    legend: { 
 
    enabled: true 
 
    }, 
 
    plotOptions: { 
 
    series: { 
 
     borderWidth: 0, 
 
     dataLabels: { 
 
     enabled: true 
 
     } 
 
    } 
 
    }, 
 
    exporting: { 
 
    enabled: true 
 
    }, 
 
    tooltip: { 
 
    formatter: function() { 
 
     if (this.point.drilldown) { 
 
     var s = this.key + ' : <b>' + this.y + ' %</b>'; 
 
     } else { 
 
     var s = this.key + ' : <b>' + this.y + '</b>'; 
 
     } 
 
     return s; 
 
    } 
 
    }, 
 
    series: [{ 
 
    name: 'Marches', 
 
    colorByPoint: true, 
 
    data: [{ 
 
     name: 'september', 
 
     y: 89, 
 
     drilldown: 'step1' 
 
     }, 
 
     { 
 
     name: 'october', 
 
     y: 17, 
 
     drilldown: 'step2' 
 
     }, { 
 
     name: 'nov', 
 
     y: 89, 
 
     drilldown: 'step3' 
 
     }, 
 
     { 
 
     name: 'dec', 
 
     y: 17, 
 
     drilldown: 'step4' 
 
     }, { 
 
     name: 'jan', 
 
     y: 89, 
 
     drilldown: 'step5' 
 
     }, 
 
     { 
 
     name: 'feb', 
 
     y: 17, 
 
     drilldown: 'step6' 
 
     }, 
 
    ] 
 
    }, { 
 
    type: 'spline', 
 

 
    data: [{ 
 
     name: 'september', 
 
     y: 89, 
 
     drilldown: 'step1' 
 
     }, 
 
     { 
 
     name: 'october', 
 
     y: 17, 
 
     drilldown: 'step2' 
 
     }, { 
 
     name: 'nov', 
 
     y: 89, 
 
     drilldown: 'step3' 
 
     }, 
 
     { 
 
     name: 'dec', 
 
     y: 17, 
 
     drilldown: 'step4' 
 
     }, { 
 
     name: 'jan', 
 
     y: 89, 
 
     drilldown: 'step5' 
 
     }, 
 
     { 
 
     name: 'feb', 
 
     y: 17, 
 
     drilldown: 'step6' 
 
     }, 
 
    ] 
 
    }], 
 
    drilldown: { 
 
    drillUpButton: { 
 
     relativeTo: 'spacingBox', 
 
     position: { 
 
     y: 0, 
 
     x: -50 
 
     } 
 
    }, 
 
    series: [{ 
 
     id: 'step1', 
 
     name: 'Step 1', 
 
     type: 'column', 
 
     data: [ 
 
      ['Game 1', 100], 
 
      ['Game 2', 100], 
 
      ['Game 3', 100] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step2', 
 
     name: 'Step 2', 
 
     type: 'column', 
 
     data: [ 
 
      ['Game 1', 0], 
 
      ['Game 2', 100], 
 
      ['Game 3', 0] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step1', 
 
     name: 'Step 1', 
 
     type: 'spline', 
 
     data: [ 
 
      ['Game 1', 83], 
 
      ['Game 2', 82], 
 
      ['Game 3', 79] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step2', 
 
     name: 'Step 2', 
 
     type: 'spline', 
 
     data: [ 
 
      ['Game 1', 0], 
 
      ['Game 2', 100], 
 
      ['Game 3', 0] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step3', 
 
     name: 'Step 3', 
 
     type: 'column', 
 
     data: [ 
 
      ['Game 1', 100], 
 
      ['Game 2', 100], 
 
      ['Game 3', 100] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step4', 
 
     name: 'Step 4', 
 
     type: 'column', 
 
     data: [ 
 
      ['Game 1', 0], 
 
      ['Game 2', 100], 
 
      ['Game 3', 0] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step3', 
 
     name: 'Step 3', 
 
     type: 'spline', 
 
     data: [ 
 
      ['Game 1', 83], 
 
      ['Game 2', 82], 
 
      ['Game 3', 79] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step4', 
 
     name: 'Step 4', 
 
     type: 'spline', 
 
     data: [ 
 
      ['Game 1', 0], 
 
      ['Game 2', 100], 
 
      ['Game 3', 0] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step5', 
 
     name: 'Step 5', 
 
     type: 'column', 
 
     data: [ 
 
      ['Game 1', 100], 
 
      ['Game 2', 100], 
 
      ['Game 3', 100] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step6', 
 
     name: 'Step 6', 
 
     type: 'column', 
 
     data: [ 
 
      ['Game 1', 0], 
 
      ['Game 2', 100], 
 
      ['Game 3', 0] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step5', 
 
     name: 'Step 5', 
 
     type: 'spline', 
 
     data: [ 
 
      ['Game 1', 83], 
 
      ['Game 2', 82], 
 
      ['Game 3', 79] 
 
     ] 
 
     }, 
 
     { 
 
     id: 'step6', 
 
     name: 'Step 6', 
 
     type: 'spline', 
 
     data: [ 
 
      ['Game 1', 0], 
 
      ['Game 2', 100], 
 
      ['Game 3', 0] 
 
     ] 
 
     } 
 
    ] 
 
    } 
 
});
<script src="https://code.highcharts.com/highcharts.js"></script> 
 
<script src="https://code.highcharts.com/modules/data.js"></script> 
 
<script src="https://code.highcharts.com/modules/drilldown.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="container" style="width:100%;height:400px;"> 
 
</div>

+0

哪個版本的IE瀏覽器是你在說的,請更新代碼你已經嘗試在問題 – user93

+0

IE 11,這是小提琴https://jsfiddle.net/2qrah67w/ –

+0

你在控制檯得到什麼錯誤? – user93

回答

0

下鑽沒有在IE工作,因爲你正在使用包括未在IE支持的方法。使用該方法的填充方法將使其工作。

if (!String.prototype.includes) { 
    String.prototype.includes = function() { 
     'use strict'; 
     return String.prototype.indexOf.apply(this, arguments) !== -1; 
    }; 
} 

這裏是更新的code在IE中工作。

+0

感謝隊友,工程罰款,但我不知道爲什麼我們添加上述腳本將是偉大的,如果你能解釋。如果這是一個愚蠢的問題,編程新手就會隨我而行。 –

+0

這是一個polyfill。由於IE中的string.prototype沒有include方法,因此您正在手動添加它。 – user93

+0

http://stackoverflow.com/questions/7087331/what-is-the-meaning-of-polyfills-in-html5希望它有幫助 – user93