ZoomCharts Documentation
Events
Pie Chart provides a set of events for your application to use.
onClick(event)
- function to be called on click.onRightClick(event)
- function to be called on right click or long press.onDoubleClick(event)
- function to be called on double click.onHoverChange(event)
- function to be called when object under pointer has changed.onSelectionChange(event)
- function to be called after user has selected or deselected some data.onSettingsChange(event)
- function to be called after settings has changed using toolbar orupdateSettings
call.onChartUpdate(event)
- function to be called after displayed pie or slices have changed.onPositionChange(event)
- function to be called when objects have been repositioned on screen.
Specifying event handlers
The event handlers can be specified using settings or added dynamically.
Using settings:
new PieChart({ ... events:{ onClick: function(event){...}, onChartUpdate: function(event){...} }, ... });
Dynamically use chart.on(event, handler)
and chart.off(event,handler)
functions. In this case skip the "on" part in event name: onClick
becomes click
.
Default behavior
Click event has default behavior of opening the clicked slice.
To disable it, call event.preventDefault()
from your event handler function.
Event properties
Events have the following properties:
chart
- the chart object.pie
- active pie.offset
- offset of the active pie.count
- number of displayed slices.slice
- hovered, clicked slice.label
- hovered, clicked label.clientX
,clientY
- mouse coordinates - for click events only.ctrlKey
,altKey
,shiftKey
- true or false if the key is pressed.origin
- event origin, one of"init"
, '"api"' or"user"
.selection
- array of selected slices.changes
- settings changes for settingsChange event.clickPie
- clicked pie, may not be active pie if clicked in center.
And the following functions
preventDefault()
- prevent default behavior.