d3。scaleSequential不是一个函数。
Following Mike Bostock's great tutorial on command-line cartography, when trying to produce a choropleth, I receive a TypeError saying that d3.scaleSequential
is not a function. I imagine it is just not being exposed? But I don't know how to deal with that through the CLI...?
在迈克·博斯托克(Mike Bostock)关于命令行制图的出色教程之后,当我试图生成一个choroples的时候,我收到了一个TypeError,说d3。scaleSequential不是一个函数。我想它只是没有暴露出来?但是我不知道如何通过CLI来解决这个问题…?
Error Traceback:
错误回溯:
TypeError: d3.scaleSequential is not a function at evalmachine.:1:26 at Interface. (/usr/local/lib/node_modules/ndjson-cli/ndjson-map:45:14) at emitOne (events.js:77:13) at Interface.emit (events.js:169:7) at Interface._onLine (readline.js:210:10) at Interface. (readline.js:340:12) at Array.forEach (native) at Interface._normalWrite (readline.js:339:11) at ReadStream.ondata (readline.js:86:10) at emitOne (events.js:77:13)
I have all of the needed libraries installed and updated through npm, so that isn't the issue..any thoughts on how to debug this would be greatly appreciated.
我已经安装并更新了所有需要的库,所以这不是问题。任何关于如何调试的想法都会非常感谢。
Currently Installed:
目前安装:
- d3@4.9.1
- d3@4.9.1
- d3-geo-projection@2.1.2
- d3-geo-projection@2.1.2
- d3-scale@1.0.6
- d3-scale@1.0.6
- d3-scale-chromatic@1.1.1
- d3-scale-chromatic@1.1.1
Sample Code
The code is copied pretty much straight from the tutorial and this is the first step that doesn't work..
代码从教程中直接复制,这是第一步行不通的。
ndjson-map -r d3 \ '(d.properties.fill = d3.scaleSequential(d3.interpolateViridis).domain([0, 4000])(d.properties.density), d)' \ ca-albers-color.ndjson
1 个解决方案
#1
0
When you are using the CLI, d3
needs to be accessible to node.js, so you should npm install -g d3
(global), or in the directory from which you're running the command line scripts, npm install d3
.
当您使用CLI时,d3需要被节点访问。js,所以您应该在npm安装- gd3(全局),或者在运行命令行脚本的目录中,npm安装d3。
UPDATE: If you use the global approach, you may need to link the package (https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/) or set your NODE_PATH
variable to have access to the folder where global modules are installed.
更新:如果您使用全局方法,您可能需要链接这个包(https://nodejs.org/en/blog/npm/npm- 1.0 -global- local-installation/),或者设置您的NODE_PATH变量,以访问安装全局模块的文件夹。
更多相关文章
- JavaScript声明全局变量三种方式的异同
- javascript变量:全局?还是局部?这个得注意
- Python NameError:全局名称“Form”没有定义pyqt
- “全局变量是坏的”是什么意思?
- python的全局变量与局部变量实验
- Python如何规避全局解释器锁(GIL)带来的限制
- Android在Service中弹出对话框(Dialog),即全局性对话框
- JAVA-全局变量与局部变量-继承-封装-(是三节哦!今天的有点多)