Styles

style() as setter

returns itself

With the style() method the style attribute can be managed like attributes with attr:

rect.style('cursor', 'pointer')

Multiple styles can be set at once using an object:

rect.style({ cursor: 'pointer', fill: '#f03' })

Or a css string:

rect.style('cursor:pointer;fill:#f03;')

Explicitly deleting individual style definitions works the same as with the attr() method:

rect.style('cursor', null)

style() as getter

returns value (string, number, ...)

Similar to attr() the style() method can also act as a getter:

rect.style('cursor')
// => pointer

Or even a full getter:

rect.style()
// => 'cursor:pointer;fill:#f03;'

hide()

returns itself

Hide element:

rect.hide()

show()

returns itself

Show (unhide) element:

rect.show()

visible()

returns boolean

To check if the element is visible:

rect.visible()
Fork me on GitHub