D3-将JSON中的颜色用于图表

时间:2018-09-19 19:02:37

标签: javascript d3.js

我有一个如下所示的JSON文件:

device:scripts work$ sudo code
Password:
module.js:550
    throw err;
    ^

Error: Cannot find module './product.json'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at [eval]:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:653:30)
    at evalScript (bootstrap_node.js:479:27)
module.js:550
    throw err;
    ^

Error: Cannot find module '/usr/local/build/lib/electron.js'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
/usr/local/bin/code: line 29: ./node_modules/.bin/gulp: No such file or directory
module.js:550
    throw err;
    ^

Error: Cannot find module '/usr/local/build/lib/builtInExtensions.js'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
/usr/local/bin/code: line 41: ./node_modules/.bin/gulp: No such file or directory
/usr/local/bin/code: line 50: /usr/local/.build/electron/.app/Contents/MacOS/Electron: No such file or directory
/usr/local/bin/code: line 50: exec: /usr/local/.build/electron/.app/Contents/MacOS/Electron: cannot execute: No such file or directory

这被馈送到读取此文件的D3图表中。我想要做的就像下面的现有填充功能一样:

update_column :to_destroy, true

取而代之的是从json中提取颜色。在这种情况下,为灰色。谁能帮我吗?

编辑:基于下面的帮助,我有此代码,但仍然无法使用:

{  
   "name":"TOPICS",
   "children":[  
      {  
         "name":"Topic A",
         "children":[  
            {  
               "name":"Anna",
               "size":5,
               "text":"A story",
               "sentiment":0.8,
               "source":"dictionary",
               "color":"gray"
            },

0 个答案:

没有答案