Skip to content

Commit

Permalink
fix: support heatmap svg with path tag (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaiVenkat authored Jan 17, 2024
1 parent 1dbf652 commit a052849
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/js/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,21 @@ class HeatMap {
if (constants.hasRect) {
for (let i = 0; i < this.plots.length; i++) {
if (this.plots[i]) {
x_coord_check.push(parseFloat(this.plots[i].getAttribute('x')));
y_coord_check.push(parseFloat(this.plots[i].getAttribute('y')));
// heatmap SVG containing path element instead of rect
if (this.plots[i] instanceof SVGPathElement) {
// Assuming the path data is in the format "M x y L x y L x y L x y"
const path_d = this.plots[i].getAttribute('d');
const coords = path_d.match(/[\d\.]+/g).map(Number);

const x = coords[0];
const y = coords[1];

x_coord_check.push(parseFloat(x));
y_coord_check.push(parseFloat(y));
} else {
x_coord_check.push(parseFloat(this.plots[i].getAttribute('x')));
y_coord_check.push(parseFloat(this.plots[i].getAttribute('y')));
}
}
}

Expand Down

0 comments on commit a052849

Please sign in to comment.