Skip to content

Commit

Permalink
feat: added small example of hierarchy usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred Cheung committed Sep 22, 2023
1 parent 13b442c commit abf69c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/src/basic/hierarchy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {html, render} from 'lit-html';
import {GraferController} from '../../../src/mod';

export async function hierarchy(container: HTMLElement): Promise<void> {
render(html`<canvas class="grafer_container"></canvas><mouse-interactions></mouse-interactions>`, container);
const canvas = document.querySelector('.grafer_container') as HTMLCanvasElement;

const points = {
data: [
{ id: 0, x: 0, y: 0 },
{ id: 1, x: 2, y: 0, parentId: 0 },
{ id: 2, x: 2, y: 0, parentId: 1 },
],
};
const nodes = {
...points,
mappings: {
point: (d: any): number => d.id,
},
};

new GraferController(canvas, { points, layers: [{nodes}] });
}
1 change: 1 addition & 0 deletions examples/src/basic/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './nodeColors';
export * from './edgeColors';
export * from './nodeRadius';
export * from './nodeID';
export * from './hierarchy';

0 comments on commit abf69c9

Please sign in to comment.