Skip to content

Shape drawing doc #2407

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

Merged
merged 5 commits into from
May 2, 2020
Merged

Shape drawing doc #2407

merged 5 commits into from
May 2, 2020

Conversation

emmanuelle
Copy link
Contributor

I've prepared the tutorials for shape drawing in preparation JS 1.54 / py 4.7. The CI will obviously fail until we upgrade the code to 1.54.

If you wish to test these tutorials locally, you should fetch this branch and run

python setup.py updateplotlyjsdev --devbranch shape-drawing

to get the right plotly.js branch

@emmanuelle emmanuelle marked this pull request as draft April 23, 2020 21:46
@nicolaskruchten nicolaskruchten added this to the 4.7.0 milestone Apr 27, 2020

In order to enable shape drawing, you need to
- define a dragmode corresponding to a drawing tool (`'drawline'`,`'drawopenpath'`, `'drawclosedpath'`, `'drawcircle'`, or `'drawrect'`)
- add modebar buttons corresponding to the drawing tools you wish to use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to the config doc here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

img_height = 900
scale_factor = 0.5
fig.add_layout_image(
dict(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the dict here is redundant I'm pretty sure, as add_layout_image accepts these values as kwargs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!


_introduced in plotly 4.7_

You can create layout shapes programatically, but you can also draw shapes manually by setting the `dragmode` to one of the shape-drawing modes: `'drawline'`,`'drawopenpath'`, `'drawclosedpath'`, `'drawcircle'`, or `'drawrect'`. If you need to switch between different shape-drawing or other dragmodes (panning, selecting, etc.), modebar buttons can be added in the `config` to select the dragmode. If you switch to a different dragmode such as pan or zoom, you will need to select the drawing tool in the modebar to go back to shape drawing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add link to config doc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@emmanuelle emmanuelle marked this pull request as ready for review May 1, 2020 16:50
@emmanuelle
Copy link
Contributor Author

The CI is now green!

@nicolaskruchten
Copy link
Contributor

💃 !

@nicolaskruchten nicolaskruchten merged commit e4c7f72 into master May 2, 2020
@nicolaskruchten nicolaskruchten deleted the shape-drawing-doc branch June 19, 2020 16:17
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.

3 participants