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

Function getScaleExtent

libs/echarts/echarts.simple.js:37598–37737  ·  view source on GitHub ↗

* Get axis scale extent before niced. * Item of returned array can only be number (including Infinity and NaN).

(scale, model)

Source from the content-addressed store, hash-verified

37596 * Item of returned array can only be number (including Infinity and NaN).
37597 */
37598function getScaleExtent(scale, model) {
37599 var scaleType = scale.type;
37600
37601 var min = model.getMin();
37602 var max = model.getMax();
37603 var originalExtent = scale.getExtent();
37604
37605 var axisDataLen;
37606 var boundaryGap;
37607 var span;
37608 if (scaleType === 'ordinal') {
37609 axisDataLen = model.getCategories().length;
37610 }
37611 else {
37612 boundaryGap = model.get('boundaryGap');
37613 if (!isArray(boundaryGap)) {
37614 boundaryGap = [boundaryGap || 0, boundaryGap || 0];
37615 }
37616 if (typeof boundaryGap[0] === 'boolean') {
37617 if (__DEV__) {
37618 console.warn('Boolean type for boundaryGap is only '
37619 + 'allowed for ordinal axis. Please use string in '
37620 + 'percentage instead, e.g., "20%". Currently, '
37621 + 'boundaryGap is set to be 0.');
37622 }
37623 boundaryGap = [0, 0];
37624 }
37625 boundaryGap[0] = parsePercent$1(boundaryGap[0], 1);
37626 boundaryGap[1] = parsePercent$1(boundaryGap[1], 1);
37627 span = (originalExtent[1] - originalExtent[0])
37628 || Math.abs(originalExtent[0]);
37629 }
37630
37631 // Notice: When min/max is not set (that is, when there are null/undefined,
37632 // which is the most common case), these cases should be ensured:
37633 // (1) For 'ordinal', show all axis.data.
37634 // (2) For others:
37635 // + `boundaryGap` is applied (if min/max set, boundaryGap is
37636 // disabled).
37637 // + If `needCrossZero`, min/max should be zero, otherwise, min/max should
37638 // be the result that originalExtent enlarged by boundaryGap.
37639 // (3) If no data, it should be ensured that `scale.setBlank` is set.
37640
37641 // FIXME
37642 // (1) When min/max is 'dataMin' or 'dataMax', should boundaryGap be able to used?
37643 // (2) When `needCrossZero` and all data is positive/negative, should it be ensured
37644 // that the results processed by boundaryGap are positive/negative?
37645
37646 if (min === 'dataMin') {
37647 min = originalExtent[0];
37648 }
37649 else if (typeof min === 'function') {
37650 min = min({
37651 min: originalExtent[0],
37652 max: originalExtent[1]
37653 });
37654 }
37655

Callers 1

niceScaleExtentFunction · 0.70

Calls 13

getMinMethod · 0.80
getMaxMethod · 0.80
isArrayFunction · 0.70
parsePercent$1Function · 0.70
minFunction · 0.70
maxFunction · 0.70
eqNaNFunction · 0.70
prepareLayoutBarSeriesFunction · 0.70
each$1Function · 0.70
makeColumnLayoutFunction · 0.70
adjustScaleForOverflowFunction · 0.70
getExtentMethod · 0.45

Tested by

no test coverage detected