-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative points #108
base: main
Are you sure you want to change the base?
Relative points #108
Changes from all commits
69086c2
d209c20
b317eaa
89e2f95
3c0339a
6a3836f
93a745c
b92e6ab
2bf10a4
3f35255
13b442c
abf69c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ An array of point objects to be loaded into Grafer. The PointData property list | |
| Property | Type | Description | | ||
| :--- | :--- | :--- | | ||
| id | string - *optional* | Name of the point. Will be used as an ID when referencing point in node, edge, and label data. Will default to its index in the PointData array if left out. | | ||
| parentId | string - *optional* | ID of the point which this point is the child of. Used to enable relative positioning of points and relative radius. Will default to *No Parent* if left out. | ||
| x | number | X-Coordinate of the point. | | ||
| y | number | Y-Coordinate of the point. | | ||
| z | number - *optional* | Z-Coordinate of the point. Will default to 0 if left out. | | ||
|
@@ -27,7 +28,19 @@ Data [mappings](../guides/mappings.md) are used to compute properties at runtime | |
| Property | Type | Description | | ||
| :--- | :--- | :--- | | ||
| id | (datum: PointData) => string - *optional* | | | ||
| parentId | (datum: PointData) => string - *optional* | | | ||
| x | (datum: PointData) => number - *optional* | | | ||
| y | (datum: PointData) => number - *optional* | | | ||
| z | (datum: PointData) => number - *optional* | | | ||
| radius | (datum: PointData) => number - *optional* | | | ||
|
||
### `options` | ||
###### { [key: string]: any } - *optional* | ||
|
||
An object containing configuration options for the points. | ||
|
||
| Property | Type | Description | | ||
| :--- | :--- | :--- | | ||
| positionHierarchyType | HierarchyTypes | Changes how point hierarchies changes the point positions. See [HierarchyTypes](./hierarchy-types.md) for more information. | | ||
| radiusHierarchyType | HierarchyTypes | Changes how point hierarchies changes the point radius. See [HierarchyTypes](./hierarchy-types.md) for more information. | | ||
| maxHierarchyDepth | number | Sets the maximum hierarchy depth that any point will have. Defaults to 100. | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how is the depth used? why is it important? when would I want to change this to be smaller / bigger? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the maxHierarchyDepth is basically only there to save the user from circular references in the data and stuff like that, which would otherwise crash the os (infinite loop in fragment shader is really not good). this should be increased if you expect the hierarchy depth in the data to be larger than the default value. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# HierarchyTypes | ||
|
||
An enum specifying how a points hierarchy influences a given point data property. | ||
|
||
<br> | ||
|
||
## Properties | ||
|
||
### `NONE` | ||
|
||
The hierarchy has no effect on a given data property. | ||
|
||
### `ADD` | ||
|
||
The value of a given point data property is the sum of all the values associated with that data property up the hierarchy. This type can be used to allow for relative point positioning as an example. |
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}] }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ID of the parent point that this point ...
Does it have to be a direct parent, or can it be any ancestor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the parentId put in here is the direct parent