Having trouble just getting the Highchart to show

前端 未结 3 746
刺人心
刺人心 2021-01-18 21:33

I\'m pretty new to Javascript, Rails and JQuery all working together.

I\'m going through this tutorial (http://www.highcharts.com/documentation/how-to-use#installati

相关标签:
3条回答
  • 2021-01-18 21:53

    The problem is in the first line of source that is var charts; remove it and you are done.

    0 讨论(0)
  • 2021-01-18 21:54

    As we discussed in chat, there were a few missing pieces.

    • You needed a local copy of the Highcharts library
    • You needed to reference your script that calls the library from the correct place.

    So, in short, you needed this in your layout:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> 
    <script src="/javascripts/js/highcharts.js" type="text/javascript"></script> <!--where you put the high charts library -->
    <script src="/highcharts.js" type="text/javascript"></script> <!-- your script -->
    

    Now going forward (assuming you are working w/ rails 3.1+), I'd suggest moving your javascripts to a more conventional location. In 3.1, rails likes to see it in app/assets/javascripts but public/javascripts is still fine, just not exactly conventional.

    You will get a lot of milage by understanding the rails helpers to insert script tags and the Asset Pipeline.

    Good luck!

    0 讨论(0)
  • 2021-01-18 22:05

    There is an issue with the Chart keyword. Please change like

    new Highcharts.Chart({ Chart is with small c

    0 讨论(0)
提交回复
热议问题