* This helper method convert value in data. * @param {string|number|Date} value * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'. * If "dimInfo.ordinalParseAndSave", ordinal value can be parsed.
(value, dimInfo)
| 23333 | * If "dimInfo.ordinalParseAndSave", ordinal value can be parsed. |
| 23334 | */ |
| 23335 | function converDataValue(value, dimInfo) { |
| 23336 | // Performance sensitive. |
| 23337 | var dimType = dimInfo && dimInfo.type; |
| 23338 | if (dimType === 'ordinal') { |
| 23339 | // If given value is a category string |
| 23340 | var ordinalMeta = dimInfo && dimInfo.ordinalMeta; |
| 23341 | return ordinalMeta |
| 23342 | ? ordinalMeta.parseAndCollect(value) |
| 23343 | : value; |
| 23344 | } |
| 23345 | |
| 23346 | if (dimType === 'time' |
| 23347 | // spead up when using timestamp |
| 23348 | && typeof value !== 'number' |
| 23349 | && value != null |
| 23350 | && value !== '-' |
| 23351 | ) { |
| 23352 | value = +parseDate(value); |
| 23353 | } |
| 23354 | |
| 23355 | // dimType defaults 'number'. |
| 23356 | // If dimType is not ordinal and value is null or undefined or NaN or '-', |
| 23357 | // parse to NaN. |
| 23358 | return (value == null || value === '') |
| 23359 | ? NaN |
| 23360 | // If string (like '-'), using '+' parse to NaN |
| 23361 | // If object, also parse to NaN |
| 23362 | : +value; |
| 23363 | } |
| 23364 | |
| 23365 | // ??? FIXME can these logic be more neat: getRawValue, getRawDataItem, |
| 23366 | // Consider persistent. |
no test coverage detected