Skip to content

Commit

Permalink
[feat] add simple apache echart presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MattDodsonEnglish committed Jul 16, 2024
1 parent 557365c commit 2bcaf9c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions layouts/_default/_markup/render-codeblock-echart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

{{ $id := printf "echart-%03d" .Ordinal }}
{{ $width := or .Attributes.width "100%" }}
{{ $height := or .Attributes.height "600px" }}

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
<div id={{ $id }} style="width: {{ $width }};height: {{ $height }};"></div>

<script type="text/javascript">
// Initialize the echarts instance based on the prepared dom
var chart = echarts.init(document.getElementById({{ $id }}));

// Specify the configuration items and data for the chart
{{ .Inner | safeJS }}

// Display the chart using the configuration items and data just specified.
chart.setOption(option);
</script>


{{ .Page.Store.Set "hasEchart" true }}
4 changes: 4 additions & 0 deletions themes/hugo-docs/layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@

<!-- DocSearch -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3" />

{{ if .Page.Store.Get "hasEchart" }}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
{{ end }}
</head>

<body>
Expand Down

0 comments on commit 2bcaf9c

Please sign in to comment.