mirror of
https://github.com/SqrtMinusOne/sqrtminusone.github.io.git
synced 2025-12-10 15:53:03 +03:00
feat(emacs): add chart.js
This commit is contained in:
parent
2478049992
commit
31d1fa8056
6 changed files with 81 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,3 +5,4 @@ org/configs/**
|
|||
/public/
|
||||
resources/_gen
|
||||
/content/configs/
|
||||
/.log/
|
||||
|
|
|
|||
12
content/posts/2023-04-14-emacs.md
Normal file
12
content/posts/2023-04-14-emacs.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
+++
|
||||
title = "Charts test"
|
||||
author = ["Pavel Korytov"]
|
||||
date = 2023-02-02
|
||||
tags = ["emacs"]
|
||||
draft = true
|
||||
scripts = ["/js/chart.js", "/js/2023-04-14-emacs.js"]
|
||||
+++
|
||||
|
||||
Hello world
|
||||
|
||||
<canvas id="myChart"></canvas>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
{{ define "main" }}
|
||||
<script defer language="javascript" type="text/javascript" src="{{ "/js/dynamic-toc.js" | urlize | relURL }}"></script>
|
||||
{{ range $script := .Params.scripts }}
|
||||
<script src="{{ $script | urlize | relURL }}"></script>
|
||||
{{ end}}
|
||||
<div class="root">
|
||||
<h1 id="title-small-screen">{{ .Title }}</h1>
|
||||
<div class="container" id="actual-content">
|
||||
|
|
|
|||
13
org/2023-04-14-emacs.org
Normal file
13
org/2023-04-14-emacs.org
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#+HUGO_SECTION: posts
|
||||
#+HUGO_BASE_DIR: ../
|
||||
#+TITLE: Charts test
|
||||
#+DATE: 2023-02-02
|
||||
#+HUGO_TAGS: emacs
|
||||
#+HUGO_DRAFT: true
|
||||
#+HUGO_CUSTOM_FRONT_MATTER: :scripts '("/js/chart.js" "/js/2023-04-14-emacs.js")
|
||||
|
||||
Hello world
|
||||
|
||||
#+begin_export html
|
||||
<canvas id="myChart"></canvas>
|
||||
#+end_export
|
||||
32
static/js/2023-04-14-emacs.js
Normal file
32
static/js/2023-04-14-emacs.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
function initChart() {
|
||||
const ctx = document.getElementById("myChart");
|
||||
|
||||
new Chart(ctx, {
|
||||
type: "bar",
|
||||
data: {
|
||||
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
|
||||
datasets: [
|
||||
{
|
||||
label: "# of Votes",
|
||||
data: [12, 19, 3, 5, 2, 3],
|
||||
borderWidth: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
function () {
|
||||
initChart();
|
||||
},
|
||||
false
|
||||
);
|
||||
20
static/js/chart.js
Normal file
20
static/js/chart.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue