Javascript highcharts组织结构图在加载模块时引发错误
我正在尝试使用highcharts和highcharts生成组织结构图。但是,在加载组织结构图模块时出现以下错误Javascript highcharts组织结构图在加载模块时引发错误,javascript,angular,highcharts,highcharts-ng,angular2-highcharts,Javascript,Angular,Highcharts,Highcharts Ng,Angular2 Highcharts,我正在尝试使用highcharts和highcharts生成组织结构图。但是,在加载组织结构图模块时出现以下错误 organization.js:9 Uncaught TypeError: Cannot read property 'prototype' of undefined at organization.js:9 at e (organization.js:9) at organization.js:9 at Module../src/app/my-network-chart/my-ne
organization.js:9 Uncaught TypeError: Cannot read property 'prototype' of undefined
at organization.js:9
at e (organization.js:9)
at organization.js:9
at Module../src/app/my-network-chart/my-network-chart.component.ts (my-network-chart.component.ts:9)
at __webpack_require__ (bootstrap:78)
at Module../src/app/app.module.ts (app.component.ts:8)
at __webpack_require__ (bootstrap:78)
at Module../src/main.ts (main.ts:1)
at __webpack_require__ (bootstrap:78)
at Object.0 (main.ts:12)
我做错什么了吗?我使用相同的代码生成网络图,它工作正常,没有任何问题。我只是用组织结构图来面对这个问题
装载组织结构图:
import { Component, OnInit } from '@angular/core';
import * as Highcharts from 'highcharts';
import HighchartsOrganization from "highcharts/modules/organization";
import HighchartsExporting from "highcharts/modules/exporting";
HighchartsOrganization(Highcharts);
HighchartsExporting(Highcharts);
正在加载网络图:在这种情况下没有问题
import { Component, OnInit } from '@angular/core';
import * as Highcharts from 'highcharts';
import HighchartsNetworkgraph from "highcharts/modules/networkgraph";
import HighchartsExporting from "highcharts/modules/exporting";
HighchartsNetworkgraph(Highcharts);
HighchartsExporting(Highcharts);
该模块需要该模块,因此您需要首先导入该模块,例如:
import { Component, OnInit } from '@angular/core';
import * as Highcharts from 'highcharts';
import HighchartsSankey from "highcharts/modules/sankey";
import HighchartsOrganization from "highcharts/modules/organization";
import HighchartsExporting from "highcharts/modules/exporting";
HighchartsSankey(Highcharts);
HighchartsOrganization(Highcharts);
HighchartsExporting(Highcharts);
请参见导入sankey.js的官方文件以进一步扩展sheilak的回答,您需要在导入组织之前导入sankey,否则您仍然会得到TypeError,可能还有错误17。如果打开organization.src.js,您将看到顶部的define使此组织结构图依赖于highcharts和sankey,这就是为什么它们必须在它之前声明的原因
这让我感到困惑,因为我们使用Bower来管理我们的依赖关系,我首先添加了organization,然后添加了sankey,我不明白为什么它仍然抛出这个错误。对导入进行重新排序修复了它 是的,成功了。我完全忽略了Sankey模块。谢谢你的帮助。