MCPcopy Create free account
hub / github.com/tensorflow/tensorboard / update

Function update

tensorboard/plugins/graph/tf_graph_common/node.ts:1461–1527  ·  view source on GitHub ↗

* Adjust annotation's position. * * @param aGroup selection of a 'g.annotation' element. * @param d Host node data. * @param a annotation node data. * @param sceneElement polymer element.

(
  aGroup,
  d: render.RenderNodeInfo,
  a: render.Annotation,
  sceneElement
)

Source from the content-addressed store, hash-verified

1459 * @param sceneElement <tf-graph-scene> polymer element.
1460 */
1461function update(
1462 aGroup,
1463 d: render.RenderNodeInfo,
1464 a: render.Annotation,
1465 sceneElement
1466) {
1467 let cx = layout.computeCXPositionOfNodeShape(d);
1468 // Annotations that point to embedded nodes (constants,summary)
1469 // don't have a render information attached so we don't stylize these.
1470 // Also we don't stylize ellipsis annotations (the string '... and X more').
1471 if (a.renderNodeInfo && a.annotationType !== render.AnnotationType.ELLIPSIS) {
1472 stylize(aGroup, a.renderNodeInfo, sceneElement, Class.Annotation.NODE);
1473 }
1474 if (a.annotationType === render.AnnotationType.SUMMARY) {
1475 // Update the width of the annotation to give space for the image.
1476 a.width += 10;
1477 }
1478 // label position
1479 aGroup
1480 .select('text.' + Class.Annotation.LABEL)
1481 .transition()
1482 .attr('x', cx + a.dx + (a.isIn ? -1 : 1) * (a.width / 2 + a.labelOffset))
1483 .attr('y', d.y + a.dy);
1484 // Some annotations (such as summary) are represented using a 12x12 image tag.
1485 // Purposely omitted units (e.g. pixels) since the images are vector graphics.
1486 // If there is an image, we adjust the location of the image to be vertically
1487 // centered with the node and horizontally centered between the arrow and the
1488 // text label.
1489 aGroup
1490 .select('use.summary')
1491 .transition()
1492 .attr('x', cx + a.dx - 3)
1493 .attr('y', d.y + a.dy - 6);
1494 // Node position (only one of the shape selection will be non-empty.)
1495 positionEllipse(
1496 aGroup.select('.' + Class.Annotation.NODE + ' ellipse'),
1497 cx + a.dx,
1498 d.y + a.dy,
1499 a.width,
1500 a.height
1501 );
1502 positionRect(
1503 aGroup.select('.' + Class.Annotation.NODE + ' rect'),
1504 cx + a.dx,
1505 d.y + a.dy,
1506 a.width,
1507 a.height
1508 );
1509 positionRect(
1510 aGroup.select('.' + Class.Annotation.NODE + ' use'),
1511 cx + a.dx,
1512 d.y + a.dy,
1513 a.width,
1514 a.height
1515 );
1516 // Edge position
1517 aGroup
1518 .select('path.' + Class.Annotation.EDGE)

Callers 1

buildGroupForAnnotationFunction · 0.70

Calls 3

positionEllipseFunction · 0.90
positionRectFunction · 0.90
stylizeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…