event
Previous
classicDark
Next
Area
Loading...
Ant Design Charts exposes some events to get the chart life cycle and interaction information. Ant Design Charts exports a ChartEvent
type, used to define the type of event.
null;
If you want to get the life cycle information of the chart, you can do the following:
chart.on(ChartEvent.AFTER_RENDER, (ev) => {console.log(ev);});
Ant Design Charts currently provides the following lifecycle events:
Event name | Explanation |
---|---|
ChartEvent. BEFORE_RENDER | Before rendering |
ChartEvent. BEFORE_PAINT | Before drawing |
ChartEvent. AFTER_PAINT | After drawing |
ChartEvent. AFTER_RENDER | After rendering |
ChartEvent. BEFORE_CHANGE_DATA | Before changing data |
ChartEvent. AFTER_CHANGE_DATA | After changing data |
ChartEvent. BEFORE_CLEAR | Before cleaning the canvas |
ChartEvent. AFTER_CLEAR | After cleaning the canvas |
ChartEvent. BEFORE_DESTROY | Before destroying the canvas |
ChartEvent. AFTER_DESTROY | After destroying the canvas |
ChartEvent. BEFORE_CHANGE_SIZE | Before changing canvas size |
ChartEvent. AFTER_CHANGE_SIZE | After changing canvas size |
If you want to get the interactive information of the chart, you can do the following:
element
eventchart.on(`element:${ChartEvent.EventType}`, (ev) => {console.log(ev);});
element
eventchart.on(`${markType}:${ChartEvent.EventType}`, (ev) => {console.log(ev);});chart.on(`interval:${ChartEvent.CLICK}`, (ev) => {console.log(ev);});
chart.on('plot:click', (event) => console.log(event));
chart.on('component:click', (event) => console.log(event));
chart.on('label:click', (event) => console.log(event));
Event name | Explanation | Callback parameters |
---|---|---|
ChartEvent. CLICK | Click | Event |
ChartEvent. DBLCLICK | Double click | Event |
Event name | Explanation | Callback parameters |
---|---|---|
ChartEvent. POINTER_TAP | Event | |
ChartEvent. POINTER_DOWN | When the pointer is pressed | Event |
ChartEvent. POINTER_UP | When the pointer is released | Event |
ChartEvent. POINTER_OVER | When the pointer enters the target element | Event |
ChartEvent. POINTER_OUT | When the pointer leaves the target element | Event |
ChartEvent. POINTER_MOVE | When the pointer changes coordinates | Event |
ChartEvent. POINTER_ENTER | When the pointer enters the target element or its child elements | Event |
ChartEvent. POINTER_LEAVE | When the pointer leaves the target element or its child elements | Event |
ChartEvent. POINTER_UPOUTSIDE | Event |
If you want to listen to drag events, you need to set the draggable and droppable properties.
{"style": {"droppable": true,"draggable": true}}
Event name | Explanation | Callback parameters |
---|---|---|
ChartEvent. DRAG_START | When starting to drag | Event |
ChartEvent. DRAG | During dragging | Event |
ChartEvent. DRAG_END | When dragging is complete | Event |
ChartEvent. DRAG_ENTER | When the element is dragged into the target element | Event |
ChartEvent. DRAG_LEAVE | When the element is dragged away from the target element | Event |
ChartEvent. DRAG_OVER | When the element is dragged and hovered within the target element | Event |
ChartEvent. DROP | When the element is placed inside the target element | Event |