Giter VIP home page Giter VIP logo

cytoscape.js-qtip's Introduction

cytoscape-qtip

DOI

Preview

Description

A Cytoscape.js extension that wraps the qTip jQuery library

It is recommended that, where possible, you use cytoscape-popper with tippy.js instead of cytoscape-qtip.

  • The qtip2 library that this extension wraps is no longer maintained by its author.
  • qtip2 does not have proper support for npm+webpack and npm+browserify, whereas cytoscape-popper does -- as do popper.js and tippy.js.
  • cytoscape-popper does not require jquery.
  • qtip2 requires the use of jquery@1 or jquery@2, which are both no longer maintained.

Dependencies

  • jQuery ^3.0 || ^2.0 || ^1.10.0, as qTip requires it
  • qTip ^3.0 || ^2.2.0
  • Cytoscape.js ^2.2.0 || ^3.0.0

Usage instructions

Download the library:

  • via npm: npm install cytoscape-qtip,
  • via bower: bower install cytoscape-qtip, or
  • via direct download in the repository (probably from a tag).

require() the library as appropriate for your project:

CommonJS:

var cytoscape = require('cytoscape');
var cyqtip = require('cytoscape-qtip');

cyqtip( cytoscape ); // register extension

AMD:

require(['cytoscape', 'cytoscape-qtip', 'jquery'], function( cytoscape, cyqtip, jquery ){
  cyqtip( cytoscape, jquery ); // register extension
});

Note that jquery must point to a jQuery object with .qtip() registered if AMD is used.

Plain HTML/JS has the extension registered for you automatically, because no require() is needed.

API

This extension wraps the qTip API so it can be used on Cytoscape.js graph elements instead of HTML DOM elements.

You can call qTip on graph elements:

eles.qtip({ /* options ... */ });

You can call qTip on the core:

cy.qtip({ /* options ... */ });

See the qTip API for details on configuration.

If you want to access the qTip API for an element:

var api = ele.qtip('api');

If you want to access the qTip API for the core:

var api = cy.qtip('api');

See the qTip docs for details on the API. If you create more than one qTip on an element and use its API, you'll have to cache the api references after creating each qTip.

API restrictions

You may not use options.position.target. If you require a different value, like 'body' or 'mouse', you don't need this extenstion -- you can simply use the qTip APIs directly on a DOM element.

API additions

These are additional options you can use for convenience. Remember: This extension is just a wrapper to qTip. If you require more complex behaviour, you should manually use the qTip API.

  • options.position.adjust.cyViewport : When true, updates element qTip position on zoom and pan. Note you'll need your own mechanism to hide out-of-bounds qTips, such as customising the parent container.

  • options.show.cyBgOnly : When true, shows core qTips only for events originated on the core (not bubbled). Useful for "background" events.

  • options.hide.cyBgOnly : When true, hides core qTips only for events originated on the core (not bubbled). Useful for "background" events.

  • options.hide.cyViewport : When true, hides qTips when the viewport is manipulated (i.e. zoom/pan).

Publishing instructions

  1. Set the version number env var: export VERSION=1.2.3
  2. Publish: gulp
  3. Make a release on GitHub to automatically register a new Zenodo DOI

cytoscape.js-qtip's People

Contributors

alexcli avatar maxkfranz avatar nicky1038 avatar nowells avatar quatrano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cytoscape.js-qtip's Issues

Allow jQuery 3.x (there is an XSS vulnerability in previous versions)

As for now cytoscape.js-qtip requires "jQuery ^2.0 || ^1.10.0, as qTip requires it".

But qTip2 requires "jquery": ">=1.6.0", i.e. it allows 3.x versions too.

It should be possible to use jQuery 3.x, and it seems cytoscape.js-qtip won't break form this change too.

Motivation: npm audit shows "Cross-Site Scripting (XSS)" vulnerability for jQuery 2.x.

I'd just specify "jquery": ">=1.6.0" in peerDependencies as in qTip2.

Opening this issue instead of a pull request to make sure if jQuery 3.x was not disallowed intentionally.

Is it possible to new line in qtip content text?

I'd like to including new line character such as '\n' in qtip content text.
e.g.)

