-
Notifications
You must be signed in to change notification settings - Fork 42
Interaction
Wiki ▸ API Reference ▸ Interaction
Polychart.js uses an event-based model for interaction, coupled with a flexible way of animating an existing chart to a new state.
Add an event handler to respond to one or more events. The handler functions are called whenever an event occurs -- i.e. when User interacts with the chart. The parameter fn
should either be a function, or an object with a method handle
that serves as the event handler.
An event handler is called when an event of any type occurs, and it is up to the event handler itself to determine the correct behaviour during each event. This is for several reasons:
- Interesting handlers tend to respond to multiple events
- Interesting handlers tend to be stateful
The handler functions are called with the following four parameters.
Type | String |
The type of event that occured, a string, one of the events types listed below
-
mover
- User moused over on a geometric object on the graph. -
mout
- User moused out of a geometric object on the graph. -
click
- User clicked on a geometric object on the graph. -
guide-click
- User clicked on a legend element. -
select
- User dragged and selected a range of data points on the graph. -
reset
- User clicked on an empty point in the graph panel. -
data
- A Polychart.js data used by one of the layers of the graph was updated.
The Raphael object with which the user interacted with, or on which the event occured. One can interact with this object programmatically, or obtain a representation of the subset of data portrayed by this object through the attribute obj.evtData
. This object uses filtering notation to describe a the subset of the data represented by the Raphael object. It can be used to change filtering or other specification on the current or other charts.
The JavaScript event that was triggered.
The chart object where the event was triggered. A specification of the chartis at chart.spec
. This specification may be formatted slightly different from the original specification that was passed to the graph.
There are several built-in interaction handlers, some of which are automatically attached to charts.
Attaches tooltip to charts. Tooltip text can be changed using the aesthetic tooltip
.
Allow users to select an area on the chart to zoom, and click the chart background to reset.
Parameters:
-
init_spec
: the initial specification of the chart -
zoomOptions
: an associate array with two attributes,x
, andy
, both of which have boolean values. IfzoomOptions.x
is set to true, then zooming is enabled for the x-axis. This is similar forzoomOptions.y
. By default both are set to true.
TODO: WRITE DOCUMENTATION