MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / mergeLayoutParam

Function mergeLayoutParam

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

* Consider Case: * When defulat option has {left: 0, width: 100}, and we set {right: 0} * through setOption or media query, using normal zrUtil.merge will cause * {right: 0} does not take effect. * * @example * ComponentModel.extend({ * init: function () { * ... * var in

(targetOption, newOption, opt)

Source from the content-addressed store, hash-verified

19879 * that width (or height) should not be calculated by left and right (or top and bottom).
19880 */
19881function mergeLayoutParam(targetOption, newOption, opt) {
19882 !isObject$1(opt) && (opt = {});
19883
19884 var ignoreSize = opt.ignoreSize;
19885 !isArray(ignoreSize) && (ignoreSize = [ignoreSize, ignoreSize]);
19886
19887 var hResult = merge$$1(HV_NAMES[0], 0);
19888 var vResult = merge$$1(HV_NAMES[1], 1);
19889
19890 copy(HV_NAMES[0], targetOption, hResult);
19891 copy(HV_NAMES[1], targetOption, vResult);
19892
19893 function merge$$1(names, hvIdx) {
19894 var newParams = {};
19895 var newValueCount = 0;
19896 var merged = {};
19897 var mergedValueCount = 0;
19898 var enoughParamNumber = 2;
19899
19900 each$3(names, function (name) {
19901 merged[name] = targetOption[name];
19902 });
19903 each$3(names, function (name) {
19904 // Consider case: newOption.width is null, which is
19905 // set by user for removing width setting.
19906 hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
19907 hasValue(newParams, name) && newValueCount++;
19908 hasValue(merged, name) && mergedValueCount++;
19909 });
19910
19911 if (ignoreSize[hvIdx]) {
19912 // Only one of left/right is premitted to exist.
19913 if (hasValue(newOption, names[1])) {
19914 merged[names[2]] = null;
19915 }
19916 else if (hasValue(newOption, names[2])) {
19917 merged[names[1]] = null;
19918 }
19919 return merged;
19920 }
19921
19922 // Case: newOption: {width: ..., right: ...},
19923 // or targetOption: {right: ...} and newOption: {width: ...},
19924 // There is no conflict when merged only has params count
19925 // little than enoughParamNumber.
19926 if (mergedValueCount === enoughParamNumber || !newValueCount) {
19927 return merged;
19928 }
19929 // Case: newOption: {width: ..., right: ...},
19930 // Than we can make sure user only want those two, and ignore
19931 // all origin params in targetOption.
19932 else if (newValueCount >= enoughParamNumber) {
19933 return newParams;
19934 }
19935 else {
19936 // Chose another param from targetOption by priority.
19937 for (var i = 0; i < names.length; i++) {
19938 var name = names[i];

Callers 2

axisModelCreatorFunction · 0.70

Calls 4

isObject$1Function · 0.70
isArrayFunction · 0.70
merge$$1Function · 0.70
copyFunction · 0.70

Tested by

no test coverage detected