我正在尝试使用 highcharts 和 highcharts-angular 生成组织结构图。但是,它在加载组织结构图模块时抛出以下错误。
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);
最佳答案
Organization chart模块需要 Sankey diagram模块,所以你需要先导入它,例如:
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);
见官方Highcharts Organization example导入 sankey.js
关于javascript - highcharts 组织结构图在加载模块时抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56027187/