|
79 | 79 | {% block tail %}
|
80 | 80 | {{ super() }}
|
81 | 81 | <script src="{{ url_for_asset('d3.min.js') }}"></script>
|
| 82 | +<script src="{{ url_for_asset('d3-tip.js') }}"></script> |
82 | 83 | <script>
|
83 | 84 | $('span.status_square').tooltip({html: true});
|
84 | 85 |
|
|
108 | 109 | var diagonal = d3.svg.diagonal()
|
109 | 110 | .projection(function(d) { return [d.y, d.x]; });
|
110 | 111 |
|
| 112 | +const taskTip = d3.tip() |
| 113 | + .attr('class', 'tooltip d3-tip') |
| 114 | + .html(function(toolTipHtml) { |
| 115 | + return toolTipHtml; |
| 116 | +}); |
| 117 | + |
111 | 118 | var svg = d3.select("svg")
|
112 | 119 | //.attr("width", width + margin.left + margin.right)
|
113 | 120 | .append("g")
|
|
145 | 152 | )
|
146 | 153 | .selectAll("text")
|
147 | 154 | .attr("transform", "rotate(-30)")
|
148 |
| - .style("text-anchor", "start"); |
| 155 | + .style("text-anchor", "start").call(taskTip); |
149 | 156 |
|
150 | 157 | function node_class(d) {
|
151 | 158 | var sclass = "node";
|
|
199 | 206 | .attr("r", (barHeight / 3))
|
200 | 207 | .attr("class", "task")
|
201 | 208 | .attr("data-toggle", "tooltip")
|
202 |
| - .attr("title", function(d){ |
| 209 | + .on("mouseover", function(d) { |
203 | 210 | var tt = "";
|
204 | 211 | if (d.operator != undefined) {
|
205 | 212 | if (d.operator != undefined) {
|
|
212 | 219 | tt += "start_date: " + escapeHtml(d.start_date) + "<br/>";
|
213 | 220 | tt += "end_date: " + escapeHtml(d.end_date) + "<br/>";
|
214 | 221 | }
|
215 |
| - return tt; |
| 222 | + taskTip.direction('e') |
| 223 | + taskTip.show(tt, this) |
| 224 | + d3.select(this).transition() |
| 225 | + .style('stroke-width', 3) |
| 226 | + }) |
| 227 | + .on('mouseout', function(d, i) { |
| 228 | + taskTip.hide(d) |
| 229 | + d3.select(this).transition() |
| 230 | + .style("stroke-width", function(d) {return (d.run_id != undefined)? "2": "1"}) |
216 | 231 | })
|
217 | 232 | .attr("height", barHeight)
|
218 | 233 | .attr("width", function(d, i) {return barWidth - d.y;})
|
|
251 | 266 | .style("shape-rendering", function(d) {return (d.run_id != undefined)? "auto": "crispEdges"})
|
252 | 267 | .style("stroke-width", function(d) {return (d.run_id != undefined)? "2": "1"})
|
253 | 268 | .style("stroke-opacity", function(d) {return d.external_trigger ? "0": "1"})
|
254 |
| - .attr("title", function(d){ |
| 269 | + .on("mouseover", function(d){ |
255 | 270 | var s = "";
|
256 | 271 | if (d.task_id != undefined ) {
|
257 | 272 | s += "Task_id: " + escapeHtml(d.task_id) + "<br>";
|
|
271 | 286 | }
|
272 | 287 | s += "State: " + escapeHtml(d.state) + "<br>";
|
273 | 288 | }
|
274 |
| - return s; |
| 289 | + taskTip.direction('n') |
| 290 | + taskTip.show(s, this) |
| 291 | + d3.select(this).transition() |
| 292 | + .style('stroke-width', 3) |
| 293 | + }) |
| 294 | + .on('mouseout', function(d,i) { |
| 295 | + taskTip.hide(d) |
| 296 | + d3.select(this).transition() |
| 297 | + .style("stroke-width", function(d) {return (d.run_id != undefined)? "2": "1"}) |
275 | 298 | })
|
276 | 299 | .attr('x', function(d, i) {return (i*(square_size+square_spacing));})
|
277 | 300 | .attr('y', -square_size/2)
|
278 | 301 | .attr('width', 10)
|
279 |
| - .attr('height', 10) |
280 |
| - .on('mouseover', function(d,i) { |
281 |
| - d3.select(this).transition() |
282 |
| - .style('stroke-width', 3) |
283 |
| - }) |
284 |
| - .on('mouseout', function(d,i) { |
285 |
| - d3.select(this).transition() |
286 |
| - .style("stroke-width", function(d) {return (d.run_id != undefined)? "2": "1"}) |
287 |
| - }) ; |
| 302 | + .attr('height', 10); |
288 | 303 |
|
289 | 304 |
|
290 | 305 | // Transition nodes to their new position.
|
|
344 | 359 | $('#loading').remove()
|
345 | 360 | }
|
346 | 361 |
|
347 |
| -function set_tooltip(){ |
348 |
| - $("rect.state").tooltip({ |
349 |
| - html: true, |
350 |
| - container: "body", |
351 |
| - }); |
352 |
| - $("circle.task").tooltip({ |
353 |
| - html: true, |
354 |
| - container: "body", |
355 |
| - }); |
356 |
| - |
357 |
| -} |
358 | 362 | function toggles(clicked_d) {
|
359 | 363 | // Collapse nodes with the same task id
|
360 | 364 | d3.selectAll("[task_id='" + clicked_d.name + "']").each(function(d){
|
|
374 | 378 | clicked_d.children = null;
|
375 | 379 | }
|
376 | 380 | update(clicked_d);
|
377 |
| - set_tooltip(); |
378 | 381 | }
|
379 | 382 | // Toggle children on click.
|
380 | 383 | function click(d) {
|
|
387 | 390 | d._children = null;
|
388 | 391 | }
|
389 | 392 | update(d);
|
390 |
| - set_tooltip(); |
391 | 393 | }
|
392 | 394 | }
|
393 |
| -set_tooltip(); |
394 | 395 |
|
395 | 396 | </script>
|
396 | 397 | {% endblock %}
|
0 commit comments