AntV
Search…
Interaction
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:
Interaction
Demo
Selection for pie chart
Selection for bar chart
Pan
Pinch
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 F2
const F2 = require('@antv/f2/lib/index');
// import all interations we provide
require('@antv/f2/lib/interaction/');
// If you just want to use one
// import pie chart selection interaction
require('@antv/f2/lib/interaction/pie-select');
// import bar chart selection interaction
require('@antv/f2/lib/interaction/interval-select');
// import pan interaction
require('@antv/f2/lib/interaction/pan');
// import pinch interaction
require('@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 instance
chart.clearInteraction('name') // clear the interaction whose name is 'name'
Copy link