dash_echarts is a Dash component library to access echarts from dash.
See CONTRIBUTING.md
After cloning the repo, at its root:
- Install node modules:
$ npm install
- Create a virtual environment named .venv
$ python -m venv .venv
- Activate the virtual environment
$ .venv/Scripts/activate
- Install required packages in the virtual environment
(.venv) $ pip install -r requirements.txt
(.venv) $ npm run build
- The demo app is in
src/demoand you will import your example component code into your demo app. - Test your code in a Python environment:
- Build your code
$ npm run build - Run and modify the
usage.pysample dash app:$ python usage.py
- Build your code
- Write tests for your component.
- A sample test is available in
tests/test_usage.py, it will loadusage.pyand you can then automate interactions with selenium. - Run the tests with
$ pytest tests. - The Dash team uses these types of integration tests extensively. Browse the Dash component code on GitHub for more examples of testing (e.g. https://github.com/plotly/dash-core-components)
- A sample test is available in
- Add custom styles to your component by putting your custom CSS files into your distribution folder (
dash_echarts).- Make sure that they are referenced in
MANIFEST.inso that they get properly included when you're ready to publish your component. - Make sure the stylesheets are added to the
_css_distdict indash_echarts/__init__.pyso dash will serve them automatically when the component suite is requested.
- Make sure that they are referenced in
- Review your code
-
Build your code:
$ npm run build -
Create a Python distribution
$ python setup.py sdist bdist_wheelThis will create source and wheel distribution in the generated the
dist/folder. See PyPA for more information. -
Test your tarball by copying it into a new environment and installing it locally:
$ pip install dash_echarts-0.0.1.tar.gz -
If it works, then you can publish the component to NPM and PyPI:
- Publish on PyPI
$ twine upload dist/* - Cleanup the dist folder (optional)
$ rm -rf dist - Publish on NPM (Optional if chosen False in
publish_on_npm)Publishing your component to NPM will make the JavaScript bundles available on the unpkg CDN. By default, Dash serves the component library's CSS and JS locally, but if you choose to publish the package to NPM you can set$ npm publishserve_locallytoFalseand you may see faster load times.
- Publish on PyPI
-
Share your component with the community! https://community.plotly.com/c/dash
- Publish this repository to GitHub
- Tag your GitHub repository with the plotly-dash tag so that it appears here: https://github.com/topics/plotly-dash
- Create a post in the Dash community forum: https://community.plotly.com/c/dash
Documentation for cookiecutter use with dash component boilerplate can be found here: https://github.com/plotly/dash-component-boilerplate
Install Cookiecutter:
$ pip install cookiecutter
Run the cookiecutter, which will create the project folder:
$ cookiecutter gh:plotly/dash-component-boilerplate
Configure the cookiecutter:
You've downloaded C:\Users\Victor\.cookiecutters\dash-component-boilerplate before. Is it okay to delete and re-download it? [y/n] (y):
[1/14] project_name (my dash component): dash_echarts
[2/14] project_shortname (dash_echarts):
[3/14] component_name (DashEcharts): DashECharts
[4/14] jl_prefix ():
[5/14] r_prefix ():
[6/14] author_name (Enter your first and last name (For package.json)): Covarians
[7/14] author_email (Enter your email (For package.json)): dirtech@covarians.eu
[8/14] github_org ():
[9/14] description (Project Description): ECharts for Dash
[10/14] Select use_async
1 - False
2 - True
Choose from [1/2] (1): 2
[11/14] Select component_type
1 - Function Component
2 - Class Component
Choose from [1/2] (1):
[12/14] Select license
1 - MIT License
2 - BSD License
3 - ISC License
4 - Apache Software License 2.0
5 - GNU General Public License v3
6 - Not open source
Choose from [1/2/3/4/5/6] (1): 6
[13/14] publish_on_npm [y/n] (y): n
[14/14] install_dependencies [y/n] (y):
Open the created folder (dash_echarts) in VSC.
Try to install packages in the package-lock.json file:
$ npm install
Install all npm packages required by the project and not yet in the package-lock.json file:
$ npm install echarts echarts-gl echarts-stat mapbox-gl
Activate the Python virtual environment:
$ venv/Scripts/Activate
Build the module (to check that there are no errors):
(venv) $ npm run build