Join GitHub today
PR Support for making Plotly more CSS friendly #1195
I've been using Plotly extensively in a SPA and one of my biggest annoyances is that Plotly adds so many inline styles!
I think Plotly could learn a bit from other svg charting libraries like Chartist in this case.
I would like to contribute a PR that attempts to move all the default values of styles for elements out from D3 and into the provided CSS. Inline styles will still be applied as they are now with the existing API so there won't be any breaking changes.
This will make Plotly MUCH more friendly to theming and applying different looks and feels with CSS instead of having to re-draw the whole chart with js.
Thanks very much for writing for in.
I have some bad news for you though. Your suggestion won't happen anytime soon.
plotly.js is designed to have only one source of truth, that being our JSON-serializable
This paradigm allows us:
We understand the power of CSS for theming charts, but for plotly.js that has only the potential to work for SVG charts generated by JS users - which at the moment is only a fraction of all plotly users.
I think I wasn't clear. My suggestion is to have zero change on the API. The json API would work exactly as it does now. However, specifically in the plotly.js side of things, the default values would be provided via CSS and overridden by explicitly provided values from the "data" and "layout" objects. Does that make sense?