Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 Update add_trace, add_traces, and add_{trace} methods to return figure #1624

Merged
merged 3 commits into from
Jun 18, 2019

Conversation

jonmmease
Copy link
Contributor

This PR updates the add_trace, add_traces, and add_{trace} figure method to return the figure their called on, rather than the newly created trace(s).

This is a breaking change for v4, as these methods used to return the newly created traces. The motivation for the change is to support method chaining. e.g.

(make_subplots(rows=2)
 .add_scatter(y=[2, 1, 3], row=1, col=1)
 .add_bar(y=[2, 1, 3], row=2, col=1)
 .update_layout(title_text='Figure Title', template='plotly_white'))

newplot

Code that formerly relied on the returned trace

bar = fig.add_bar(...)

will need to be updated for v4 compatibility to grab the newly added trace from the returned figure's data array

bar = fig.add_bar(...).data[-1]

@nicolaskruchten

@jonmmease jonmmease merged commit 4bcd671 into v4_integration Jun 18, 2019
@jonmmease jonmmease deleted the v4_add_trace_return_fig branch June 18, 2019 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant