Skip to content
Snippets Groups Projects
Commit ede84bef authored by Cee Nell's avatar Cee Nell
Browse files

remove pointer event for better response

parent 01731716
No related branches found
No related tags found
1 merge request!26Clean up hero
......@@ -141,7 +141,7 @@
.attr('height', height);
const yScale = d3.scaleLinear()
.domain([30, d3.max(data.value, d => d.level_agreement)])
.domain([40, d3.max(data.value, d => d.level_agreement)])
.range([height-margin.bottom, margin.top]);
// Set radius based on evidence value
......@@ -172,9 +172,9 @@
// Set forces
const forceY = d3.forceY(d => yScale(d.level_agreement)).strength(0.9);
const forceX = d3.forceX(margin.left + (width / 2)).strength(0.1);
const forceCollide = d3.forceCollide(d => radiusScale(d.evidence_val) + 2).iterations(16);
const forceY = d3.forceY(d => yScale(d.level_agreement)).strength(0.5);
const forceX = d3.forceX(margin.left + (width / 2)).strength(0.2);
const forceCollide = d3.forceCollide(d => radiusScale(d.evidence_val) + 2).iterations(20);
const forceManyBody = d3.forceManyBody().strength(-10);
const bubbles = svg
......@@ -189,12 +189,19 @@
const [x, y] = d3.pointer(event);
d3.select('#tooltip')
.style('opacity', 1)
.html(`${d.determinant}<br>Evidence: ${d.evidence_val}`)
.html(`<strong>${d.determinant}</strong><br>appeared in ${d.evidence_val} studies`)
.style('left', (x + 10) + 'px')
.style('top', (y - 28) + 'px');
d3.select(this)
.attr('stroke', d => dimensionColors[d.dimension.replace(' ', '')])
.attr('stroke-width', 15);
})
.on('mouseout', function () {
d3.select('#tooltip').style('opacity', 0);
d3.select(this)
.attr('stroke', null)
.attr('stroke-width', null);
});
// Run simulation
......@@ -226,7 +233,7 @@
function updateChart() {
console.log('Update chart called');
const yScale = d3.scaleLinear()
.domain([30, d3.max(data.value, d => d.level_agreement)])
.domain([40, d3.max(data.value, d => d.level_agreement)])
.range([height-margin.bottom, margin.top]);
// Set radius based on evidence value
......@@ -371,5 +378,15 @@
color: $Exposure;
border-color: $Exposure;
}
#tooltip {
position: absolute;
opacity: 0;
background: #f9f9f9;
padding: 5px;
border: 15px solid black;
border-radius: 15px;
pointer-events: none; /* Prevent tooltip from blocking mouse events */
}
</style>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment