Skip to content
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

How to include plots from Plotly #509

Open
edgardomortiz opened this issue Aug 2, 2021 · 0 comments
Open

How to include plots from Plotly #509

edgardomortiz opened this issue Aug 2, 2021 · 0 comments

Comments

@edgardomortiz
Copy link

edgardomortiz commented Aug 2, 2021

Hello,

I would like to insert plots from Plotly, I have been trying the solutions listed here:
https://mertbakir.gitlab.io/hugo/plotly-with-hugo/

and following the example from here:
https://github.com/kc-tal/hugo-plotly-example

But it doesn't work with the Learn theme, after adding to the HEAD section in layouts/partials/header.html:

    {{ if .Params.plotly }}
        <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
    {{ end }}

and adding layouts/shortcodes/load-plotly.html:

{{ if not ($.Page.Scratch.Get "plotlyloaded") }}
  {{ $.Page.Scratch.Set "plotlyloaded" 1 }}
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
{{ end }}

and layout/shortcodes/plotly:

{{ $json := .Get "json" }}
{{ $height := .Get "height" | default "200px" }}
<div id="{{$json}}" class="plotly" style="height:{{$height}}"></div>
<script>
Plotly.d3.json({{$json}}, function(err, fig) {
    Plotly.plot('{{$json}}', fig.data, fig.layout, {responsive: true});
});
</script>

and setting plotly: true in the front matter and using in the markdown:

{{% load-plotly /%}} {{% plotly json="example.json" height="450px" /%}}

I get this error:

Rebuild failed:

"/Users/emortiz/software/GitHub/package/docs/content/basics/parallelization.md:22:18": failed to extract shortcode: shortcode "%}}" has no .Inner, yet a closing tag was provided

20 ___
21 see:
22 {{% load-plotly /%}} {{% plotly json="example.json" height="450px" /%}}

hugo v0.85.0+extended darwin/amd64 BuildDate=unknown

I am using hugo 0.85 in macOS Catalina

Thanks!

Edgardo

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

No branches or pull requests

1 participant