2017-02-10 62 views
0

**編輯 - 我將其縮小到這一行來打破它 - pointFormat:'{series.name}:{point.percentage:.1f}%' 任何想法爲什麼會發生?除'bar'圖表之外的任何其他內容highcharts.js

幾年前,我使用了highcharts,我剛剛重新認識。出於某種原因,除餅圖工作外,我無法獲得任何其他信息。

使用基本欄示例正常工作:

<script> 
$(function() { 
var myChart = Highcharts.chart('stats_container', { 
    chart: { 
     type: 'bar' 
    }, 
    title: { 
     text: 'Fruit Consumption' 
    }, 
    xAxis: { 
     categories: ['Apples', 'Bananas', 'Oranges'] 
    }, 
    yAxis: { 
     title: { 
      text: 'Fruit eaten' 
     } 
    }, 
    series: [{ 
     name: 'Jane', 
     data: [1, 0, 4] 
    }, { 
     name: 'John', 
     data: [5, 7, 3] 
    }] 
}); 
}); 
</script> 

但是當我去使用任何其他例子,如餅圖:

<script> 
$(function() { 
var myChart = Highcharts.chart('stats_container', { 
chart: { 
    plotBackgroundColor: null, 
    plotBorderWidth: null, 
    plotShadow: false, 
    type: 'pie' 
}, 
title: { 
    text: 'Browser market shares January, 2015 to May, 2015' 
}, 
tooltip: { 
    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' 
}, 
plotOptions: { 
    pie: { 
     allowPointSelect: true, 
     cursor: 'pointer', 
     dataLabels: { 
      enabled: true, 
      format: '<b>{point.name}</b>: {point.percentage:.1f} %', 
      style: { 
       color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' 
      } 
     } 
    } 
}, 
series: [{ 
    name: 'Brands', 
    colorByPoint: true, 
    data: [{ 
     name: 'Microsoft Internet Explorer', 
     y: 56.33 
    }, { 
     name: 'Chrome', 
     y: 24.03, 
     sliced: true, 
     selected: true 
    }, { 
     name: 'Firefox', 
     y: 10.38 
    }, { 
     name: 'Safari', 
     y: 4.77 
    }, { 
     name: 'Opera', 
     y: 0.91 
    }, { 
     name: 'Proprietary or Undetectable', 
     y: 0.2 
    }] 
}] 
}); 
}); 
</script> 

我得到一個HTTP 500錯誤。我也嘗試了一個很高的例子,並且發生了同樣的問題。任何人都可以看到我要去哪裏嗎?我可以放入餅圖的系列和其他細節,但是當我開始放置提示圖標時,它會中斷。謝謝

+1

在你的代碼中沒有向任何服務器請願......如果你獲得HTTP 500,它必須與服務器相關。 Javascript不會導致錯誤500,內部服務器錯誤導致它。 – r1verside

+0

好的,謝謝@ r1verside。一個人工作而另一個人工作真的很奇怪。無法弄清楚。 – user1180888

回答

0

我使用smarty模板,並且js不在{literal}標記中。 Oooops

相關問題