* Make value user readable for tooltip and label. * "User readable": * Try to not print programmer-specific text like NaN, Infinity, null, undefined. * Avoid to display an empty string, which users can not recognize there is * a value and it might look like a bug.
(value, valueType, useUTC)
| 16471 | */ |
| 16472 | |
| 16473 | function makeValueReadable(value, valueType, useUTC) { |
| 16474 | var USER_READABLE_DEFUALT_TIME_PATTERN = '{yyyy}-{MM}-{dd} {hh}:{mm}:{ss}'; |
| 16475 | |
| 16476 | function stringToUserReadable(str) { |
| 16477 | return str && trim(str) ? str : '-'; |
| 16478 | } |
| 16479 | |
| 16480 | function isNumberUserReadable(num) { |
| 16481 | return !!(num != null && !isNaN(num) && isFinite(num)); |
| 16482 | } |
| 16483 | |
| 16484 | var isTypeTime = valueType === 'time'; |
| 16485 | var isValueDate = value instanceof Date; |
| 16486 | |
| 16487 | if (isTypeTime || isValueDate) { |
| 16488 | var date = isTypeTime ? parseDate(value) : value; |
| 16489 | |
| 16490 | if (!isNaN(+date)) { |
| 16491 | return format(date, USER_READABLE_DEFUALT_TIME_PATTERN, useUTC); |
| 16492 | } else if (isValueDate) { |
| 16493 | return '-'; |
| 16494 | } // In other cases, continue to try to display the value in the following code. |
| 16495 | |
| 16496 | } |
| 16497 | |
| 16498 | if (valueType === 'ordinal') { |
| 16499 | return isStringSafe(value) ? stringToUserReadable(value) : isNumber(value) ? isNumberUserReadable(value) ? value + '' : '-' : '-'; |
| 16500 | } // By default. |
| 16501 | |
| 16502 | |
| 16503 | var numericResult = numericToNumber(value); |
| 16504 | return isNumberUserReadable(numericResult) ? addCommas(numericResult) : isStringSafe(value) ? stringToUserReadable(value) : '-'; |
| 16505 | } |
| 16506 | var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; |
| 16507 | |
| 16508 | var wrapVar = function (varName, seriesIdx) { |
no test coverage detected
searching dependent graphs…