-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
60 lines (56 loc) · 2.11 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>chromoMap Example</title>
<script src="./d3.v5.js"></script>
<script src="./chromoMap.v5.ALPHA.js"></script>
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
<div id="chromoMap_Area" style="border:solid black;"></div>
<script>
// Load data dynamically from a JSON file
fetch('./data.json') // Path to JSON
.then(response => {
if (!response.ok) {
throw new Error("Error loading JSON file");
}
return response.json();
})
.then(data => {
// Extract chromosome data and annotations from JSON
const chrom = data.chromosomes; // List of chromosomes
const regions = data.regions; // Associated regions
const annotations = data.annotations; // Annotations
// Initialise chromoMap
var cmap = chromoMap
.chromosomes(chrom, regions) // Load chromosomes and regions
.mappings(annotations, annotations); // Loading annotations
// Graphic configuration
cmap.params({
title: "Chromosome Visualisation",
n_win_factor: 10,
labels: true,
label_font: 15,
label_angle: -45,
chr_curve: 1,
chr_length: 1,
guides: true,
ploidy: 2,
top_margin: 50
})
.params_per_ploidy({
anno_col: Array(2).fill("#F9FF33"),
chr_color: ["darkgray", "#FF5733"]
});
// Graphic rendering
cmap.render();
})
.catch(error => {
console.error("Error:", error);
});
</script>
</body>
</html>