From c88f31c3645bb0002171bf21850c7ca6d217c73f Mon Sep 17 00:00:00 2001
From: DhammaCharts <100090806+DhammaCharts@users.noreply.github.com>
Date: Thu, 02 Jun 2022 07:16:02 +0000
Subject: [PATCH] change to object destructuring for drawGraph() arguments
---
data/graphConfig.yaml | 44 +++++++++++----------
assets/js/graph.js | 11 ++---
layouts/partials/head.html | 22 ++---------
3 files changed, 32 insertions(+), 45 deletions(-)
diff --git a/assets/js/graph.js b/assets/js/graph.js
index 87d8d58..9199bef 100644
--- a/assets/js/graph.js
+++ b/assets/js/graph.js
@@ -1,16 +1,15 @@
-async function drawGraph(
- baseUrl,
- pathColors,
+async function drawGraph(baseUrl,isHome,pathColors,graphConfig) {
+
+ let {
depth,
enableDrag,
enableLegend,
enableZoom,
- isHome,
opacityScale,
scale,
repelForce,
- fontSize
-) {
+ fontSize} = graphConfig;
+
const container = document.getElementById("graph-container")
const { index, links, content } = await fetchData
diff --git a/data/graphConfig.yaml b/data/graphConfig.yaml
index f8b9941..06ce2b0 100644
--- a/data/graphConfig.yaml
+++ b/data/graphConfig.yaml
@@ -5,31 +5,33 @@
### Local Graph ###
-enableLegend: false
-enableDrag: true
-enableZoom: true
-depth: 1 # set to -1 to show full graph
-scale: 1.2
-repelForce: 2
-centerForce: 1
-linkDistance: 1
-fontSize: 0.6
-opacityScale: 3
+localGraph:
+ enableLegend: false
+ enableDrag: true
+ enableZoom: true
+ depth: 1 # set to -1 to show full graph
+ scale: 1.2
+ repelForce: 2
+ centerForce: 1
+ linkDistance: 1
+ fontSize: 0.6
+ opacityScale: 3
### Global Graph ###
-enableLegendGG: false
-enableDragGG: true
-enableZoomGG: true
-depthGG: -1 # set to -1 to show full graph
-scaleGG: 1.4
-repelForceGG: 1
-centerForceGG: 1
-linkDistanceGG: 1
-fontSizeGG: 0.5
-opacityScaleGG: 3
+globalGraph:
+ enableLegend: false
+ enableDrag: true
+ enableZoom: true
+ depth: -1 # set to -1 to show full graph
+ scale: 1.4
+ repelForce: 1
+ centerForce: 1
+ linkDistance: 1
+ fontSize: 0.5
+ opacityScale: 3
-### Graphs ###
+### For all graphs ###
paths:
- /moc: "#4388cc"
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index b56c291..ba02260 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -79,30 +79,16 @@
if (isHome && {{$.Site.Data.graphConfig.enableGlobalGraph}}) {
drawGraph(
{{strings.TrimRight "/" .Site.BaseURL}},
- {{$.Site.Data.graphConfig.paths}},
- {{$.Site.Data.graphConfig.depthGG}},
- {{$.Site.Data.graphConfig.enableDragGG}},
- {{$.Site.Data.graphConfig.enableLegendGG}},
- {{$.Site.Data.graphConfig.enableZoomGG}},
true,
- {{$.Site.Data.graphConfig.opacityScaleGG}},
- {{$.Site.Data.graphConfig.scaleGG}},
- {{$.Site.Data.graphConfig.repelForceGG}},
- {{$.Site.Data.graphConfig.fontSizeGG}}
+ {{$.Site.Data.graphConfig.paths}},
+ {{$.Site.Data.graphConfig.globalGraph}}
);
} else {
drawGraph(
{{strings.TrimRight "/" .Site.BaseURL}},
- {{$.Site.Data.graphConfig.paths}},
- {{$.Site.Data.graphConfig.depth}},
- {{$.Site.Data.graphConfig.enableDrag}},
- {{$.Site.Data.graphConfig.enableLegend}},
- {{$.Site.Data.graphConfig.enableZoom}},
false,
- {{$.Site.Data.graphConfig.opacityScale}},
- {{$.Site.Data.graphConfig.scale}},
- {{$.Site.Data.graphConfig.repelForce}},
- {{$.Site.Data.graphConfig.fontSize}}
+ {{$.Site.Data.graphConfig.paths}},
+ {{$.Site.Data.graphConfig.localGraph}}
);
}
--
Gitblit v1.10.0