我正在使用用 Highcharts 创建的图表。它们在我的本地开发环境中运行良好,但在 Heroku 上没有显示图表。div 只是空的:
<div id="dashboard_chart_75"></div>
我正在使用lazy_high_charts gem,这是我的application.js
:
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require general.js.erb
//= require_tree .
//= require turbolinks
//= require highcharts/highcharts
//= require highcharts/highcharts-more
//= require social-share-button
//= require ckeditor-jquery
这是生成图表的代码:
spider_chart = LazyHighCharts::HighChart.new('graph') do |f|
f.chart(polar: true, type: 'line', height: @height)
f.pane(size: @size)
f.colors(['#C41D21','#1c77bb'])
f.xAxis(
categories: categories.map{ |c| [@survey.id,c.id, c.name] },
tickmarkPlacement: 'on',
lineWidth: 0,
labels: {
style: {
fontSize: '12px',
weight: 'bold',
width: '100%'
},
formatter: %|function() {return '<a href="' + window.location.hostname + '/dashboards/spiders?level=2&survey_id=' + this.value[0] + '&category_id=' + this.value[1] + '">' + this.value[2] + '</a>';}|.js_code }
)
f.yAxis(gridLineInterpolation: 'polygon', lineWidth: 0, min: 0, max: 10,tickInterval: 1, tickWidth: 20)
f.tooltip(enabled: false)
f.series(name: "Gemiddelde van gewenste score", data: norm_scores, pointPlacement: 'on')
f.series(name: "Gemiddelde van huidige score", data: current_scores, pointPlacement: 'on')
f.legend(enabled: @legend, align: 'center', verticalAlign: 'top', y: 10, layout: 'vertical')
end
在生产中,我在控制台中看到此错误:
Uncaught ReferenceError: Highcharts is not defined at window.onload
指的是这一行:
window.chart_spider_chart = new Highcharts.Chart(options);
这可能是什么原因?