cy.on('click', 'edge', function(e){
  var test = 'test'
  this.qtip({
    content: {text: `test\n${test}`}
});

But not work '\n'.
Is it had to finding other way instead of using '\n'?

Qtip unpositioned for `mousover`

The new 2.5.1 version has not been working for me. it simply returns either a warning or an error stating:

Query.Deferred exception: Cannot assign to read only property 'left' of object '#<ClientRect>' 
TypeError: Cannot assign to read only property 'left' of object '#<ClientRect>'

This error was also in Firefox, which issued the error:

jQuery.Deferred exception: setting a property that has only a getter z.reposition

2.4.0 worked well prior to this. Let me know if I can provide any other debugging information.
Thank you for all your work!
Joe

qtip api method reposition not working

I am trying to always show a qtip on a node even if the node is moved.

In the free event, I am using the api of the qtip to show it and reposition it.

The reposition method of the API is not working in this case because the qtip is still shown at its original place.

I used the demo from https://gist.github.com/maxkfranz/546dd8ca4872cc87106a and I have modified the file code.js (I have tried to updload the modified demo as a Zip file however I keep getting the error "We don’t support that file type. Choose Files Try again with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, PDF, or ZIP.") :

$(function(){ // on dom ready

var cy = cytoscape({

container: document.getElementById('cy'),

boxSelectionEnabled: false,
autounselectify: true,

elements: {
nodes: [
{ data: { id: 'n', label: 'Tap me' } }
]
},

layout: {
name: 'grid',
padding: 100
},

ready: function(){
window.cy = this;
},

style: 'node { content: data(label); }'
});

// you can use qtip's regular options
// see http://qtip2.com/
var node = cy.$('#n').qtip({
content: 'Hello!',
position: {
my: 'top center',
at: 'bottom center'
},
style: {
classes: 'qtip-bootstrap',
tip: {
width: 16,
height: 8
}
},
show: {ready: true}
});

cy.on('free', function(evt){
var api = node.qtip('api');
api.reposition();
api.show();
api.reposition();
});

}); // on dom ready

Child node qtips don't get displayed properly

The show event from a child gets propagated up to a parent node, and the parent tries to show its tooltip. The show and hide event handlers need checks that the element is the target of the event.

From adding a parent node to the demo.html and clicking on Jerry:
image

Not show qtip on node on React Project

Hi,
I must show a popover when tne user mouseover on a node on my graph.
I add this line code

cy.nodes().qtip({ content: 'hi', position: { my: 'top center', at: 'bottom center' } })

but the popover is show at the end of the generic html div in which there is the graph drawed and not on single node

Showing multiple qtips on different nodes is broken

After updating to cytoscape 3 and the current cytoscape-qtip i can no longer show multiple qtips at different nodes, all are shown at the same node (the last one called)..
the problem was introduced with commit 7dbcff0
before that it was working correctly

qTip is rendered for all parent elements when a child node is clicked.

Hi,

When a child node is clicked which is inside a compound node, qTip pops up for the parents of this clicked node too. You can try qtip demo of cytoscape-js with the following javascript code to reproduce the issue.

image

Thanks,

$(function(){ // on dom ready

var cy = cytoscape({

  container: document.getElementById('cy'),

  boxSelectionEnabled: false,
  autounselectify: true,

  elements: {
    nodes: [
      { data: { id: 'n', parent: 'k', label: 'Tap me' } },
      { data: { id: 'k', label: 'Tap me' } }

    ]
  },

  layout: {
    name: 'grid',
    padding: 100
  },

  ready: function(){
    window.cy = this;
  },

  style: 'node { content: data(label); }'
});

// you can use qtip's regular options
// see http://qtip2.com/
cy.nodes().qtip({
  content: 'Hello!',
  position: {
    my: 'top center',
    at: 'bottom center'
  },
  style: {
    classes: 'qtip-bootstrap',
    tip: {
      width: 16,
      height: 8
    }
  }
});

}); // on dom ready

reference to $$.element

I would like to show node specific data in qtip. I couldn't figure out how to do this without modifying the code, so I made a little change, by adding a ref to the element object

see this commit

so this way if content is a function, here is how you can access to the element the event triggered on.

$scope.cy.nodes().qtip({
    content: function(d,o){
      return o.options.ele.data().weight;
    },
    show: {
      event: 'mouseover'
    },
    hide:{
      event: 'mouseout'
    },
    position: {
      my: 'top center',
      at: 'bottom center',
      adjust: {
        cyViewport: true
      }
    },
    style: {
      classes: 'qtip-bootstrap',
      tip: {
        width: 16,
        height: 8
      }
    }
  });

Is there other (better) way to do this?

Edge tooltip position not correct

By using the library, the tooltip for nodes is working completely fine but for the edges, they are displayed at the top right corner of the screen. I am using the same code for both nodes and edges. Below is the code that I tried:

cy.edges().qtip({
    content: function () {
        return 'Expression: ' + this.data('value')
    },
    position: {
        my: 'top center',
        at: 'bottom center'
    },
    style: {
        classes: 'qtip-bootstrap',
	tip: {
		width: 16,
		height: 8
	}
    },
    show: {
	event: 'click',
	solo: true,
	effect: function (offset) {
		$(this).slideDown(100); // "this" refers to the tooltip
	}
    }
});

I also tried with target: mouse without using this library but the result were the same:

cy.on('tap', 'edge', function (evt) {
    evt.target.qtip({
        content: function () {
	    return 'Expression: ' + this.data('value')
        },
	position: {
	    target: 'mouse'
	},
	style: {
	    classes: 'qtip-bootstrap',
	    tip: {
	        width: 16,
		height: 8
	    }
	},
	show: {
	    event: 'click',
	    solo: true,
	    effect: function (offset) {
	        $(this).slideDown(100); // "this" refers to the tooltip
	    }
	}
    });
});

Edge tooltip position is not working as expected

I am facing an issue where am getting the correct position of tooptip for Nodes but for edges it is showing the tooltip on top left corner of the screen.
While looking into the jQuery qtip library, jquery.qtip.js, i have found that for egdes the "target" option of "position" is an array of two elements [0,0] due to which tooltip appearing on the top left of the screen whereas for Nodes it's not an array hence correct position of tooptip.
This seems to be the possible reason of this problem.
Another observation is that, in cytoscape-qtip.js library, in updateposition function there is a variable used "isNode", which make this function and position setting for Nodes only and not for any other element.

I have checked the Demo example at the following link:
https://github.com/cytoscape/cytoscape.js-qtip

Using the cytoscape-qtip.js file from there, i can see the tooltip bubble box at correct position for edges.

But, i am getting the tooltip bubble box at [0,0] location i.e top left corner of screen as well. So there are 2 tooltip bubble box appearing at the same time, one at the correct mouse location on edge, other one at the [0,0] location i.e top left corner of screen.

when i comment out the following line in cytoscape-qtip.js, the problem of extra tooltip bubble box at [0,0] location is resolved:
opts.position.target = [0, 0]; // Line no. 201

Could any help, how to proceed on this.

Thanks & Regards.

qtip.$domEle.qtip( opts ) is not a function, again.

I'm using webpack & react and getting an error where qtip.$domEle.qtip( opts ); is not a function. I have seen a similar issue #22 where the solution was to require jquery before registering the crytoscape-qtip extension. However, this did not fix the issue. After further investigation I noticed that you added this #hack to the cytoscape-qtip library already.

I then tried just passing in jQuery directly to cytoscape-qtip and had some success, the register methods became the following:

Webpack:

plugins: [
  new webpack.ProvidePlugin({
    '$': 'jquery',
    'jQuery': 'jquery',
    'window.jQuery': 'jquery',
    'window.$': 'jquery'
  })
],

My App:

import cytoscape from 'cytoscape'
import qtip from 'qtip2'
import cyqtip from 'cytoscape-qtip'
cyqtip(cytoscape, window.jQuery)

renderCytoscape = (graphData) => {
    cy.on('tap', 'node', function(event) {
        event.target.qtip({
            content: 'this is content'
        }, event)
    })
}

cytoscape-qtip:

if( typeof module !== 'undefined' && module.exports ){ // expose as a commonjs module
    module.exports = function( cytoscape, jQuery ){
        register( cytoscape, jQuery );
    };
} else if( typeof define !== 'undefined' && define.amd ){ // expose as an amd/requirejs module
    define('cytoscape-qtip', function(){
        return register;
    });
}

After this the position of the tooltip when I select a node is correct, I can see the hidden div. However, the qtip tooltip will be displayed offscreen or sometimes is not generated at all.

screen shot 2017-05-08 at 4 38 39 pm

Share qtip instance per collection when possible

The most common case for Qtips is only one is shown at a time and all elements in one call have the same behaviour.

If this case can be reliably detected, this would increase performance for large graphs when calling eles.qtip().

removing a qtip bug

Having an issue removing a qtip from cytsoscape nodes. Because the DOM elements are added on demand, qtip crashes when you try to run cy.elements('node').qtip("destroy"); - it says, cannot read property set of undefined. Qtip doesn't let you "overwrite" the qtip - it just renders two qtips on top of each other. Similarly, using the api method,
cy.elements('node').qtip('api').destroy();, although it doesn't cause an error, fails to actually remove the qtips.
Updating qtips according to their documentation cy.elements('node').qtip('option', 'content', 'newcontent'); gives a similar error.

Click on node label doesn't open qTip

Hi & congrats for your plugins.
I'm using to display multiple information related to a node but I've a problem.

the code works fine when I click on the node.
If I click on the node label (content) qTip doesn't appear.

I try to add cy.emit to trigger node tap with no luck
I also try to change the selector of cy.$('#myid').qTip... in cy.$('#myid, #myid:after, #myid:before').qTip... (hoping that 'content' attribute was "that" kind of content but it doesn't work yet.

Is it possible to achieve this task?
How?

Thank you in advance
ronkpunk

qtip does not honor position

Great stuff, thank you.

I notice in the preview image that the qtips can be placed at various locations on the cytoscape elements, e.g. bottom center: Preview

However, when I clone the repo (git rev-parse HEAD = 72be0c8) and render demo.html in Safari and Firefox, the tips appear only in the center of a node.
cytojs

Looking at the demo.html source, it seems to intend that they display at the bottom center as in the preview image above: these lines

Any thoughts?

"content.title" option is ignored

The content.title option is ignored during qtip initialization. eg:

elem.qtip({
  content: {
    title: 'My Title'
  }
});

or

elem.qtip({
  content: {
    title: function (event, api) {
      api.set('content.title', 'My Title');
    }
  }
});

In this block it looks like content.title is neglected, but it should receive the same treatment as content.text. An easy workaround is to call api.set('content.title', 'My Title'); from within my content.text function.

"position.target" can't be overridden

The position.target option is ignored during qtip initialization, and is always set to [0, 0] here. I was interested in using:

elem.qtip({
  position: {
    target: 'mouse'
  }
});

I'm sure this is related to how you've adapted qtip to work with non-HTMLDomElements, so position.target = 'mouse' may not be feasible, but I thought it should be documented.

Show qtip on hover or right click

Is it possible to have qtip be shown on

  1. As context menu , means by right clicking element
  2. Show on hover(mouse-over) instead of left click (so that I can do another action on left click). should be configurable to hide qtip on mouse-out or not so that user can interact with html in qtip

These 2 will be very helpful additions to qTip

show cytoscape.js-qtip on right click

I am creating this issue again because this was closed and no one would reply on issue if it is closed.

qtip2 (right-clicks work )

  1. qtip2 supports showing tootip on right-clicks
  2. see reference here http://qtip2.com/guides#events.rightclick
  3. see working jsfiddle https://jsfiddle.net/bababalcksheep/L56sd6ye/

cytoscape.js-qtip (right-clicks do not work)

  1. right-clicks do not work with cytoscape.js-qtip
  2. Does cytoscape.js support right-click ?
  3. See jsfiddle (cytoscape.js-qtip with right-click) https://jsfiddle.net/bababalcksheep/84s18jyx/
    -- uses options from http://qtip2.com/guides#events.rightclick

qtip.$domEle.qtip is not a function

I am getting qtip.$domEle.qtip is not a function error when I try to show qtip. When I debug through, qtip.$domEle returns div element but qtip (on the right) is undefined.
I cannot understand what went wrong. How could I fix this?

var cytoscape = require('cytoscape');
var jquery = require('jquery');
var cyqtip = require('cytoscape-qtip');

cyqtip(cytoscape, jquery);

.....

cy.on('tap', 'node', function (event) {
  event.cyTarget.qtip({
     content: 'content'
  }, event);
});

Tech stack:
ReactJS
Cytoscape 2.7.10
jquery 2.2.4
qtip2: 2.2.0
cytoscape-qtip 2.5.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.