Skip to content

Commit ac0d745

Browse files
committed
Merge branch '1.2.0' into add-legend
2 parents 738203c + 26f1568 commit ac0d745

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ Allow for up to 200 UNIQUE rows and columns
99
Print "No Data" instead of throwing error if dataframe is empty
1010
## 1.0.9
1111
update grafana tooling to webpack
12+
13+
## 1.2.0
14+
Updates to work with Grafana 12

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "esnet-matrix-panel",
3-
"version": "1.0.10",
3+
"version": "1.2.0",
44
"description": "ESnet Matrix Panel",
55
"scripts": {
66
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",

src/matrix.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function createViz(elem, id, height, rowNames, colNames, matrix, options, theme,
6767
//and be moved into place on hover
6868
//on mouse out the div will move back to 0,0 so
6969
//as not to be covering other boxes we want to hover
70-
var div = d3
70+
var tooltip = d3
7171
.select('body')
7272
.append('div')
7373
.attr('class', 'matrix-tooltip')
@@ -112,24 +112,23 @@ function createViz(elem, id, height, rowNames, colNames, matrix, options, theme,
112112
.attr('fill', theme.colors.text.primary)
113113
.call(truncateLabel, maxTxtLength)
114114
.on('mouseover', function (event, d) {
115-
div.html(d);
115+
tooltip.html(d);
116116

117117
//to center the tooltip appropriately we need to find the rendered width of both the
118118
//the box they hovered and of the tooltip with the text in it.
119-
var rect = event.target.getBoundingClientRect();
120-
var divSize = div.node().getBoundingClientRect();
119+
// var rect = event.target.getBoundingClientRect();
120+
var divSize = tooltip.node().getBoundingClientRect();
121121

122-
//place the tooltip along the X axis so that it's middle lines up with the
123-
//middle of the box they hovered
124-
div
125-
.style('left', rect.left + rect.width - divSize.width / 2 + 'px')
122+
// tooltip for label
123+
tooltip
124+
.style('left', event.pageX - divSize.width + 'px')
126125
//place the tooltip 5 pixels above the box they hovered
127-
.style('top', rect.top - divSize.height - 5 + 'px')
126+
.style('top', event.pageY - divSize.height - 5 + 'px')
128127
.style('opacity', 1);
129128
})
130129
.on('mouseout', function (d, i) {
131130
d3.select(this).attr('opacity', '1');
132-
div.style('opacity', 0).style('left', '0px').style('top', '0px');
131+
tooltip.style('opacity', 0).style('left', '0px').style('top', '0px');
133132
});
134133

135134
//build the matrix /////////////////////////////////////////
@@ -191,6 +190,7 @@ function createViz(elem, id, height, rowNames, colNames, matrix, options, theme,
191190
return defaultColor;
192191
}
193192
})
193+
// the tooltip for boxes
194194
.on('mouseover', function (event, d) {
195195
if (d != -1) {
196196
//turn down the opacity slightly to show the hover
@@ -202,7 +202,7 @@ function createViz(elem, id, height, rowNames, colNames, matrix, options, theme,
202202

203203
//like the mouseover above go ahead and render the text so we can calculate its size
204204
//and position correctly.
205-
div.html(() => {
205+
tooltip.html(() => {
206206
var thisDisplay = d.display;
207207
var text = `<p><b>${srcText}:</b> ${d.row}
208208
<br>
@@ -213,23 +213,28 @@ function createViz(elem, id, height, rowNames, colNames, matrix, options, theme,
213213
return text;
214214
});
215215

216-
var rect = event.target.getBoundingClientRect();
217-
var divSize = div.node().getBoundingClientRect();
218-
219-
div
220-
.style('left', rect.left + rect.width - divSize.width / 2 + 'px')
221-
.style('top', rect.top - divSize.height - 5 + 'px')
216+
tooltip
217+
// .style('left', rect.left + rect.width - divSize.width / 2 + 'px')
218+
// .style('top', rect.top - divSize.height - 5 + 'px')
219+
.style('left', event.pageX + 5 + 'px')
220+
.style('top', event.pageY + 5 + 'px')
222221
.style('opacity', 1);
223222
}
224223
})
225224
.on('mouseout', function (d, i) {
226-
//reset the opacity and move the div out of the way. If we dont move it it will prevent hovering over other boxes.
225+
//reset the opacity and move the tooltip out of the way. If we dont move it it will prevent hovering over other boxes.
227226
d3.select(this)
228227
// .attr('opacity', '1')
229228
.attr('transform', 'translate(0, 0)')
230229
.attr('width', x.bandwidth())
231230
.attr('height', y.bandwidth());
232-
div.style('opacity', 0).style('left', '0px').style('top', '0px');
231+
tooltip.style('opacity', 0).style('left', '0px').style('top', '0px');
232+
})
233+
.on('click', function (d) {
234+
if(linkURL) {
235+
// d3.select(this).remove();
236+
tooltip.remove();
237+
}
233238
});
234239

235240
////// LEGEND ////////////

0 commit comments

Comments
 (0)