Skip to content
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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
13 changes: 13 additions & 0 deletions docs/api/grafer-points-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Collaborator

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?

Copy link
Contributor Author

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

| 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. |
Expand All @@ -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. |
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

15 changes: 15 additions & 0 deletions docs/api/hierarchy-types.md
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.
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';
Loading
Loading