IBChart에서는 다양한 비즈니스 로직 구성을 위한 이벤트를 제공합니다.
이벤트 추가는setEventListener와setEvents,setOptionsmethod를 통해 추가할 수 있습니다.
| name | type | required | description |
|---|---|---|---|
event |
object |
선택 | 이벤트 인자 객체 |
type |
function |
선택 | 이벤트 타입 |
//예시1
myChart.setEvents({
addSeries: function(event) {
console.log("addSeries");
}
});
//예시2
myChart.setEventListener("addSeries", function(event){
console.log("addSeries");
});
//예시3
myChart.setOptions({
events : {
addSeries: function(event) {
console.log("addSeries");
}
}
})
이벤트 핸들러에서 return false를 반환하거나 event.preventDefault()를 호출하면, 그 이벤트의 기본 동작(축 범위 변경, 범례 클릭 시 숨김 등)이 취소됩니다.
취소할 수 있는 이벤트는 각 이벤트 페이지에 표시되어 있습니다. (return false와 아래 예제의 xAxisSetExtremes 이벤트는 7.3.1.32부터 지원)
// x축 범위가 0보다 작아지지 않도록 확대/이동 취소
myChart.setEventListener("xAxisSetExtremes", function(event) {
if (event.min < 0) {
return false;
}
});
| version | desc |
|---|---|
| 7.3.0.0 | |
| 7.3.1.32 | return false로 기본 동작 취소 지원 |