Skip to content

Add support for layout templates #62

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 14 commits into from
May 10, 2022
Merged

Add support for layout templates #62

merged 14 commits into from
May 10, 2022

Conversation

mfreeborn
Copy link
Contributor

@mfreeborn mfreeborn commented Apr 21, 2022

References #4

plotly.js allows you to add a template key to the layout object, which sets the default template that the plot will be displayed with. This initial PR replaces the current &str parameter for the Layout::template method with a proper Template struct. This struct holds a LayoutTemplate struct, which is identical to Layout except it lacks a template field itself - otherwise Layout would be infinitely recursive.

The reason for having Template -> LayoutTemplate is because plotly.js also supports a TraceTemplate, which could be added in a separate PR.

To fully resolve #4 (which is also what I actually ultimately want), we need to implement pre-made themes, and the user in question was referring to the themes defined in python plotly.

@mfreeborn mfreeborn marked this pull request as ready for review April 21, 2022 13:53
@mfreeborn
Copy link
Contributor Author

mfreeborn commented Apr 21, 2022

This now has a (very) partial implementation of the plotly_dark theme as a proof of concept. It allows for users to provide their own (owned) LayoutTemplate, or they can use a &'static predefined one

@mfreeborn
Copy link
Contributor Author

mfreeborn commented Apr 21, 2022

commit c3cf844 closes #52
commit 8664350 closes #57
In principle this now closes #4. Perhaps a new issues could be made to support other themes

@mfreeborn mfreeborn mentioned this pull request Apr 21, 2022
@mfreeborn
Copy link
Contributor Author

Layout::template() is now generic such that it accepts both an owned Template and a &'static Template, using the Into<Cow<'static, Template>> impl

@mfreeborn mfreeborn changed the base branch from master to dev April 23, 2022 15:23
@mfreeborn mfreeborn merged commit de1489a into plotly:dev May 10, 2022
@mfreeborn mfreeborn deleted the add-template-themes branch May 10, 2022 07:53
mfreeborn added a commit that referenced this pull request Aug 26, 2022
* Update dependencies

* Improve NumOrString (#76)

* reimplement NumOrString + tests

* changelog

* Fix contributing typos (#77)

* fix typos

* update changelog

* Fix Visible enum implementation (#70)

* implement proper Visible enum

* fix implementation and add tests

* improve test

* remove TruthyEnum

* update changelog

* add PartialEq impl and tests (#61)

* add PartialEq impl and tests

* impl clone with test

* add Clone derives

* update changelog

* Add support for the majority of config options (#65)

* add support for the majority of config options

* fix enum serialization representations

* add DoubleClick enum

* refine options

* doc fix

* add tests

* fix dependencies

* update changelog

* add setter for `Plot.configuration`

* impl Serialize for Plot (#68)

* impl Serialize for Plot

* serialize Traces/Layout separately

* improve tests

* refactor template rendering with serializable plot

* add to doctest to prove html tags aren't escaped

* update changelog

* add getter for `Plot.configuration`

* Add support for layout templates (#62)

* add LayoutTemplate struct

* add constructor for Template

* add test

* WIP

* support static predefined themes

* implement plotly_dark layout template

* make theme public

* fix colorbar recursive Default impl

* fix incorrect rename for Marker.size_mode

* make Layout::template() method generic

* add plotly_white and default (empty) themes

* fix dependencies

* update changelog

* Serialize plotly_kaleido::PlotData correctly (#75)

* impl Serialize for Plot

* serialize Traces/Layout separately

* improve tests

* refactor template rendering with serializable plot

* add to doctest to prove html tags aren't escaped

* serialize PlotData

* serialize PlotData

* update changelog

* Support wasm (#59)

* builds for wasm-unknown-unknown

* add wasm feature to readme

* update conditional compilation derives

* add bindings to plotly.js newPlot() and react()

* add helper function Plot::to_js_object()

* fix imports

* update changelog

* update workflows for new feature

* fix conditional imports

* update readme

* fix variable interpolation (#78)

* Add tests (#74)

* partial test coverage of common/mod.rs

* finish tests for common.rs

* start layout tests

* finish tests for enums

* just a few more structs to go for layout...

* more tests

* make tests pass

* update changelog

* Support Sankey Diagrams (#69)

* working basic example

* fix examples

* implement the rest of sankey

* fix Domain

* improve test

* add sankey tests

* add test for Domain

* fix tests

* add Sankey to book

* Impl clone for colors (#79)

* add Clone/Copy derives

* update changelog

* Update plotly js (#80)

* update plotly and mathjax deps

* fix imports + typo

* update changelog

* Add tests for layout module (#81)

* add tests for bar trace (#82)

* Fix stack overflow in layout tests (#83)

* box some layout struct fields

* undo method signature changes

* Fix unused Dependencies warning with proper feature gating #84

* Tidy up folder structure (#85)

* reconfigure folder structure

* disambiguate import and fix feature gating

* Refactor Color trait and apply throughout codebase (#87)

* Add Scatter3d support (#66)

* scatter 3D plot example running

* added 3D line plot and examples for 3d line plot and surface plot

* fixes and cleanup

* adjusted CHANGELOG.md

* adjusted CHANGELOG.md

* remove unintentionally included test output file

* fix merge

* tweak examples

* derive Default and sort imports

* fix feature-gated import

* add tests

* update book

* fix examples

* add plot3d examples to ci

* update book

* fix newest book examples

Co-authored-by: Michael Freeborn <[email protected]>

* Align API for saving/showing plots more closely with plotly.py (#89)

* reconfigure API for saving/showing plots

* update changelog

* update book introduction with new api

* add rustfmt step to ci (#90)

* add wasm example to book (#91)

* Add serde_with::skip_serializing_none macro (#94)

* add serde_with dependency

* apply skip_serializing_none macro

* finish applying skip_if_none macro

* fix typo

* fix typo

* clippy lints (#95)

* add tests (#96)

* add tests

* add tests

* prepare v0.8.0 (#97)

Co-authored-by: Ioannis Giagkiozis <[email protected]>
Co-authored-by: Mario Herzog <[email protected]>
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.

Layout Template
1 participant