GithubHelp home page GithubHelp logo

d3-context-menu's People

Contributors

adrianbota avatar antony avatar danielepala avatar frazer avatar iartem avatar jadurda avatar jovannic avatar kimxogus avatar matsuby avatar ngg avatar patorjk avatar thdc-abota 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  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  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

d3-context-menu's Issues

Warning when integrating with React

WARNING in ./src/app/components/chart.js
803:49-63 "export 'contextMenu' (imported as 'd3') was not found in 'd3'

Here i used d3 whole package and also d3-context-menu package

Nested context menu options?

Is it possible to nest menu items? Say I want two top level options Select and Deselect. Clicking on each would reveal a submenu with attributes to select or deselect by. Is this supported and if so could an example be provided? Cant seem to get this use case to work.

Vuejs

How use with ES6 and VueJS ?

Importing
import * as d3 from 'd3'
import contextMenu from 'd3-context-menu'

Init
let d3ContextMenu = contextMenu(d3)

Config
.on('contextmenu', d3ContextMenu([ { title: 'Item #1', action: (elm, d, i) => { console.log('Item #1 clicked!') console.log('The data for this circle is: ' + d) } }, { title: 'Item #2', action: (elm, d, i) => { console.log('You have clicked the second item!') console.log('The data for this circle is: ' + d) } } ]))

My graph work, but nothing on click, just the real right click of the browser...

Incompatibility with d3 v4

Using the following code for bootstrapping the contextMenu, with d3 v4, webpack v4, and babel v7:

import * as d3 from 'd3';
import contextMenu from 'd3-context-menu';
d3.contextMenu = contextMenu(d3);

I'm receiving the following error:

Uncaught TypeError: Cannot read property 'pageX' of null
    at Object.contextMenu (d3-context-menu.js:170)

Peeking into the code:

				// display context menu
				d3.select('.d3-context-menu')
					.style('left', (position ? position.left : d3.event.pageX - 2) + 'px')
					.style('top', (position ? position.top : d3.event.pageY - 2) + 'px')
					.style('display', 'block');

In v4, d3.event is null until an actual event is defined, thus the error. I'm expecting a simple guard to check to ensure d3.event will suffice to get things working with v4.

Thanks in advance!

Context menu close on mousedown outside of menu doesn't work

I saw the 1.0.1 release note has this Context menu now closes on mousedown outside of the menu, instead of click outside (to mimic behaviour of the native context menu). It doesn't work for me. I also made sure the simulation was stopped thinking something might be capturing my click. What could be happening?

When I left click outside nothing happens, when I right click outside it opens the google chrome menu and the context menu dissapears but I'd like to have this working on a left click outside,

Feature: Be able to attach menu to 'SVG'.

I would like to be able to attach the menu to the SVG, so that I could right click on the blank areas of the d3 SVG versus an element on the SVG.

Is this already doable and I can't find the example?

bower install doesn't work

Hi,

when I make a bower install I have the following error:
bower d3-context-menu#0.1.1 ENORESTARGET No version found that was able to satisfy 0.1.1

Same with:
bower install d3-context-menu

Maybe it's a version problem because bower.json contains 0.1.1 and npm contains 0.1.2.

Support headers and dividers

One thing that would be nice is support for headers and dividers, similar to bootstrap: http://getbootstrap.com/components/#dropdowns-divider

I'm not sure how to approach this, or if it even makes sense passing decorative html elements via the json menu. Maybe something like support for multiple "types": action, header, and divider.

For now, I think my only solution is to programmatically inject a list-item and define a custom class for it.

Any thoughts? Thanks.

How to use d3-context-menu in d3v4 and angular2

Hi,
I am trying the steps you posted in github.
But, it's not working in d3v4 and angular2 (typescript).
When, I right click, the menu details append to bottom of the page?
Can you help me out these?
Thanks...

D3v5 compatibility

I am trying to use d3v5 dagre-d3 and d3-context-menu .

"d3": "^5.16.0",
"d3-context-menu": "^1.1.2",
"dagre-d3": "^0.6.4",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"

d3-context-menu.dew.js:122 Uncaught TypeError: d3.selectAll is not a function
at SVGGElement. (VM990 d3-context-menu.dew.js:122)
at SVGGElement. (VM1310 d3-selection.dew.js:722)
(anonymous) @ d3-context-menu.dew.js:122
(anonymous) @ d3-selection.dew.js:722

