Dynamic bullseye displayed on a Vis.js network node

I am currently utilizing Vis.js to create network diagrams. I am interested in adding a notification feature where when an AJAX update is received for a specific node, the canvas will move that node to the center (which Vis.js can already do). Following this, I would like to have a bullseye animation over the node to attract the user's attention until they click on it. An example of the kind of animation effect I am seeking can be found at http://codepen.io/MateiGCopot/pen/ogEKRK.


var w = c.width = 400,
h = c.height = 400,
ctx = c.getContext('2d'),

frame = 0;

function anim(){
  window.requestAnimationFrame(anim);

  ++frame;

  for(var i = 0; i < w; ++i){
    ctx.strokeStyle = i%20 === 0 ? 'hsl(hue, 80%, 50%)'.replace('hue',
        (360 / (w/3) * i - frame) % 360
    ) : 'rgba(0, 0, 0, .08)';
    ctx.beginPath();
    ctx.arc(w/2, h/2, (i + frame)%w/2, 0, Math.PI*2);
    ctx.stroke();
    ctx.closePath();
  }
}
anim();

Would this method be the most effective way to achieve this type of effect? When running it on my machine, there seems to be a spike in CPU usage, indicating that it may not be very efficient.
Additionally, how could I integrate something like this with Vis.js so that it appears over an image node and stops once the node is clicked? The example provided draws circles outward, but I would prefer them to be drawn inwards, although I was unable to determine how to change their direction.

JavaScript is not my strong point, so a detailed explanation would be much appreciated. Also, while I am currently using Vis.js, if there is another library that offers similar functionality (along with comparable features to Vis.js), I am open to switching to it.

Answer №1

As the creator of the visjs network viewer, I want to mention that currently, it is not feasible through the public API. We are actively developing version 4.0 which will provide a feature allowing you to effortlessly embed your custom code in the render loop. If you require this functionality earlier than our estimated release date in April, feel free to create an issue on our GitHub repository, and I can guide you through integrating it into the source code yourself. To streamline support queries, we prefer all discussions to stay on GitHub for better accessibility.

Additionally, as a workaround, you have the option to modify colors or utilize the focus feature to emphasize a node. However, if these options do not meet your requirements, consider placing a div overlay above the node containing a GIF animation with a click event handler. By leveraging the vis API, you can determine the exact position of the targeted node for enhanced interaction.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The underscore module was not loaded by requirejs

Encountering an error - unclear on the exact issue. Occasionally the page/modules load fine, but often I am faced with this error message. This is happening with the most recent versions of underscore and backbone modules. Error: Module name 'under ...

Simulation of loopback session

Currently, I am utilizing loopback in conjunction with express session to store cartId. However, for the purpose of making my tests function properly, it is essential that I inject cartId into the request session. Within my remote method, I have implemen ...

C# MVC - Enabling dynamic row addition in an HTML table with multiple fields consolidated into a single cell

Hello, I'm new to c# MVC and could use some guidance. Currently, I am utilizing an example from Matt Lunn (here) to dynamically add new items to a bound list within an HTML table. However, the issue is that all the new items are being added to the fir ...

I am attempting to send an array from the controller to JavaScript using AJAX, but instead of returning as an array, it is being returned as a string

Here is the code snippet from my controller: <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; class AjaxController extends Controller { public function s ...

Attempting to utilize Ajax to save a file in Laravel, however unsure of what may be causing the issue in my code

Looking for a way to save an image file using ajax in Laravel, here is the code I am currently using: Controller public function store(Request $request) { $item = new Item; // if remove $it_files_path , $it_files_name , $path code work co ...

Issues with HTML structure across various devices

Being a novice in web development, I've been experimenting with creating a modal body. https://i.sstatic.net/Qk5BR.png The code snippet below represents my attempt at structuring the modal body: <div className="row modalRowMargin textStyle" > ...

JavaScript/jQuery - dynamic name selector with animation

I've been working on developing a raffle ticket picking script using JS and jQuery. Initially, my script is functioning well. However, I am now looking to enhance its visual appeal so that it can be operated in assembly. In order to achieve this, I ...

Text affected by mix-blend-mode glitch

Currently, I am experimenting with knockout text using the mix-blend-mode property. An interesting issue arises when I examine the responsiveness of my design by utilizing Developer tools in the browser console - there are faint lines that momentarily appe ...

Utilize AJAX to submit a form in CodeIgniter efficiently

Is there a problem with submitting a form via Ajax? The form is not being submitted as expected and the Ajax function does not seem to be picking up the submit id. It is currently submitting in the usual way, but I need it to work through Ajax. Can anyon ...

Leveraging a service variable in Angular

Is there a way to access data shared in a service within a directive? Let's say we have a directive called resultsDirective, and a service named dataService. How can we retrieve a variable from the service within the directive? angular.module("someMo ...

The callback function fails to remove the JQuery row from the table

I am facing an issue with deleting a dynamically created row from a grid in my project. I use jQuery to send an Ajax request to the server to delete the corresponding data from the database. If the deletion is successful, I want to remove the row from th ...

Implement the setInterval method within the function and include additional arguments as parameters

Is it possible to use setInterval in a function and pass parameters? In this code snippet, I am attempting to utilize the red_orange_on variable to achieve this. I want to know if this is the correct approach or if there is a better way to accomplish this ...

Interactive navigation with jQuery

I am currently utilizing a jQuery menu script that enhances the navigation structure on my website: (function($) { $.fn.blowfish = function() { // concealing the original ul dom tree $(this).hide(); // constructing a container from top-l ...

Applying styled numbering to elements using nth-child selector in

I have a div with multiple p tags inside. My goal is to assign them numbers using CSS. The number of p tags may vary. By using the :nth-child() selector and the ::before pseudo-element, I can achieve something like this: div p:first-child::before { ...

Dynamic population of dropdown not working as expected

Below is the code I am using to populate a Dropdown: $(document).ready(function(){ $('#inDistrict').sSelect(); $("#inDistrict").change(function(){ $.getJSON("filldistricts.php",{id: $(this).val(), ajax: 'true'}, function(j) ...

Understanding how to access POST content in Meteor.js is an important aspect

In my Meteor app, I am trying to retrieve data using POST requests. Here is the code snippet I am using on the server side: __meteor_bootstrap__.app.stack.splice (0, 0, { route: '/input', handle: function(req, res, next) { req.on(' ...

The resource being requested is missing the 'Access-Control-Allow-Origin' header - Issue with Pinterest OAuth implementation

While working on implementing OAuth for Pinterest, I successfully retrieved the access code. However, when attempting to perform a GET /v1/me/ request, I encountered an error in the Chrome console: XMLHttpRequest cannot load . No 'Access-Contro ...

Utilize WebdriverIO to loop through elements and trigger a click event on a link

I am currently using Javascript and webdriverio (v2.1.2) for data extraction on an internal website. The process involves: Authentication Opening the necessary URL once authenticated Searching for an anchor tag with a specific keyword on the new page Cli ...

Using arrow keys and return to effortlessly navigate through text input fields

Currently, I am working on developing a jQuery-based navigation system for switching between multiple input fields. The first part of the code is functioning correctly, allowing users to navigate downwards using either the down arrow or the return key. H ...

The `Ext.create` function yields a constructor rather than an object as

Ext.application({ name: 'example', launch: function() { var panel = Ext.create('Ext.panel.Panel', { id:'myPanel', renderTo: Ext.getBody(), width: 400, ...