Skip to content

Interactive Minimap

yh-flow's minimap component not only displays an overview of the flowchart but also supports interactive navigation and layout controls.

Basic Usage

Enabling the Minimap

vue
<template>
  <yh-flow :nodes="nodes" :edges="edges" show-minimap />
</template>

Minimap Position

You can set the minimap position using the position property:

vue
<yh-flow
  :nodes="nodes"
  :edges="edges"
  show-minimap
  :minimap-node-color="(node) => (node.selected ? '#3b82f6' : '#94a3b8')"
/>
Position ValueDescription
bottom-rightBottom right (default)
bottom-leftBottom left
top-rightTop right
top-leftTop left

Interactive Features

Click-to-Navigate

When interactiveMinimap is enabled, clicking anywhere on the minimap will smoothly pan the canvas to the corresponding position:

vue
<template>
  <yh-flow ref="flowRef" :nodes="nodes" :edges="edges" show-minimap interactive-minimap />
</template>

Drag Navigation

The minimap supports drag navigation by default:

typescript
// Plugin options
const minimapOptions = {
  pannable: true, // Enable drag navigation (default: true)
  zoomable: true // Enable zoom (default: true)
}

Layout Controls

Showing Layout Buttons

Use showLayoutControls to display layout control buttons on the minimap:

vue
<template>
  <yh-flow
    ref="flowRef"
    :nodes="nodes"
    :edges="edges"
    show-minimap
    show-layout-controls
    layout-type="dagre"
    layout-direction="TB"
    @layout-change="handleLayoutChange"
  />
</template>

<script setup lang="ts">
const handleLayoutChange = (layout: string) => {
  console.log('Layout changed to:', layout)
  // Execute auto-layout based on layout type
}
</script>

Layout Button Reference

ButtonDescription
DDagre Layout (Hierarchical)
EELK Layout (Elastic)
FForce Layout
TBTop to Bottom
LRLeft to Right

Complete Example

Start
Process
Branch
End
Interactive Minimap Demo

API Reference

Flow Props

PropertyTypeDefaultDescription
showMinimapbooleanfalseShow minimap
interactiveMinimapbooleanfalseEnable click-to-navigate
showLayoutControlsbooleanfalseShow layout control buttons
layoutType'dagre' | 'elk' | 'force' | 'grid' | 'none''none'Current layout type
layoutDirection'TB' | 'BT' | 'LR' | 'RL''TB'Layout direction

Events

EventDescriptionParameters
layout-changeTriggered when layout type changes(layout: string) => void
direction-changeTriggered when layout direction changes(direction: string) => void

MiniMap Plugin Options

OptionTypeDefaultDescription
position'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''bottom-right'Minimap position
widthnumber200Minimap width
heightnumber150Minimap height
nodeColor(node: Node) => string-Node color function
pannablebooleantrueEnable drag navigation
interactivebooleanfalseEnable click navigation
showLayoutControlsbooleanfalseShow layout buttons

Best Practices

  1. Combine with auto-layout: Combine minimap layout controls with auto-layout algorithms for a one-stop layout experience
  2. Visual feedback: Use nodeColor function to display different colors based on node status
  3. Navigation efficiency: Enable interactive navigation in large flowcharts to help users quickly locate areas of interest

TIP

Clicking on empty areas of the minimap quickly jumps to the corresponding canvas position, especially useful for navigation in large flowcharts.

Released under the MIT License.