Here is the plunker to reproduce the problem.

https://plnkr.co/edit/t4CKN9IaBvO35uKd

Please let me know if you require other info.

Cannot read property 'pageX' of null

hi
using d3 v5 and reactjs and d3-context-menu
I'm receiving the following error:

TypeError: Cannot read property 'pageX' of null

import * as d3 from "d3";
import contextMenuFactory from "d3-context-menu";
 let contextMenu = contextMenuFactory(d3);
      var menu = [
        {
          title: "Item #1",
          action: function(d, i) {
            console.log("Item #1 clicked!");
            console.log("The data for this circle is: " + d);
          },
          disabled: false // optional, defaults to false
        },
        {
          title: "Item #2",
          action: function(d, i) {
            console.log("You have clicked the second item!");
            console.log("The data for this circle is: " + d);
          }
        }
      ];
      svgContextMenu.selectAll("g").on("contextmenu", contextMenu(menu));


Accessing event information with D3 6.x

In D3 6.x the global d3.event has been removed, so in order to access event information from the context menu callbacks I think it would be useful to add the event as a second input parameter, in addition to the datum d.
Is this something you are willing to add?

Injecting html in the item titles ?

Is it possible to have more control in the title of a menu item, to inject html ? For example, I would like to add svg shapes to each of the items before their title.

Thanks

Using Angular directives

Hello Pat,

According to you, what we would be the best way to use the context-menu into an Angular app ?
For instance I'd like to use Angular directives as titles.

Regards

An example from readme does not work

http://plnkr.co/edit/hAx36JQhb0RsvVn7TomS?p=info

Ubuntu Mozilla Firefox 78.0.2

Cookie “plnkr.access_token” will be soon rejected because it has the “sameSite” attribute set to “none” or an invalid value, without the “secure” attribute. To know more about the “sameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite hAx36JQhb0RsvVn7TomS

This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. hAx36JQhb0RsvVn7TomS

The resource at “https://www.google-analytics.com/analytics.js” was blocked because content blocking is enabled.
hAx36JQhb0RsvVn7TomS

Uncaught (in promise) Error: No available storage method found.
    n https://cdn.plnkr.co/build/v1.0.0-243-g51e3baf/0437413f03c257522678.js:38

When my svg is zoomable, and they pan outside of the original rectangle, the context menu no longer appears.

When my svg is zoomable, and you pan your shapes outside of the original rectangle, the context menu no longer appears.

I modified the demo plnkr to make the svg zoom and pan.

http://plnkr.co/edit/bT8QqG1J4glEtrTJRCax?p=preview

When you start, the menu is available by right clicking the circles. If you pan the diagram, the menu is no longer available. If you pan to locate the shapes back to their original location they are clickable. Drag the shapes up and the context menu is lost from the top circle, but not the bottom.

The menu seems to be available only within the boundaries where the group should be if not transformed.

I am guessing that the contextmenu in the example is placed on the group (g), not on the svg, and that I should have some sort of hidden background element.

Has anyone got advice for sorting this out?

Thanks

Kevin

In fullscreen mode, context menu won't show up in certain browsers

If context menu element is not contained within the DOM element used for full screen mode, certain browsers (such as Firefox) just won't show it. Perhaps, d3-context-menu could be enhanced to allow the specification of a selector (as an option) so that the context menu be inserted in that container instead.

Prevent menu removing after clicking ?

Hello,

Is it possible to call some function to prevent the menu disappearing after clicking on it ? I would like to add checkboxes to the menu but right now the menu window is closing after any click.

Thanks

div gets appended outside body tag instead of in it

I am trying to implement a list on right click of a data node. d3-context-menu plugin is perfect for my requirements. But when I tried to use it in my code, the library is not working. When i right click on the data node, it won't give me a menu and instead an extra scroll bar gets added to the page. When I tried to debug the behavior I noticed that the div element with class "d3-context-menu" is outside the body tag. I feel that could be the reason of list not appearing. The plugin is working on the background and is not visible.

