1.1.2 • Published 2 years ago

@livereader/graphly-d3-vue v1.1.2

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 years ago

Graphly D3 Vue

This is a Vue component library implementing a wrapper component around Graphly D3 for an easy way to utilize it in a Vue application.

How to use

  1. install the component library with npm install graphly-d3-vue in your Vue project.
npm install @livereader/graphly-d3-vue
  1. import the GraphlyD3 component and style from the library.
import { GraphlyD3 } from "@livereader/graphly-d3-vue";
import "@livereader/graphly-d3-vue/style.css";
  1. embed the component in your Vue file with the <GraphlyD3 /> tag.
<GraphlyD3 ref="graphly" />
  1. access the ref to the Graphly D3 ForceSimulation instance and use it to control the simulation.
<template>
  <GraphlyD3 ref="graphly" />
</template>

<script setup>
	import { ref, onMounted } from "vue";
	import { GraphlyD3 } from "@livereader/graphly-d3-vue";
	import "@livereader/graphly-d3-vue/style.css";

	const graphly = ref(null);

	onMounted(() => {
		const simulation = graphly.value.simulation;
		simulation.render({
			nodes: [],
			links: [],
		})
	});
</script>

To learn more about the simulation reference, take a look at the Graphly D3 documentation and learn which methods and properties are available.

GraphlyD3 Props

The GraphlyD3 Vue component accepts the following properties:

PropertyTypeDescriptionReference
darkBooleanwhether to use the dark themeDocs
remoteOriginStringthe remote origin from where to fetch templatesDocs
selectedNodesArray<sring>the selected nodesDocs
envGravityNumberthe gravity of the environmentDocs
linkDistanceNumberthe minimum distance of linksDocs
animationDurationNumberthe duration of animationsDocs
draggableNodesBooleanwhether nodes can be draggedDocs
zoomEnabledBooleanwhether the zoom is enabledDocs
zoomScaleExtentArray<nmber>the zoom scale extentDocs

Example:

<GraphlyD3 ref="graphly" :dark="true" />

GraphlyD3 Emits

The GraphlyD3 Vue component also emits all Event API events.

EmitDescriptionReference
nodeClickuser click on node shapeDocs
nodeDoubleClickuser double click on node shapeDocs
nodeContextMenuuser right click on node shapeDocs
nodeDragStartuser started dragging a node shapeDocs
nodeDragMoveuser dragging a node shapeDocs
nodeDragEnduser released dragging a node shapeDocs
linkClickuser click on link shapeDocs
linkDoubleClickuser double click on link shapeDocs
linkContextMenuuser right click on link shapeDocs
linkDragStartuser started dragging a link shapeDocs
linkDragMoveuser dragging a link shapeDocs
linkDragEnduser released dragging a link shapeDocs
environmentClickuser click on svg backgroundDocs
environmentDoubleClickuser double click on svg backgroundDocs
environmentContextMenuuser right click on svg backgroundDocs
environmentMovesvg world moved by user or moveTo methodDocs
simulationTicksimulation ticked one simulation stepDocs
simulationTickEndsimulation finished ticking simulation stepsDocs

Example

<GraphlyD3 ref="graphly" @node-click="(e, d) => console.log(d.id)" />

Community

You are very welcome to join our Discord Server and ask questions or discuss ideas on how to use Graphly D3 in your projects.