Skip to content
Snippets Groups Projects

Fixes dendrogram data source

Merged Clarke, Aileen requested to merge update-dendro-datasource into main
1 file
+ 18
6
Compare changes
  • Side-by-side
  • Inline
@@ -46,6 +46,17 @@ const data = ref([]);
@@ -46,6 +46,17 @@ const data = ref([]);
const mobileView = isMobile;
const mobileView = isMobile;
const metaText = metaAnalysisText.metaAnalysisText;
const metaText = metaAnalysisText.metaAnalysisText;
 
// set colors for lines
 
const dimensionColors = {
 
Demographiccharacteristics: "#625D0B",
 
Landtenure: "#5C0601",
 
Livingconditions: "#0B4E8B",
 
Socioeconomicstatus: "#DC8260",
 
Health: "#7F4A89",
 
Riskperception: "#249CB1",
 
Exposure: "#B47D83"
 
}
 
// load data and then make chart
// load data and then make chart
onMounted(() => {
onMounted(() => {
loadData().then(() => {
loadData().then(() => {
@@ -63,7 +74,7 @@ onMounted(() => {
@@ -63,7 +74,7 @@ onMounted(() => {
async function loadData() {
async function loadData() {
// console.log(data);
// console.log(data);
data.value = await d3.csv(publicPath + 'p2_agree_evid_stats.csv', (d) => {
data.value = await d3.csv(publicPath + 'indicator_uncertainty.csv', (d) => {
d.level_agreement = +d.level_agreement
d.level_agreement = +d.level_agreement
d.evidence_val = +d.evidence_val
d.evidence_val = +d.evidence_val
return d
return d
@@ -290,13 +301,14 @@ function createDendrogram(result) {
@@ -290,13 +301,14 @@ function createDendrogram(result) {
}
}
// Define a color scale for the nodes based on category names and depth
// Define a color scale for the nodes based on category names and depth
const colorScale = d3.scaleOrdinal()
const colorScale = d3.scaleOrdinal()
.domain(["Demographic Characteristics", "Exposure", "Health", "Land Tenure", "Living Conditions", "Risk Perception", "Socioeconomic Status"])
.domain(["Demographic characteristics", "Exposure", "Health", "Land tenure", "Living conditions", "Risk perception", "Socioeconomic status"])
.range(["#625D0B", "#5C0601", "#0B4E8B", "#DC8260", "#7F4A89", "#249cb1", "#B47D83"]);
.range(Object.entries(dimensionColors).map(([key, value]) => value));
// Function to determine the color of a node based on its category
// Function to determine the color of a node based on its category
function getNodeColor(d) {
function getNodeColor(d) {
// If the node is one of the main categories, return its color
// If the node is one of the main categories, return its color
 
console.log(d.data.name);
if (d.depth === 1) {
if (d.depth === 1) {
return colorScale(d.data.name);
return colorScale(d.data.name);
}
}
Loading