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

Commit 9555141

Browse files
authored
Merge pull request #1 from plotly/master
merge upstream
2 parents 0812a01 + e133a33 commit 9555141

File tree

5 files changed

+65
-9
lines changed

5 files changed

+65
-9
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
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.22.1] - 2018-04-09
6+
### Fixed
7+
- Various bugs with the `ohlc` and `candlestick` chart type in the `dcc.Graph`
8+
component were fixed. See https://github.com/plotly/dash-core-components/pull/184.
9+
510
## [0.22.0] - 2018-04-03
611
### Added
712
- Previously, if a user named their app file `dash.py`, an unhelpful error

dash_core_components/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.22.0'
1+
__version__ = '0.22.1'

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-core-components",
3-
"version": "0.22.0",
3+
"version": "0.22.1",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",

src/components/Graph.react.js

+22-7
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, filter, has, isNil, type} from 'ramda';
3+
import {contains, intersection, filter, has, isNil, type, pluck} from 'ramda';
44
/* global Plotly:true */
55

66
const filterEventData = (gd, eventData, event) => {
@@ -73,16 +73,31 @@ export default class PlotlyGraph extends Component {
7373
plot(props) {
7474
const {id, figure, animate, animation_options, config} = props;
7575
const gd = document.getElementById(id);
76+
7677
if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
7778
return Plotly.animate(id, figure, animation_options);
7879
} else {
79-
return Plotly.react(id, figure.data, figure.layout, config).then(() => {
80-
if (!this._hasPlotted) {
81-
this.bindEvents();
82-
Plotly.Plots.resize(document.getElementById(id));
83-
this._hasPlotted = true;
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(
92+
() => {
93+
if (!this._hasPlotted) {
94+
this.bindEvents();
95+
Plotly.Plots.resize(document.getElementById(id));
96+
this._hasPlotted = true;
97+
}
8498
}
85-
});
99+
);
100+
86101
}
87102
}
88103

test/test_integration.py

+36
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,39 @@ def update_pathname(n_clicks, current_pathname):
460460
self.wait_for_text_to_equal('#test-search', '?queryA=valueA')
461461
self.wait_for_text_to_equal('#test-hash', '')
462462
self.snapshot('link -- /test/pathname/a?queryA=valueA')
463+
464+
465+
def test_candlestick(self):
466+
app = dash.Dash(__name__)
467+
app.layout = html.Div([
468+
html.Button(
469+
id='button',
470+
children='Update Candlestick',
471+
n_clicks=0
472+
),
473+
dcc.Graph(id='graph')
474+
])
475+
476+
@app.callback(Output('graph', 'figure'), [Input('button', 'n_clicks')])
477+
def update_graph(n_clicks):
478+
return {
479+
'data': [{
480+
'open': [1] * 5,
481+
'high': [3] * 5,
482+
'low': [0] * 5,
483+
'close': [2] * 5,
484+
'x': [n_clicks] * 5,
485+
'type': 'candlestick'
486+
}]
487+
}
488+
self.startServer(app=app)
489+
490+
button = self.wait_for_element_by_css_selector('#button')
491+
self.snapshot('candlestick - initial')
492+
button.click()
493+
time.sleep(2)
494+
self.snapshot('candlestick - 1 click')
495+
496+
button.click()
497+
time.sleep(2)
498+
self.snapshot('candlestick - 2 click')

0 commit comments

Comments
 (0)