* Init chart instance * @param ds * @param options * @returns {Chart}
(ds: HTMLElement | string, options?: Options)
| 90 | * @returns {Chart} |
| 91 | */ |
| 92 | function init (ds: HTMLElement | string, options?: Options): Nullable<Chart> { |
| 93 | logTag() |
| 94 | let dom: Nullable<HTMLElement> = null |
| 95 | if (isString(ds)) { |
| 96 | dom = document.getElementById(ds) |
| 97 | } else { |
| 98 | dom = ds |
| 99 | } |
| 100 | if (dom === null) { |
| 101 | logError('', '', 'The chart cannot be initialized correctly. Please check the parameters. The chart container cannot be null and child elements need to be added!!!') |
| 102 | return null |
| 103 | } |
| 104 | let chart = charts.get(dom.id) |
| 105 | if (isValid(chart)) { |
| 106 | logWarn('', '', 'The chart has been initialized on the dom!!!') |
| 107 | return chart |
| 108 | } |
| 109 | const id = `k_line_chart_${chartBaseId++}` |
| 110 | chart = new ChartImp(dom, options) |
| 111 | chart.id = id |
| 112 | dom.setAttribute('k-line-chart-id', id) |
| 113 | charts.set(id, chart) |
| 114 | return chart |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Destroy chart instance |
no test coverage detected