Skip to content

Commit

Permalink
fixed heatmap, treemap labels and changed cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Lugiasc committed Jun 4, 2023
1 parent 486cb1b commit 85bb5ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
9 changes: 5 additions & 4 deletions website/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ p {
line-height: 1.5;
}

p.clickable:hover {
color: #2072F3;
cursor: pointer;
}

b {
font-weight: 600;
color: #2072F3;
Expand Down Expand Up @@ -491,10 +496,6 @@ section {
text-decoration: none;
}

p.clickable:hover {
color: #2072F3;
}

.promo-item {
height: 200px;
line-height: 180px;
Expand Down
10 changes: 5 additions & 5 deletions website/js/heatmap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// set the dimensions and margins of the graph
var marginHeatmap = {top: 20, right: 25, bottom: 30, left: 40},
widthHeatmap = 800 - marginHeatmap.left - marginHeatmap.right,
heightHeatmap = 450 - marginHeatmap.top - marginHeatmap.bottom;
widthHeatmap = 850 - marginHeatmap.left - marginHeatmap.right,
heightHeatmap = 800 - marginHeatmap.top - marginHeatmap.bottom;


// set the color scale
Expand Down Expand Up @@ -73,8 +73,8 @@ function updateHeatmapChart(data) {
d3.select("#heatmap").selectAll("svg").remove();
var svg = d3.select("#heatmap")
.append("svg")
.attr("width", width + marginHeatmap.left + marginHeatmap.right)
.attr("height", height + marginHeatmap.top + marginHeatmap.bottom)
.attr("width", widthHeatmap + marginHeatmap.left + marginHeatmap.right)
.attr("height", heightHeatmap + marginHeatmap.top + marginHeatmap.bottom)
.append("g")
.attr("transform",
"translate(" + marginHeatmap.left + "," + marginHeatmap.top + ")");
Expand All @@ -88,7 +88,7 @@ function updateHeatmapChart(data) {

// Build X scales and axis:
var x = d3.scaleBand()
.range([ 0, width ])
.range([ 0, widthHeatmap ])
.domain(myGroups)
.padding(0.05);
svg.append("g")
Expand Down
17 changes: 9 additions & 8 deletions website/js/treemap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// set the dimensions and margins of the graph
var marginTreemap = {top: 50, right: 50, bottom: 0, left: 0},
var marginTreemap = {top: 50, right: 30, bottom: 0, left: 0},
marginTreemapLabel = 10,
widthTreemap = document.getElementsByClassName("column-left-75")[0].offsetWidth,
heightTreemap = 900,
tile = d3.treemapResquarify,
Expand Down Expand Up @@ -211,27 +212,27 @@ function updateTreemap(data, dataType) {
textLabels
.enter()
.append("text")
.attr("x", function(d){ return d.x0 + 10}) // +8 to adjust position (more right)
.attr("x", function(d){ return d.x0 + 10}) // +10 to adjust position (more right)
.attr("y", function(d){ return d.y0 + 25}) // +20 to adjust position (lower)
.attr("opacity", 0)
.transition()
.duration(500)
.attr("opacity", 1)
.attr("x", function(d){ return d.x0 + 10}) // +8 to adjust position (more right)
.attr("x", function(d){ return d.x0 + 10}) // +10 to adjust position (more right)
.attr("y", function(d){ return d.y0 + 25}) // +20 to adjust position (lower)
.text(function(d){
var name = d.data.name
var widthTemp = d.x1 - d.x0
var heightTemp = d.y1 - d.y0
var textWidth = getTextWidth(name, fontSizeTreemap) + marginTreemap.right
var textHeight = parseInt(fontSizeTreemap.substring(0, 2)) + 12
var textWidth = getTextWidth(name, fontSizeTreemap) + 2 * marginTreemapLabel
var textHeight = parseInt(fontSizeTreemap.substring(0, 2)) + marginTreemapLabel
var truncatedName = name

if (textWidth > widthTemp) {
var substringLength = findMaxSubstringLength(name, widthTemp - marginTreemap.right, fontSizeTreemap)
var substringLength = findMaxSubstringLength(name, widthTemp - marginTreemapLabel, fontSizeTreemap)

if (substringLength > 1) {
truncatedName = name.substring(0, findMaxSubstringLength(name, widthTemp - marginTreemap.right, fontSizeTreemap)) + "..."
truncatedName = name.substring(0, findMaxSubstringLength(name, widthTemp - marginTreemapLabel, fontSizeTreemap)) + "..."
}
else {
truncatedName = ""
Expand Down Expand Up @@ -260,7 +261,7 @@ function findMaxSubstringLength(text, desiredWidth, fontSize) {
while (low <= high) {
var mid = Math.floor((low + high) / 2);
var substr = text.substr(0, mid + 1);
var width = getTextWidth(substr, fontSize) + marginTreemap.right + marginTreemap.left;
var width = getTextWidth(substr, fontSize) + 2 * marginTreemapLabel;

if (width <= desiredWidth) {
maxSubstrLength = mid + 1;
Expand Down

0 comments on commit 85bb5ce

Please sign in to comment.