Vue.js Graph Component
How to integrate custom graph visualization into your Vue.js-based web application. Effortlessly.
The open-source web application framework Vue.js is a popular choice among web developers. There exist many accompanying component libraries that facilitate the build of a modern web application. Its component-based approach allows creating use case specific components easily. For example, wrapping yFiles for HTML in a Vue.js component, yields a graph visualization component with an easy to use interface, customizable visualization, and sophisticated layouts.
yFiles for HTML is a commercial programming library explicitly designed for graph, network, and diagram visualization. Note that the word "graph" refers to the mathematical graph with nodes and edges, rather than a function graph or bar charts, here. yFiles' built-in user input handling makes the graph visualization accessible with keyboard, mouse, or touch gestures. The graph visualization can be tailored to any domain with flexible style options. And its sophisticated layout algorithms easily create readable, pleasing, and informative graph visualizations.
Data Binding For Elements
Vue.js components typically use data binding to visualize business data that is associated with an element. The framework provides specific directives to bind data in templates easily.
These templates can be used to create dynamic, arbitrary element visualization. For example, rendering node elements that are zoom-dependent to show the different detailed data:
yFiles for HTML comes with a ready-to-use element visualization that uses Vue.js template expressions for data binding and conditional rendering, making it easy to create e.g. zoom-dependent visualizations for arbitrary data:
<template v-if="zoom >= 0.7">
...
</template>
<template v-else>
...
</template>
Graph Creation
In a component-based web application, data is usually passed to the component to create the graph. Although yFiles for HTML can be directly attached to an asynchronous data provider, it is also possible to provide data objects (e.g., JSON) from which a graph will be generated.
This allows defining an interface for the component that binds to the graph data. Thus, all features of the yFiles graph visualization library can be utilized on the data to create a perfectly tailored user experience.
Automatic Graph Layout
Often, connected data does not contain positional information and relies on the user or the application to arrange the elements in a meaningful way.
yFiles’ sophisticated layout algorithms provide arrangements for many different use cases out of the box, each of which can be configured to match specific requirements.
Sample Application and Source Code
Blueprint repo
You can find the blueprint for a complete, working sample application in this GitHub repository:
Demo apps
yFiles for HTML comes with Vue sample applications out-of-the box that show how to integrate yFiles for HTML in a Vue project by simply adding yFiles as npm module dependency.
The source code of thes demo application is available on the yWorks GitHub repository and part of the yFiles for HTML package.
AppGenerator for yFiles for HTML
The App Generator allows you to test and play with yFiles for HTML in a low-code environment: Build upon various example projects or start from scratch. Configure your data-sources, select the features you want for your app, preview and share the prototype.
Eventually, let the source code generator scaffold a bundle for you and your development team. The bundle includes a Vue-based diagram component with the features and functionality you configured in the generator.
yFiles for HTML in Your Vue.js Project
Test and experience the yFiles for HTML graph visualization library with a fully functional trial package. The recommended way to use yFiles for HTML in a Vue.js application is shown by the Vue.js source code examples that are part of that package.
-
Download a trial version of yFiles for HTML.
-
Navigate to the source directory of the Vue.js or Vue.js Template Node Style Sample Application, respectively.
-
Inspect the sample applications’ documentation and
-
copy its build configuration and its Vue.js graph components to your project or
-
adjust its source code to match your requirements.
-