* @param {HTMLElement} dom * @param {Object} [theme] * @param {Object} opts * @param {number} [opts.devicePixelRatio] Use window.devicePixelRatio by default * @param {string} [opts.renderer] Can choose 'canvas' or 'svg' to render the chart. * @param {number} [opts.width] Use clientWidth of the
(dom, theme$$1, opts)
| 29165 | * Can be 'auto' (the same as null/undefined) |
| 29166 | */ |
| 29167 | function init(dom, theme$$1, opts) { |
| 29168 | if (__DEV__) { |
| 29169 | // Check version |
| 29170 | if ((version$1.replace('.', '') - 0) < (dependencies.zrender.replace('.', '') - 0)) { |
| 29171 | throw new Error( |
| 29172 | 'zrender/src ' + version$1 |
| 29173 | + ' is too old for ECharts ' + version |
| 29174 | + '. Current version need ZRender ' |
| 29175 | + dependencies.zrender + '+' |
| 29176 | ); |
| 29177 | } |
| 29178 | |
| 29179 | if (!dom) { |
| 29180 | throw new Error('Initialize failed: invalid dom.'); |
| 29181 | } |
| 29182 | } |
| 29183 | |
| 29184 | var existInstance = getInstanceByDom(dom); |
| 29185 | if (existInstance) { |
| 29186 | if (__DEV__) { |
| 29187 | console.warn('There is a chart instance already initialized on the dom.'); |
| 29188 | } |
| 29189 | return existInstance; |
| 29190 | } |
| 29191 | |
| 29192 | if (__DEV__) { |
| 29193 | if (isDom(dom) |
| 29194 | && dom.nodeName.toUpperCase() !== 'CANVAS' |
| 29195 | && ( |
| 29196 | (!dom.clientWidth && (!opts || opts.width == null)) |
| 29197 | || (!dom.clientHeight && (!opts || opts.height == null)) |
| 29198 | ) |
| 29199 | ) { |
| 29200 | console.warn('Can\'t get DOM width or height. Please check ' |
| 29201 | + 'dom.clientWidth and dom.clientHeight. They should not be 0.' |
| 29202 | + 'For example, you may need to call this in the callback ' |
| 29203 | + 'of window.onload.'); |
| 29204 | } |
| 29205 | } |
| 29206 | |
| 29207 | var chart = new ECharts(dom, theme$$1, opts); |
| 29208 | chart.id = 'ec_' + idBase++; |
| 29209 | instances[chart.id] = chart; |
| 29210 | |
| 29211 | setAttribute(dom, DOM_ATTRIBUTE_KEY, chart.id); |
| 29212 | |
| 29213 | enableConnect(chart); |
| 29214 | |
| 29215 | return chart; |
| 29216 | } |
| 29217 | |
| 29218 | /** |
| 29219 | * @return {string|Array.<module:echarts~ECharts>} groupId |
nothing calls this directly
no test coverage detected