I followed this example : [http://plnkr.co/edit/hAx36JQhb0RsvVn7TomS?p=preview]
My code looks like this:

eventGroup = focusClip.selectAll(".event").data(data);
eventGroupEnter = eventGroup.enter().append("svg");
// Event Group
            eventGroup
                .attr("class", "event")
                .attr("x", function (d) { return parseInt(x(d.time)) - 10; }) // offset for the bg and center of dot
                .attr("y", function (d) { return parseInt(y(d.plotY)); })
                .attr("width", function (d) { return parseInt((d.label.length / 2)) + 60 + "em";})
                .attr("height", "20");

            // Background
            eventGroup.select("rect")
                .attr("x", 0) // removes the "<rect> attribute x: Expected length, 'NaN'" Error
                .attr("y", 4)
                .attr("width", "100%")
                .attr("height", "12")
                .attr("fill", "url(#event-bg)");

            menu = [{
                title: "Item #1"
            }];
            // Dot
            eventGroup.select("circle")
                .attr("class", "dot")
                .attr("r", 4)
                .attr("cx", 10)
                .attr("cy", 10)
                .attr("fill", function(d) { return d.evtColor ? d.evtColor : "#229ae5"; })
                .attr("stroke", function(d) { return d.evtColor ? d.evtColor : "#229ae5"; })
                .attr("stroke-width", 2)
                .on("contextmenu", d3.contextMenu(menu, function() {
                    console.log("Quick! Before the menu appears!");
                }))
                .on("mouseenter", tooltip.mouseover)
                .on("mouseleave", tooltip.mouseout)
                .on("click", annotateBox.click);

I am trying to get the list on the dot element. So when i right click on the dot, the menu should appear. Currently, when I right click on the dot, an extra scroll bar appears and even the console message is displayed but the list is not visible.

ReferenceError: d3 is not defined

Using d3.v3.min.js

Get error when include your js file. (See Firebug snapshot for details)

ReferenceError: d3 is not defined
d3.contextMenu = function (menu, openCallback) {

error
It is quite a strange error because d3 does exist, though contextMenu is undefined for d3. I fixed it by simply changing d3.contextMenu = function (menu, openCallback) {...} to var contextMenu = function (menu, openCallback) {..} and then accordingly calling .on('contextmenu', contextMenu(menu)); on my node.enter().

ES6 support

Is there a way to import d3-context-menu using es6 import statements?

How to add an image to the context-menu?

Hello guys,

I want to add an image to some titles of the context-menu, but I dont know how
Can anyone help me?

I tried something like this:

var menu = [
{title: 'MyItem',
icon: 'C:...\Desktop\Pics\f.png',
action: function (elm, d, i) {...}
},

I hope you can help me.

Best regards!

How to dynamically make a context menu item "Disabled"?

I tried passing following kind of function for disabled:

var menu = [
                {
                    title: 'Open',
                    action: function(elm, d, i) {
                        console.log('You have clicked OPEN item!');
                        console.log('The data for this node is: ' + d.id);
                    },
                    disabled: function(d) {
                        console.log(d);
                        console.log('> '+(d.id == 0));
                        return (d.id == 0);
                    }
                }
            ];

But it is always disabling the item, I only want to disable menu item for Root Node of the array. How can this be implemented, if anyone has ideas?

Dynamic menu for each Item callback based

I'm looking for a way to populate a dynamic context menu in a callback ajax call.
I mean i found a method to create dynamic numbers of row(li) but it works on modyfing directly the DOM element and i don't think is a good practice especially because i have to add an hanlder function click for every element of menu.
So i don't understand reading all requests and issues if the object menu in
.on('contextmenu',d3.contextMenu(menu,...must only be instantiated before contextMenu function called.

Add support for close callback

It would be useful to have an optional closeCallback so I can reclass nodes that are no longer selected. The closeCallback would be called when the menu is dismissed or when an action is clicked.

multiple menu items

I'm having trouble getting this to work with more than one menu item. With multiple items the default right-click menu appears.

(I'm running it on a Macbook Pro, Yosemite, and Chrome.)

Any thoughts?

Thanks.

Getting error when trying to use latest version 1.1.0

When i am trying to use the latest version , i am receiving an error
SyntaxError: Expected token ')'
06:08:52 at /app/bower_components/d3-context-menu/js/d3-context-menu.js:149

I want to use the previous version 1.0.2. I want to keep my version fixed to 1.0.2. But since no tag is there i am not able to do so. Can you please release a tag for 1.0.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.