{"id":13482137,"url":"https://github.com/d3-node/d3-node","last_synced_at":"2025-04-04T18:10:19.582Z","repository":{"id":9769705,"uuid":"63279498","full_name":"d3-node/d3-node","owner":"d3-node","description":"Server-side D3 for static chart/map generation ✨📊","archived":false,"fork":false,"pushed_at":"2023-09-25T00:41:03.000Z","size":1053,"stargazers_count":678,"open_issues_count":8,"forks_count":68,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-04-14T18:54:08.842Z","etag":null,"topics":["d3","data-visualization","node"],"latest_commit_sha":null,"homepage":"https://bradoyler.com/projects/d3-node/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d3-node.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-07-13T21:06:21.000Z","updated_at":"2024-04-02T22:28:14.000Z","dependencies_parsed_at":"2023-01-13T15:33:44.959Z","dependency_job_id":"f1b01856-12c4-4352-838e-656d6199370a","html_url":"https://github.com/d3-node/d3-node","commit_stats":null,"previous_names":["bradoyler/d3-node"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3-node%2Fd3-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3-node%2Fd3-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3-node%2Fd3-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3-node%2Fd3-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d3-node","download_url":"https://codeload.github.com/d3-node/d3-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226215,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["d3","data-visualization","node"],"created_at":"2024-07-31T17:00:59.364Z","updated_at":"2025-04-04T18:10:19.562Z","avatar_url":"https://github.com/d3-node.png","language":"JavaScript","readme":"# D3-Node  \n[![Build Status](https://github.com/d3-node/d3-node/actions/workflows/node.js.yml/badge.svg)](https://github.com/d3-node/d3-node/actions/workflows/node.js.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/d3-node/d3-node.svg)](https://travis-ci.com/d3-node/d3-node)\n[![npm](https://img.shields.io/npm/dm/d3-node.svg)](https://www.npmjs.com/package/d3-node)\n[![npm](https://img.shields.io/npm/l/d3-node.svg)](https://www.npmjs.com/package/d3-node)\n\nServer-side D3 with ease  \n\n\n\u003e Tested on Nodejs v16 \u0026 up\n\n\u003cimg width=\"768\" alt=\"maps and charts with d3-node\" src=\"https://cloud.githubusercontent.com/assets/425966/24722031/2a424edc-1a10-11e7-96a5-cd68ff335017.png\"\u003e\n\n[see examples \u003e](examples)\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\n### Why?\n\n- Performance: pre-rendering allows offloading data processing, and network overhead\n- Take advantage of the entire ecosystem: [npmjs.com](https://www.npmjs.com/)\n- Static rendering of [Data-Driven Documents (D3.js)](https://d3js.org/)\n- Portable SVG with [embedded stylesheets](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/style)\n- Easily adapt examples from [bl.ocks.org](http://bl.ocks.org/)\n\n### Basic usage:\n\n[![NPM](https://nodei.co/npm/d3-node.png?downloads=true\u0026downloadRank=true)](https://nodei.co/npm/d3-node/)\n\n__Create a SVG__\n\n```javascript\n import { D3Node } from 'd3-node' // const D3Node = require('d3-node')\n const d3n = new D3Node()      // initializes D3 with container element\n d3n.createSVG(10,20).append('g') // create SVG w/ 'g' tag and width/height\n d3n.svgString() // output: \u003csvg width=10 height=20 xmlns=\"http://www.w3.org/2000/svg\"\u003e\u003cg\u003e\u003c/g\u003e\u003c/svg\u003e\n```\n\n### Advanced usage\n\n__Setting container \u0026 insertion point via selector__\n\n```javascript\n const options = { selector: '#chart', container: '\u003cdiv id=\"container\"\u003e\u003cdiv id=\"chart\"\u003e\u003c/div\u003e\u003c/div\u003e' }\n const d3n = new D3Node(options) // initializes D3 with container element\n const d3 = d3n.d3\n d3.select(d3n.document.querySelector('#chart')).append('span') // insert span tag into #chart\n d3n.html()   // output: \u003chtml\u003e\u003cbody\u003e\u003cdiv id=\"container\"\u003e\u003cdiv id=\"chart\"\u003e\u003cspan\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/body\u003e\u003c/html\u003e\n d3n.chartHTML()   // output: \u003cdiv id=\"chart\"\u003e\u003cspan\u003e\u003c/span\u003e\u003c/div\u003e\n```\n\n__Inline SVG styles__\n\n```javascript\n const d3n = new D3Node({styles:'.test {fill:#000;}'})\n d3n.createSVG().append('g')\n d3n.svgString()\n```\n\n\u003e Output\n```html\n\u003csvg xmlns=\"http://www.w3.org/2000/svg\"\u003e\n   \u003cdefs\u003e\n     \u003cstyle type=\"text/css\"\u003e\u003c![CDATA[ .test{fill:#000;} ]]\u003e\u003c/style\u003e\n   \u003c/defs\u003e\n   \u003cg\u003e\u003c/g\u003e\n\u003csvg\u003e\n```\n\n__Create a canvas (for generating a png)__\n```javascript\n const canvasModule = require('canvas'); // supports node-canvas v1 \u0026 v2.x\n const d3n = new D3Node({ canvasModule }); // pass it node-canvas\n const canvas = d3n.createCanvas(960, 500);\n const context = canvas.getContext('2d');\n // draw on your canvas, then output canvas to png\n canvas.pngStream().pipe(fs.createWriteStream('output.png'));\n```\n\n### [See examples for more...](examples)\n\n### Run Tests:\n\n```\n$ npm test\n```\n\n### TODOs:\n\n- Add more examples: (remote data, world map)\n- Create Gulp task\n- Add option to inject css/js into html output\n","funding_links":[],"categories":["Server side","Data Visualization"],"sub_categories":["React Components"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3-node%2Fd3-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd3-node%2Fd3-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3-node%2Fd3-node/lists"}