Skip to content

kg: explore-page camera-fit zooms to entire graph, not the path #693

Description

@jung-thomas

Follow-up from PR #687 (Track 3-B Task 5).

After clicking 'Find path' in /explore/, the camera calls renderer.getCamera().animatedReset() which re-centers on the entire graph, guaranteeing the path is visible but not zoomed to it. For a 1700-node graph the path is hard to spot.

Change

In app/explore/src/components/ExploreGraph.vue, replace animatedReset() with a bounding-box compute over the path nodes:

// Compute the bounding box of path nodes
const pathNodes = newPath.map(id => graph.getNodeAttributes(id))
const xs = pathNodes.map(n => n.x).filter(x => Number.isFinite(x))
const ys = pathNodes.map(n => n.y).filter(y => Number.isFinite(y))
if (xs.length && ys.length) {
  const minX = Math.min(...xs), maxX = Math.max(...xs)
  const minY = Math.min(...ys), maxY = Math.max(...ys)
  const centerX = (minX + maxX) / 2
  const centerY = (minY + maxY) / 2
  const ratio = Math.max(maxX - minX, maxY - minY) / 2 || 0.5
  renderer.getCamera().animate({ x: centerX, y: centerY, ratio }, { duration: 600 })
}

Verify against Sigma v3's actual camera API — getCamera().animate(target, options) is the documented method.

Acceptance

  • After clicking 'Find path', the camera animates to fit the path's bounding box with some padding.
  • Edge case: path of length 1 (impossible — path always has ≥2 nodes) → no-op.
  • Test (or PR 6 manual smoke check) confirms the path is visibly highlighted in the camera viewport.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions