MCPcopy
hub / github.com/tdewolff/minify / prepareLayoutInfo

Function prepareLayoutInfo

_benchmarks/sample_echarts.js:67252–67318  ·  view source on GitHub ↗
(itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset, symbolPosition, valueLineWidth, boundingLength, repeatCutLength, opt, outputSymbolMeta)

Source from the content-addressed store, hash-verified

67250 }
67251
67252 function prepareLayoutInfo(itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset, symbolPosition, valueLineWidth, boundingLength, repeatCutLength, opt, outputSymbolMeta) {
67253 var categoryDim = opt.categoryDim;
67254 var valueDim = opt.valueDim;
67255 var pxSign = outputSymbolMeta.pxSign;
67256 var unitLength = Math.max(symbolSize[valueDim.index] + valueLineWidth, 0);
67257 var pathLen = unitLength; // Note: rotation will not effect the layout of symbols, because user may
67258 // want symbols to rotate on its center, which should not be translated
67259 // when rotating.
67260
67261 if (symbolRepeat) {
67262 var absBoundingLength = Math.abs(boundingLength);
67263 var symbolMargin = retrieve(itemModel.get('symbolMargin'), '15%') + '';
67264 var hasEndGap = false;
67265
67266 if (symbolMargin.lastIndexOf('!') === symbolMargin.length - 1) {
67267 hasEndGap = true;
67268 symbolMargin = symbolMargin.slice(0, symbolMargin.length - 1);
67269 }
67270
67271 var symbolMarginNumeric = parsePercent$1(symbolMargin, symbolSize[valueDim.index]);
67272 var uLenWithMargin = Math.max(unitLength + symbolMarginNumeric * 2, 0); // When symbol margin is less than 0, margin at both ends will be subtracted
67273 // to ensure that all of the symbols will not be overflow the given area.
67274
67275 var endFix = hasEndGap ? 0 : symbolMarginNumeric * 2; // Both final repeatTimes and final symbolMarginNumeric area calculated based on
67276 // boundingLength.
67277
67278 var repeatSpecified = isNumeric(symbolRepeat);
67279 var repeatTimes = repeatSpecified ? symbolRepeat : toIntTimes((absBoundingLength + endFix) / uLenWithMargin); // Adjust calculate margin, to ensure each symbol is displayed
67280 // entirely in the given layout area.
67281
67282 var mDiff = absBoundingLength - repeatTimes * unitLength;
67283 symbolMarginNumeric = mDiff / 2 / (hasEndGap ? repeatTimes : repeatTimes - 1);
67284 uLenWithMargin = unitLength + symbolMarginNumeric * 2;
67285 endFix = hasEndGap ? 0 : symbolMarginNumeric * 2; // Update repeatTimes when not all symbol will be shown.
67286
67287 if (!repeatSpecified && symbolRepeat !== 'fixed') {
67288 repeatTimes = repeatCutLength ? toIntTimes((Math.abs(repeatCutLength) + endFix) / uLenWithMargin) : 0;
67289 }
67290
67291 pathLen = repeatTimes * uLenWithMargin - endFix;
67292 outputSymbolMeta.repeatTimes = repeatTimes;
67293 outputSymbolMeta.symbolMargin = symbolMarginNumeric;
67294 }
67295
67296 var sizeFix = pxSign * (pathLen / 2);
67297 var pathPosition = outputSymbolMeta.pathPosition = [];
67298 pathPosition[categoryDim.index] = layout[categoryDim.wh] / 2;
67299 pathPosition[valueDim.index] = symbolPosition === 'start' ? sizeFix : symbolPosition === 'end' ? boundingLength - sizeFix : boundingLength / 2; // 'center'
67300
67301 if (symbolOffset) {
67302 pathPosition[0] += symbolOffset[0];
67303 pathPosition[1] += symbolOffset[1];
67304 }
67305
67306 var bundlePosition = outputSymbolMeta.bundlePosition = [];
67307 bundlePosition[categoryDim.index] = layout[categoryDim.xy];
67308 bundlePosition[valueDim.index] = layout[valueDim.xy];
67309 var barRectShape = outputSymbolMeta.barRectShape = extend({}, layout);

Callers 1

getSymbolMetaFunction · 0.85

Calls 5

retrieveFunction · 0.85
parsePercent$1Function · 0.85
toIntTimesFunction · 0.85
isNumericFunction · 0.70
extendFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…