{"id":14970832,"url":"https://github.com/andfanilo/streamlit-d3-demo","last_synced_at":"2025-10-26T13:31:32.449Z","repository":{"id":55068089,"uuid":"268390962","full_name":"andfanilo/streamlit-d3-demo","owner":"andfanilo","description":"D3 in React in Streamlit tech demo","archived":false,"fork":false,"pushed_at":"2020-07-06T17:09:20.000Z","size":1518,"stargazers_count":79,"open_issues_count":1,"forks_count":17,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-09-28T13:41:10.423Z","etag":null,"topics":["d3","python3","react","streamlit"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/andfanilo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-01T00:45:11.000Z","updated_at":"2024-09-27T17:50:49.000Z","dependencies_parsed_at":"2022-08-14T11:00:35.613Z","dependency_job_id":null,"html_url":"https://github.com/andfanilo/streamlit-d3-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andfanilo%2Fstreamlit-d3-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andfanilo%2Fstreamlit-d3-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andfanilo%2Fstreamlit-d3-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andfanilo%2Fstreamlit-d3-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andfanilo","download_url":"https://codeload.github.com/andfanilo/streamlit-d3-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219862885,"owners_count":16555951,"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","python3","react","streamlit"],"created_at":"2024-09-24T13:44:12.742Z","updated_at":"2025-10-26T13:31:31.485Z","avatar_url":"https://github.com/andfanilo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# D3 Demo in Streamlit\n\nAn example project for a custom D3 chart _with React hooks_ into Streamlit. \n\n* Dynamic line chart\n* Overlapping scatter plot, with customizable size/color\n* Interactive tooltip\n* TODO : Select a circle and return it's value\n* TODO : Zoom/Pan ?\n\nFeel free to fork this project as a starter for your own D3 components.\n\n![](./images/demo.gif)\n\n## Install\n\n```shell script\npip install streamlit-d3-demo\n```\n\n## Example Usage\n\n```python\nimport random\nfrom streamlit_d3_demo import d3_line\n\ndef generate_random_data(x_r, y_r):\n    return list(zip(range(x_r), [random.randint(0, y_r) for _ in range(x_r)]))\n\nd3_line(generate_random_data(20, 500), circle_radius=15, circle_color=\"#6495ed\")\n```\n\n## Development \n\n### Install\n\n* JS side\n\n```shell script\ncd frontend\nnpm install\n```\n\n* Python side \n\n```shell script\nconda create -n streamlit-d3 python=3.7\nconda activate streamlit-d3\npip install -e .\n```\n\n### Run\n\nBoth JS and Python should run at the same time.\n\n* JS side\n\n```shell script\ncd frontend\nnpm run start\n```\n\n* Python side\n\n```shell script\nstreamlit run app.py\n```\n\n## References\n\nD3 :\n* https://observablehq.com/@d3/learn-d3\n* https://observablehq.com/@d3/margin-convention\n* https://wattenberger.com/blog/d3\n* https://wattenberger.com/blog/d3-interactive-charts\n* https://spin.atomicobject.com/2017/07/20/d3-react-typescript/\n* https://medium.com/@kj_schmidt/show-data-on-mouse-over-with-d3-js-3bf598ff8fc2\n\nReact :\n* https://kentcdodds.com/blog/usememo-and-usecallback\n* https://overreacted.io/a-complete-guide-to-useeffect/\n\nD3 + React hooks :\n* https://wattenberger.com/blog/react-and-d3\n* https://medium.com/@jeffbutsch/using-d3-in-react-with-hooks-4a6c61f1d102\n* https://www.youtube.com/playlist?list=PLDZ4p-ENjbiPo4WH7KdHjh_EMI7Ic8b2B\n* https://observablehq.com/@herrstucki/react-hooks-and-d3\n* https://clhenrick.io/animating-svg-d3-react-hooks/\n* https://medium.com/@stopyransky/react-hooks-and-d3-39be1d900fb\n* https://swizec.com/blog/easy-d3-blackbox-components-react-hooks/swizec/8689\n* https://dev.to/benjaminadk/basketball-stats-through-d3-react-4m10\n* https://medium.com/stationfive/how-to-create-a-pie-chart-with-d3-js-and-react-hooks-part-1-81bcd7f39b32\n\nD3 + React class component :\n* https://hackernoon.com/how-and-why-to-use-d3-with-react-d239eb1ea274/\n* https://www.smashingmagazine.com/2018/02/react-d3-ecosystem/\n* https://gist.github.com/alexcjohnson/a4b714eee8afd2123ee00cb5b3278a5f\n* https://blog.logrocket.com/data-visualization-in-react-using-react-d3-c35835af16d0/\n* https://www.freecodecamp.org/news/how-to-get-started-with-d3-and-react-c7da74a5bd9f/\n* https://grafana.com/tutorials/build-a-panel-plugin-with-d3/#6\n* https://stackoverflow.com/questions/49611148/how-to-add-tooltip-in-react-d3-v4-bar-chart\n* https://stackoverflow.com/questions/38116805/react-js-d3-charts-tooltip/56674517#56674517\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandfanilo%2Fstreamlit-d3-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandfanilo%2Fstreamlit-d3-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandfanilo%2Fstreamlit-d3-demo/lists"}