(params?: {
width?: number,
height?: number,
theme?: Parameters<typeof init>[1],
opts?: Parameters<typeof init>[2]
})
| 31 | |
| 32 | |
| 33 | export function createChart(params?: { |
| 34 | width?: number, |
| 35 | height?: number, |
| 36 | theme?: Parameters<typeof init>[1], |
| 37 | opts?: Parameters<typeof init>[2] |
| 38 | }): EChartsType { |
| 39 | params = params || {}; |
| 40 | const el = document.createElement('div'); |
| 41 | el.style.cssText = [ |
| 42 | 'visibility:hidden', |
| 43 | 'width:' + (params.width || '500') + 'px', |
| 44 | 'height:' + (params.height || '400') + 'px', |
| 45 | 'position:absolute', |
| 46 | 'bottom:0', |
| 47 | 'right:0' |
| 48 | ].join(';'); |
| 49 | Object.defineProperty(el, 'clientWidth', { |
| 50 | get() { |
| 51 | return params.width || 500; |
| 52 | } |
| 53 | }); |
| 54 | Object.defineProperty(el, 'clientHeight', { |
| 55 | get() { |
| 56 | return params.height || 400; |
| 57 | } |
| 58 | }); |
| 59 | const chart = init(el, params.theme, params.opts); |
| 60 | return chart; |
| 61 | }; |
| 62 | |
| 63 | export function removeChart(chart: EChartsType): void { |
| 64 | chart.dispose(); |
no test coverage detected
searching dependent graphs…