我可以通过在application.js
中要求在Ruby on Rails应用程序中创建图表高点图和雷达图:
//= require jquery3
//= require highcharts
//= require highcharts/highcharts-more
然后,我需要添加一个高图地图。但是,调用地图生成函数Highcharts.mapChart('container', {...
会引发:
Uncaught TypeError: Highcharts.mapChart is not a function
我似乎可以通过将//= require highcharts
替换为//= require highmaps
并添加//= require highcharts/modules/map
来解决该错误。现在我既有柱形图又有地图。但是删除//= require highcharts
会导致在调用雷达图Uncaught ReferenceError: Highcharts is not defined
时出错。由于出现冲突,我不能同时要求highcharts和highmaps
Uncaught Error: Highcharts error #16: Highcharts already defined in the page
This error happens if the Highcharts namespace already exists when loading Highcharts or Highstock.
尝试将//= require highmaps
放在//= require highcharts/highcharts-more
之前可以解决该错误,但会引发两个新错误:Uncaught TypeError: Cannot read property 'prototype' of undefined
和Uncaught TypeError: Cannot read property 'updateCenter' of undefined
。
如何在同一应用程序中同时获取柱,雷达和地图?
答案 0 :(得分:0)
您不应同时使用Highmaps
和map
模块。您可以将map
插件用作Highcharts
的插件:
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/maps/modules/map.js"></script>