Skip to content

Commit

Permalink
Merge branch 'dev' into fix/#2512
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
T4rk1n committed May 19, 2023
2 parents 9b27589 + 55753d7 commit 723ecb5
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 56 deletions.
5 changes: 2 additions & 3 deletions @plotly/dash-component-plugins/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ module.exports = {
output: {
path: path.resolve(__dirname, `./dist`),
filename: 'index.js',
library: `dash-component-plugins`,
libraryTarget: 'umd'
library: {name: `dash-component-plugins`, type: 'umd' },
},
externals: {
react: {
Expand All @@ -27,4 +26,4 @@ module.exports = {
}
]
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ module.exports = {
output: {
path: path.resolve(__dirname, dashLibraryName, 'nested'),
filename: `${dashLibraryName}.js`,
library: dashLibraryName,
libraryTarget: 'window',
library: {
name: dashLibraryName,
type: 'window',
}
},
module: {
rules: [
Expand All @@ -29,4 +31,4 @@ module.exports = {
}
],
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ module.exports = {
output: {
path: path.resolve(__dirname, dashLibraryName),
filename: `${dashLibraryName}.js`,
library: dashLibraryName,
libraryTarget: 'window',
library: {
name: dashLibraryName,
type: 'window',
}
},
module: {
rules: [
Expand All @@ -29,4 +31,4 @@ module.exports = {
}
],
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ module.exports = function (env, argv) {
const output = {
path: path.resolve(__dirname, dashLibraryName),
filename: `${dashLibraryName}.js`,
library: dashLibraryName,
libraryTarget: 'umd',
library: {
name: dashLibraryName,
type: 'umd',
}
}

const externals = {
Expand Down
6 changes: 4 additions & 2 deletions @plotly/dash-test-components/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ module.exports = {
path: path.resolve(__dirname, dashLibraryName),
chunkFilename: '[name].js',
filename: `${dashLibraryName}.js`,
library: dashLibraryName,
libraryTarget: 'window',
library: {
name: dashLibraryName,
type: 'window',
}
},
module: {
rules: [
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ This project adheres to [Semantic Versioning](https://semver.org/).

- [#2508](https://github.com/plotly/dash/pull/2508) Fix error message, when callback output has different length than spec
- [#2207](https://github.com/plotly/dash/pull/2207) Fix object of components support.
- [#2500](https://github.com/plotly/dash/pull/2500) Passing customdata by click for scattermapbox, fix [#2493](https://github.com/plotly/dash/issues/2493)
- [#2513](https://github.com/plotly/dash/pull/2513) Raise error when iterating over patch objects, fix [#2512](https://github.com/plotly/dash/issues/2512)

## Updated

- [#2533](https://github.com/plotly/dash/pull/2533) Update Plotly.js to v2.23.1 from v2.20.0.
- Feature release [2.23.0](https://github.com/plotly/plotly.js/releases/tag/v2.23.0) adds legend/colorbar xref/yref.
- Feature release [2.22.0](https://github.com/plotly/plotly.js/releases/tag/v2.22.0) adds `legend` references to traces.
- Feature release [2.21.0](https://github.com/plotly/plotly.js/releases/tag/v2.21.0) adds label.texttemplate to parametric shapes.
- Patch release [2.23.1](https://github.com/plotly/plotly.js/releases/tag/v2.23.1) fix heatmap rendering on iOS and Safari when zsmooth is set to false.

## [2.9.3] - 2023-04-13

## Fixed
Expand Down
14 changes: 7 additions & 7 deletions components/dash-core-components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/dash-core-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"mathjax": "^3.2.2",
"moment": "^2.29.4",
"node-polyfill-webpack-plugin": "^2.0.1",
"plotly.js-dist-min": "2.20.0",
"plotly.js-dist-min": "2.23.1",
"prop-types": "^15.8.1",
"ramda": "^0.28.0",
"rc-slider": "^9.7.5",
Expand Down
20 changes: 15 additions & 5 deletions components/dash-core-components/src/fragments/Graph.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,22 @@ const filterEventData = (gd, eventData, event) => {
has('customdata', data[pointData.curveNumber])
) {
if (has('pointNumber', fullPoint)) {
pointData.customdata =
data[pointData.curveNumber].customdata[
fullPoint.pointNumber
];
if (typeof fullPoint.pointNumber === 'number') {
pointData.customdata =
data[pointData.curveNumber].customdata[
fullPoint.pointNumber
];
} else if (
!fullPoint.pointNumber &&
fullPoint.data.mode.includes('lines')
) {
pointData.customdata =
data[pointData.curveNumber].customdata;
}
} else if (has('pointNumbers', fullPoint)) {
pointData.customdata = fullPoint.pointNumbers.map(point => {
pointData.customdata = fullPoint.pointNumbers.map(function (
point
) {
return data[pointData.curveNumber].customdata[point];
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from dash.html import Div
from dash.dash_table import DataTable

from flaky import flaky


@flaky(max_runs=3)
def test_ddst001_cursor_should_be_pointer(dash_duo):
app = Dash(__name__)
app.layout = Div(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,51 @@ def set_data(dataset):
assert dash_dcc.wait_for_text_to_equal(
"#relayout-data", "[0, -1, -2]"
), "graph data must contain frame [0,-1,-2]"


def test_grbs007_graph_scatter_lines_customdata(dash_dcc):
app = Dash(__name__)

expected_value = "obj-1"

scatter_figures = go.Figure(
data=[
go.Scatter(
x=[0, 1, 1, 0, 0],
y=[1, 1, 2, 2, 1],
mode="lines",
fill="toself",
customdata=[expected_value],
)
]
)

app.layout = html.Div(
[
dcc.Graph(
id="scatter-lines",
figure=scatter_figures,
style={"width": 600, "height": 300},
),
dcc.Textarea(id="test-text-area"),
],
style={"width": 1000, "height": 500},
)

@app.callback(
Output("test-text-area", "value"), Input("scatter-lines", "clickData")
)
def handleClick(clickData):
return json.dumps(clickData)

dash_dcc.start_server(app)
dash_dcc.wait_for_element("#scatter-lines")

dash_dcc.find_elements("g .xy")[0].click()

data = dash_dcc.wait_for_element("#test-text-area").get_attribute("value")
assert data != "", "graph clickData must contain data"

data = json.loads(data)
assert "customdata" in data["points"][0], "graph clickData must contain customdata"
assert data["points"][0]["customdata"][0] == expected_value
6 changes: 4 additions & 2 deletions components/dash-core-components/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ module.exports = (env, argv) => {
path: path.resolve(__dirname, dashLibraryName),
chunkFilename: '[name].js',
filename,
library: dashLibraryName,
libraryTarget: 'window',
library: {
name: dashLibraryName,
type: 'window',
}
},
externals,
module: {
Expand Down
8 changes: 6 additions & 2 deletions components/dash-html-components/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ def test_click_static(dash_duo):
[
html.Div("no event listener", className="div-1"),
html.Div("event listener", id="div-2", n_clicks=0),
html.Div("no event listener", id="div-3", n_clicks=0, disable_n_clicks=True),
html.Div("event listener", id="div-4", n_clicks=0, disable_n_clicks=False),
html.Div(
"no event listener", id="div-3", n_clicks=0, disable_n_clicks=True
),
html.Div(
"event listener", id="div-4", n_clicks=0, disable_n_clicks=False
),
html.Div(id="div-output"),
]
)
Expand Down
6 changes: 4 additions & 2 deletions components/dash-html-components/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ module.exports = (env, argv) => {
output: {
path: path.resolve(__dirname, dashLibraryName),
filename,
library: dashLibraryName,
libraryTarget: 'window',
library: {
name: dashLibraryName,
type: 'window',
}
},
externals,
module: {
Expand Down
6 changes: 4 additions & 2 deletions components/dash-table/.config/webpack/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ module.exports = (options = {}) => {
output: {
path: path.resolve(__dirname, `./../../${dashLibraryName}`),
filename: '[name].js',
library: dashLibraryName,
libraryTarget: 'window'
library: {
name: dashLibraryName,
type: 'window',
}
},
devtool: 'source-map',
externals: {
Expand Down
28 changes: 14 additions & 14 deletions dash/_get_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ def get_relative_path(path):
When working locally, `requests_pathname_prefix` might be unset and
so a relative URL like `/page-2` can just be `/page-2`.
However, when the app is deployed to a URL like `/my-dash-app`, then
`app.get_relative_path('/page-2')` will return `/my-dash-app/page-2`.
`dash.get_relative_path('/page-2')` will return `/my-dash-app/page-2`.
This can be used as an alternative to `get_asset_url` as well with
`app.get_relative_path('/assets/logo.png')`
`dash.get_relative_path('/assets/logo.png')`
Use this function with `app.strip_relative_path` in callbacks that
Use this function with `dash.strip_relative_path` in callbacks that
deal with `dcc.Location` `pathname` routing.
That is, your usage may look like:
```
app.layout = html.Div([
dcc.Location(id='url'),
html.Div(id='content')
])
@app.callback(Output('content', 'children'), [Input('url', 'pathname')])
@dash.callback(Output('content', 'children'), [Input('url', 'pathname')])
def display_content(path):
page_name = app.strip_relative_path(path)
page_name = dash.strip_relative_path(path)
if not page_name: # None or ''
return html.Div([
dcc.Link(href=app.get_relative_path('/page-1')),
dcc.Link(href=app.get_relative_path('/page-2')),
dcc.Link(href=dash.get_relative_path('/page-1')),
dcc.Link(href=dash.get_relative_path('/page-2')),
])
elif page_name == 'page-1':
return chapters.page_1
Expand Down Expand Up @@ -90,13 +90,13 @@ def strip_relative_path(path):
dcc.Location(id='url'),
html.Div(id='content')
])
@app.callback(Output('content', 'children'), [Input('url', 'pathname')])
@dash.callback(Output('content', 'children'), [Input('url', 'pathname')])
def display_content(path):
page_name = app.strip_relative_path(path)
page_name = dash.strip_relative_path(path)
if not page_name: # None or ''
return html.Div([
dcc.Link(href=app.get_relative_path('/page-1')),
dcc.Link(href=app.get_relative_path('/page-2')),
dcc.Link(href=dash.get_relative_path('/page-1')),
dcc.Link(href=dash.get_relative_path('/page-2')),
])
elif page_name == 'page-1':
return chapters.page_1
Expand All @@ -113,15 +113,15 @@ def display_content(path):
When working locally, `requests_pathname_prefix` might be unset and
so a relative URL like `/page-2` can just be `/page-2`.
However, when the app is deployed to a URL like `/my-dash-app`, then
`app.get_relative_path('/page-2')` will return `/my-dash-app/page-2`
`dash.get_relative_path('/page-2')` will return `/my-dash-app/page-2`
The `pathname` property of `dcc.Location` will return '`/my-dash-app/page-2`'
to the callback.
In this case, `app.strip_relative_path('/my-dash-app/page-2')`
In this case, `dash.strip_relative_path('/my-dash-app/page-2')`
will return `'page-2'`
For nested URLs, slashes are still included:
`app.strip_relative_path('/page-1/sub-page-1/')` will return
`dash.strip_relative_path('/page-1/sub-page-1/')` will return
`page-1/sub-page-1`
```
"""
Expand Down
12 changes: 8 additions & 4 deletions dash/dash-renderer/webpack.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ const rendererOptions = {
output: {
path: path.resolve(__dirname, "build"),
filename: `${dashLibraryName}.dev.js`,
library: dashLibraryName,
libraryTarget: 'window',
library: {
name: dashLibraryName,
type: 'window',
}
},
externals: {
react: 'React',
Expand All @@ -84,8 +86,10 @@ module.exports = options => [
output: {
path: path.resolve(__dirname, "build"),
filename: `${dashLibraryName}.min.js`,
library: dashLibraryName,
libraryTarget: 'window',
library: {
name: dashLibraryName,
type: 'window',
}
},
plugins: R.concat(
options.plugins || [],
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/renderer/test_request_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,7 @@ def wrap(*args, **kwargs):
try:
if flask.request.method == "OPTIONS":
return func(*args, **kwargs)
token = (
flask.request.authorization
or flask.request.headers.environ.get("HTTP_AUTHORIZATION")
)
token = flask.request.headers.environ.get("HTTP_AUTHORIZATION")
if required_jwt_len and (
not token or len(token) != required_jwt_len + len("Bearer ")
):
Expand Down

0 comments on commit 723ecb5

Please sign in to comment.