d3 support

This commit is contained in:
zzossig 2020-12-01 00:16:52 +09:00
parent 9a5a692aab
commit 13e290e9dc
3 changed files with 251 additions and 1 deletions

View File

@ -64,7 +64,6 @@
# css
[css.katex]
sri = "sha256-V8SV2MO1FUb63Bwht5Wx9x6PVHNa02gv8BgH/uH3ung="
@ -106,3 +105,135 @@
[reveal.plugin.highlight]
sri = "sha256-ZksQEvQYWeyyAZ67Oi6Ob1eLnb1IpmIV+IGstqKyxgw="
url = "https://cdn.jsdelivr.net/npm/reveal.js@3.8.0/plugin/highlight/highlight.js"
# d3
[d3.d3]
sri = "sha256-AFWyORP4OXUzC8rHTpEW7fyXtxg94+ZzivnZiTb1NDg="
url = "https://cdn.jsdelivr.net/npm/d3@6.2.0/dist/d3.min.js"
[d3.d3_hierarchy]
sri = "sha256-dtbU7jTXuLCRWKGtvdkLY4rxF99K2+QiaitwZUad724="
url = "https://cdn.jsdelivr.net/npm/d3-hierarchy@2.0.0/dist/d3-hierarchy.min.js"
[d3.d3_chord]
sri = "sha256-U9vN3je/JFBbIylxi6a0QQTD7G7NhTaPjzKy+26VV04="
url = "https://cdn.jsdelivr.net/npm/d3-chord@2.0.0/dist/d3-chord.min.js"
[d3.d3_scale]
sri = "sha256-cPuRiIDVnHuoqntmS4c3g5fiOYUaGlFSrd8JQyNiQ/0="
url = "https://cdn.jsdelivr.net/npm/d3-scale@3.2.3/dist/d3-scale.min.js"
[d3.d3_array]
sri = "sha256-LElbjahQVyLc02LK/jxcL9XB+pduNfeqI/hzsoahmpU="
url = "https://cdn.jsdelivr.net/npm/d3-array@2.8.0/dist/d3-array.min.js"
[d3.d3_time]
sri = "sha256-eh+F/na1O1TKgtP2hS7Hn+WRcVR4vTXNIsM9ooGx/+g="
url = "https://cdn.jsdelivr.net/npm/d3-time@2.0.0/dist/d3-time.min.js"
[d3.d3_color]
sri = "sha256-q6AewSdFihb0Ivx9H/OYYrakVi32V28/YaBsx6WsOy4="
url = "https://cdn.jsdelivr.net/npm/d3-color@2.0.0/dist/d3-color.min.js"
[d3.d3_interpolate]
sri = "sha256-P1W6DCrxw4sXLNcLfzvgNYbvt1wRmBDKxqI/W1Mdg="
url = "https://cdn.jsdelivr.net/npm/d3-interpolate@2.0.1/dist/d3-interpolate.min.js"
[d3.d3_format]
sri = "sha256-AKzQvR0TkyTa3c1ysXFHHqOXD0c62Qilf8nhN0uJgFQ="
url = "https://cdn.jsdelivr.net/npm/d3-format@2.0.0/dist/d3-format.min.js"
[d3.d3_shape]
sri = "sha256-9B5EThAf6dtMdM6i6Bk+RdVuCT9utGs93tZk6XddosA="
url = "https://cdn.jsdelivr.net/npm/d3-shape@2.0.0/dist/d3-shape.min.js"
[d3.d3_time_format]
sri = "sha256-Z+x3KiVqFtiMKtrqiIrrcTlUyd+47J/dx+QWYVApQes="
url = "https://cdn.jsdelivr.net/npm/d3-time-format@3.0.0/dist/d3-time-format.min.js"
[d3.d3_geo]
sri = "sha256-xZWdUp5Za2GR50z6oa3h3lgnmGLklpZNbQJ1adTKiw8="
url = "https://cdn.jsdelivr.net/npm/d3-geo@2.0.1/dist/d3-geo.min.js"
[d3.d3_path]
sri = "sha256-8k9A+YNlYmtlw3dMKgBCUaz827pImA2sBqvVMDyi2cc="
url = "https://cdn.jsdelivr.net/npm/d3-path@2.0.0/dist/d3-path.min.js"
[d3.d3_collection]
sri = "sha256-NCMoV+CugFd4nyewJ9N5j96ZN6LRArEp2pSjtON5fNk="
url = "https://cdn.jsdelivr.net/npm/d3-collection@1.0.7/dist/d3-collection.min.js"
[d3.d3_timer]
sri = "sha256-1pmTErM5B7Vvr2jL5roQTCh/LIx6jxa1zO5IA7o96o4="
url = "https://cdn.jsdelivr.net/npm/d3-timer@2.0.0/dist/d3-timer.min.js"
[d3.d3_ease]
sri = "sha256-B2rj4Zh6nUUF47NMo+6tby3yob2eIdBuj/AakAeRwSE="
url = "https://cdn.jsdelivr.net/npm/d3-ease@2.0.0/dist/d3-ease.min.js"
[d3.d3_dispatch]
sri = "sha256-QmkMXTtH6RvxasB3nXUBjn9R81NP9G4OF36X2CUb8AI="
url = "https://cdn.jsdelivr.net/npm/d3-dispatch@2.0.0/dist/d3-dispatch.min.js"
[d3.d3_selection]
sri = "sha256-x/Z3vkIy98JMpcyi0VizY1btggFV30l+HQUmUSSWAm8="
url = "https://cdn.jsdelivr.net/npm/d3-selection@2.0.0/dist/d3-selection.min.js"
[d3.d3_transition]
sri = "sha256-QduTNttH+PA2VJSoGk5vp1OBZVrZio9yFkTSSc6Jksg="
url = "https://cdn.jsdelivr.net/npm/d3-transition@2.0.0/dist/d3-transition.min.js"
[d3.d3_force]
sri = "sha256-dL14uW+TjPPEgnKDqHzomvQ8kzo+gcae/nriqIJCD5g="
url = "https://cdn.jsdelivr.net/npm/d3-force@2.1.1/dist/d3-force.min.js"
[d3.d3_quadtree]
sri = "sha256-xymtd4rNxO1nVCw6cQ35vpKKF+IV2qwEfXONZyBJWZE="
url = "https://cdn.jsdelivr.net/npm/d3-quadtree@2.0.0/dist/d3-quadtree.min.js"
[d3.d3_dsv]
sri = "sha256-Pr4ci/Ja/AAdfIaGS07qwCgR21oC0ohaoScBqbFD9fI="
url = "https://cdn.jsdelivr.net/npm/d3-dsv@2.0.0/dist/d3-dsv.min.js"
[d3.d3_drag]
sri = "sha256-XYs7fS4WOujiXGvS/s9UpVnlelmzsS9IcWHvrnuQKg0="
url = "https://cdn.jsdelivr.net/npm/d3-drag@2.0.0/dist/d3-drag.min.js"
[d3.d3_axis]
sri = "sha256-uwGy/Tx9m7TojgBRgOvMO4+FkA68ueGSSpPrBIvUTEw="
url = "https://cdn.jsdelivr.net/npm/d3-axis@2.0.0/dist/d3-axis.min.js"
[d3.d3_random]
sri = "sha256-bpm9eaWv1gCHRYYx3FYdU1M8xwtIJRtCgJdfWpx1P9Q="
url = "https://cdn.jsdelivr.net/npm/d3-random@2.2.2/dist/d3-random.min.js"
[d3.d3_scale_chromatic]
sri = "sha256-6j4tMdLVRyhccNbjkfHgQCTYUmR68g0v9a+MvHPd2yI="
url = "https://cdn.jsdelivr.net/npm/d3-scale-chromatic@2.0.0/dist/d3-scale-chromatic.min.js"
[d3.d3_fetch]
sri = "sha256-yZPADzSS1tJycc9A8qESjci2VqVegCUVSGRCG5qSsOEhVk0="
url = "https://cdn.jsdelivr.net/npm/d3-fetch@2.0.0/dist/d3-fetch.min.js"
[d3.d3_voronoi]
sri = "sha256-im0m580XGAWXKCrJBfoAJ2cjs7GKXcncAWz4LCUISEE="
url = "https://cdn.jsdelivr.net/npm/d3-voronoi@1.1.4/dist/d3-voronoi.min.js"
[d3.d3_brush]
sri = "sha256-2WuoXSdR57Vd7P33a2QoHiB9Rb6aPbTCFPDNdUy8wV0="
url = "https://cdn.jsdelivr.net/npm/d3-brush@2.1.0/dist/d3-brush.min.js"
[d3.d3_zoom]
sri = "sha256-kYaE50K/AOo+qwLOoR2CVq6GhzA7shguxWf1n8bfHy0="
url = "https://cdn.jsdelivr.net/npm/d3-zoom@2.0.0/dist/d3-zoom.min.js"
[d3.d3_polygon]
sri = "sha256-hj6CABB+QH7MENztFRi2oM/iq3qkpUBeTQNjfL84EaE="
url = "https://cdn.jsdelivr.net/npm/d3-polygon@2.0.0/dist/d3-polygon.min.js"
[d3.d3_contour]
sri = "sha256-i10ISq4/JP3k0HZE8gqbakhgaOjQKWn0Pm8oBUUwqNQ="
url = "https://cdn.jsdelivr.net/npm/d3-contour@2.0.0/dist/d3-contour.min.js"

