MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / parsePercent$1

Function parsePercent$1

libs/echarts/echarts-en.simple.js:18915–18939  ·  view source on GitHub ↗

* Convert a percent string to absolute number. * Returns NaN if percent is not a valid string or number * @memberOf module:echarts/util/number * @param {string|number} percent * @param {number} all * @return {number}

(percent, all)

Source from the content-addressed store, hash-verified

18913 * @return {number}
18914 */
18915function parsePercent$1(percent, all) {
18916 switch (percent) {
18917 case 'center':
18918 case 'middle':
18919 percent = '50%';
18920 break;
18921 case 'left':
18922 case 'top':
18923 percent = '0%';
18924 break;
18925 case 'right':
18926 case 'bottom':
18927 percent = '100%';
18928 break;
18929 }
18930 if (typeof percent === 'string') {
18931 if (_trim(percent).match(/%$/)) {
18932 return parseFloat(percent) / 100 * all;
18933 }
18934
18935 return parseFloat(percent);
18936 }
18937
18938 return percent == null ? NaN : +percent;
18939}
18940
18941/**
18942 * (1) Fix rounding error of float numbers.

Callers 7

getLayoutRectFunction · 0.70
makeColumnLayoutFunction · 0.70
doCalBarWidthAndOffsetFunction · 0.70
getScaleExtentFunction · 0.70
labelLayoutFunction · 0.70
pieLayoutFunction · 0.70

Calls 2

matchMethod · 0.80
_trimFunction · 0.70

Tested by

no test coverage detected