thclark / sphinx-charts

Interactive charts in sphinx HTML docs, using plot.ly and D3
MIT License
26 stars 3 forks source link

Proposal: Add user defined class or id to the chart when embedding chart in html #8

Open nvn-nil opened 3 years ago

nvn-nil commented 3 years ago

The use case is to style the charts (not necessarily the chart itself but at least the chart container) that have been embedded in the final html. The more specific use case is when adding a plotly table, it comes with a border and padding which makes the table look like it wants nothing to do with everything around it.

I'm not sure this is an antipattern or if this can be achieved some other way, but what good is an html element that can't be styled?

This is only a proposal, just wanted to know what you think about it.

thclark commented 3 years ago

Can you add a screenshot of what you mean @nvn-nil?

Some things spring to mind-

  1. If its just about the margin internal to the container border: Plotly elements define their own border margins, but not very intelligently by default which is annoying - you can manipulate them through the layout object.

  2. If you’re wanting to apply extra css I believe that it’d be most appropriate for that to be done by the theme, as opposed to injecting it during the build. This should be possible, as chart divs have a css class applied already which you could define properties for. If any elements don’t have a specific class allowing you to override the styling, just shout and we can add them.

  3. You mentioned plotly tables? I wasn’t aware that was a thing and assume you mean charts.... however If plotly has a way of showing tables I’m unaware of, you might be better off using the tabulate library to put the data directly into rst.