0

我想在 Angular 项目中使用 d3plus。主要是因为它巧妙的文字换行。

我制作了一个d3.lib.ts文件:

export * from 'd3';
export * from 'd3plus';

IntelliJ 中的“d3plus”为红色。我已经 npm 安装了 d3、d3plus、@types/d3 和 @types/d3plus。这可能是矫枉过正,但肯定这里的东西应该工作。

当我构建时,我得到:

ERROR in ./node_modules/d3plus/src/init.coffee 1:0
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
> ###*
| # @class d3plus
| ###
ERROR in ./node_modules/d3plus/src/libs.coffee 1:26
Module parse failed: Unexpected token (1:26)
You may need an appropriate loader to handle this file type.
> window.d3       = require "d3"
| window.topojson = require "topojson"

Angular 似乎正在尝试解释咖啡脚本,但我不知道它为什么会这样做。为什么不简单地忽略它并使用其上方文件夹中的 d3plus.js?

我如何让这个工作?这是正确的方法吗?

4

2 回答 2

1

尝试 npm i d3plus@next ,它将安装剩余的软件包。

于 2018-12-07T14:58:11.090 回答
1

我会警告我的答案 - 我正在使用 d3plus 进行文本换行功能。我无法使用d3plus.textwrap某些博客中发布的功能。我从网上的信息推断,在 d3 v4 中必须使用单独的 d3plus 包。以 textwrap 为例,我们必须使用 d3plus-text 包,然后访问 textwrap 函数,如下所示:

new d3plus-text.textWrap()...
于 2019-03-04T20:36:54.633 回答