Skip to content

Commit

Permalink
Merge pull request #33 from bcliang/support-dash-1-5-0
Browse files Browse the repository at this point in the history
Component fix for dash versions using async components (>= 1.4.0)
  • Loading branch information
bcliang authored Nov 24, 2019
2 parents 877320e + 14a2633 commit 15e7927
Show file tree
Hide file tree
Showing 9 changed files with 3,594 additions and 159 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include dash_extendable_graph/dash_extendable_graph.min.js
include dash_extendable_graph/dash_extendable_graph.dev.js
include dash_extendable_graph/plotly-1.51.1.min.js
include dash_extendable_graph/metadata.json
include dash_extendable_graph/package.json
include README.md
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

dash-extendable-graph is a Dash component library. This library contains a single component: `ExtendableGraph`. The component is a fork of the Graph() component of [dash-core-components](https://github.com/plotly/dash-core-components) (v 1.1.1). However, the `extendData` for this component has been modified to follow an api that matches the format of `figure['data']` (as opposed to the api defined `Graph.extendData` and `Plotly.extendTraces()`).

Note: plotly.js is required. However, the library is NOT explicitly listed in `MANIFEST.in` or in `dash_extendable_graph\__init__.py` as a way to reduce bundle size. Plotly.js is already distributed with the dash-core-components package, and most projects will import dcc as well as dash-extendable-graph.
Note: As of version 1.1.0, dash-extendable-graph includes PlotlyJS. Previously, the component assumed it would be used in conjunction with `plotly/dash-core-components`, but as of version 1.5.0, PlotlyJS is only available asynchronously when a Graph component exists on the page.

## Installation

Expand Down
11 changes: 9 additions & 2 deletions dash_extendable_graph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@
{
'relative_package_path': 'dash_extendable_graph.min.js',
'dev_package_path': 'dash_extendable_graph.dev.js',
'external_url': 'https://unpkg.com/{0}@{2}/{1}/{1}.min.js'.format(
package_name, __name__, __version__),
'external_url': 'https://unpkg.com/{0}@{1}/{0}/{2}.min.js'.format(
package_name, __version__, __name__),
'namespace': package_name
},
{
'relative_package_path': 'plotly-1.51.1.min.js',
'external_url': (
'https://unpkg.com/{0}@{1}/{0}/plotly-1.51.1.min.js'
).format(package_name, __version__),
'namespace': package_name,
},
]

_css_dist = []
Expand Down
8 changes: 5 additions & 3 deletions dash_extendable_graph/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "dash_extendable_graph",
"version": "1.0.4",
"version": "1.1.0",
"description": "plotly-dash custom component. Adds Plotly.extendTraces() support to dash_core_components.Graph()",
"homepage": "https://github.com/bcliang/dash-extendable-graph",
"main": "build/index.js",
"scripts": {
"start": "wp --config config/serve.config.js",
"validate-init": "python _validate_init.py",
"generator": "node generator/plotly.js",
"prepare": "npm run validate-init && npm run lint && npm run lint:py && npm run format && npm run build",
"build:js-dev": "wp --config config/webpack.config.js --mode development",
"build:js": "npm run lint && wp --config config/webpack.config.js --mode production",
"build:py": "dash-generate-components ./src/lib/components dash_extendable_graph",
"build": "npm run build:js && npm run build:js-dev && npm run build:py",
"build": "npm run generator && npm run build:js && npm run build:js-dev && npm run build:py",
"lint": "eslint src",
"lint:py": "flake8 --ignore=E501,F401,F841,F811 tests",
"format": "prettier --config .prettierrc --write src/**/*.js src/**/**/*.js",
Expand All @@ -25,7 +26,8 @@
},
"license": "MIT",
"dependencies": {
"ramda": "^0.26.1"
"ramda": "^0.26.1",
"plotly.js": "1.51.1"
},
"devDependencies": {
"@babel/core": "^7.5.4",
Expand Down
7 changes: 7 additions & 0 deletions dash_extendable_graph/plotly-1.51.1.min.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions generator/plotly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require('fs');

const package = JSON.parse(fs.readFileSync('package.json'));

const plotlyJsVersion =
(package.dependencies && package.dependencies['plotly.js']) ||
(package.devDependencies && package.devDependencies['plotly.js']);

fs.copyFile(
'node_modules/plotly.js/dist/plotly.min.js',
`dash_extendable_graph/plotly-${plotlyJsVersion}.min.js`,
err => {
if (err) {
throw err;
}

console.log('copied plotly.js', plotlyJsVersion);
}
);
Loading

0 comments on commit 15e7927

Please sign in to comment.