SciNim / nim-plotly

plotly wrapper for nim-lang
https://scinim.github.io/nim-plotly/
MIT License
173 stars 15 forks source link

Layout Width as % of Container #70

Closed sdmcallister closed 3 years ago

sdmcallister commented 3 years ago

I have a karax widget where I want to embed a plot but I want the plot width to be responsive to the container.

I think this might be achieved by adding a config param: https://plotly.com/javascript/responsive-fluid-layout/

Karax Widget.

proc renderPlotlyCard(title, subtitle, body: string): VNode = 
  result = buildHtml(tdiv(class="card")):
    h2: text title
    h5: text subtitle
    tdiv(id="plot0", style="height:400px;width:100%;".toCss)
    verbatim(doPlot())
    p: text body

The doPlot proc just returns:

"""<script>
                  Plotly.newPlot('plot0', $1, $2)
              </script>""" % [parseTraces(p.traces), $(%p.layout)]
sdmcallister commented 3 years ago

I just saw the autosize option. Thank you. Great library btw.