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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ABC LoCs</title>
|
| 7 |
+
<!-- Include ECharts library -->
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/echarts@latest/dist/echarts.min.js"></script>
|
| 9 |
+
<!-- Include jQuery library -->
|
| 10 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<!-- Placeholder for the chart -->
|
| 14 |
+
<div id="main" style="width: 100%; height: fit-content; min-height: 800px;"></div>
|
| 15 |
+
|
| 16 |
+
<script>
|
| 17 |
+
var chartDom = document.getElementById('main');
|
| 18 |
+
var myChart = echarts.init(chartDom);
|
| 19 |
+
|
| 20 |
+
myChart.showLoading();
|
| 21 |
+
|
| 22 |
+
$.getJSON('data/output_echart.json')
|
| 23 |
+
.done(function (graph) {
|
| 24 |
+
myChart.hideLoading();
|
| 25 |
+
|
| 26 |
+
var functionNodes = graph.nodes.filter(node => node.category !== 0);
|
| 27 |
+
var organizationNodes = graph.nodes.filter(node => node.category === 0);
|
| 28 |
+
|
| 29 |
+
// Define colors for the functions matching those in the JSON
|
| 30 |
+
var functionColors = {
|
| 31 |
+
// "Data curation and hosting": "#5470c6",
|
| 32 |
+
// "Access to computational resources": "#fc8452",
|
| 33 |
+
// "Education and capacity building": "#fac858",
|
| 34 |
+
// "Field Data Collection": "#ee6666",
|
| 35 |
+
// "Global Research Collaboration": "#73c0de",
|
| 36 |
+
// "Inclusive community building and engagement": "#3ba272",
|
| 37 |
+
// "Tech transfer and open-source tools development": "#9a60b4"
|
| 38 |
+
"Data curation and hosting": "#7f3c8d",
|
| 39 |
+
"Access to computational resources": "#11a579",
|
| 40 |
+
"Education and capacity building": "#3969ac",
|
| 41 |
+
"Field Data Collection": "#f2b701",
|
| 42 |
+
"Global Research Collaboration": "#e73f74",
|
| 43 |
+
"Inclusive community building and engagement": "#80ba5a",
|
| 44 |
+
"Tech transfer and open-source tools development": "#e68310"
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
functionNodes.forEach((node, index) => {
|
| 48 |
+
node.x = Math.cos(2 * Math.PI * index / functionNodes.length) * 400;
|
| 49 |
+
node.y = Math.sin(2 * Math.PI * index / functionNodes.length) * 400;
|
| 50 |
+
node.symbolSize = 125;
|
| 51 |
+
node.itemStyle = { color: functionColors[node.name] };
|
| 52 |
+
var verticalPadding = node.y / 2 ;
|
| 53 |
+
var paddingRight = node.y >= 0 ? node.symbolSize : 0-node.symbolSize;
|
| 54 |
+
node.symbol = node.value;
|
| 55 |
+
node.label = {
|
| 56 |
+
show: true,
|
| 57 |
+
rotate: false,
|
| 58 |
+
position: 'inside',
|
| 59 |
+
align: 'center',
|
| 60 |
+
verticalAlign: 'middle',
|
| 61 |
+
// backgroundColor: '#000',
|
| 62 |
+
rotate: false,
|
| 63 |
+
padding: [0, paddingRight, 0, 0],
|
| 64 |
+
fontweight: 'bold',
|
| 65 |
+
fontSize: 12,
|
| 66 |
+
color: '#fff',
|
| 67 |
+
|
| 68 |
+
formatter: function(params) {
|
| 69 |
+
var name = params.data.name;
|
| 70 |
+
return wrapText(name, 15); // Handle text wrapping
|
| 71 |
+
|
| 72 |
+
}
|
| 73 |
+
// formatter: '{b}'
|
| 74 |
+
};
|
| 75 |
+
});
|
| 76 |
+
|
| 77 |
+
organizationNodes.forEach((node, index) => {
|
| 78 |
+
node.x = Math.cos(2 * Math.PI * index / organizationNodes.length) * 500;
|
| 79 |
+
node.y = Math.sin(2 * Math.PI * index / organizationNodes.length) * 500;
|
| 80 |
+
node.symbolSize = 5;
|
| 81 |
+
node.itemStyle = { color: '#000' };
|
| 82 |
+
|
| 83 |
+
node.label = {
|
| 84 |
+
show: true,
|
| 85 |
+
fontSize: 10,
|
| 86 |
+
color: '#000',
|
| 87 |
+
formatter: function(params) {
|
| 88 |
+
var name = params.data.name;
|
| 89 |
+
return wrapText(name, 50);
|
| 90 |
+
}
|
| 91 |
+
};
|
| 92 |
+
});
|
| 93 |
+
|
| 94 |
+
function wrapText(text, maxLength) {
|
| 95 |
+
var words = text.split(' ');
|
| 96 |
+
var lines = [];
|
| 97 |
+
var currentLine = '';
|
| 98 |
+
|
| 99 |
+
words.forEach(function(word) {
|
| 100 |
+
if (currentLine.length + word.length <= maxLength) {
|
| 101 |
+
currentLine += (currentLine ? ' ' : '') + word;
|
| 102 |
+
} else {
|
| 103 |
+
lines.push(currentLine);
|
| 104 |
+
currentLine = word;
|
| 105 |
+
}
|
| 106 |
+
});
|
| 107 |
+
|
| 108 |
+
lines.push(currentLine);
|
| 109 |
+
return lines.join('\n');
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
var option = {
|
| 113 |
+
tooltip: {
|
| 114 |
+
trigger: 'item',
|
| 115 |
+
formatter: function (params) {
|
| 116 |
+
return params.name;
|
| 117 |
+
}
|
| 118 |
+
},
|
| 119 |
+
animationDuration: 1500,
|
| 120 |
+
animationEasingUpdate: 'quinticInOut',
|
| 121 |
+
series: [
|
| 122 |
+
{
|
| 123 |
+
name: 'ABC LoCs',
|
| 124 |
+
type: 'graph',
|
| 125 |
+
layout: 'circular',
|
| 126 |
+
data: functionNodes.concat(organizationNodes),
|
| 127 |
+
links: graph.links.map(link => ({
|
| 128 |
+
...link,
|
| 129 |
+
lineStyle: {
|
| 130 |
+
color: functionColors[link.target] || '#ccc',
|
| 131 |
+
width: 1,
|
| 132 |
+
curveness: 0.3
|
| 133 |
+
}
|
| 134 |
+
})),
|
| 135 |
+
circular: {
|
| 136 |
+
rotateLabel: true
|
| 137 |
+
},
|
| 138 |
+
roam: false,
|
| 139 |
+
draggable: true,
|
| 140 |
+
labelLayout: {
|
| 141 |
+
hideOverlap: true
|
| 142 |
+
},
|
| 143 |
+
lineStyle: {
|
| 144 |
+
curveness: 0.2,
|
| 145 |
+
width: 1
|
| 146 |
+
},
|
| 147 |
+
emphasis: {
|
| 148 |
+
focus: 'adjacency',
|
| 149 |
+
lineStyle: {
|
| 150 |
+
width: 2
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
]
|
| 155 |
+
};
|
| 156 |
+
|
| 157 |
+
// Apply the updated option to the chart
|
| 158 |
+
myChart.setOption(option);
|
| 159 |
+
})
|
| 160 |
+
.fail(function (jqxhr, textStatus, error) {
|
| 161 |
+
var err = textStatus + ", " + error;
|
| 162 |
+
console.log("Request Failed: " + err);
|
| 163 |
+
chartDom.innerHTML = "Failed to load data: " + err;
|
| 164 |
+
});
|
| 165 |
+
</script>
|
| 166 |
+
</body>
|
| 167 |
</html>
|