* Formats data to the internal format used by this chart.
(data: Array<{value: number}>|number[]|
TypedArray)
| 201 | * Formats data to the internal format used by this chart. |
| 202 | */ |
| 203 | function prepareData(data: Array<{value: number}>|number[]| |
| 204 | TypedArray): Array<{value: number}> { |
| 205 | if (data.length == null) { |
| 206 | throw new Error('input data must be an array'); |
| 207 | } |
| 208 | |
| 209 | if (data.length === 0) { |
| 210 | return []; |
| 211 | } else if (typeof data[0] === 'object') { |
| 212 | if ((data[0] as {value: number}).value == null) { |
| 213 | throw new Error('input data must have a value field'); |
| 214 | } else { |
| 215 | return data as Array<{value: number}>; |
| 216 | } |
| 217 | } else { |
| 218 | const ret = Array(data.length); |
| 219 | for (let i = 0; i < data.length; i++) { |
| 220 | ret[i] = {value: data[i]}; |
| 221 | } |
| 222 | return ret; |
| 223 | } |
| 224 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…