-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added small example of hierarchy usage
- Loading branch information
Manfred Cheung
committed
Sep 22, 2023
1 parent
13b442c
commit abf69c9
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}] }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters