問題描述
Electron 的網站說,使用 electron 制作的應用程序可以訪問節點模塊.他們可以訪問 D3 庫嗎?如果可以,如何設置?
Electron's website says that the applications made with electron can have access to node modules. Can they have access to the D3 library? If so, how can it be set up?
推薦答案
D3 可作為 Node.js模塊,可以導入到您要用于呈現可視化應用程序的 JavaScript 代碼中.
D3 is available as a Node.js module that can be imported into the JavaScript code you want to use to render your visualisation application.
作為如何將 D3 集成到 Electron 應用程序的示例,請查看我的 GitHub 上的 D3 Space Filler Explorer 應用程序.此應用程序通過多個 D3 餅圖和 D3 樹狀圖可視化磁盤空間使用情況.
As an example of how to integrate D3 into an Electron application, have a look at my D3 Space Filler Explorer application on GitHub. This application visualises disk space use with multiple D3 pie charts and a D3 treemap.
我發現一種有用的模式是將 SVG 元素注入到 D3 可視化中,這與 D3 示例中通常在可視化中創建 SVG 元素的方法不同.在/app/js/pie-chart.js 和/app/js/treemap-chart.js 文件中查看這種依賴注入的示例.
One pattern I found useful was to inject the SVG element into the D3 visualisation, which differs from the usual approach in D3 examples which creates the SVG element in the visualisation. See examples of this dependency injection in the /app/js/pie-chart.js and /app/js/treemap-chart.js files.
這篇關于D3 庫可以與 Electron(Atom shell)一起使用嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!