removeChart
생성된 IBChart 객체를을 제거합니다.
getId()- 차트 객체의 아이디(전역변수 이름)
사용 예제
IBChart 객체를 생성하고 3초 후에 제거하는 예제
// get global loader instanceimport loader from '@ibsheet/loader'// load ibchart libraryloader.load({name: 'ibchart',baseUrl: '<publicpath>/ibchart',dependentUrls: ['https://code.highcharts.com/highcharts.js']})const REMOVE_TIME = 3000loader// when created chart.once('created-chart', evt => {// evt.target: IBChart 인스턴스const sid = evt.target.getId()console.log(`"${sid}" 차트는 ${REMOVE_TIME}ms 후에 제거됩니다.`)setTimeout(() => {loader.removeChart(sid)}, REMOVE_TIME)})// when removed chart.once('removed-chart', evt => {// evt.data.id: 제거된 차트의 아이디const sid = evt.data.idconsole.log(`"${sid}" 차트가 제거되었습니다.`)})// create chart.createChart({id: 'chart',cont: 'chartWrapper',options: {width: // ...your chart widthheight: // ...your chart height}})// when created chart.then(chart => {console.log(`"${chart.getId()}" 차트가 만들어졌습니다.`)})
이벤트
remove-chart
차트를 제거 할 때 발생
this:IBSheetLoaderevent.target:IBChartInstance
Usage
loader.once('remove-chart', evt => {const chart = evt.targetconsole.log('remove chartId:', chart.getId())})
removed-chart
차트를 성공적으로 제거했을 때 발생
this:IBSheetLoaderevent.target:IBChartStaticevent.data.id: 차트 아이디
Usage
loader.once('removed-chart', evt => {const { data } = evtconsole.log('removed sheetId:', data.id)})
remove-sheet-failed
차트 제거에 실패했을 때 발생
this:IBSheetLoaderevent.target:IBChartStaticevent.error:Error
Usage
loader.once('remove-chart-failed', evt => {const { data, error } = evtconsole.error('[REMOVE_CHART_ERROR]', data.id, error)})