Usage guidesLayoutRecommended optional layouts

Fishbone layout

Place a problem at the end of a spine, with cause categories on either side.

Overview

Place the problem at the end of the spine. Each cause category joins the spine with a diagonal branch, and shorter horizontal lines attach individual causes to that branch.

When to use it

Use it for three-level structures such as a problem, cause categories, and specific causes.

Basic usage

This layout is optional. Import and register it before setting layout.type. For CDN usage, see Optional layouts.

import { Graph, register } from '@antv/g6-lite';
import fishbone from '@antv/g6-lite/layouts/fishbone';

register('layout', 'fishbone', fishbone);

const graph = new Graph({
  container,
  data,
  layout: { type: 'fishbone' },
  edge: { type: 'polyline', style: { router: 'fishbone', endArrow: false } },
});

Options

OptionDescriptionTypeDefault
categoryGapGap between categories along the spine.number180
categoryDistanceVertical distance from a category to the spine.number200
itemHStepAdditional horizontal offset for item nodes.number20
getWidthNode width used by the layout. Match it to the rendered width.Function returning a widthReturns 80
direction'RL' mirrors the 'LR' arrangement horizontally.'LR' | 'RL''LR'

Common layout options · Layout reference

Code example

Define parent-child relationships as edges. Use the parent ID as source and the child ID as target.

This diagram breaks down a late release into four categories. People, Tools, Process, and Scope each have two specific causes.

Loading example…
Drag to pan or scroll to zoom.
import { register } from '@antv/g6-lite';

import fishboneLayout from '@antv/g6-lite/layouts/fishbone';

register('layout', 'fishbone', fishboneLayout);

const layout = {
  type: 'fishbone',
  direction: 'LR',
  categoryGap: 200,
  categoryDistance: 138,
  itemHStep: 26,
  getWidth: () => 96,
};

const edge = {
  type: 'polyline',
  style: { router: 'fishbone', endArrow: false, stroke: '#7086a8', lineWidth: 2 },
} as const;

Compare tree layouts