mirror of
https://github.com/olehomelchenko/olehomelchenko.com.git
synced 2025-12-21 21:22:22 +00:00
add vega-lite embed
This commit is contained in:
@@ -12,4 +12,15 @@
|
|||||||
g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
|
g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
{{ if .Params.load_vega }}
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
|
||||||
|
{{ end }}
|
||||||
|
<style>
|
||||||
|
.vega-embed {
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 6px 20px rgba(0, 0, 0, 0.19);
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<!-- End Matomo Code -->
|
<!-- End Matomo Code -->
|
||||||
9
layouts/shortcodes/vega-lite.html
Normal file
9
layouts/shortcodes/vega-lite.html
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<!-- Create a unique ID for the div where the Vega-Lite visualization will be rendered -->
|
||||||
|
<div class="vegaVis" id="{{ .Get "id" | default "vega-lite-vis" }}"></div>
|
||||||
|
<script>
|
||||||
|
const spec = {{ .Inner | safeJS }};
|
||||||
|
spec['width'] = {{ .Get "width" | default 700}};
|
||||||
|
spec['height'] = {{ .Get "height" | default 300}};
|
||||||
|
vegaEmbed('#{{ .Get "id" | default "vega-lite-vis" }}', spec, {"actions": false}).catch(console.error);
|
||||||
|
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user