javascript 一起使用 Highchart 和 Highmap 时解决冲突(TypeError: ma is not a function)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25230483/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 04:13:03  来源:igfitidea点击:

Resolve Conflict When Using Highchart and Highmap together (TypeError: ma is not a function)

javascriptjqueryhighchartsconflicting-librarieshighmaps

提问by m hanif

I've a page that contain chart and map menu for report function. Then, I choose Highchart-Highmap library to reach the purpose above. The chart function runs well but when I develop map function there's a error appear

我有一个页面,其中包含用于报告功能的图表和地图菜单。然后,我选择 Highchart-Highmap 库来达到上述目的。图表功能运行良好,但是当我开发地图功能时出现错误

TypeError: ma is not a function

类型错误:ma 不是函数

  • I've traced the problem that the ma function is appear in highchart.js and highmaps.js but I don't know how to resolve this conflict.
  • I've try put jQuery.noConflict();in highmaps but the conflict still appear
  • 查到了highchart.js和highmaps.js中ma函数出现的问题,但是不知道怎么解决这个冲突。
  • 我试过放入高图jQuery.noConflict();,但冲突仍然出现

This how I code in main page

这是我在主页上编码的方式

... some html code
<script type="text/javascript" src="././js/highcharts/highcharts.js"></script>
<script type="text/javascript" src="././js/highcharts/highcharts-more.js"></script>
<script type="text/javascript" src="././js/highcharts/highcharts-3d.js"></script>            
<script type="text/javascript" src="././js/highcharts/modules/drilldown.js"></script>
<script type="text/javascript" src="././js/highcharts/modules/exporting.js"></script>

... some html code
<script type="text/javascript" src="././js/Highmaps/highmaps.js"></script>
<script type="text/javascript" src="././js/Highmaps/modules/data.js"></script>                
<script type="text/javascript" src="././js/Highmaps/modules/exporting.js"></script> 

How I can resolve this problem?

我该如何解决这个问题?

回答by Sebastian Bochan

Instead of highmaps, you need to use map.js module.

您需要使用 map.js 模块而不是 highmaps。

<script src="//code.highcharts.com/maps/modules/map.js"></script>

Here is the documentation on using both together.

这是有关同时使用两者的文档

回答by gfivehost

You must include this script tag after highcharts.js:

您必须在以下之后包含此脚本标记highcharts.js

<script src="https://code.highcharts.com/maps/modules/map.js"></script> 

回答by Danny Shumer

I encountered the same issue, and resolved it by placing highcharts after the maps

我遇到了同样的问题,并通过在地图之后放置 highcharts 解决了这个问题

<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/maps/modules/data.js"></script>
<script src="http://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="http://code.highcharts.com/mapdata/custom/world.js"></script>
<script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>

http://jsfiddle.net/danny_shumer/tc898kgv/2/

http://jsfiddle.net/danny_shumer/tc898kgv/2/