|
|
@@ -7,8 +7,6 @@ import { getColor, isValidColor } from '../utils/colors'; |
|
|
|
import { runSMILAnimation } from '../utils/animation'; |
|
|
|
import { downloadFile, prepareForExport } from '../utils/export'; |
|
|
|
|
|
|
|
let BOUND_DRAW_FN; |
|
|
|
|
|
|
|
export default class BaseChart { |
|
|
|
constructor(parent, options) { |
|
|
|
|
|
|
@@ -90,18 +88,14 @@ export default class BaseChart { |
|
|
|
this.height = height - getExtraHeight(this.measures); |
|
|
|
|
|
|
|
// Bind window events |
|
|
|
BOUND_DRAW_FN = this.boundDrawFn.bind(this); |
|
|
|
window.addEventListener('resize', BOUND_DRAW_FN); |
|
|
|
window.addEventListener('orientationchange', this.boundDrawFn.bind(this)); |
|
|
|
} |
|
|
|
|
|
|
|
boundDrawFn() { |
|
|
|
this.draw(true); |
|
|
|
this.boundDrawFn = () => this.draw(true); |
|
|
|
window.addEventListener('resize', this.boundDrawFn); |
|
|
|
window.addEventListener('orientationchange', this.boundDrawFn); |
|
|
|
} |
|
|
|
|
|
|
|
unbindWindowEvents() { |
|
|
|
window.removeEventListener('resize', BOUND_DRAW_FN); |
|
|
|
window.removeEventListener('orientationchange', this.boundDrawFn.bind(this)); |
|
|
|
destroy() { |
|
|
|
window.removeEventListener('resize', this.boundDrawFn); |
|
|
|
window.removeEventListener('orientationchange', this.boundDrawFn); |
|
|
|
} |
|
|
|
|
|
|
|
// Has to be called manually |
|
|
|