0

D3 supports to change the cursor with the help of inline attributes, like:

...

node.style("cursor", "pointer")

...

Lets assume I want a custom cursor. A .PNG or .SVG for example. How can I achieve this? Unfortunately I can´t use CSS for this purpose as the custom cursor depends on JavaScript functions which are not always used.

In CSS it would be possible with:

node{
cursor: url("custom.png"), auto
}
ICoded
  • 319
  • 3
  • 18
  • Here is a similar question: https://stackoverflow.com/questions/45962081/css-cursor-pointer-with-svg-image/45966695 – Michael Rovinsky Mar 26 '21 at 10:07
  • This might be useful as well: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Basic_User_Interface/Using_URL_values_for_the_cursor_property – Michael Rovinsky Mar 26 '21 at 10:09
  • 1
    Hello @MichaelRovinsky thanks for both hints. But as I mentioned my problem isn´t that I can´t use a custom cursor with the help of CSS. I need to know how can I toggle it either in D3 or Javascript. CSS only works for this or that but not for toggle needs. – ICoded Mar 26 '21 at 10:15
  • You can specify 2 classes in CSS and change the element class on toggle – Michael Rovinsky Mar 26 '21 at 11:04

0 Answers0