{"id":13606306,"url":"https://github.com/ResidentMario/py_d3","last_synced_at":"2025-04-12T08:31:00.110Z","repository":{"id":10723079,"uuid":"66747788","full_name":"ResidentMario/py_d3","owner":"ResidentMario","description":"D3 block magic for Jupyter notebook.","archived":false,"fork":false,"pushed_at":"2022-02-20T00:55:57.000Z","size":6604,"stargazers_count":452,"open_issues_count":1,"forks_count":38,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-04T09:45:57.814Z","etag":null,"topics":["d3","data-visualization","jupyter","jupyter-notebook"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ResidentMario.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-28T03:38:28.000Z","updated_at":"2025-03-25T11:22:31.000Z","dependencies_parsed_at":"2022-08-07T06:00:25.947Z","dependency_job_id":null,"html_url":"https://github.com/ResidentMario/py_d3","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ResidentMario%2Fpy_d3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ResidentMario%2Fpy_d3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ResidentMario%2Fpy_d3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ResidentMario%2Fpy_d3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ResidentMario","download_url":"https://codeload.github.com/ResidentMario/py_d3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248539783,"owners_count":21121233,"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","jupyter","jupyter-notebook"],"created_at":"2024-08-01T19:01:07.950Z","updated_at":"2025-04-12T08:30:55.102Z","avatar_url":"https://github.com/ResidentMario.png","language":"Python","readme":"# py_d3  [![PyPi version](https://img.shields.io/pypi/v/py_d3.svg)](https://pypi.python.org/pypi/py_d3/) ![t](https://img.shields.io/badge/status-unmaintained-red.svg)\n\n## Deprecation notice\n\nThe `py_d3` package has been retired. This package was only ever intended to work in the classical Jupyter Notebook environment, this has been replaced pretty much all applications by the more advanced and more feature-complete Jupyter Lab. Jupyter Lab has a completely different SDK for notebook extensions, which this package neither uses nor supports.\n\nAs such this package is now unmaintained.\n\nFor users looking for an interactive environment for building D3.JS visualizations in, I recommend [Observable Notebooks](https://observablehq.com/explore).\n\nFor users looking to embed D3.JS visualizations in their Jupyter Lab notebooks, [check out this Gist](https://gist.github.com/gnestor/f1893e0226ced227e910f11b769adc06).\n\nHappy plotting!\n\n## About\n\n`py_d3` is an IPython extension which adds D3 support to the Jupyter Notebook environment.\n\nD3 is a powerful JavaScript data visualization library, while Jupyter is an intuitive browser-hosted Python \ndevelopment environment. Wouldn't it be great if you could use them together? Now you can.\n\n## Quickstart\n\nYou can install `py_d3` by running `pip install py_d3`. Then load it into a Jupyter notebook by \nrunning`%load_ext py_d3`.\n\nUse the `%%d3` [cell magic](http://ipython.readthedocs.io/en/stable/config/extensions/index.html#ipython-extensions) \nto define notebook cells with D3 content.\n\n![alt text](./figures/import-py-d3-example.png \"Logo Title Text 1\")\n\n`py_d3` allows you to express even very complex visual ideas within a Jupyter Notebook without much difficulty.\nA [Radial Reingold-Tilford Tree](http://bl.ocks.org/mbostock/4063550), for example:\n\n![alt text](./figures/radial-tree-example.png \"Logo Title Text 1\")\n\nAn interactive treemap ([original](http://bl.ocks.org/mbostock/4063582)):\n\n![alt text](./figures/tree-diagram-example.gif \"Logo Title Text 1\")\n\nOr even the entire [D3 Show Reel](https://bl.ocks.org/mbostock/1256572) animation:\n\n![alt text](./figures/show-reel.gif \"Logo Title Text 1\")\n\nFor more examples refer to the [examples notebooks](https://github.com/ResidentMario/py_d3/tree/master/notebooks).\n\n## Features\n\n### Configuration\n\nThe cell magic will default to loading the latest stable version of D3.JS available online (via \n[CDNJS](https://cdnjs.com/about); `d3@4.13.0` at time of writing). To load a specific version, append the version \nname to the command, e.g. `%%d3 \"3.5.17\"`. To load D3.JS from a local file pass the filepath, e.g. \n`%%d3 \"d3.v5.min.js\"`.\n\nOnly one version of D3.JS may be loaded at a time. Both `3.x` and `4.x` versions of D3 are supported, but you may \nonly run one version of D3 per notebook. You can check which versions are available by running `%d3 versions`, and check which version \nis loaded in the *current* notebook using `%d3 version`. \n\n### Documentation\n\nPages from the [D3 API Reference](https://github.com/d3/d3/blob/master/API.md) may be rendered in-notebook using \n`%d3 doc`. For example, you can render the `d3-array` reference by running `%d3 doc \"d3-array\"`.\n\n### Verbose Mode\n\nYou can view code to-be-rendered using verbose mode: `%d3 -v`. This is helpful for debugging your application.\n\n## Technical\n\n### How it works\n\nJupyter notebooks allow executing arbitrary JavaScript code using `IPython.display.JavaScript`, however it makes no \neffort to restrict the level of DOM objects accessible to executable code. `py_d3` works by restricting `d3` scope to\nwhatever cell you are running the code in, by monkey-patching the `d3.select` and `d3.selectAll` methods (see \n[here](https://github.com/d3/d3/issues/2947) for why this works).\n\n### Porting\n\nMost HTML-hosted D3 visualizations, even very complex ones, can be made to run inside of a Jupyter Notebook `%%d3` cell with just two modifications:\n\n* Remove any D3 imports in the cell (e.g. `\u003cscript src=\"https://d3js.org/d3.v3.js\"\u003e\u003c/script\u003e`).\n* Make sure to create and append to a legal HTML document sub-element. `d3.select(\"body\").append(\"g\")` won't work.\n\n### Contributing\n\nSee `CONTRIBUTING.md` for instructions on how to contribute.\n","funding_links":[],"categories":["Python","Jupyter-magic拓展"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FResidentMario%2Fpy_d3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FResidentMario%2Fpy_d3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FResidentMario%2Fpy_d3/lists"}