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

Commit 5cccfd3

Browse files
authored
Merge pull request #285 from rmarren1/graph-bugs
Fix #260, allow '{}' as Graph.figure
2 parents de74f62 + df8dc31 commit 5cccfd3

File tree

10 files changed

+53
-32
lines changed

10 files changed

+53
-32
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
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+
## [0.28.1] - 2018-08-29
6+
### Changed
7+
- `candlestick` and `OHLC` charts are now plotted using the `Plotly.react` method instead of the `Plotly.newPlot` method.
8+
### Fixed
9+
- Fix bug where front-end error was thrown when setting `Graph.figure = {}` (fixes [#260]).
10+
511
## [0.28.0]
612
- Upgraded Plotly.js, the underlying library behind the
713
`dash_core_components.Graph` component, to [version 1.40.1](https://github.com/plotly/plotly.js/releases/tag/v1.40.1).

dash_core_components/bundle.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_core_components/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,7 @@
27032703
"required": false,
27042704
"description": "Overrides the default (inline) styles when disabled",
27052705
"defaultValue": {
2706-
"value": "{\n color: '#d6d6d6',\n}",
2706+
"value": "{\n color: '#d6d6d6'\n}",
27072707
"computed": false
27082708
}
27092709
},
@@ -2864,7 +2864,7 @@
28642864
"required": false,
28652865
"description": "Holds the colors used by the Tabs and Tab components. If you set these, you should specify colors for all properties, so:\ncolors: {\n border: '#d6d6d6',\n primary: '#1975FA',\n background: '#f9f9f9'\n }",
28662866
"defaultValue": {
2867-
"value": "{\n border: '#d6d6d6',\n primary: '#1975FA',\n background: '#f9f9f9',\n}",
2867+
"value": "{\n border: '#d6d6d6',\n primary: '#1975FA',\n background: '#f9f9f9'\n}",
28682868
"computed": false
28692869
}
28702870
}

dash_core_components/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.28.0'
1+
__version__ = '0.28.1'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-core-components",
3-
"version": "0.28.0",
3+
"version": "0.28.1",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",

src/components/Graph.react.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
3-
import {contains, intersection, filter, has, isNil, type, pluck} from 'ramda';
3+
import {contains, filter, has, isNil, type} from 'ramda';
44
/* global Plotly:true */
55

66
const filterEventData = (gd, eventData, event) => {
@@ -77,18 +77,7 @@ export default class PlotlyGraph extends Component {
7777
if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
7878
return Plotly.animate(id, figure, animation_options);
7979
} else {
80-
81-
let PlotMethod;
82-
if (intersection(
83-
pluck('type', figure.data),
84-
['candlestick', 'ohlc']).length
85-
) {
86-
PlotMethod = Plotly.newPlot;
87-
} else {
88-
PlotMethod = Plotly.react;
89-
}
90-
91-
return PlotMethod(id, figure.data, figure.layout, config).then(
80+
return Plotly.react(id, figure.data, figure.layout, config).then(
9281
() => {
9382
if (!this._hasPlotted) {
9483
this.bindEvents();

src/components/Tab.react.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ Tab.propTypes = {
6363
/**
6464
* Overrides the default (inline) styles for the Tab component when it is selected.
6565
*/
66-
selected_style: PropTypes.object,
66+
selected_style: PropTypes.object
6767
};
6868

6969
Tab.defaultProps = {
7070
disabled: false,
7171
disabled_style: {
72-
color: '#d6d6d6',
73-
},
72+
color: '#d6d6d6'
73+
}
7474
};
7575

7676
export default Tab;

src/components/Tabs.react.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const EnhancedTab = ({
1717
disabled_className,
1818
mobile_breakpoint,
1919
amountOfTabs,
20-
colors,
20+
colors
2121
}) => {
2222
let tabStyle = style;
2323
if (disabled) {
@@ -110,14 +110,14 @@ export default class Tabs extends Component {
110110
constructor(props) {
111111
super(props);
112112
this.state = {
113-
selected: this.props.value || 'tab-1',
113+
selected: this.props.value || 'tab-1'
114114
};
115115

116116
this.selectHandler = this.selectHandler.bind(this);
117117
}
118118
selectHandler(value) {
119119
this.setState({
120-
selected: value,
120+
selected: value
121121
});
122122
if (this.props.setProps) {
123123
this.props.setProps({value: value});
@@ -126,7 +126,7 @@ export default class Tabs extends Component {
126126
componentWillReceiveProps(newProps) {
127127
const value = newProps.value;
128128
this.setState({
129-
selected: value,
129+
selected: value
130130
});
131131
}
132132
render() {
@@ -270,8 +270,8 @@ Tabs.defaultProps = {
270270
colors: {
271271
border: '#d6d6d6',
272272
primary: '#1975FA',
273-
background: '#f9f9f9',
274-
},
273+
background: '#f9f9f9'
274+
}
275275
};
276276

277277
Tabs.propTypes = {
@@ -343,6 +343,6 @@ Tabs.propTypes = {
343343
colors: PropTypes.shape({
344344
border: PropTypes.string,
345345
primary: PropTypes.string,
346-
background: PropTypes.string,
347-
}),
346+
background: PropTypes.string
347+
})
348348
};

test.py

Whitespace-only changes.

test/test_integration.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import dash_html_components as html
1313
import dash_core_components as dcc
1414
import dash_table_experiments as dt
15-
from selenium import webdriver
1615
from selenium.webdriver.common.keys import Keys
1716
from selenium.common.exceptions import InvalidElementStateException
1817

@@ -851,3 +850,30 @@ def on_click(n_clicks):
851850
time.sleep(2)
852851

853852
self.driver.switch_to.alert.accept()
853+
854+
def test_empty_graph(self):
855+
app = dash.Dash(__name__)
856+
857+
app.layout = html.Div([
858+
html.Button(id='click', children='Click me'),
859+
dcc.Graph(
860+
id='graph',
861+
figure={
862+
'data': [dict(x=[1, 2, 3], y=[1, 2, 3], type='scatter')]
863+
}
864+
)
865+
])
866+
867+
@app.callback(dash.dependencies.Output('graph', 'figure'),
868+
[dash.dependencies.Input('click', 'n_clicks')],
869+
[dash.dependencies.State('graph', 'figure')])
870+
def render_content(click, prev_graph):
871+
if click:
872+
return {}
873+
return prev_graph
874+
875+
self.startServer(app)
876+
button = self.wait_for_element_by_css_selector('#click')
877+
button.click()
878+
time.sleep(2) # Wait for graph to re-render
879+
self.snapshot('render-empty-graph')

0 commit comments

Comments
 (0)