Skip to content

Commit 337c4f6

Browse files
committed
Provide helper paths in graph to let handle tooltips with marker draw
1 parent b19e696 commit 337c4f6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

scripts/JSRoot.more.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,10 +1459,13 @@ JSROOT.define(['d3', 'painter', 'math', 'gpad'], (d3, jsrp) => {
14591459
let path = "", pnt, grx, gry;
14601460

14611461
this.createAttMarker({ attr: graph, style: this.options.Mark - 100 });
1462-
1462+
14631463
this.marker_size = this.markeratt.getFullSize();
14641464

14651465
this.markeratt.resetPos();
1466+
1467+
let want_tooltip = !JSROOT.batch_mode && JSROOT.settings.Tooltip && !this.markeratt.fill && !nodes,
1468+
hints_marker = "", hsz = Math.max(5, Math.round(this.marker_size*0.7));
14661469

14671470
// let produce SVG at maximum 1MB
14681471
let maxnummarker = 1000000 / (this.markeratt.getMarkerLength() + 7), step = 1;
@@ -1477,8 +1480,10 @@ JSROOT.define(['d3', 'painter', 'math', 'gpad'], (d3, jsrp) => {
14771480
grx = funcs.grx(pnt.x);
14781481
if ((grx > -this.marker_size) && (grx < w + this.marker_size)) {
14791482
gry = funcs.gry(pnt.y);
1480-
if ((gry > -this.marker_size) && (gry < h + this.marker_size))
1483+
if ((gry > -this.marker_size) && (gry < h + this.marker_size)) {
14811484
path += this.markeratt.create(grx, gry);
1485+
if (want_tooltip) hints_marker += `M${grx-hsz},${gry-hsz}h${2*hsz}v${2*hsz}h${-2*hsz}z`;
1486+
}
14821487
}
14831488
}
14841489

@@ -1488,8 +1493,13 @@ JSROOT.define(['d3', 'painter', 'math', 'gpad'], (d3, jsrp) => {
14881493
.call(this.markeratt.func);
14891494
if ((nodes===null) && (this.draw_kind == "none"))
14901495
this.draw_kind = (this.options.Mark == 101) ? "path" : "mark";
1491-
14921496
}
1497+
if (want_tooltip && hints_marker)
1498+
this.draw_g.append("svg:path")
1499+
.attr("d", hints_marker)
1500+
.attr("stroke", "none")
1501+
.attr("fill", "none")
1502+
.attr("pointer-events", "visibleFill");
14931503
}
14941504

14951505
if (!JSROOT.batch_mode)
@@ -1813,7 +1823,7 @@ JSROOT.define(['d3', 'painter', 'math', 'gpad'], (d3, jsrp) => {
18131823
if (!hint.islines) {
18141824
elem.style('stroke', hint.color1 == 'black' ? 'green' : 'black').style('fill','none');
18151825
} else {
1816-
if (this.options.Line)
1826+
if (this.options.Line || this.options.Curve)
18171827
elem.call(this.lineatt.func);
18181828
else
18191829
elem.style('stroke','black');

0 commit comments

Comments
 (0)