* Chart.js can take a string id of a canvas element, a 2d context, or a canvas element itself. * Attempt to unwrap the item passed into the chart constructor so that it is a canvas element (if possible).
(item)
| 49 | * Attempt to unwrap the item passed into the chart constructor so that it is a canvas element (if possible). |
| 50 | */ |
| 51 | function getCanvas(item) { |
| 52 | if (_isDomSupported() && typeof item === 'string') { |
| 53 | item = document.getElementById(item); |
| 54 | } else if (item && item.length) { |
| 55 | // Support for array based queries (such as jQuery) |
| 56 | item = item[0]; |
| 57 | } |
| 58 | |
| 59 | if (item && item.canvas) { |
| 60 | // Support for any object associated to a canvas (including a context2d) |
| 61 | item = item.canvas; |
| 62 | } |
| 63 | return item; |
| 64 | } |
| 65 | |
| 66 | const instances = {}; |
| 67 | const getChart = (key) => { |
no test coverage detected