al_charts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 25e0b671f1ebb9b628e4a963ec2b6ccd842f9e93137bc41254811573e2906595
4
+ data.tar.gz: 8b6051a35be65a16d4b26ee212edb287da2d618160d5c3e8a73e62708bdd6bd4
5
+ SHA512:
6
+ metadata.gz: 42d573ccc8d8e94d7ece7cd2a2f5ed38a74e7e21a35724815043a8d8e663e237c55f662ee7ceb875fec680bef97554ebc087c73bd5878868e6071aa3812135be
7
+ data.tar.gz: 46e6eb624f7c87dfb9dd7ac4e03c4ea23043a7c65af6dfd2c4b12c479a52a4a055a7df1226369561c21db92bd9e04b24ee3f625c5603cc66b38b2fef7f2bd72c
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2026-02-07
4
+ - Initial gem release.
5
+ - Added standalone charts and diagram asset pipeline for Jekyll/al-folio sites.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Maruan Al-Shedivat.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Al-Charts
2
+
3
+ A Jekyll plugin that provides chart/diagram script loading and setup logic.
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ gem 'al_charts'
9
+ ```
10
+
11
+ Enable in `_config.yml`:
12
+
13
+ ```yaml
14
+ plugins:
15
+ - al_charts
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```liquid
21
+ {% al_charts_scripts %}
22
+ ```
data/lib/al_charts.rb ADDED
@@ -0,0 +1,97 @@
1
+ require 'jekyll'
2
+
3
+ module AlCharts
4
+ PLUGIN_NAME = 'al_charts'
5
+ ASSETS_DIR = 'assets'
6
+ JS_DIR = 'js'
7
+
8
+ class PluginStaticFile < Jekyll::StaticFile; end
9
+
10
+ class AssetsGenerator < Jekyll::Generator
11
+ safe true
12
+ priority :low
13
+
14
+ def generate(site)
15
+ plugin_lib_path = File.expand_path('.', __dir__)
16
+ Dir.glob(File.join(plugin_lib_path, ASSETS_DIR, PLUGIN_NAME, JS_DIR, '*.js')).each do |source_path|
17
+ site.static_files << PluginStaticFile.new(site, plugin_lib_path, File.join(ASSETS_DIR, PLUGIN_NAME, JS_DIR), File.basename(source_path))
18
+ end
19
+ end
20
+ end
21
+
22
+ class ChartsScriptsTag < Liquid::Tag
23
+ def render(context)
24
+ site = context.registers[:site]
25
+ return '' unless site
26
+
27
+ page = context.registers[:page] || context['page'] || {}
28
+ cfg = site.config
29
+ libs = cfg['third_party_libraries'] || {}
30
+ baseurl = cfg['baseurl'] || ''
31
+ out = []
32
+
33
+ if truthy?(nested_value(page, 'mermaid', 'enabled'))
34
+ out << %(<script defer src="#{libs.dig('mermaid', 'url', 'js')}" integrity="#{libs.dig('mermaid', 'integrity', 'js')}" crossorigin="anonymous"></script>)
35
+ if truthy?(nested_value(page, 'mermaid', 'zoomable'))
36
+ out << %(<script defer src="#{libs.dig('d3', 'url', 'js')}" integrity="#{libs.dig('d3', 'integrity', 'js')}" crossorigin="anonymous"></script>)
37
+ end
38
+ out << %(<script defer src="#{baseurl}/assets/al_charts/js/mermaid-setup.js" type="text/javascript"></script>)
39
+ end
40
+
41
+ if truthy?(page['code_diff'])
42
+ out << %(<script src="#{libs.dig('diff2html', 'url', 'js')}" integrity="#{libs.dig('diff2html', 'integrity', 'js')}" crossorigin="anonymous"></script>)
43
+ out << %(<script defer src="#{baseurl}/assets/al_charts/js/diff2html-setup.js" type="text/javascript"></script>)
44
+ end
45
+
46
+ if truthy?(page['map'])
47
+ out << %(<script src="#{libs.dig('leaflet', 'url', 'js')}" integrity="#{libs.dig('leaflet', 'integrity', 'js')}" crossorigin="anonymous"></script>)
48
+ out << %(<script defer src="#{baseurl}/assets/al_charts/js/leaflet-setup.js" type="text/javascript"></script>)
49
+ end
50
+
51
+ if truthy?(nested_value(page, 'chart', 'chartjs'))
52
+ out << %(<script defer src="#{libs.dig('chartjs', 'url', 'js')}" integrity="#{libs.dig('chartjs', 'integrity', 'js')}" crossorigin="anonymous"></script>)
53
+ out << %(<script defer src="#{baseurl}/assets/al_charts/js/chartjs-setup.js" type="text/javascript"></script>)
54
+ end
55
+
56
+ if truthy?(nested_value(page, 'chart', 'echarts'))
57
+ out << %(<script src="#{libs.dig('echarts', 'url', 'js', 'library')}" integrity="#{libs.dig('echarts', 'integrity', 'js', 'library')}" crossorigin="anonymous"></script>)
58
+ if truthy?(cfg['enable_darkmode'])
59
+ out << %(<script src="#{libs.dig('echarts', 'url', 'js', 'dark_theme')}" integrity="#{libs.dig('echarts', 'integrity', 'js', 'dark_theme')}" crossorigin="anonymous"></script>)
60
+ end
61
+ out << %(<script defer src="#{baseurl}/assets/al_charts/js/echarts-setup.js" type="text/javascript"></script>)
62
+ end
63
+
64
+ if truthy?(nested_value(page, 'chart', 'plotly'))
65
+ out << %(<script defer src="#{libs.dig('plotly', 'url', 'js')}" integrity="#{libs.dig('plotly', 'integrity', 'js')}" crossorigin="anonymous"></script>)
66
+ out << %(<script defer src="#{baseurl}/assets/al_charts/js/plotly-setup.js" type="text/javascript"></script>)
67
+ end
68
+
69
+ if truthy?(nested_value(page, 'chart', 'vega_lite'))
70
+ out << %(<script defer src="#{libs.dig('vega', 'url', 'js')}" integrity="#{libs.dig('vega', 'integrity', 'js')}" crossorigin="anonymous"></script>)
71
+ out << %(<script defer src="#{libs.dig('vega-lite', 'url', 'js')}" integrity="#{libs.dig('vega-lite', 'integrity', 'js')}" crossorigin="anonymous"></script>)
72
+ out << %(<script defer src="#{libs.dig('vega-embed', 'url', 'js')}" integrity="#{libs.dig('vega-embed', 'integrity', 'js')}" crossorigin="anonymous"></script>)
73
+ out << %(<script defer src="#{baseurl}/assets/al_charts/js/vega-setup.js" type="text/javascript"></script>)
74
+ end
75
+
76
+ out.join("\n")
77
+ end
78
+
79
+ private
80
+
81
+ def truthy?(value)
82
+ value == true || value.to_s == 'true'
83
+ end
84
+
85
+ def nested_value(container, *keys)
86
+ current = container
87
+ keys.each do |key|
88
+ return nil unless current.respond_to?(:[])
89
+
90
+ current = current[key]
91
+ end
92
+ current
93
+ end
94
+ end
95
+ end
96
+
97
+ Liquid::Template.register_tag('al_charts_scripts', AlCharts::ChartsScriptsTag)
@@ -0,0 +1,14 @@
1
+ $(document).ready(function () {
2
+ var $canvas = null,
3
+ $this = null,
4
+ _ctx = null,
5
+ _text = "";
6
+ $(".language-chartjs").each(function () {
7
+ $this = $(this);
8
+ $canvas = $("<canvas></canvas>");
9
+ _text = $this.text();
10
+ $this.text("").append($canvas);
11
+ _ctx = $canvas.get(0).getContext("2d");
12
+ _ctx && _text && new Chart(_ctx, JSON.parse(_text)) && $this.attr("data-processed", true);
13
+ });
14
+ });
@@ -0,0 +1,20 @@
1
+ let diff2HtmlTheme = determineComputedTheme();
2
+
3
+ /* Create diff2html as another node and hide the code block, appending the diff2html node after it
4
+ this is done to enable retrieving the code again when changing theme between light/dark */
5
+ document.addEventListener("readystatechange", () => {
6
+ if (document.readyState === "complete") {
7
+ document.querySelectorAll("pre>code.language-diff2html").forEach((elem) => {
8
+ const textData = elem.textContent;
9
+ const backup = elem.parentElement;
10
+ backup.classList.add("unloaded");
11
+ /* create diff node */
12
+ let diffElement = document.createElement("div");
13
+ diffElement.classList.add("diff2html");
14
+ backup.after(diffElement);
15
+ const configuration = { colorScheme: diff2HtmlTheme, drawFileList: true, highlight: true, matching: "lines" };
16
+ const diff2htmlUi = new Diff2HtmlUI(diffElement, textData, configuration);
17
+ diff2htmlUi.draw();
18
+ });
19
+ }
20
+ });
@@ -0,0 +1,29 @@
1
+ let echartsTheme = determineComputedTheme();
2
+
3
+ /* Create echarts chart as another node and hide the code block, appending the echarts node after it
4
+ this is done to enable retrieving the code again when changing theme between light/dark */
5
+ document.addEventListener("readystatechange", () => {
6
+ if (document.readyState === "complete") {
7
+ document.querySelectorAll("pre>code.language-echarts").forEach((elem) => {
8
+ const jsonData = elem.textContent;
9
+ const backup = elem.parentElement;
10
+ backup.classList.add("unloaded");
11
+ /* create echarts node */
12
+ let chartElement = document.createElement("div");
13
+ chartElement.classList.add("echarts");
14
+ backup.after(chartElement);
15
+
16
+ /* create echarts */
17
+ if (echartsTheme === "dark") {
18
+ var chart = echarts.init(chartElement, "dark-fresh-cut");
19
+ } else {
20
+ var chart = echarts.init(chartElement);
21
+ }
22
+
23
+ chart.setOption(JSON.parse(jsonData));
24
+ window.addEventListener("resize", function () {
25
+ chart.resize();
26
+ });
27
+ });
28
+ }
29
+ });
@@ -0,0 +1,22 @@
1
+ /* Create leaflet map as another node and hide the code block, appending the leaflet node after it */
2
+ document.addEventListener("readystatechange", () => {
3
+ if (document.readyState === "complete") {
4
+ document.querySelectorAll("pre>code.language-geojson").forEach((elem) => {
5
+ const jsonData = elem.textContent;
6
+ const backup = elem.parentElement;
7
+ backup.classList.add("unloaded");
8
+ /* create leaflet node */
9
+ let mapElement = document.createElement("div");
10
+ mapElement.classList.add("map");
11
+ backup.after(mapElement);
12
+
13
+ var map = L.map(mapElement);
14
+ L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
15
+ maxZoom: 19,
16
+ attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
17
+ }).addTo(map);
18
+ let geoJSON = L.geoJSON(JSON.parse(jsonData)).addTo(map);
19
+ map.fitBounds(geoJSON.getBounds());
20
+ });
21
+ }
22
+ });
@@ -0,0 +1,37 @@
1
+ let mermaidTheme = determineComputedTheme();
2
+
3
+ /* Create mermaid diagram as another node and hide the code block, appending the mermaid node after it
4
+ this is done to enable retrieving the code again when changing theme between light/dark */
5
+ document.addEventListener("readystatechange", () => {
6
+ if (document.readyState === "complete") {
7
+ document.querySelectorAll("pre>code.language-mermaid").forEach((elem) => {
8
+ const svgCode = elem.textContent;
9
+ const backup = elem.parentElement;
10
+ backup.classList.add("unloaded");
11
+ /* create mermaid node */
12
+ let mermaid = document.createElement("pre");
13
+ mermaid.classList.add("mermaid");
14
+ const text = document.createTextNode(svgCode);
15
+ mermaid.appendChild(text);
16
+ backup.after(mermaid);
17
+ });
18
+
19
+ mermaid.initialize({ theme: mermaidTheme });
20
+
21
+ /* Zoomable mermaid diagrams */
22
+ if (typeof d3 !== "undefined") {
23
+ window.addEventListener("load", function () {
24
+ var svgs = d3.selectAll(".mermaid svg");
25
+ svgs.each(function () {
26
+ var svg = d3.select(this);
27
+ svg.html("<g>" + svg.html() + "</g>");
28
+ var inner = svg.select("g");
29
+ var zoom = d3.zoom().on("zoom", function (event) {
30
+ inner.attr("transform", event.transform);
31
+ });
32
+ svg.call(zoom);
33
+ });
34
+ });
35
+ }
36
+ }
37
+ });
@@ -0,0 +1,52 @@
1
+ let plotlyTheme = determineComputedTheme();
2
+ /* Create plotly chart as another node and hide the code block, appending the plotly node after it
3
+ this is done to enable retrieving the code again when changing theme between light/dark */
4
+ document.addEventListener("readystatechange", () => {
5
+ if (document.readyState === "complete") {
6
+ document.querySelectorAll("pre>code.language-plotly").forEach((elem) => {
7
+ const jsonCode = elem.textContent;
8
+ const backup = elem.parentElement;
9
+ backup.classList.add("unloaded");
10
+ /* create plotly node */
11
+ let chartElement = document.createElement("div");
12
+ backup.after(chartElement);
13
+
14
+ /* create plotly */
15
+ var jsonData = JSON.parse(jsonCode);
16
+
17
+ if (plotlyTheme === "dark") {
18
+ // dark theme extracted from https://github.com/plotly/plotly.py/blob/main/plotly/package_data/templates/plotly_dark.json?raw=true
19
+ // prettier-ignore
20
+ const plotlyDarkLayout = {"layout":{"autotypenumbers":"strict","colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#f2f5fa"},"hovermode":"closest","hoverlabel":{"align":"left"},"paper_bgcolor":"rgb(17,17,17)","plot_bgcolor":"rgb(17,17,17)","polar":{"bgcolor":"rgb(17,17,17)","angularaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"radialaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""}},"ternary":{"bgcolor":"rgb(17,17,17)","aaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"baxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"caxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""}},"coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]]},"xaxis":{"gridcolor":"#283442","linecolor":"#506784","ticks":"","title":{"standoff":15},"zerolinecolor":"#283442","automargin":true,"zerolinewidth":2},"yaxis":{"gridcolor":"#283442","linecolor":"#506784","ticks":"","title":{"standoff":15},"zerolinecolor":"#283442","automargin":true,"zerolinewidth":2},"scene":{"xaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3","gridwidth":2},"yaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3","gridwidth":2},"zaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3","gridwidth":2}},"shapedefaults":{"line":{"color":"#f2f5fa"}},"annotationdefaults":{"arrowcolor":"#f2f5fa","arrowhead":0,"arrowwidth":1},"geo":{"bgcolor":"rgb(17,17,17)","landcolor":"rgb(17,17,17)","subunitcolor":"#506784","showland":true,"showlakes":true,"lakecolor":"rgb(17,17,17)"},"title":{"x":0.05},"updatemenudefaults":{"bgcolor":"#506784","borderwidth":0},"sliderdefaults":{"bgcolor":"#C8D4E3","borderwidth":1,"bordercolor":"rgb(17,17,17)","tickwidth":0},"mapbox":{"style":"dark"}},"data":{"histogram2dcontour":[{"type":"histogram2dcontour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"choropleth":[{"type":"choropleth","colorbar":{"outlinewidth":0,"ticks":""}}],"histogram2d":[{"type":"histogram2d","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"heatmap":[{"type":"heatmap","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"contourcarpet":[{"type":"contourcarpet","colorbar":{"outlinewidth":0,"ticks":""}}],"contour":[{"type":"contour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"surface":[{"type":"surface","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"mesh3d":[{"type":"mesh3d","colorbar":{"outlinewidth":0,"ticks":""}}],"scatter":[{"marker":{"line":{"color":"#283442"}},"type":"scatter"}],"parcoords":[{"type":"parcoords","line":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolargl":[{"type":"scatterpolargl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"bar":[{"error_x":{"color":"#f2f5fa"},"error_y":{"color":"#f2f5fa"},"marker":{"line":{"color":"rgb(17,17,17)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"scattergeo":[{"type":"scattergeo","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolar":[{"type":"scatterpolar","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"scattergl":[{"marker":{"line":{"color":"#283442"}},"type":"scattergl"}],"scatter3d":[{"type":"scatter3d","line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattermap":[{"type":"scattermap","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattermapbox":[{"type":"scattermapbox","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterternary":[{"type":"scatterternary","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattercarpet":[{"type":"scattercarpet","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"carpet":[{"aaxis":{"endlinecolor":"#A2B1C6","gridcolor":"#506784","linecolor":"#506784","minorgridcolor":"#506784","startlinecolor":"#A2B1C6"},"baxis":{"endlinecolor":"#A2B1C6","gridcolor":"#506784","linecolor":"#506784","minorgridcolor":"#506784","startlinecolor":"#A2B1C6"},"type":"carpet"}],"table":[{"cells":{"fill":{"color":"#506784"},"line":{"color":"rgb(17,17,17)"}},"header":{"fill":{"color":"#2a3f5f"},"line":{"color":"rgb(17,17,17)"}},"type":"table"}],"barpolar":[{"marker":{"line":{"color":"rgb(17,17,17)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"pie":[{"automargin":true,"type":"pie"}]}};
21
+
22
+ // if jsonData.layout exists, then update the theme
23
+ if (jsonData.layout) {
24
+ if (jsonData.layout.template) {
25
+ jsonData.layout.template = { ...plotlyDarkLayout, ...jsonData.layout.template };
26
+ } else {
27
+ jsonData.layout.template = plotlyDarkLayout;
28
+ }
29
+ } else {
30
+ jsonData.layout = { template: plotlyDarkLayout };
31
+ }
32
+ } else {
33
+ // light theme extracted from https://github.com/plotly/plotly.py/blob/main/plotly/package_data/templates/plotly_white.json?raw=true
34
+ // prettier-ignore
35
+ const plotlyLightLayout = {"layout":{"autotypenumbers":"strict","colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"hovermode":"closest","hoverlabel":{"align":"left"},"paper_bgcolor":"white","plot_bgcolor":"white","polar":{"bgcolor":"white","angularaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":""},"radialaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":""}},"ternary":{"bgcolor":"white","aaxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""},"baxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""},"caxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""}},"coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]]},"xaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":"","title":{"standoff":15},"zerolinecolor":"#EBF0F8","automargin":true,"zerolinewidth":2},"yaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":"","title":{"standoff":15},"zerolinecolor":"#EBF0F8","automargin":true,"zerolinewidth":2},"scene":{"xaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8","gridwidth":2},"yaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8","gridwidth":2},"zaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8","gridwidth":2}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"geo":{"bgcolor":"white","landcolor":"white","subunitcolor":"#C8D4E3","showland":true,"showlakes":true,"lakecolor":"white"},"title":{"x":0.05},"mapbox":{"style":"light"}},"data":{"histogram2dcontour":[{"type":"histogram2dcontour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"choropleth":[{"type":"choropleth","colorbar":{"outlinewidth":0,"ticks":""}}],"histogram2d":[{"type":"histogram2d","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"heatmap":[{"type":"heatmap","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"contourcarpet":[{"type":"contourcarpet","colorbar":{"outlinewidth":0,"ticks":""}}],"contour":[{"type":"contour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"surface":[{"type":"surface","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"mesh3d":[{"type":"mesh3d","colorbar":{"outlinewidth":0,"ticks":""}}],"scatter":[{"fillpattern":{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"parcoords":[{"type":"parcoords","line":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolargl":[{"type":"scatterpolargl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"scattergeo":[{"type":"scattergeo","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolar":[{"type":"scatterpolar","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"scattergl":[{"type":"scattergl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatter3d":[{"type":"scatter3d","line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattermap":[{"type":"scattermap","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattermapbox":[{"type":"scattermapbox","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterternary":[{"type":"scatterternary","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattercarpet":[{"type":"scattercarpet","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"#C8D4E3","linecolor":"#C8D4E3","minorgridcolor":"#C8D4E3","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"#C8D4E3","linecolor":"#C8D4E3","minorgridcolor":"#C8D4E3","startlinecolor":"#2a3f5f"},"type":"carpet"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}],"barpolar":[{"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"pie":[{"automargin":true,"type":"pie"}]}};
36
+
37
+ // if jsonData.layout exists, then update the theme
38
+ if (jsonData.layout) {
39
+ if (jsonData.layout.template) {
40
+ jsonData.layout.template = { ...plotlyLightLayout, ...jsonData.layout.template };
41
+ } else {
42
+ jsonData.layout.template = plotlyLightLayout;
43
+ }
44
+ } else {
45
+ jsonData.layout = { template: plotlyLightLayout };
46
+ }
47
+ }
48
+
49
+ Plotly.react(chartElement, jsonData.data, jsonData.layout);
50
+ });
51
+ }
52
+ });
@@ -0,0 +1,24 @@
1
+ let vegaTheme = determineComputedTheme();
2
+
3
+ /* Create vega lite chart as another node and hide the code block, appending the vega lite node after it
4
+ this is done to enable retrieving the code again when changing theme between light/dark */
5
+ document.addEventListener("readystatechange", () => {
6
+ if (document.readyState === "complete") {
7
+ document.querySelectorAll("pre>code.language-vega_lite").forEach((elem) => {
8
+ const jsonData = elem.textContent;
9
+ const backup = elem.parentElement;
10
+ backup.classList.add("unloaded");
11
+ /* create vega lite node */
12
+ let chartElement = document.createElement("div");
13
+ chartElement.classList.add("vega-lite");
14
+ backup.after(chartElement);
15
+
16
+ /* Embed the visualization in the container */
17
+ if (vegaTheme === "dark") {
18
+ vegaEmbed(chartElement, JSON.parse(jsonData), { theme: "dark" });
19
+ } else {
20
+ vegaEmbed(chartElement, JSON.parse(jsonData));
21
+ }
22
+ });
23
+ }
24
+ });
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: al_charts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - al-org
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-02-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.9'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.9'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: liquid
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '4.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '4.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '2.0'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '2.0'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '3.0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: rake
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '13.0'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '13.0'
87
+ description: Jekyll plugin extracted from al-folio that ships chart assets and conditionally
88
+ renders Mermaid, ECharts, Plotly, Vega-Lite, Leaflet, and diff2html scripts.
89
+ email:
90
+ - dev@al-org.dev
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - CHANGELOG.md
96
+ - LICENSE
97
+ - README.md
98
+ - lib/al_charts.rb
99
+ - lib/assets/al_charts/js/chartjs-setup.js
100
+ - lib/assets/al_charts/js/diff2html-setup.js
101
+ - lib/assets/al_charts/js/echarts-setup.js
102
+ - lib/assets/al_charts/js/leaflet-setup.js
103
+ - lib/assets/al_charts/js/mermaid-setup.js
104
+ - lib/assets/al_charts/js/plotly-setup.js
105
+ - lib/assets/al_charts/js/vega-setup.js
106
+ homepage: https://github.com/al-org-dev/al-charts
107
+ licenses:
108
+ - MIT
109
+ metadata:
110
+ allowed_push_host: https://rubygems.org
111
+ homepage_uri: https://github.com/al-org-dev/al-charts
112
+ source_code_uri: https://github.com/al-org-dev/al-charts
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '2.7'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubygems_version: 3.0.3.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Chart and diagram asset pipeline for al-folio Jekyll sites
132
+ test_files: []