F2 provides an interaction mechanism to achieve the encapsulation and reuse of common interaction behavior. Based on this mechanism, we provide the following four common interactions:
For developers, they can encapsulate their own interaction behavior based on this mechanism. For details, see the Custom Interaction Behavior(todo).
Usage
For better package size, interaction mode is not packaged by default into @antv/f2. So we should require it.
// import F2constF2=require('@antv/f2/lib/index');// import all interations we providerequire('@antv/f2/lib/interaction/');// If you just want to use one// import pie chart selection interactionrequire('@antv/f2/lib/interaction/pie-select');// import bar chart selection interactionrequire('@antv/f2/lib/interaction/interval-select');// import pan interactionrequire('@antv/f2/lib/interaction/pan');// import pinch interactionrequire('@antv/f2/lib/interaction/pinch');
The touch gestures for interactions all base on Hammer.js.
call interaction
chart.interaction('name', config);
clear interaction
chart.clearInteraction() // clear all interactions for current chart instancechart.clearInteraction('name') // clear the interaction whose name is 'name'