|
@ -35,6 +35,7 @@ export function StudySite(props) { |
|
|
document.documentElement.style.height = height; |
|
|
document.documentElement.style.height = height; |
|
|
|
|
|
|
|
|
if (heatmapInstance === undefined) { |
|
|
if (heatmapInstance === undefined) { |
|
|
|
|
|
document.getElementById("studySiteContainer").style.height = height; |
|
|
heatmapInstance = h337.create({ |
|
|
heatmapInstance = h337.create({ |
|
|
container: document.getElementById("studySiteContainer"), |
|
|
container: document.getElementById("studySiteContainer"), |
|
|
radius: 40, |
|
|
radius: 40, |
|
@ -50,6 +51,10 @@ export function StudySite(props) { |
|
|
heatmapInstance.addData({ x: x, y: y, value: 1 }); |
|
|
heatmapInstance.addData({ x: x, y: y, value: 1 }); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener("scroll", function (event) { |
|
|
|
|
|
updateHeatmapSize(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// Function to capture clicks |
|
|
// Function to capture clicks |
|
|
document.addEventListener("click", function (event) { |
|
|
document.addEventListener("click", function (event) { |
|
|
var x = event.pageX; |
|
|
var x = event.pageX; |
|
@ -57,13 +62,31 @@ export function StudySite(props) { |
|
|
|
|
|
|
|
|
// Add more value for clicks |
|
|
// Add more value for clicks |
|
|
heatmapInstance.addData({ x: x, y: y, value: 5 }); |
|
|
heatmapInstance.addData({ x: x, y: y, value: 5 }); |
|
|
|
|
|
updateHeatmapSize(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Function to update heatmap container size on resize |
|
|
// Function to update heatmap container size on resize |
|
|
function updateHeatmapSize() { |
|
|
function updateHeatmapSize() { |
|
|
var container = document.getElementById("heatmapOverlay"); |
|
|
var container = document.getElementById("heatmapOverlay"); |
|
|
container.style.width = document.body.scrollWidth + "px"; |
|
|
|
|
|
|
|
|
container.style.width = |
|
|
|
|
|
document.getElementById("root").style.width + "px"; |
|
|
container.style.height = document.body.scrollHeight + "px"; |
|
|
container.style.height = document.body.scrollHeight + "px"; |
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("studySiteContainer").style.width = |
|
|
|
|
|
document.getElementById("root").style.width + "px"; |
|
|
|
|
|
document.getElementById("studySiteContainer").style.height = |
|
|
|
|
|
document.body.scrollHeight + "px"; |
|
|
|
|
|
|
|
|
|
|
|
const heatmapData = heatmapInstance.getData(); |
|
|
|
|
|
for (var el of document.getElementsByTagName("canvas")) { |
|
|
|
|
|
el.remove(); |
|
|
|
|
|
} |
|
|
|
|
|
heatmapInstance = h337.create({ |
|
|
|
|
|
container: document.getElementById("studySiteContainer"), |
|
|
|
|
|
radius: 40, |
|
|
|
|
|
}); |
|
|
|
|
|
heatmapInstance.setData(heatmapData); |
|
|
|
|
|
heatmapInstance.setDataMax(HEATMAP_MAX); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const handleStart = (evt) => { |
|
|
const handleStart = (evt) => { |
|
@ -162,5 +185,5 @@ export function StudySite(props) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function getHeatmapData() { |
|
|
export function getHeatmapData() { |
|
|
return (heatmapInstance !== undefined) ? heatmapInstance.getData() : {}; |
|
|
|
|
|
|
|
|
return heatmapInstance !== undefined ? heatmapInstance.getData() : {}; |
|
|
} |
|
|
} |