Highcharts doesn't work on Heroku

馋奶兔 提交于 2019-12-24 09:24:03

问题


I have a ruby on rails app that uses highcharts.

Locally it works like a charm, however when I push the app to Heroku, Highcharts stops working and the div tag that is supposed to contain the chart appears empty. I even tested it with one of the Highcharts examples (which has only hardcoded data), and still nothing.


回答1:


Figured it out: The problem was in the precompiling of assets. Turned out that highcharts was not precompiled

Added :

config.assets.precompile += ['rollover.js', 'highcharts.js'] to production.rb (i suppose application.rb should work as well)

and

to layout file.

(since i expected all javascript files gets compiled in application.jss i only had <%= javascript_include_tag "application" %> in my layout file)




回答2:


Sounds like Highcharts is not loading - either because it isn't being pushed to Heroku or because it isn't being served properly. Go to the URL where highcharts.js should be and see if you get the JavaScript or a 404.

If you can reach highcharts.js without issue then the problem is most likely in the setup code. Check and see if the appropriate variables are loaded onto the page (using the web developer tools for the browser you are testing in) and if there are any JavaScript errors showing up when the page is loaded.




回答3:


Using lazy highcharts gem. Googled for an hour Nothing worked out for me. Finally I've copied highcharts.js from Vendor directory and pasted it to assets. Viola!



来源:https://stackoverflow.com/questions/11998902/highcharts-doesnt-work-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!