Ogma
Main Ogma component, it automatically creates an Ogma instance and provides it to its children. If you want to pass it your own instance, or if you want to type nodes and edges data types, see useOgma.
Props
width
- type:
number | undeifined
- default:
undefined
Width of Ogma canvas. If not set, width of the container will be used.
height
- type:
number | undefined
- default:
undefined
Height of Ogma canvas. If not set, height of the container will be used.
graph
- type: RawGraph
| undefined
- default:
() => ({ nodes: [], edges: [] })
Graph to render. If not set, an empty graph will be rendered.
options
- type: OgmaOptions
| undefined
- default:
undefined
Options to pass to Ogma instance. If not set, default options will be used.
layoutOnMounted
- type:
boolean
- default:
true
Whether to layout the graph when the component is mounted.
events
- type:
string[] | "all"
- default:
"all"
Events to listen to. If set to "all"
, all events will be listened to. See events for a list of available events.
Events
addEdges
- payload: AddEdgesEvent
Triggered when edges are added to the graph.
addGraph
- payload: AddGraphEvent
Triggered when a graph is added to the graph.
addNodes
- payload: AddNodesEvent
Triggered when nodes are added to the graph.
beforeRemoveEdges
- payload: BeforeRemoveEdgesEvent
Triggered before edges are removed from the graph.
beforeRemoveNodes
- payload: BeforeRemoveNodesEvent
Triggered before nodes are removed from the graph.
clearGraph
- payload: ClearGraphEvent
Triggered when the graph is cleared.
click
- payload: ClickEvent
Triggered when the user clicks on the graph.
connectNodes
- payload: ConnectNodesEvent
Triggered when nodes are connected.
destroy
- payload: DestroyEvent
Triggered when the Ogma instance is destroyed.
doubleclick
- payload: DoubleclickEvent
Triggered when the user double clicks on the graph.
dragEnd
- payload: DragEndEvent
Triggered when the user stops dragging the graph.
dragProgress
- payload: DragProgressEvent
Triggered when the user drags the graph.
dragStart
- payload: DragStartEvent
Triggered when the user starts dragging the graph.
drop
- payload: DropEvent
Triggered when the user drops something on the graph.
edgesSelected
- payload: EdgesSelectedEvent
Triggered when edges are selected.
geoDisabled
- payload: GeoDisabledEvent
Triggered when the geo mode is disabled.
geoEnabled
- payload: GeoEnabledEvent
Triggered when the geo mode is enabled.
geoLoaded
- payload: GeoLoadedEvent
Triggered when the geo mode is loaded.
gestureEnd
- payload: GestureEndEvent
Triggered when the user stops a gesture.
gestureProgress
- payload: GestureProgressEvent
Triggered when the user performs a gesture.
gestureStart
- payload: GestureStartEvent
Triggered when the user starts a gesture.
keydown
- payload: KeydownEvent
Triggered when the user presses a key.
keyup
- payload: KeyupEvent
Triggered when the user releases a key.
layoutComputed
- payload: LayoutComputedEvent
Triggered when the layout is computed.
layoutEnd
- payload: LayoutEndEvent
Triggered when the layout ends.
layoutStart
- payload: LayoutStartEvent
Triggered when the layout starts.
mousedown
- payload: MousedownEvent
Triggered when the user presses the mouse button.
mousemove
- payload: MousemoveEvent
Triggered when the user moves the mouse.
mouseout
- payload: MouseoutEvent
Triggered when the user moves the mouse out of the graph.
mouseover
- payload: MouseoverEvent
Triggered when the user moves the mouse over the graph.
mouseup
- payload: MouseupEvent
Triggered when the user releases the mouse button.
mousewheel
- payload: MousewheelEvent
Triggered when the user scrolls the mouse wheel.
nodesDragEnd
- payload: NodesDragEndEvent
Triggered when the user stops dragging nodes.
nodesDragProgress
- payload: NodesDragProgressEvent
Triggered when the user drags nodes.
nodesDragStart
- payload: NodesDragStartEvent
Triggered when the user starts dragging nodes.
nodesSelected
- payload: NodesSelectedEvent
Triggered when nodes are selected.
nodesUnselected
- payload: NodesUnselectedEvent
Triggered when nodes are unselected.
removeEdges
- payload: RemoveEdgesEvent
Triggered when edges are removed from the graph.
removeNodes
- payload: RemoveNodesEvent
Triggered when nodes are removed from the graph.
rendererStateChange
- payload: RendererStateChangeEvent
Triggered when the renderer state changes.
resize
- payload: ResizeEvent
Triggered when the graph is resized.
rotate
- payload: RotateEvent
Triggered when the graph is rotated.
tooltipHide
- payload: TooltipHideEvent
Triggered when the tooltip is hidden.
tooltipShow
- payload: TooltipShowEvent
Triggered when the tooltip is shown.
transformationDestroyed
- payload: TransformationDestroyedEvent
Triggered when a transformation is destroyed.
transformationDisabled
- payload: TransformationDisabledEvent
Triggered when a transformation is disabled.
transformationEnabled
- payload: TransformationEnabledEvent
Triggered when a transformation is enabled.
transformationRefresh
- payload: TransformationRefreshEvent
Triggered when a transformation is refreshed.
transformationSetIndex
- payload: TransformationSetIndexEvent
Triggered when a transformation index is set.
updateEdgeData
- payload: UpdateEdgeDataEvent
Triggered when edge data is updated.
updateNodeData
- payload: UpdateNodeDataEvent
Triggered when node data is updated.
viewChanged
- payload: ViewChangedEvent
Triggered when the view changes.
Slots
default
- type:
VNode[]
Put your Ogma components here. They will be provided with the Ogma instance.
Provide
ogma
- type: Ogma
The Ogma instance created by the component (or passed to if using useOgma).
Example
<template>
<Ogma :graph="graph" :options="options" @addNodes="onAddNodes">
<NodeFilter :options="nodeFilterOptions" :enabled="true" />
<NodeRule :attributes="nodeAttributes" />
</Ogma>
</template>
<script setup lang="ts">
import { ref } from "vue";
import axios from "axios";
import {
Ogma,
NodeFilter,
NodeRule,
OgmaProps,
NodeFilterProps,
NodeRuleProps,
} from "@linkurious/ogma-vue";
const graph = ref<OgmaProps["graph"]>({
nodes: [],
edges: [],
});
const nodeAttributes = ref<NodeRuleProps["attributes"]>({
color: "#33dd66",
});
const nodeFilterOptions = ref<NodeFilterProps["options"]>({
nodeFilter: (node) => node.data("type") === "person",
});
onMounted(() => {
axios.fetch("/some/api").then(({ data }) => {
graph.value = data;
});
});
function onAddNodes(nodes: NodeList) {
console.log("new nodes: ", nodes.getId());
}
</script>