Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 3da3477

Browse files
Add async usage for Graph and Plotlyjs
1 parent b08c4da commit 3da3477

22 files changed

+5235
-1294
lines changed

.babelrc

-14
This file was deleted.

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
command: |
8282
. venv/bin/activate && mkdir packages
8383
# build main dash
84-
git clone --depth 1 https://github.com/plotly/dash.git dash-main
84+
git clone --depth 1 -b exp-dynamic https://github.com/plotly/dash.git dash-main
8585
cd dash-main && pip install -e .[dev] --progress-bar off && python setup.py sdist && mv dist/* ../packages/
8686
cd dash-renderer && npm run build
8787
python setup.py sdist && mv dist/* ../../packages/ && cd ../..

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"no-extend-native": ["error"],
6464
"no-extra-bind": ["error"],
6565
"no-extra-boolean-cast": ["error"],
66-
"no-inline-comments": ["error"],
66+
"no-inline-comments": ["off"],
6767
"no-implicit-coercion": ["error"],
6868
"no-implied-eval": ["error"],
6969
"no-inner-declarations": ["off"],

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [Unreleased]
6+
### Added
7+
- [#616](https://github.com/plotly/dash-core-components/pull/616) Async Graph and Plotly.js
8+
59
## [1.3.1] - 2019-10-17
610
### Updated
711
- Upgraded plotly.js to 1.50.1 [#681](https://github.com/plotly/dash-core-components/issues/681)

CONTRIBUTING.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ Locally](README.md#testing-locally) section of README.md.
3333

3434
## Updating Plotly.js
3535

36-
1. Download the latest plotly.js from the cdn: `$ wget https://github.com/plotly/plotly.js/releases/tag/v1.49.4`
37-
2. Update `dash_core_components/__init__.py` plotly.js `external_url`
38-
3. Update `CHANGELOG.md` with links to the releases and a description of the changes. The message should state (see the existing `CHANGELOG.md` for examples):
36+
1. Update the version of `plotly.js` in package.json. Always use an exact version without "^" or "~"
37+
2. Run `npm install` followed by `npm run build`, this will ensure the latest version of Plotly.js is in `node_modules` and copy
38+
that version over with the other build artifacts
39+
3. Update `dash_core_components_base/__init__.py` plotly.js `relative_package_path` and `external_url`
40+
4. Update `CHANGELOG.md` with links to the releases and a description of the changes. The message should state (see the existing `CHANGELOG.md` for examples):
3941
* If you're only bumping the patch level, the heading is "Fixed" and the text starts "Patched plotly.js". Otherwise the heading is "Updated" and the text starts "Upgraded plotly.js"
4042
* The new plotly.js version number, and the PR in which this was done
4143
* All major or minor versions included, with links to their release pages and a summary of the major new features in each. If there are multiple minor/major releases included, be sure to look at all of their release notes to construct the summary. Call minor versions "feature" versions for the benefit of users not steeped in semver terminology.
4244
* All patch versions included, with links to their release pages and a note that these fix bugs
43-
4. When bumping the dcc version, a plotly.js patch/minor/major constitutes a dcc patch/minor/major respectively as well.
45+
5. When bumping the dcc version, a plotly.js patch/minor/major constitutes a dcc patch/minor/major respectively as well.
4446

4547
## Financial Contributions
4648

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
include dash_core_components/dash_core_components.min.js
22
include dash_core_components/dash_core_components.min.js.map
3+
include dash_core_components/async~*.js
4+
include dash_core_components/async~*.js.map
35
include dash_core_components/highlight.pack.js
46
include dash_core_components/metadata.json
57
include dash_core_components/package-info.json

babel.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const presets = [
2+
['@babel/env', {
3+
useBuiltIns: 'usage',
4+
corejs: 3
5+
}],
6+
'@babel/preset-react'
7+
];
8+
9+
const plugins = [
10+
'@babel/plugin-syntax-dynamic-import'
11+
];
12+
13+
// eslint-disable-next-line no-process-env
14+
if (process.env.ENV === "test") {
15+
plugins.push("styled-jsx/babel-test");
16+
} else {
17+
plugins.push("styled-jsx/babel");
18+
}
19+
20+
module.exports = { presets, plugins };

dash_core_components_base/__init__.py

+47-8
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@
3939

4040
_this_module = _sys.modules[__name__]
4141

42-
4342
_js_dist = [
44-
{
45-
'external_url': 'https://cdn.plot.ly/plotly-1.50.1.min.js',
46-
'relative_package_path': 'plotly-1.50.1.min.js',
47-
'namespace': 'dash_core_components'
48-
},
4943
{
5044
'relative_package_path': 'highlight.pack.js',
5145
'namespace': 'dash_core_components'
@@ -66,8 +60,53 @@
6660
).format(__version__),
6761
'namespace': 'dash_core_components',
6862
'dynamic': True
69-
}
63+
},
64+
{
65+
'relative_package_path': 'async~graph.js',
66+
'external_url': (
67+
'https://unpkg.com/dash-core-components@{}'
68+
'/dash_core_components/async~graph.js'
69+
).format(__version__),
70+
'namespace': 'dash_core_components',
71+
'async': True
72+
},
73+
{
74+
'relative_package_path': 'async~graph.js.map',
75+
'external_url': (
76+
'https://unpkg.com/dash-core-components@{}'
77+
'/dash_core_components/async~graph.js.map'
78+
).format(__version__),
79+
'namespace': 'dash_core_components',
80+
'dynamic': True
81+
},
82+
{
83+
'relative_package_path': 'plotly-1.50.1.min.js',
84+
'external_url': (
85+
'https://unpkg.com/dash-core-components@{}'
86+
'/dash_core_components/plotly-1.50.1.min.js'
87+
).format(__version__),
88+
'namespace': 'dash_core_components',
89+
'async': 'eager'
90+
},
91+
{
92+
'relative_package_path': 'async~plotlyjs.js',
93+
'external_url': (
94+
'https://unpkg.com/dash-core-components@{}'
95+
'/dash_core_components/async~graph~plotlyjs.js'
96+
).format(__version__),
97+
'namespace': 'dash_core_components',
98+
'async': 'lazy'
99+
},
100+
{
101+
'relative_package_path': 'async~plotlyjs.js.map',
102+
'external_url': (
103+
'https://unpkg.com/dash-core-components@{}'
104+
'/dash_core_components/async~graph~plotlyjs.js.map'
105+
).format(__version__),
106+
'namespace': 'dash_core_components',
107+
'dynamic': True
108+
},
70109
]
71110

72111
for _component in __all__:
73-
setattr(locals()[_component], '_js_dist', _js_dist)
112+
setattr(locals()[_component], '_js_dist', _js_dist)

generator/plotly.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require('fs');
2+
3+
const package = JSON.parse(fs.readFileSync('package.json'));
4+
5+
const plotlyJsVersion = (package.dependencies && package.dependencies['plotly.js']) ||
6+
(package.devDependencies && package.devDependencies['plotly.js']);
7+
8+
fs.copyFile('node_modules/plotly.js/dist/plotly.min.js', `dash_core_components/plotly-${plotlyJsVersion}.min.js`, err => {
9+
if (err) {
10+
throw err;
11+
}
12+
13+
console.log('copied plotly.js', plotlyJsVersion);
14+
});

0 commit comments

Comments
 (0)