View File

@ -1,5 +1,6 @@
{{ $js := .Site.Data.lib.js }}
{{ $css := .Site.Data.lib.css }}
{{ $d3 := .Site.Data.lib.d3 }}
{{ $getParents := resources.Get "js/helper/getParents.js" | resources.Minify }}
<script defer src="{{ $getParents.RelPermalink }}"></script>
@ -12,6 +13,103 @@
{{ $fadeinout := resources.Get "js/helper/fadeinout.js" | resources.Minify }}
<script defer src="{{ $fadeinout.RelPermalink }}"></script>
{{ if in .Params.Libraries "d3" }}
<script defer src="{{ $d3.d3.url }}" integrity="{{ $d3.d3.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_hierarchy" }}
<script defer src="{{ $d3.d3_hierarchy.url }}" integrity="{{ $d3.d3_hierarchy.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_chord" }}
<script defer src="{{ $d3.d3_chord.url }}" integrity="{{ $d3.d3_chord.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_scale" }}
<script defer src="{{ $d3.d3_scale.url }}" integrity="{{ $d3.d3_scale.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_array" }}
<script defer src="{{ $d3.d3_array.url }}" integrity="{{ $d3.d3_array.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_time" }}
<script defer src="{{ $d3.d3_time.url }}" integrity="{{ $d3.d3_time.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_color" }}
<script defer src="{{ $d3.d3_color.url }}" integrity="{{ $d3.d3_color.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_interpolate" }}
<script defer src="{{ $d3.d3_interpolate.url }}" integrity="{{ $d3.d3_interpolate.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_format" }}
<script defer src="{{ $d3.d3_format.url }}" integrity="{{ $d3.d3_format.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_shape" }}
<script defer src="{{ $d3.d3_shape.url }}" integrity="{{ $d3.d3_shape.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_time_format" }}
<script defer src="{{ $d3.d3_time_format.url }}" integrity="{{ $d3.d3_time_format.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_geo" }}
<script defer src="{{ $d3.d3_geo.url }}" integrity="{{ $d3.d3_geo.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_path" }}
<script defer src="{{ $d3.d3_path.url }}" integrity="{{ $d3.d3_path.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_collection" }}
<script defer src="{{ $d3.d3_collection.url }}" integrity="{{ $d3.d3_collection.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_timer" }}
<script defer src="{{ $d3.d3_timer.url }}" integrity="{{ $d3.d3_timer.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_ease" }}
<script defer src="{{ $d3.d3_ease.url }}" integrity="{{ $d3.d3_ease.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_dispatch" }}
<script defer src="{{ $d3.d3_dispatch.url }}" integrity="{{ $d3.d3_dispatch.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_selection" }}
<script defer src="{{ $d3.d3_selection.url }}" integrity="{{ $d3.d3_selection.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_transition" }}
<script defer src="{{ $d3.d3_transition.url }}" integrity="{{ $d3.d3_transition.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_force" }}
<script defer src="{{ $d3.d3_force.url }}" integrity="{{ $d3.d3_force.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_quadtree" }}
<script defer src="{{ $d3.d3_quadtree.url }}" integrity="{{ $d3.d3_quadtree.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_dsv" }}
<script defer src="{{ $d3.d3_dsv.url }}" integrity="{{ $d3.d3_dsv.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_drag" }}
<script defer src="{{ $d3.d3_drag.url }}" integrity="{{ $d3.d3_drag.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_axis" }}
<script defer src="{{ $d3.d3_axis.url }}" integrity="{{ $d3.d3_axis.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_random" }}
<script defer src="{{ $d3.d3_random.url }}" integrity="{{ $d3.d3_random.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_scale_chromatic" }}
<script defer src="{{ $d3.d3_scale_chromatic.url }}" integrity="{{ $d3.d3_scale_chromatic.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_fetch" }}
<script defer src="{{ $d3.d3_fetch.url }}" integrity="{{ $d3.d3_fetch.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_voronoi" }}
<script defer src="{{ $d3.d3_voronoi.url }}" integrity="{{ $d3.d3_voronoi.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_brush" }}
<script defer src="{{ $d3.d3_brush.url }}" integrity="{{ $d3.d3_brush.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_zoom" }}
<script defer src="{{ $d3.d3_zoom.url }}" integrity="{{ $d3.d3_zoom.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_polygon" }}
<script defer src="{{ $d3.d3_polygon.url }}" integrity="{{ $d3.d3_polygon.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "d3_contour" }}
<script defer src="{{ $d3.d3_contour.url }}" integrity="{{ $d3.d3_contour.sri }}" crossorigin="anonymous"></script>
{{ end }}
{{ if in .Params.Libraries "mermaid" }}
<script defer src="{{ $js.mermaid.url }}" integrity="{{ $js.mermaid.sri }}" crossorigin="anonymous"></script>
{{ end }}

View File

@ -0,0 +1,21 @@
{{ $scriptPath := (.Get "script") }}
{{ $stylePath := (.Get "style") }}
<div class="d3-container">{{ .Inner }}</div>
<link rel="stylesheet" href="{{ $stylePath }}">
<script>
document.addEventListener('DOMContentLoaded', function () {
var scriptPath = JSON.parse({{ $scriptPath | jsonify }});
var stylePath = JSON.parse({{ $stylePath | jsonify }});
var myScript = document.createElement('script');
myScript.setAttribute('src', scriptPath);
myScript.setAttribute('defer', '');
myScript.setAttribute('crossorigin', 'anonymous');
myScript.onload = function () {
}
document.querySelector('.d3-container').appendChild(myScript);
});
</script>