Highmaps with US States in Rails

947 views Asked by At

I am trying to add a widget in my rails application, in which i am going to display the US states maps as given Demo here in highcharts

The app is using highcharts-rails gem of version 4.0.4, to display some other charts in the application. To use the maps, i am trying to include the js files from gem in application.js file as follows.

//= require highcharts
//= require highcharts/modules/data
//= require highcharts/modules/map

and also the JS file for loading states information in application.html.erb

<script src="http://code.highcharts.com/mapdata/countries/us/us-all.js"></script>

I am able to get the state codes Highcharts.maps['countries/us/us-all'] and also constructed the data from application as required. But the map is not displaying any thing and not seeing any errors in the console also.

But when i remove the including lines from application.js file and add the Java Script files explicitly, the map is loading perfectly without any issues. The below are the two js files that i am adding in my layout.

<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/mapdata/countries/us/us-all.js"></script>

Any help, why it is not loading the maps when i include the files through gem ?

Thanks in Advance.

1

There are 1 answers

0
Sagar Bommidi On BEST ANSWER

Finally able to make it work with the gem itself, but i have to explicitly include the

//= require highcharts/modules/map

with the file that is available in http://www.highcharts.com/download for highmaps plugin, available in Highmaps-1.0.4/js/modules/map.src.js

Check the issue in github