code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function prepareChunks(storage, dimInfo, chunkSize, chunkCount, end) {
var DataCtor = dataCtors[dimInfo.type];
var lastChunkIndex = chunkCount - 1;
var dim = dimInfo.name;
var resizeChunkArray = storage[dim][lastChunkIndex];
if (resizeChunkArray && resizeChunkArray.length < chunkSize) {
var newStore = new DataCtor(Math.min(end - lastChunkIndex * chunkSize, chunkSize));
// The cost of the copy is probably inconsiderable
// within the initial chunkSize.
for (var j = 0; j < resizeChunkArray.length; j++) {
newStore[j] = resizeChunkArray[j];
}
storage[dim][lastChunkIndex] = newStore;
}
// Create new chunks.
for (var k = chunkCount * chunkSize; k < end; k += chunkSize) {
storage[dim].push(new DataCtor(Math.min(end - k, chunkSize)));
}
}
|
Get value for multi dimensions.
@param {Array.<string>} [dimensions] If ignored, using all dimensions.
@param {number} idx
@return {number}
|
prepareChunks
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function prepareInvertedIndex(list) {
var invertedIndicesMap = list._invertedIndicesMap;
each$1(invertedIndicesMap, function (invertedIndices, dim) {
var dimInfo = list._dimensionInfos[dim];
// Currently, only dimensions that has ordinalMeta can create inverted indices.
var ordinalMeta = dimInfo.ordinalMeta;
if (ordinalMeta) {
invertedIndices = invertedIndicesMap[dim] = new CtorInt32Array(
ordinalMeta.categories.length
);
// The default value of TypedArray is 0. To avoid miss
// mapping to 0, we should set it as INDEX_NOT_FOUND.
for (var i = 0; i < invertedIndices.length; i++) {
invertedIndices[i] = INDEX_NOT_FOUND;
}
for (var i = 0; i < list._count; i++) {
// Only support the case that all values are distinct.
invertedIndices[list.get(dim, i)] = i;
}
}
});
}
|
If value is NaN. Inlcuding '-'
Only check the coord dimensions.
@param {string} dim
@param {number} idx
@return {number}
|
prepareInvertedIndex
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getRawValueFromStore(list, dimIndex, rawIndex) {
var val;
if (dimIndex != null) {
var chunkSize = list._chunkSize;
var chunkIndex = Math.floor(rawIndex / chunkSize);
var chunkOffset = rawIndex % chunkSize;
var dim = list.dimensions[dimIndex];
var chunk = list._storage[dim][chunkIndex];
if (chunk) {
val = chunk[chunkOffset];
var ordinalMeta = list._dimensionInfos[dim].ordinalMeta;
if (ordinalMeta && ordinalMeta.categories.length) {
val = ordinalMeta.categories[val];
}
}
}
return val;
}
|
Get extent of data in one dimension
@param {string} dim
@param {boolean} stack
|
getRawValueFromStore
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getRawIndexWithoutIndices(idx) {
return idx;
}
|
Select data in range. (For optimization of filter)
(Manually inline code, support 5 million data filtering in data zoom.)
|
getRawIndexWithoutIndices
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getRawIndexWithIndices(idx) {
if (idx < this._count && idx >= 0) {
return this._indices[idx];
}
return -1;
}
|
Select data in range. (For optimization of filter)
(Manually inline code, support 5 million data filtering in data zoom.)
|
getRawIndexWithIndices
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getId(list, rawIndex) {
var id = list._idList[rawIndex];
if (id == null) {
id = getRawValueFromStore(list, list._idDimIdx, rawIndex);
}
if (id == null) {
// FIXME Check the usage in graph, should not use prefix.
id = ID_PREFIX + rawIndex;
}
return id;
}
|
Select data in range. (For optimization of filter)
(Manually inline code, support 5 million data filtering in data zoom.)
|
getId
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function normalizeDimensions(dimensions) {
if (!isArray(dimensions)) {
dimensions = [dimensions];
}
return dimensions;
}
|
Select data in range. (For optimization of filter)
(Manually inline code, support 5 million data filtering in data zoom.)
|
normalizeDimensions
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function validateDimensions(list, dims) {
for (var i = 0; i < dims.length; i++) {
// stroage may be empty when no data, so use
// dimensionInfos to check.
if (!list._dimensionInfos[dims[i]]) {
console.error('Unkown dimension ' + dims[i]);
}
}
}
|
Select data in range. (For optimization of filter)
(Manually inline code, support 5 million data filtering in data zoom.)
|
validateDimensions
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function cloneListForMapAndSample(original, excludeDimensions) {
var allDimensions = original.dimensions;
var list = new List(
map(allDimensions, original.getDimensionInfo, original),
original.hostModel
);
// FIXME If needs stackedOn, value may already been stacked
transferProperties(list, original);
var storage = list._storage = {};
var originalStorage = original._storage;
// Init storage
for (var i = 0; i < allDimensions.length; i++) {
var dim = allDimensions[i];
if (originalStorage[dim]) {
// Notice that we do not reset invertedIndicesMap here, becuase
// there is no scenario of mapping or sampling ordinal dimension.
if (indexOf(excludeDimensions, dim) >= 0) {
storage[dim] = cloneDimStore(originalStorage[dim]);
list._rawExtent[dim] = getInitialExtent();
list._extent[dim] = null;
}
else {
// Direct reference for other dimensions
storage[dim] = originalStorage[dim];
}
}
}
return list;
}
|
Get model of one data item.
@param {number} idx
|
cloneListForMapAndSample
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function cloneDimStore(originalDimStore) {
var newDimStore = new Array(originalDimStore.length);
for (var j = 0; j < originalDimStore.length; j++) {
newDimStore[j] = cloneChunk(originalDimStore[j]);
}
return newDimStore;
}
|
Set visual property
@param {string|Object} key
@param {*} [value]
@example
setVisual('color', color);
setVisual({
'color': color
});
|
cloneDimStore
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getInitialExtent() {
return [Infinity, -Infinity];
}
|
Set layout property.
@param {string|Object} key
@param {*} [val]
|
getInitialExtent
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
setItemDataAndSeriesIndex = function (child) {
child.seriesIndex = this.seriesIndex;
child.dataIndex = this.dataIndex;
child.dataType = this.dataType;
}
|
@see {module:echarts/test/ut/spec/data/completeDimensions}
This method builds the relationship between:
+ "what the coord sys or series requires (see `sysDims`)",
+ "what the user defines (in `encode` and `dimensions`, see `opt.dimsDef` and `opt.encodeDef`)"
+ "what the data source provids (see `source`)".
Some guess strategy will be adapted if user does not define something.
If no 'value' dimension specified, the first no-named dimension will be
named as 'value'.
@param {Array.<string>} sysDims Necessary dimensions, like ['x', 'y'], which
provides not only dim template, but also default order.
properties: 'name', 'type', 'displayName'.
`name` of each item provides default coord name.
[{dimsDef: [string|Object, ...]}, ...] dimsDef of sysDim item provides default dim name, and
provide dims count that the sysDim required.
[{ordinalMeta}] can be specified.
@param {module:echarts/data/Source|Array|Object} source or data (for compatibal with pervious)
@param {Object} [opt]
@param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
For example: ['asdf', {name, type}, ...].
@param {Object|HashMap} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
@param {Function} [opt.encodeDefaulter] Called if no `opt.encodeDef` exists.
If not specified, auto find the next available data dim.
param source {module:data/Source}
param dimCount {number}
return {Object} encode Never be `null/undefined`.
@param {string} [opt.generateCoord] Generate coord dim with the given name.
If not specified, extra dim names will be:
'value', 'value0', 'value1', ...
@param {number} [opt.generateCoordCount] By default, the generated dim name is `generateCoord`.
If `generateCoordCount` specified, the generated dim names will be:
`generateCoord` + 0, `generateCoord` + 1, ...
can be Infinity, indicate that use all of the remain columns.
@param {number} [opt.dimCount] If not specified, guess by the first data item.
@return {Array.<module:data/DataDimensionInfo>}
|
setItemDataAndSeriesIndex
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function completeDimensions(sysDims, source, opt) {
if (!Source.isInstance(source)) {
source = Source.seriesDataToSource(source);
}
opt = opt || {};
sysDims = (sysDims || []).slice();
var dimsDef = (opt.dimsDef || []).slice();
var dataDimNameMap = createHashMap();
var coordDimNameMap = createHashMap();
// var valueCandidate;
var result = [];
var dimCount = getDimCount(source, sysDims, dimsDef, opt.dimCount);
// Apply user defined dims (`name` and `type`) and init result.
for (var i = 0; i < dimCount; i++) {
var dimDefItem = dimsDef[i] = extend(
{}, isObject$1(dimsDef[i]) ? dimsDef[i] : {name: dimsDef[i]}
);
var userDimName = dimDefItem.name;
var resultItem = result[i] = new DataDimensionInfo();
// Name will be applied later for avoiding duplication.
if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
// Only if `series.dimensions` is defined in option
// displayName, will be set, and dimension will be diplayed vertically in
// tooltip by default.
resultItem.name = resultItem.displayName = userDimName;
dataDimNameMap.set(userDimName, i);
}
dimDefItem.type != null && (resultItem.type = dimDefItem.type);
dimDefItem.displayName != null && (resultItem.displayName = dimDefItem.displayName);
}
var encodeDef = opt.encodeDef;
if (!encodeDef && opt.encodeDefaulter) {
encodeDef = opt.encodeDefaulter(source, dimCount);
}
encodeDef = createHashMap(encodeDef);
// Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
encodeDef.each(function (dataDims, coordDim) {
dataDims = normalizeToArray(dataDims).slice();
// Note: It is allowed that `dataDims.length` is `0`, e.g., options is
// `{encode: {x: -1, y: 1}}`. Should not filter anything in
// this case.
if (dataDims.length === 1 && !isString(dataDims[0]) && dataDims[0] < 0) {
encodeDef.set(coordDim, false);
return;
}
var validDataDims = encodeDef.set(coordDim, []);
each$1(dataDims, function (resultDimIdx, idx) {
// The input resultDimIdx can be dim name or index.
isString(resultDimIdx) && (resultDimIdx = dataDimNameMap.get(resultDimIdx));
if (resultDimIdx != null && resultDimIdx < dimCount) {
validDataDims[idx] = resultDimIdx;
applyDim(result[resultDimIdx], coordDim, idx);
}
});
});
// Apply templetes and default order from `sysDims`.
var availDimIdx = 0;
each$1(sysDims, function (sysDimItem, sysDimIndex) {
var coordDim;
var sysDimItem;
var sysDimItemDimsDef;
var sysDimItemOtherDims;
if (isString(sysDimItem)) {
coordDim = sysDimItem;
sysDimItem = {};
}
else {
coordDim = sysDimItem.name;
var ordinalMeta = sysDimItem.ordinalMeta;
sysDimItem.ordinalMeta = null;
sysDimItem = clone(sysDimItem);
sysDimItem.ordinalMeta = ordinalMeta;
// `coordDimIndex` should not be set directly.
sysDimItemDimsDef = sysDimItem.dimsDef;
sysDimItemOtherDims = sysDimItem.otherDims;
sysDimItem.name = sysDimItem.coordDim = sysDimItem.coordDimIndex =
sysDimItem.dimsDef = sysDimItem.otherDims = null;
}
var dataDims = encodeDef.get(coordDim);
// negative resultDimIdx means no need to mapping.
if (dataDims === false) {
return;
}
var dataDims = normalizeToArray(dataDims);
// dimensions provides default dim sequences.
if (!dataDims.length) {
for (var i = 0; i < (sysDimItemDimsDef && sysDimItemDimsDef.length || 1); i++) {
while (availDimIdx < result.length && result[availDimIdx].coordDim != null) {
availDimIdx++;
}
availDimIdx < result.length && dataDims.push(availDimIdx++);
}
}
// Apply templates.
each$1(dataDims, function (resultDimIdx, coordDimIndex) {
var resultItem = result[resultDimIdx];
applyDim(defaults(resultItem, sysDimItem), coordDim, coordDimIndex);
if (resultItem.name == null && sysDimItemDimsDef) {
var sysDimItemDimsDefItem = sysDimItemDimsDef[coordDimIndex];
!isObject$1(sysDimItemDimsDefItem) && (sysDimItemDimsDefItem = {name: sysDimItemDimsDefItem});
resultItem.name = resultItem.displayName = sysDimItemDimsDefItem.name;
resultItem.defaultTooltip = sysDimItemDimsDefItem.defaultTooltip;
}
// FIXME refactor, currently only used in case: {otherDims: {tooltip: false}}
sysDimItemOtherDims && defaults(resultItem.otherDims, sysDimItemOtherDims);
});
});
function applyDim(resultItem, coordDim, coordDimIndex) {
if (OTHER_DIMENSIONS.get(coordDim) != null) {
resultItem.otherDims[coordDim] = coordDimIndex;
}
else {
resultItem.coordDim = coordDim;
resultItem.coordDimIndex = coordDimIndex;
coordDimNameMap.set(coordDim, true);
}
}
// Make sure the first extra dim is 'value'.
var generateCoord = opt.generateCoord;
var generateCoordCount = opt.generateCoordCount;
var fromZero = generateCoordCount != null;
generateCoordCount = generateCoord ? (generateCoordCount || 1) : 0;
var extra = generateCoord || 'value';
// Set dim `name` and other `coordDim` and other props.
for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
var resultItem = result[resultDimIdx] = result[resultDimIdx] || new DataDimensionInfo();
var coordDim = resultItem.coordDim;
if (coordDim == null) {
resultItem.coordDim = genName(
extra, coordDimNameMap, fromZero
);
resultItem.coordDimIndex = 0;
if (!generateCoord || generateCoordCount <= 0) {
resultItem.isExtraCoord = true;
}
generateCoordCount--;
}
resultItem.name == null && (resultItem.name = genName(
resultItem.coordDim,
dataDimNameMap
));
if (resultItem.type == null
&& (
guessOrdinal(source, resultDimIdx, resultItem.name) === BE_ORDINAL.Must
// Consider the case:
// {
// dataset: {source: [
// ['2001', 123],
// ['2002', 456],
// ...
// ['The others', 987],
// ]},
// series: {type: 'pie'}
// }
// The first colum should better be treated as a "ordinal" although it
// might not able to be detected as an "ordinal" by `guessOrdinal`.
|| (resultItem.isExtraCoord
&& (resultItem.otherDims.itemName != null
|| resultItem.otherDims.seriesName != null
)
)
)
) {
resultItem.type = 'ordinal';
}
}
return result;
}
|
@see {module:echarts/test/ut/spec/data/completeDimensions}
This method builds the relationship between:
+ "what the coord sys or series requires (see `sysDims`)",
+ "what the user defines (in `encode` and `dimensions`, see `opt.dimsDef` and `opt.encodeDef`)"
+ "what the data source provids (see `source`)".
Some guess strategy will be adapted if user does not define something.
If no 'value' dimension specified, the first no-named dimension will be
named as 'value'.
@param {Array.<string>} sysDims Necessary dimensions, like ['x', 'y'], which
provides not only dim template, but also default order.
properties: 'name', 'type', 'displayName'.
`name` of each item provides default coord name.
[{dimsDef: [string|Object, ...]}, ...] dimsDef of sysDim item provides default dim name, and
provide dims count that the sysDim required.
[{ordinalMeta}] can be specified.
@param {module:echarts/data/Source|Array|Object} source or data (for compatibal with pervious)
@param {Object} [opt]
@param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
For example: ['asdf', {name, type}, ...].
@param {Object|HashMap} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
@param {Function} [opt.encodeDefaulter] Called if no `opt.encodeDef` exists.
If not specified, auto find the next available data dim.
param source {module:data/Source}
param dimCount {number}
return {Object} encode Never be `null/undefined`.
@param {string} [opt.generateCoord] Generate coord dim with the given name.
If not specified, extra dim names will be:
'value', 'value0', 'value1', ...
@param {number} [opt.generateCoordCount] By default, the generated dim name is `generateCoord`.
If `generateCoordCount` specified, the generated dim names will be:
`generateCoord` + 0, `generateCoord` + 1, ...
can be Infinity, indicate that use all of the remain columns.
@param {number} [opt.dimCount] If not specified, guess by the first data item.
@return {Array.<module:data/DataDimensionInfo>}
|
completeDimensions
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function applyDim(resultItem, coordDim, coordDimIndex) {
if (OTHER_DIMENSIONS.get(coordDim) != null) {
resultItem.otherDims[coordDim] = coordDimIndex;
}
else {
resultItem.coordDim = coordDim;
resultItem.coordDimIndex = coordDimIndex;
coordDimNameMap.set(coordDim, true);
}
}
|
@param {module:echarts/data/Source|module:echarts/data/List} source or data.
@param {Object|Array} [opt]
@param {Array.<string|Object>} [opt.coordDimensions=[]]
@param {number} [opt.dimensionsCount]
@param {string} [opt.generateCoord]
@param {string} [opt.generateCoordCount]
@param {Array.<string|Object>} [opt.dimensionsDefine=source.dimensionsDefine] Overwrite source define.
@param {Object|HashMap} [opt.encodeDefine=source.encodeDefine] Overwrite source define.
@param {Function} [opt.encodeDefaulter] Make default encode if user not specified.
@return {Array.<Object>} dimensionsInfo
|
applyDim
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getCoordSysInfoBySeries(seriesModel) {
var coordSysName = seriesModel.get('coordinateSystem');
var result = new CoordSysInfo(coordSysName);
var fetch = fetchers[coordSysName];
if (fetch) {
fetch(seriesModel, result, result.axisMap, result.categoryAxisMap);
return result;
}
}
|
Note that it is too complicated to support 3d stack by value
(have to create two-dimension inverted index), so in 3d case
we just support that stacked by index.
@param {module:echarts/model/Series} seriesModel
@param {Array.<string|Object>} dimensionInfoList The same as the input of <module:echarts/data/List>.
The input dimensionInfoList will be modified.
@param {Object} [opt]
@param {boolean} [opt.stackedCoordDimension=''] Specify a coord dimension if needed.
@param {boolean} [opt.byIndex=false]
@return {Object} calculationInfo
{
stackedDimension: string
stackedByDimension: string
isStackedByIndex: boolean
stackedOverDimension: string
stackResultDimension: string
}
|
getCoordSysInfoBySeries
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function isCategory(axisModel) {
return axisModel.get('type') === 'category';
}
|
@param {module:echarts/data/List} data
@param {string} stackedDim
|
isCategory
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function enableDataStack(seriesModel, dimensionInfoList, opt) {
opt = opt || {};
var byIndex = opt.byIndex;
var stackedCoordDimension = opt.stackedCoordDimension;
// Compatibal: when `stack` is set as '', do not stack.
var mayStack = !!(seriesModel && seriesModel.get('stack'));
var stackedByDimInfo;
var stackedDimInfo;
var stackResultDimension;
var stackedOverDimension;
each$1(dimensionInfoList, function (dimensionInfo, index) {
if (isString(dimensionInfo)) {
dimensionInfoList[index] = dimensionInfo = {name: dimensionInfo};
}
if (mayStack && !dimensionInfo.isExtraCoord) {
// Find the first ordinal dimension as the stackedByDimInfo.
if (!byIndex && !stackedByDimInfo && dimensionInfo.ordinalMeta) {
stackedByDimInfo = dimensionInfo;
}
// Find the first stackable dimension as the stackedDimInfo.
if (!stackedDimInfo
&& dimensionInfo.type !== 'ordinal'
&& dimensionInfo.type !== 'time'
&& (!stackedCoordDimension || stackedCoordDimension === dimensionInfo.coordDim)
) {
stackedDimInfo = dimensionInfo;
}
}
});
if (stackedDimInfo && !byIndex && !stackedByDimInfo) {
// Compatible with previous design, value axis (time axis) only stack by index.
// It may make sense if the user provides elaborately constructed data.
byIndex = true;
}
// Add stack dimension, they can be both calculated by coordinate system in `unionExtent`.
// That put stack logic in List is for using conveniently in echarts extensions, but it
// might not be a good way.
if (stackedDimInfo) {
// Use a weird name that not duplicated with other names.
stackResultDimension = '__\0ecstackresult';
stackedOverDimension = '__\0ecstackedover';
// Create inverted index to fast query index by value.
if (stackedByDimInfo) {
stackedByDimInfo.createInvertedIndices = true;
}
var stackedDimCoordDim = stackedDimInfo.coordDim;
var stackedDimType = stackedDimInfo.type;
var stackedDimCoordIndex = 0;
each$1(dimensionInfoList, function (dimensionInfo) {
if (dimensionInfo.coordDim === stackedDimCoordDim) {
stackedDimCoordIndex++;
}
});
dimensionInfoList.push({
name: stackResultDimension,
coordDim: stackedDimCoordDim,
coordDimIndex: stackedDimCoordIndex,
type: stackedDimType,
isExtraCoord: true,
isCalculationCoord: true
});
stackedDimCoordIndex++;
dimensionInfoList.push({
name: stackedOverDimension,
// This dimension contains stack base (generally, 0), so do not set it as
// `stackedDimCoordDim` to avoid extent calculation, consider log scale.
coordDim: stackedOverDimension,
coordDimIndex: stackedDimCoordIndex,
type: stackedDimType,
isExtraCoord: true,
isCalculationCoord: true
});
}
return {
stackedDimension: stackedDimInfo && stackedDimInfo.name,
stackedByDimension: stackedByDimInfo && stackedByDimInfo.name,
isStackedByIndex: byIndex,
stackedOverDimension: stackedOverDimension,
stackResultDimension: stackResultDimension
};
}
|
@param {module:echarts/data/Source|Array} source Or raw data.
@param {module:echarts/model/Series} seriesModel
@param {Object} [opt]
@param {string} [opt.generateCoord]
@param {boolean} [opt.useEncodeDefaulter]
|
enableDataStack
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function isDimensionStacked(data, stackedDim /*, stackedByDim*/) {
// Each single series only maps to one pair of axis. So we do not need to
// check stackByDim, whatever stacked by a dimension or stacked by index.
return !!stackedDim && stackedDim === data.getCalculationInfo('stackedDimension');
// && (
// stackedByDim != null
// ? stackedByDim === data.getCalculationInfo('stackedByDimension')
// : data.getCalculationInfo('isStackedByIndex')
// );
}
|
@param {module:echarts/data/Source|Array} source Or raw data.
@param {module:echarts/model/Series} seriesModel
@param {Object} [opt]
@param {string} [opt.generateCoord]
@param {boolean} [opt.useEncodeDefaulter]
|
isDimensionStacked
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getStackedDimension(data, targetDim) {
return isDimensionStacked(data, targetDim)
? data.getCalculationInfo('stackResultDimension')
: targetDim;
}
|
@param {module:echarts/data/Source|Array} source Or raw data.
@param {module:echarts/model/Series} seriesModel
@param {Object} [opt]
@param {string} [opt.generateCoord]
@param {boolean} [opt.useEncodeDefaulter]
|
getStackedDimension
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function createListFromArray(source, seriesModel, opt) {
opt = opt || {};
if (!Source.isInstance(source)) {
source = Source.seriesDataToSource(source);
}
var coordSysName = seriesModel.get('coordinateSystem');
var registeredCoordSys = CoordinateSystemManager.get(coordSysName);
var coordSysInfo = getCoordSysInfoBySeries(seriesModel);
var coordSysDimDefs;
if (coordSysInfo) {
coordSysDimDefs = map(coordSysInfo.coordSysDims, function (dim) {
var dimInfo = {name: dim};
var axisModel = coordSysInfo.axisMap.get(dim);
if (axisModel) {
var axisType = axisModel.get('type');
dimInfo.type = getDimensionTypeByAxis(axisType);
// dimInfo.stackable = isStackable(axisType);
}
return dimInfo;
});
}
if (!coordSysDimDefs) {
// Get dimensions from registered coordinate system
coordSysDimDefs = (registeredCoordSys && (
registeredCoordSys.getDimensionsInfo
? registeredCoordSys.getDimensionsInfo()
: registeredCoordSys.dimensions.slice()
)) || ['x', 'y'];
}
var dimInfoList = createDimensions(source, {
coordDimensions: coordSysDimDefs,
generateCoord: opt.generateCoord,
encodeDefaulter: opt.useEncodeDefaulter
? curry(makeSeriesEncodeForAxisCoordSys, coordSysDimDefs, seriesModel)
: null
});
var firstCategoryDimIndex;
var hasNameEncode;
coordSysInfo && each$1(dimInfoList, function (dimInfo, dimIndex) {
var coordDim = dimInfo.coordDim;
var categoryAxisModel = coordSysInfo.categoryAxisMap.get(coordDim);
if (categoryAxisModel) {
if (firstCategoryDimIndex == null) {
firstCategoryDimIndex = dimIndex;
}
dimInfo.ordinalMeta = categoryAxisModel.getOrdinalMeta();
}
if (dimInfo.otherDims.itemName != null) {
hasNameEncode = true;
}
});
if (!hasNameEncode && firstCategoryDimIndex != null) {
dimInfoList[firstCategoryDimIndex].otherDims.itemName = 0;
}
var stackCalculationInfo = enableDataStack(seriesModel, dimInfoList);
var list = new List(dimInfoList, seriesModel);
list.setCalculationInfo(stackCalculationInfo);
var dimValueGetter = (firstCategoryDimIndex != null && isNeedCompleteOrdinalData(source))
? function (itemOpt, dimName, dataIndex, dimIndex) {
// Use dataIndex as ordinal value in categoryAxis
return dimIndex === firstCategoryDimIndex
? dataIndex
: this.defaultDimValueGetter(itemOpt, dimName, dataIndex, dimIndex);
}
: null;
list.hasItemOption = false;
list.initData(source, null, dimValueGetter);
return list;
}
|
@param {module:echarts/data/Source|Array} source Or raw data.
@param {module:echarts/model/Series} seriesModel
@param {Object} [opt]
@param {string} [opt.generateCoord]
@param {boolean} [opt.useEncodeDefaulter]
|
createListFromArray
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getDefaultLabel(data, dataIndex) {
var labelDims = data.mapDimension('defaultedLabel', true);
var len = labelDims.length;
// Simple optimization (in lots of cases, label dims length is 1)
if (len === 1) {
return retrieveRawValue(data, dataIndex, labelDims[0]);
}
else if (len) {
var vals = [];
for (var i = 0; i < labelDims.length; i++) {
var val = retrieveRawValue(data, dataIndex, labelDims[i]);
vals.push(val);
}
return vals.join(' ');
}
}
|
Update symbol properties
@param {module:echarts/data/List} data
@param {number} idx
@param {Object} [seriesScope]
@param {Object} [seriesScope.itemStyle]
@param {Object} [seriesScope.hoverItemStyle]
@param {Object} [seriesScope.symbolRotate]
@param {Object} [seriesScope.symbolOffset]
@param {module:echarts/model/Model} [seriesScope.labelModel]
@param {module:echarts/model/Model} [seriesScope.hoverLabelModel]
@param {boolean} [seriesScope.hoverAnimation]
@param {Object} [seriesScope.cursorStyle]
@param {module:echarts/model/Model} [seriesScope.itemModel]
@param {string} [seriesScope.symbolInnerColor]
@param {Object} [seriesScope.fadeIn=false]
|
getDefaultLabel
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function SymbolClz(data, idx, seriesScope) {
Group.call(this);
this.updateData(data, idx, seriesScope);
}
|
@param {module:echarts/data/List} data
@param {number} idx
@param {Array.<number>} symbolSize
@param {Object} [seriesScope]
|
SymbolClz
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getScale(symbolSize) {
return [symbolSize[0] / 2, symbolSize[1] / 2];
}
|
@param {module:echarts/data/List} data
@param {number} idx
@param {Array.<number>} symbolSize
@param {Object} [seriesScope]
|
getScale
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function driftSymbol(dx, dy) {
this.parent.drift(dx, dy);
}
|
@param {module:echarts/data/List} data
@param {number} idx
@param {Array.<number>} symbolSize
@param {Object} [seriesScope]
|
driftSymbol
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getLabelDefaultText(idx, opt) {
return useNameLabel ? data.getName(idx) : getDefaultLabel(data, idx);
}
|
Update symbols draw by new data
@param {module:echarts/data/List} data
@param {Object} [opt] Or isIgnore
@param {Function} [opt.isIgnore]
@param {Object} [opt.clipShape]
|
getLabelDefaultText
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function highDownOnUpdate(fromState, toState) {
// Do not support this hover animation util some scenario required.
// Animation can only be supported in hover layer when using `el.incremetal`.
if (this.incremental || this.useHoverLayer) {
return;
}
if (toState === 'emphasis') {
var scale = this.__symbolOriginalScale;
var ratio = scale[1] / scale[0];
var emphasisOpt = {
scale: [
Math.max(scale[0] * 1.1, scale[0] + 3),
Math.max(scale[1] * 1.1, scale[1] + 3 * ratio)
]
};
// FIXME
// modify it after support stop specified animation.
// toState === fromState
// ? (this.stopAnimation(), this.attr(emphasisOpt))
this.animateTo(emphasisOpt, 400, 'elasticOut');
}
else if (toState === 'normal') {
this.animateTo({
scale: this.__symbolOriginalScale
}, 400, 'elasticOut');
}
}
|
Update symbols draw by new data
@param {module:echarts/data/List} data
@param {Object} [opt] Or isIgnore
@param {Function} [opt.isIgnore]
@param {Object} [opt.clipShape]
|
highDownOnUpdate
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function SymbolDraw(symbolCtor) {
this.group = new Group();
this._symbolCtor = symbolCtor || SymbolClz;
}
|
Update symbols draw by new data
@param {module:echarts/data/List} data
@param {Object} [opt] Or isIgnore
@param {Function} [opt.isIgnore]
@param {Object} [opt.clipShape]
|
SymbolDraw
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function symbolNeedsDraw(data, point, idx, opt) {
return point && !isNaN(point[0]) && !isNaN(point[1])
&& !(opt.isIgnore && opt.isIgnore(idx))
// We do not set clipShape on group, because it will cut part of
// the symbol element shape. We use the same clip shape here as
// the line clip.
&& !(opt.clipShape && !opt.clipShape.contain(point[0], point[1]))
&& data.getItemVisual(idx, 'symbol') !== 'none';
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
symbolNeedsDraw
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function updateIncrementalAndHover(el) {
if (!el.isGroup) {
el.incremental = el.useHoverLayer = true;
}
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
updateIncrementalAndHover
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function normalizeUpdateOpt(opt) {
if (opt != null && !isObject$1(opt)) {
opt = {isIgnore: opt};
}
return opt || {};
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
normalizeUpdateOpt
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeSeriesScope(data) {
var seriesModel = data.hostModel;
return {
itemStyle: seriesModel.getModel('itemStyle').getItemStyle(['color']),
hoverItemStyle: seriesModel.getModel('emphasis.itemStyle').getItemStyle(),
symbolRotate: seriesModel.get('symbolRotate'),
symbolOffset: seriesModel.get('symbolOffset'),
hoverAnimation: seriesModel.get('hoverAnimation'),
labelModel: seriesModel.getModel('label'),
hoverLabelModel: seriesModel.getModel('emphasis.label'),
cursorStyle: seriesModel.get('cursor')
};
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
makeSeriesScope
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function prepareDataCoordInfo(coordSys, data, valueOrigin) {
var baseAxis = coordSys.getBaseAxis();
var valueAxis = coordSys.getOtherAxis(baseAxis);
var valueStart = getValueStart(valueAxis, valueOrigin);
var baseAxisDim = baseAxis.dim;
var valueAxisDim = valueAxis.dim;
var valueDim = data.mapDimension(valueAxisDim);
var baseDim = data.mapDimension(baseAxisDim);
var baseDataOffset = valueAxisDim === 'x' || valueAxisDim === 'radius' ? 1 : 0;
var dims = map(coordSys.dimensions, function (coordDim) {
return data.mapDimension(coordDim);
});
var stacked;
var stackResultDim = data.getCalculationInfo('stackResultDimension');
if (stacked |= isDimensionStacked(data, dims[0] /*, dims[1]*/)) { // jshint ignore:line
dims[0] = stackResultDim;
}
if (stacked |= isDimensionStacked(data, dims[1] /*, dims[0]*/)) { // jshint ignore:line
dims[1] = stackResultDim;
}
return {
dataDimsForPoint: dims,
valueStart: valueStart,
valueAxisDim: valueAxisDim,
baseAxisDim: baseAxisDim,
stacked: !!stacked,
valueDim: valueDim,
baseDim: baseDim,
baseDataOffset: baseDataOffset,
stackedOverDimension: data.getCalculationInfo('stackedOverDimension')
};
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
prepareDataCoordInfo
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getValueStart(valueAxis, valueOrigin) {
var valueStart = 0;
var extent = valueAxis.scale.getExtent();
if (valueOrigin === 'start') {
valueStart = extent[0];
}
else if (valueOrigin === 'end') {
valueStart = extent[1];
}
// auto
else {
// Both positive
if (extent[0] > 0) {
valueStart = extent[0];
}
// Both negative
else if (extent[1] < 0) {
valueStart = extent[1];
}
// If is one positive, and one negative, onZero shall be true
}
return valueStart;
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
getValueStart
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getStackedOnPoint(dataCoordInfo, coordSys, data, idx) {
var value = NaN;
if (dataCoordInfo.stacked) {
value = data.get(data.getCalculationInfo('stackedOverDimension'), idx);
}
if (isNaN(value)) {
value = dataCoordInfo.valueStart;
}
var baseDataOffset = dataCoordInfo.baseDataOffset;
var stackedData = [];
stackedData[baseDataOffset] = data.get(dataCoordInfo.baseDim, idx);
stackedData[1 - baseDataOffset] = value;
return coordSys.dataToPoint(stackedData);
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
getStackedOnPoint
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function diffData(oldData, newData) {
var diffResult = [];
newData.diff(oldData)
.add(function (idx) {
diffResult.push({cmd: '+', idx: idx});
})
.update(function (newIdx, oldIdx) {
diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx});
})
.remove(function (idx) {
diffResult.push({cmd: '-', idx: idx});
})
.execute();
return diffResult;
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
diffData
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
lineAnimationDiff = function (
oldData, newData,
oldStackedOnPoints, newStackedOnPoints,
oldCoordSys, newCoordSys,
oldValueOrigin, newValueOrigin
) {
var diff = diffData(oldData, newData);
// var newIdList = newData.mapArray(newData.getId);
// var oldIdList = oldData.mapArray(oldData.getId);
// convertToIntId(newIdList, oldIdList);
// // FIXME One data ?
// diff = arrayDiff(oldIdList, newIdList);
var currPoints = [];
var nextPoints = [];
// Points for stacking base line
var currStackedPoints = [];
var nextStackedPoints = [];
var status = [];
var sortedIndices = [];
var rawIndices = [];
var newDataOldCoordInfo = prepareDataCoordInfo(oldCoordSys, newData, oldValueOrigin);
var oldDataNewCoordInfo = prepareDataCoordInfo(newCoordSys, oldData, newValueOrigin);
for (var i = 0; i < diff.length; i++) {
var diffItem = diff[i];
var pointAdded = true;
// FIXME, animation is not so perfect when dataZoom window moves fast
// Which is in case remvoing or add more than one data in the tail or head
switch (diffItem.cmd) {
case '=':
var currentPt = oldData.getItemLayout(diffItem.idx);
var nextPt = newData.getItemLayout(diffItem.idx1);
// If previous data is NaN, use next point directly
if (isNaN(currentPt[0]) || isNaN(currentPt[1])) {
currentPt = nextPt.slice();
}
currPoints.push(currentPt);
nextPoints.push(nextPt);
currStackedPoints.push(oldStackedOnPoints[diffItem.idx]);
nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]);
rawIndices.push(newData.getRawIndex(diffItem.idx1));
break;
case '+':
var idx = diffItem.idx;
currPoints.push(
oldCoordSys.dataToPoint([
newData.get(newDataOldCoordInfo.dataDimsForPoint[0], idx),
newData.get(newDataOldCoordInfo.dataDimsForPoint[1], idx)
])
);
nextPoints.push(newData.getItemLayout(idx).slice());
currStackedPoints.push(
getStackedOnPoint(newDataOldCoordInfo, oldCoordSys, newData, idx)
);
nextStackedPoints.push(newStackedOnPoints[idx]);
rawIndices.push(newData.getRawIndex(idx));
break;
case '-':
var idx = diffItem.idx;
var rawIndex = oldData.getRawIndex(idx);
// Data is replaced. In the case of dynamic data queue
// FIXME FIXME FIXME
if (rawIndex !== idx) {
currPoints.push(oldData.getItemLayout(idx));
nextPoints.push(newCoordSys.dataToPoint([
oldData.get(oldDataNewCoordInfo.dataDimsForPoint[0], idx),
oldData.get(oldDataNewCoordInfo.dataDimsForPoint[1], idx)
]));
currStackedPoints.push(oldStackedOnPoints[idx]);
nextStackedPoints.push(
getStackedOnPoint(oldDataNewCoordInfo, newCoordSys, oldData, idx)
);
rawIndices.push(rawIndex);
}
else {
pointAdded = false;
}
}
// Original indices
if (pointAdded) {
status.push(diffItem);
sortedIndices.push(sortedIndices.length);
}
}
// Diff result may be crossed if all items are changed
// Sort by data index
sortedIndices.sort(function (a, b) {
return rawIndices[a] - rawIndices[b];
});
var sortedCurrPoints = [];
var sortedNextPoints = [];
var sortedCurrStackedPoints = [];
var sortedNextStackedPoints = [];
var sortedStatus = [];
for (var i = 0; i < sortedIndices.length; i++) {
var idx = sortedIndices[i];
sortedCurrPoints[i] = currPoints[idx];
sortedNextPoints[i] = nextPoints[idx];
sortedCurrStackedPoints[i] = currStackedPoints[idx];
sortedNextStackedPoints[i] = nextStackedPoints[idx];
sortedStatus[i] = status[idx];
}
return {
current: sortedCurrPoints,
next: sortedNextPoints,
stackedOnCurrent: sortedCurrStackedPoints,
stackedOnNext: sortedNextStackedPoints,
status: sortedStatus
};
}
|
@param {Object} coordSys
@param {module:echarts/data/List} data
@param {string} valueOrigin lineSeries.option.areaStyle.origin
|
lineAnimationDiff
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function isPointNull(p) {
return isNaN(p[0]) || isNaN(p[1]);
}
|
Draw smoothed line in non-monotone, in may cause undesired curve in extreme
situations. This should be used when points are non-monotone neither in x or
y dimension.
|
isPointNull
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function drawSegment(
ctx, points, start, segLen, allLen,
dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
) {
// if (smoothMonotone == null) {
// if (isMono(points, 'x')) {
// return drawMono(ctx, points, start, segLen, allLen,
// dir, smoothMin, smoothMax, smooth, 'x', connectNulls);
// }
// else if (isMono(points, 'y')) {
// return drawMono(ctx, points, start, segLen, allLen,
// dir, smoothMin, smoothMax, smooth, 'y', connectNulls);
// }
// else {
// return drawNonMono.apply(this, arguments);
// }
// }
// else if (smoothMonotone !== 'none' && isMono(points, smoothMonotone)) {
// return drawMono.apply(this, arguments);
// }
// else {
// return drawNonMono.apply(this, arguments);
// }
if (smoothMonotone === 'none' || !smoothMonotone) {
return drawNonMono.apply(this, arguments);
}
else {
return drawMono.apply(this, arguments);
}
}
|
Draw smoothed line in non-monotone, in may cause undesired curve in extreme
situations. This should be used when points are non-monotone neither in x or
y dimension.
|
drawSegment
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function drawMono(
ctx, points, start, segLen, allLen,
dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
) {
var prevIdx = 0;
var idx = start;
for (var k = 0; k < segLen; k++) {
var p = points[idx];
if (idx >= allLen || idx < 0) {
break;
}
if (isPointNull(p)) {
if (connectNulls) {
idx += dir;
continue;
}
break;
}
if (idx === start) {
ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
}
else {
if (smooth > 0) {
var prevP = points[prevIdx];
var dim = smoothMonotone === 'y' ? 1 : 0;
// Length of control point to p, either in x or y, but not both
var ctrlLen = (p[dim] - prevP[dim]) * smooth;
v2Copy(cp0, prevP);
cp0[dim] = prevP[dim] + ctrlLen;
v2Copy(cp1, p);
cp1[dim] = p[dim] - ctrlLen;
ctx.bezierCurveTo(
cp0[0], cp0[1],
cp1[0], cp1[1],
p[0], p[1]
);
}
else {
ctx.lineTo(p[0], p[1]);
}
}
prevIdx = idx;
idx += dir;
}
return k;
}
|
Draw smoothed line in non-monotone, in may cause undesired curve in extreme
situations. This should be used when points are non-monotone neither in x or
y dimension.
|
drawMono
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function drawNonMono(
ctx, points, start, segLen, allLen,
dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
) {
var prevIdx = 0;
var idx = start;
for (var k = 0; k < segLen; k++) {
var p = points[idx];
if (idx >= allLen || idx < 0) {
break;
}
if (isPointNull(p)) {
if (connectNulls) {
idx += dir;
continue;
}
break;
}
if (idx === start) {
ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
v2Copy(cp0, p);
}
else {
if (smooth > 0) {
var nextIdx = idx + dir;
var nextP = points[nextIdx];
if (connectNulls) {
// Find next point not null
while (nextP && isPointNull(points[nextIdx])) {
nextIdx += dir;
nextP = points[nextIdx];
}
}
var ratioNextSeg = 0.5;
var prevP = points[prevIdx];
var nextP = points[nextIdx];
// Last point
if (!nextP || isPointNull(nextP)) {
v2Copy(cp1, p);
}
else {
// If next data is null in not connect case
if (isPointNull(nextP) && !connectNulls) {
nextP = p;
}
sub(v, nextP, prevP);
var lenPrevSeg;
var lenNextSeg;
if (smoothMonotone === 'x' || smoothMonotone === 'y') {
var dim = smoothMonotone === 'x' ? 0 : 1;
lenPrevSeg = Math.abs(p[dim] - prevP[dim]);
lenNextSeg = Math.abs(p[dim] - nextP[dim]);
}
else {
lenPrevSeg = dist(p, prevP);
lenNextSeg = dist(p, nextP);
}
// Use ratio of seg length
ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
scaleAndAdd$1(cp1, p, v, -smooth * (1 - ratioNextSeg));
}
// Smooth constraint
vec2Min(cp0, cp0, smoothMax);
vec2Max(cp0, cp0, smoothMin);
vec2Min(cp1, cp1, smoothMax);
vec2Max(cp1, cp1, smoothMin);
ctx.bezierCurveTo(
cp0[0], cp0[1],
cp1[0], cp1[1],
p[0], p[1]
);
// cp0 of next segment
scaleAndAdd$1(cp0, p, v, smooth * ratioNextSeg);
}
else {
ctx.lineTo(p[0], p[1]);
}
}
prevIdx = idx;
idx += dir;
}
return k;
}
|
Draw smoothed line in non-monotone, in may cause undesired curve in extreme
situations. This should be used when points are non-monotone neither in x or
y dimension.
|
drawNonMono
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getBoundingBox(points, smoothConstraint) {
var ptMin = [Infinity, Infinity];
var ptMax = [-Infinity, -Infinity];
if (smoothConstraint) {
for (var i = 0; i < points.length; i++) {
var pt = points[i];
if (pt[0] < ptMin[0]) {
ptMin[0] = pt[0];
}
if (pt[1] < ptMin[1]) {
ptMin[1] = pt[1];
}
if (pt[0] > ptMax[0]) {
ptMax[0] = pt[0];
}
if (pt[1] > ptMax[1]) {
ptMax[1] = pt[1];
}
}
}
return {
min: smoothConstraint ? ptMin : ptMax,
max: smoothConstraint ? ptMax : ptMin
};
}
|
Draw smoothed line in non-monotone, in may cause undesired curve in extreme
situations. This should be used when points are non-monotone neither in x or
y dimension.
|
getBoundingBox
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function createGridClipPath(cartesian, hasAnimation, seriesModel) {
var rect = cartesian.getArea();
var isHorizontal = cartesian.getBaseAxis().isHorizontal();
var x = rect.x;
var y = rect.y;
var width = rect.width;
var height = rect.height;
var lineWidth = seriesModel.get('lineStyle.width') || 2;
// Expand the clip path a bit to avoid the border is clipped and looks thinner
x -= lineWidth / 2;
y -= lineWidth / 2;
width += lineWidth;
height += lineWidth;
var clipPath = new Rect({
shape: {
x: x,
y: y,
width: width,
height: height
}
});
if (hasAnimation) {
clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
initProps(clipPath, {
shape: {
width: width,
height: height
}
}, seriesModel);
}
return clipPath;
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
createGridClipPath
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function createPolarClipPath(polar, hasAnimation, seriesModel) {
var sectorArea = polar.getArea();
// Avoid float number rounding error for symbol on the edge of axis extent.
var clipPath = new Sector({
shape: {
cx: round$1(polar.cx, 1),
cy: round$1(polar.cy, 1),
r0: round$1(sectorArea.r0, 1),
r: round$1(sectorArea.r, 1),
startAngle: sectorArea.startAngle,
endAngle: sectorArea.endAngle,
clockwise: sectorArea.clockwise
}
});
if (hasAnimation) {
clipPath.shape.endAngle = sectorArea.startAngle;
initProps(clipPath, {
shape: {
endAngle: sectorArea.endAngle
}
}, seriesModel);
}
return clipPath;
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
createPolarClipPath
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function createClipPath(coordSys, hasAnimation, seriesModel) {
if (!coordSys) {
return null;
}
else if (coordSys.type === 'polar') {
return createPolarClipPath(coordSys, hasAnimation, seriesModel);
}
else if (coordSys.type === 'cartesian2d') {
return createGridClipPath(coordSys, hasAnimation, seriesModel);
}
return null;
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
createClipPath
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function isPointsSame(points1, points2) {
if (points1.length !== points2.length) {
return;
}
for (var i = 0; i < points1.length; i++) {
var p1 = points1[i];
var p2 = points2[i];
if (p1[0] !== p2[0] || p1[1] !== p2[1]) {
return;
}
}
return true;
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
isPointsSame
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getSmooth(smooth) {
return typeof (smooth) === 'number' ? smooth : (smooth ? 0.5 : 0);
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
getSmooth
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getStackedOnPoints(coordSys, data, dataCoordInfo) {
if (!dataCoordInfo.valueDim) {
return [];
}
var points = [];
for (var idx = 0, len = data.count(); idx < len; idx++) {
points.push(getStackedOnPoint(dataCoordInfo, coordSys, data, idx));
}
return points;
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
getStackedOnPoints
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function turnPointsIntoStep(points, coordSys, stepTurnAt) {
var baseAxis = coordSys.getBaseAxis();
var baseIndex = baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1;
var stepPoints = [];
for (var i = 0; i < points.length - 1; i++) {
var nextPt = points[i + 1];
var pt = points[i];
stepPoints.push(pt);
var stepPt = [];
switch (stepTurnAt) {
case 'end':
stepPt[baseIndex] = nextPt[baseIndex];
stepPt[1 - baseIndex] = pt[1 - baseIndex];
// default is start
stepPoints.push(stepPt);
break;
case 'middle':
// default is start
var middle = (pt[baseIndex] + nextPt[baseIndex]) / 2;
var stepPt2 = [];
stepPt[baseIndex] = stepPt2[baseIndex] = middle;
stepPt[1 - baseIndex] = pt[1 - baseIndex];
stepPt2[1 - baseIndex] = nextPt[1 - baseIndex];
stepPoints.push(stepPt);
stepPoints.push(stepPt2);
break;
default:
stepPt[baseIndex] = pt[baseIndex];
stepPt[1 - baseIndex] = nextPt[1 - baseIndex];
// default is start
stepPoints.push(stepPt);
}
}
// Last points
points[i] && stepPoints.push(points[i]);
return stepPoints;
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
turnPointsIntoStep
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getVisualGradient(data, coordSys) {
var visualMetaList = data.getVisual('visualMeta');
if (!visualMetaList || !visualMetaList.length || !data.count()) {
// When data.count() is 0, gradient range can not be calculated.
return;
}
if (coordSys.type !== 'cartesian2d') {
if (__DEV__) {
console.warn('Visual map on line style is only supported on cartesian2d.');
}
return;
}
var coordDim;
var visualMeta;
for (var i = visualMetaList.length - 1; i >= 0; i--) {
var dimIndex = visualMetaList[i].dimension;
var dimName = data.dimensions[dimIndex];
var dimInfo = data.getDimensionInfo(dimName);
coordDim = dimInfo && dimInfo.coordDim;
// Can only be x or y
if (coordDim === 'x' || coordDim === 'y') {
visualMeta = visualMetaList[i];
break;
}
}
if (!visualMeta) {
if (__DEV__) {
console.warn('Visual map on line style only support x or y dimension.');
}
return;
}
// If the area to be rendered is bigger than area defined by LinearGradient,
// the canvas spec prescribes that the color of the first stop and the last
// stop should be used. But if two stops are added at offset 0, in effect
// browsers use the color of the second stop to render area outside
// LinearGradient. So we can only infinitesimally extend area defined in
// LinearGradient to render `outerColors`.
var axis = coordSys.getAxis(coordDim);
// dataToCoor mapping may not be linear, but must be monotonic.
var colorStops = map(visualMeta.stops, function (stop) {
return {
coord: axis.toGlobalCoord(axis.dataToCoord(stop.value)),
color: stop.color
};
});
var stopLen = colorStops.length;
var outerColors = visualMeta.outerColors.slice();
if (stopLen && colorStops[0].coord > colorStops[stopLen - 1].coord) {
colorStops.reverse();
outerColors.reverse();
}
var tinyExtent = 10; // Arbitrary value: 10px
var minCoord = colorStops[0].coord - tinyExtent;
var maxCoord = colorStops[stopLen - 1].coord + tinyExtent;
var coordSpan = maxCoord - minCoord;
if (coordSpan < 1e-3) {
return 'transparent';
}
each$1(colorStops, function (stop) {
stop.offset = (stop.coord - minCoord) / coordSpan;
});
colorStops.push({
offset: stopLen ? colorStops[stopLen - 1].offset : 0.5,
color: outerColors[1] || 'transparent'
});
colorStops.unshift({ // notice colorStops.length have been changed.
offset: stopLen ? colorStops[0].offset : 0.5,
color: outerColors[0] || 'transparent'
});
// zrUtil.each(colorStops, function (colorStop) {
// // Make sure each offset has rounded px to avoid not sharp edge
// colorStop.offset = (Math.round(colorStop.offset * (end - start) + start) - start) / (end - start);
// });
var gradient = new LinearGradient(0, 0, 0, 0, colorStops, true);
gradient[coordDim] = minCoord;
gradient[coordDim + '2'] = maxCoord;
return gradient;
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
getVisualGradient
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getIsIgnoreFunc(seriesModel, data, coordSys) {
var showAllSymbol = seriesModel.get('showAllSymbol');
var isAuto = showAllSymbol === 'auto';
if (showAllSymbol && !isAuto) {
return;
}
var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
if (!categoryAxis) {
return;
}
// Note that category label interval strategy might bring some weird effect
// in some scenario: users may wonder why some of the symbols are not
// displayed. So we show all symbols as possible as we can.
if (isAuto
// Simplify the logic, do not determine label overlap here.
&& canShowAllSymbolForCategory(categoryAxis, data)
) {
return;
}
// Otherwise follow the label interval strategy on category axis.
var categoryDataDim = data.mapDimension(categoryAxis.dim);
var labelMap = {};
each$1(categoryAxis.getViewLabels(), function (labelItem) {
labelMap[labelItem.tickValue] = 1;
});
return function (dataIndex) {
return !labelMap.hasOwnProperty(data.get(categoryDataDim, dataIndex));
};
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
getIsIgnoreFunc
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function canShowAllSymbolForCategory(categoryAxis, data) {
// In mose cases, line is monotonous on category axis, and the label size
// is close with each other. So we check the symbol size and some of the
// label size alone with the category axis to estimate whether all symbol
// can be shown without overlap.
var axisExtent = categoryAxis.getExtent();
var availSize = Math.abs(axisExtent[1] - axisExtent[0]) / categoryAxis.scale.count();
isNaN(availSize) && (availSize = 0); // 0/0 is NaN.
// Sampling some points, max 5.
var dataLen = data.count();
var step = Math.max(1, Math.round(dataLen / 5));
for (var dataIndex = 0; dataIndex < dataLen; dataIndex += step) {
if (SymbolClz.getSymbolSize(
data, dataIndex
// Only for cartesian, where `isHorizontal` exists.
)[categoryAxis.isHorizontal() ? 1 : 0]
// Empirical number
* 1.5 > availSize
) {
return false;
}
}
return true;
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
canShowAllSymbolForCategory
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function createLineClipPath(coordSys, hasAnimation, seriesModel) {
if (coordSys.type === 'cartesian2d') {
var isHorizontal = coordSys.getBaseAxis().isHorizontal();
var clipPath = createGridClipPath(coordSys, hasAnimation, seriesModel);
// Expand clip shape to avoid clipping when line value exceeds axis
if (!seriesModel.get('clip', true)) {
var rectShape = clipPath.shape;
var expandSize = Math.max(rectShape.width, rectShape.height);
if (isHorizontal) {
rectShape.y -= expandSize;
rectShape.height += expandSize * 2;
}
else {
rectShape.x -= expandSize;
rectShape.width += expandSize * 2;
}
}
return clipPath;
}
else {
return createPolarClipPath(coordSys, hasAnimation, seriesModel);
}
}
|
@param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
@param {module:echarts/data/List} data
@param {Object} dataCoordInfo
@param {Array.<Array.<number>>} points
|
createLineClipPath
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
indexSampler = function (frame, value) {
return Math.round(frame.length / 2);
}
|
@abstract
@param {*} tick
@return {string} label of the tick.
|
indexSampler
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
dataSample = function (seriesType) {
return {
seriesType: seriesType,
modifyOutputEnd: true,
reset: function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var sampling = seriesModel.get('sampling');
var coordSys = seriesModel.coordinateSystem;
// Only cartesian2d support down sampling
if (coordSys.type === 'cartesian2d' && sampling) {
var baseAxis = coordSys.getBaseAxis();
var valueAxis = coordSys.getOtherAxis(baseAxis);
var extent = baseAxis.getExtent();
// Coordinste system has been resized
var size = extent[1] - extent[0];
var rate = Math.round(data.count() / size);
if (rate > 1) {
var sampler;
if (typeof sampling === 'string') {
sampler = samplers[sampling];
}
else if (typeof sampling === 'function') {
sampler = sampling;
}
if (sampler) {
// Only support sample the first dim mapped from value axis.
seriesModel.setData(data.downSample(
data.mapDimension(valueAxis.dim), 1 / rate, sampler, indexSampler
));
}
}
}
}
};
}
|
@abstract
@param {*} tick
@return {string} label of the tick.
|
dataSample
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function Scale(setting) {
this._setting = setting || {};
/**
* Extent
* @type {Array.<number>}
* @protected
*/
this._extent = [Infinity, -Infinity];
/**
* Step is calculated in adjustExtent
* @type {Array.<number>}
* @protected
*/
this._interval = 0;
this.init && this.init.apply(this, arguments);
}
|
@param {*} category
@return {number} The ordinal. If not found, return NaN.
|
Scale
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getOrCreateMap(ordinalMeta) {
return ordinalMeta._map || (
ordinalMeta._map = createHashMap(ordinalMeta.categories)
);
}
|
@param {number} interval
@return {number} interval precision
|
getOrCreateMap
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getName(obj) {
if (isObject$1(obj) && obj.value != null) {
return obj.value;
}
else {
return obj + '';
}
}
|
@param {number} interval
@return {number} interval precision
|
getName
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function intervalScaleNiceTicks(extent, splitNumber, minInterval, maxInterval) {
var result = {};
var span = extent[1] - extent[0];
var interval = result.interval = nice(span / splitNumber, true);
if (minInterval != null && interval < minInterval) {
interval = result.interval = minInterval;
}
if (maxInterval != null && interval > maxInterval) {
interval = result.interval = maxInterval;
}
// Tow more digital for tick.
var precision = result.intervalPrecision = getIntervalPrecision(interval);
// Niced extent inside original extent
var niceTickExtent = result.niceTickExtent = [
roundNumber$1(Math.ceil(extent[0] / interval) * interval, precision),
roundNumber$1(Math.floor(extent[1] / interval) * interval, precision)
];
fixExtent(niceTickExtent, extent);
return result;
}
|
@param {number} [splitNumber=5]
@return {Array.<Array.<number>>}
|
intervalScaleNiceTicks
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getIntervalPrecision(interval) {
// Tow more digital for tick.
return getPrecisionSafe(interval) + 2;
}
|
@param {number} [splitNumber=5]
@return {Array.<Array.<number>>}
|
getIntervalPrecision
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function clamp(niceTickExtent, idx, extent) {
niceTickExtent[idx] = Math.max(Math.min(niceTickExtent[idx], extent[1]), extent[0]);
}
|
@param {number} data
@param {Object} [opt]
@param {number|string} [opt.precision] If 'auto', use nice presision.
@param {boolean} [opt.pad] returns 1.50 but not 1.5 if precision is 2.
@return {string}
|
clamp
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function fixExtent(niceTickExtent, extent) {
!isFinite(niceTickExtent[0]) && (niceTickExtent[0] = extent[0]);
!isFinite(niceTickExtent[1]) && (niceTickExtent[1] = extent[1]);
clamp(niceTickExtent, 0, extent);
clamp(niceTickExtent, 1, extent);
if (niceTickExtent[0] > niceTickExtent[1]) {
niceTickExtent[0] = niceTickExtent[1];
}
}
|
@param {number} data
@param {Object} [opt]
@param {number|string} [opt.precision] If 'auto', use nice presision.
@param {boolean} [opt.pad] returns 1.50 but not 1.5 if precision is 2.
@return {string}
|
fixExtent
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getSeriesStackId(seriesModel) {
return seriesModel.get('stack') || STACK_PREFIX + seriesModel.seriesIndex;
}
|
Map from axis.index to values.
For a single time axis, axisValues is in the form like
{'x_0': [1495555200000, 1495641600000, 1495728000000]}.
Items in axisValues[x], e.g. 1495555200000, are time values of all
series.
|
getSeriesStackId
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getAxisKey(axis) {
return axis.dim + axis.index;
}
|
Map from axis.index to values.
For a single time axis, axisValues is in the form like
{'x_0': [1495555200000, 1495641600000, 1495728000000]}.
Items in axisValues[x], e.g. 1495555200000, are time values of all
series.
|
getAxisKey
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function prepareLayoutBarSeries(seriesType, ecModel) {
var seriesModels = [];
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
// Check series coordinate, do layout for cartesian2d only
if (isOnCartesian(seriesModel) && !isInLargeMode(seriesModel)) {
seriesModels.push(seriesModel);
}
});
return seriesModels;
}
|
Map from axis.index to values.
For a single time axis, axisValues is in the form like
{'x_0': [1495555200000, 1495641600000, 1495728000000]}.
Items in axisValues[x], e.g. 1495555200000, are time values of all
series.
|
prepareLayoutBarSeries
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getValueAxesMinGaps(barSeries) {
/**
* Map from axis.index to values.
* For a single time axis, axisValues is in the form like
* {'x_0': [1495555200000, 1495641600000, 1495728000000]}.
* Items in axisValues[x], e.g. 1495555200000, are time values of all
* series.
*/
var axisValues = {};
each$1(barSeries, function (seriesModel) {
var cartesian = seriesModel.coordinateSystem;
var baseAxis = cartesian.getBaseAxis();
if (baseAxis.type !== 'time' && baseAxis.type !== 'value') {
return;
}
var data = seriesModel.getData();
var key = baseAxis.dim + '_' + baseAxis.index;
var dim = data.mapDimension(baseAxis.dim);
for (var i = 0, cnt = data.count(); i < cnt; ++i) {
var value = data.get(dim, i);
if (!axisValues[key]) {
// No previous data for the axis
axisValues[key] = [value];
}
else {
// No value in previous series
axisValues[key].push(value);
}
// Ignore duplicated time values in the same axis
}
});
var axisMinGaps = [];
for (var key in axisValues) {
if (axisValues.hasOwnProperty(key)) {
var valuesInAxis = axisValues[key];
if (valuesInAxis) {
// Sort axis values into ascending order to calculate gaps
valuesInAxis.sort(function (a, b) {
return a - b;
});
var min = null;
for (var j = 1; j < valuesInAxis.length; ++j) {
var delta = valuesInAxis[j] - valuesInAxis[j - 1];
if (delta > 0) {
// Ignore 0 delta because they are of the same axis value
min = min === null ? delta : Math.min(min, delta);
}
}
// Set to null if only have one data
axisMinGaps[key] = min;
}
}
}
return axisMinGaps;
}
|
Map from axis.index to values.
For a single time axis, axisValues is in the form like
{'x_0': [1495555200000, 1495641600000, 1495728000000]}.
Items in axisValues[x], e.g. 1495555200000, are time values of all
series.
|
getValueAxesMinGaps
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeColumnLayout(barSeries) {
var axisMinGaps = getValueAxesMinGaps(barSeries);
var seriesInfoList = [];
each$1(barSeries, function (seriesModel) {
var cartesian = seriesModel.coordinateSystem;
var baseAxis = cartesian.getBaseAxis();
var axisExtent = baseAxis.getExtent();
var bandWidth;
if (baseAxis.type === 'category') {
bandWidth = baseAxis.getBandWidth();
}
else if (baseAxis.type === 'value' || baseAxis.type === 'time') {
var key = baseAxis.dim + '_' + baseAxis.index;
var minGap = axisMinGaps[key];
var extentSpan = Math.abs(axisExtent[1] - axisExtent[0]);
var scale = baseAxis.scale.getExtent();
var scaleSpan = Math.abs(scale[1] - scale[0]);
bandWidth = minGap
? extentSpan / scaleSpan * minGap
: extentSpan; // When there is only one data value
}
else {
var data = seriesModel.getData();
bandWidth = Math.abs(axisExtent[1] - axisExtent[0]) / data.count();
}
var barWidth = parsePercent$1(
seriesModel.get('barWidth'), bandWidth
);
var barMaxWidth = parsePercent$1(
seriesModel.get('barMaxWidth'), bandWidth
);
var barMinWidth = parsePercent$1(
// barMinWidth by default is 1 in cartesian. Because in value axis,
// the auto-calculated bar width might be less than 1.
seriesModel.get('barMinWidth') || 1, bandWidth
);
var barGap = seriesModel.get('barGap');
var barCategoryGap = seriesModel.get('barCategoryGap');
seriesInfoList.push({
bandWidth: bandWidth,
barWidth: barWidth,
barMaxWidth: barMaxWidth,
barMinWidth: barMinWidth,
barGap: barGap,
barCategoryGap: barCategoryGap,
axisKey: getAxisKey(baseAxis),
stackId: getSeriesStackId(seriesModel)
});
});
return doCalBarWidthAndOffset(seriesInfoList);
}
|
Map from axis.index to values.
For a single time axis, axisValues is in the form like
{'x_0': [1495555200000, 1495641600000, 1495728000000]}.
Items in axisValues[x], e.g. 1495555200000, are time values of all
series.
|
makeColumnLayout
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function doCalBarWidthAndOffset(seriesInfoList) {
// Columns info on each category axis. Key is cartesian name
var columnsMap = {};
each$1(seriesInfoList, function (seriesInfo, idx) {
var axisKey = seriesInfo.axisKey;
var bandWidth = seriesInfo.bandWidth;
var columnsOnAxis = columnsMap[axisKey] || {
bandWidth: bandWidth,
remainedWidth: bandWidth,
autoWidthCount: 0,
categoryGap: '20%',
gap: '30%',
stacks: {}
};
var stacks = columnsOnAxis.stacks;
columnsMap[axisKey] = columnsOnAxis;
var stackId = seriesInfo.stackId;
if (!stacks[stackId]) {
columnsOnAxis.autoWidthCount++;
}
stacks[stackId] = stacks[stackId] || {
width: 0,
maxWidth: 0
};
// Caution: In a single coordinate system, these barGrid attributes
// will be shared by series. Consider that they have default values,
// only the attributes set on the last series will work.
// Do not change this fact unless there will be a break change.
var barWidth = seriesInfo.barWidth;
if (barWidth && !stacks[stackId].width) {
// See #6312, do not restrict width.
stacks[stackId].width = barWidth;
barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
columnsOnAxis.remainedWidth -= barWidth;
}
var barMaxWidth = seriesInfo.barMaxWidth;
barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
var barMinWidth = seriesInfo.barMinWidth;
barMinWidth && (stacks[stackId].minWidth = barMinWidth);
var barGap = seriesInfo.barGap;
(barGap != null) && (columnsOnAxis.gap = barGap);
var barCategoryGap = seriesInfo.barCategoryGap;
(barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
});
var result = {};
each$1(columnsMap, function (columnsOnAxis, coordSysName) {
result[coordSysName] = {};
var stacks = columnsOnAxis.stacks;
var bandWidth = columnsOnAxis.bandWidth;
var categoryGap = parsePercent$1(columnsOnAxis.categoryGap, bandWidth);
var barGapPercent = parsePercent$1(columnsOnAxis.gap, 1);
var remainedWidth = columnsOnAxis.remainedWidth;
var autoWidthCount = columnsOnAxis.autoWidthCount;
var autoWidth = (remainedWidth - categoryGap)
/ (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
autoWidth = Math.max(autoWidth, 0);
// Find if any auto calculated bar exceeded maxBarWidth
each$1(stacks, function (column) {
var maxWidth = column.maxWidth;
var minWidth = column.minWidth;
if (!column.width) {
var finalWidth = autoWidth;
if (maxWidth && maxWidth < finalWidth) {
finalWidth = Math.min(maxWidth, remainedWidth);
}
// `minWidth` has higher priority. `minWidth` decide that wheter the
// bar is able to be visible. So `minWidth` should not be restricted
// by `maxWidth` or `remainedWidth` (which is from `bandWidth`). In
// the extreme cases for `value` axis, bars are allowed to overlap
// with each other if `minWidth` specified.
if (minWidth && minWidth > finalWidth) {
finalWidth = minWidth;
}
if (finalWidth !== autoWidth) {
column.width = finalWidth;
remainedWidth -= finalWidth + barGapPercent * finalWidth;
autoWidthCount--;
}
}
else {
// `barMinWidth/barMaxWidth` has higher priority than `barWidth`, as
// CSS does. Becuase barWidth can be a percent value, where
// `barMaxWidth` can be used to restrict the final width.
var finalWidth = column.width;
if (maxWidth) {
finalWidth = Math.min(finalWidth, maxWidth);
}
// `minWidth` has higher priority, as described above
if (minWidth) {
finalWidth = Math.max(finalWidth, minWidth);
}
column.width = finalWidth;
remainedWidth -= finalWidth + barGapPercent * finalWidth;
autoWidthCount--;
}
});
// Recalculate width again
autoWidth = (remainedWidth - categoryGap)
/ (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
autoWidth = Math.max(autoWidth, 0);
var widthSum = 0;
var lastColumn;
each$1(stacks, function (column, idx) {
if (!column.width) {
column.width = autoWidth;
}
lastColumn = column;
widthSum += column.width * (1 + barGapPercent);
});
if (lastColumn) {
widthSum -= lastColumn.width * barGapPercent;
}
var offset = -widthSum / 2;
each$1(stacks, function (column, stackId) {
result[coordSysName][stackId] = result[coordSysName][stackId] || {
bandWidth: bandWidth,
offset: offset,
width: column.width
};
offset += column.width * (1 + barGapPercent);
});
});
return result;
}
|
@param {Object} barWidthAndOffset The result of makeColumnLayout
@param {module:echarts/coord/Axis} axis
@param {module:echarts/model/Series} [seriesModel] If not provided, return all.
@return {Object} {stackId: {offset, width}} or {offset, width} if seriesModel provided.
|
doCalBarWidthAndOffset
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function retrieveColumnLayout(barWidthAndOffset, axis, seriesModel) {
if (barWidthAndOffset && axis) {
var result = barWidthAndOffset[getAxisKey(axis)];
if (result != null && seriesModel != null) {
result = result[getSeriesStackId(seriesModel)];
}
return result;
}
}
|
@param {string} seriesType
@param {module:echarts/model/Global} ecModel
|
retrieveColumnLayout
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function layout(seriesType, ecModel) {
var seriesModels = prepareLayoutBarSeries(seriesType, ecModel);
var barWidthAndOffset = makeColumnLayout(seriesModels);
var lastStackCoords = {};
each$1(seriesModels, function (seriesModel) {
var data = seriesModel.getData();
var cartesian = seriesModel.coordinateSystem;
var baseAxis = cartesian.getBaseAxis();
var stackId = getSeriesStackId(seriesModel);
var columnLayoutInfo = barWidthAndOffset[getAxisKey(baseAxis)][stackId];
var columnOffset = columnLayoutInfo.offset;
var columnWidth = columnLayoutInfo.width;
var valueAxis = cartesian.getOtherAxis(baseAxis);
var barMinHeight = seriesModel.get('barMinHeight') || 0;
lastStackCoords[stackId] = lastStackCoords[stackId] || [];
data.setLayout({
bandWidth: columnLayoutInfo.bandWidth,
offset: columnOffset,
size: columnWidth
});
var valueDim = data.mapDimension(valueAxis.dim);
var baseDim = data.mapDimension(baseAxis.dim);
var stacked = isDimensionStacked(data, valueDim /*, baseDim*/);
var isValueAxisH = valueAxis.isHorizontal();
var valueAxisStart = getValueAxisStart(baseAxis, valueAxis, stacked);
for (var idx = 0, len = data.count(); idx < len; idx++) {
var value = data.get(valueDim, idx);
var baseValue = data.get(baseDim, idx);
var sign = value >= 0 ? 'p' : 'n';
var baseCoord = valueAxisStart;
// Because of the barMinHeight, we can not use the value in
// stackResultDimension directly.
if (stacked) {
// Only ordinal axis can be stacked.
if (!lastStackCoords[stackId][baseValue]) {
lastStackCoords[stackId][baseValue] = {
p: valueAxisStart, // Positive stack
n: valueAxisStart // Negative stack
};
}
// Should also consider #4243
baseCoord = lastStackCoords[stackId][baseValue][sign];
}
var x;
var y;
var width;
var height;
if (isValueAxisH) {
var coord = cartesian.dataToPoint([value, baseValue]);
x = baseCoord;
y = coord[1] + columnOffset;
width = coord[0] - valueAxisStart;
height = columnWidth;
if (Math.abs(width) < barMinHeight) {
width = (width < 0 ? -1 : 1) * barMinHeight;
}
// Ignore stack from NaN value
if (!isNaN(width)) {
stacked && (lastStackCoords[stackId][baseValue][sign] += width);
}
}
else {
var coord = cartesian.dataToPoint([baseValue, value]);
x = coord[0] + columnOffset;
y = baseCoord;
width = columnWidth;
height = coord[1] - valueAxisStart;
if (Math.abs(height) < barMinHeight) {
// Include zero to has a positive bar
height = (height <= 0 ? -1 : 1) * barMinHeight;
}
// Ignore stack from NaN value
if (!isNaN(height)) {
stacked && (lastStackCoords[stackId][baseValue][sign] += height);
}
}
data.setItemLayout(idx, {
x: x,
y: y,
width: width,
height: height
});
}
}, this);
}
|
@param {string} seriesType
@param {module:echarts/model/Global} ecModel
|
layout
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
bisect = function (a, x, lo, hi) {
while (lo < hi) {
var mid = lo + hi >>> 1;
if (a[mid][1] < x) {
lo = mid + 1;
}
else {
hi = mid;
}
}
return lo;
}
|
@param {module:echarts/model/Model}
@return {module:echarts/scale/Time}
|
bisect
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function fixRoundingError(val, originalVal) {
return roundingErrorFix(val, getPrecisionSafe$1(originalVal));
}
|
Get axis scale extent before niced.
Item of returned array can only be number (including Infinity and NaN).
|
fixRoundingError
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getScaleExtent(scale, model) {
var scaleType = scale.type;
var min = model.getMin();
var max = model.getMax();
var fixMin = min != null;
var fixMax = max != null;
var originalExtent = scale.getExtent();
var axisDataLen;
var boundaryGap;
var span;
if (scaleType === 'ordinal') {
axisDataLen = model.getCategories().length;
}
else {
boundaryGap = model.get('boundaryGap');
if (!isArray(boundaryGap)) {
boundaryGap = [boundaryGap || 0, boundaryGap || 0];
}
if (typeof boundaryGap[0] === 'boolean') {
if (__DEV__) {
console.warn('Boolean type for boundaryGap is only '
+ 'allowed for ordinal axis. Please use string in '
+ 'percentage instead, e.g., "20%". Currently, '
+ 'boundaryGap is set to be 0.');
}
boundaryGap = [0, 0];
}
boundaryGap[0] = parsePercent$1(boundaryGap[0], 1);
boundaryGap[1] = parsePercent$1(boundaryGap[1], 1);
span = (originalExtent[1] - originalExtent[0])
|| Math.abs(originalExtent[0]);
}
// Notice: When min/max is not set (that is, when there are null/undefined,
// which is the most common case), these cases should be ensured:
// (1) For 'ordinal', show all axis.data.
// (2) For others:
// + `boundaryGap` is applied (if min/max set, boundaryGap is
// disabled).
// + If `needCrossZero`, min/max should be zero, otherwise, min/max should
// be the result that originalExtent enlarged by boundaryGap.
// (3) If no data, it should be ensured that `scale.setBlank` is set.
// FIXME
// (1) When min/max is 'dataMin' or 'dataMax', should boundaryGap be able to used?
// (2) When `needCrossZero` and all data is positive/negative, should it be ensured
// that the results processed by boundaryGap are positive/negative?
if (min == null) {
min = scaleType === 'ordinal'
? (axisDataLen ? 0 : NaN)
: originalExtent[0] - boundaryGap[0] * span;
}
if (max == null) {
max = scaleType === 'ordinal'
? (axisDataLen ? axisDataLen - 1 : NaN)
: originalExtent[1] + boundaryGap[1] * span;
}
if (min === 'dataMin') {
min = originalExtent[0];
}
else if (typeof min === 'function') {
min = min({
min: originalExtent[0],
max: originalExtent[1]
});
}
if (max === 'dataMax') {
max = originalExtent[1];
}
else if (typeof max === 'function') {
max = max({
min: originalExtent[0],
max: originalExtent[1]
});
}
(min == null || !isFinite(min)) && (min = NaN);
(max == null || !isFinite(max)) && (max = NaN);
scale.setBlank(
eqNaN(min)
|| eqNaN(max)
|| (scaleType === 'ordinal' && !scale.getOrdinalMeta().categories.length)
);
// Evaluate if axis needs cross zero
if (model.getNeedCrossZero()) {
// Axis is over zero and min is not set
if (min > 0 && max > 0 && !fixMin) {
min = 0;
}
// Axis is under zero and max is not set
if (min < 0 && max < 0 && !fixMax) {
max = 0;
}
}
// If bars are placed on a base axis of type time or interval account for axis boundary overflow and current axis
// is base axis
// FIXME
// (1) Consider support value axis, where below zero and axis `onZero` should be handled properly.
// (2) Refactor the logic with `barGrid`. Is it not need to `makeBarWidthAndOffsetInfo` twice with different extent?
// Should not depend on series type `bar`?
// (3) Fix that might overlap when using dataZoom.
// (4) Consider other chart types using `barGrid`?
// See #6728, #4862, `test/bar-overflow-time-plot.html`
var ecModel = model.ecModel;
if (ecModel && (scaleType === 'time' /*|| scaleType === 'interval' */)) {
var barSeriesModels = prepareLayoutBarSeries('bar', ecModel);
var isBaseAxisAndHasBarSeries;
each$1(barSeriesModels, function (seriesModel) {
isBaseAxisAndHasBarSeries |= seriesModel.getBaseAxis() === model.axis;
});
if (isBaseAxisAndHasBarSeries) {
// Calculate placement of bars on axis
var barWidthAndOffset = makeColumnLayout(barSeriesModels);
// Adjust axis min and max to account for overflow
var adjustedScale = adjustScaleForOverflow(min, max, model, barWidthAndOffset);
min = adjustedScale.min;
max = adjustedScale.max;
}
}
return [min, max];
}
|
Get axis scale extent before niced.
Item of returned array can only be number (including Infinity and NaN).
|
getScaleExtent
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function adjustScaleForOverflow(min, max, model, barWidthAndOffset) {
// Get Axis Length
var axisExtent = model.axis.getExtent();
var axisLength = axisExtent[1] - axisExtent[0];
// Get bars on current base axis and calculate min and max overflow
var barsOnCurrentAxis = retrieveColumnLayout(barWidthAndOffset, model.axis);
if (barsOnCurrentAxis === undefined) {
return {min: min, max: max};
}
var minOverflow = Infinity;
each$1(barsOnCurrentAxis, function (item) {
minOverflow = Math.min(item.offset, minOverflow);
});
var maxOverflow = -Infinity;
each$1(barsOnCurrentAxis, function (item) {
maxOverflow = Math.max(item.offset + item.width, maxOverflow);
});
minOverflow = Math.abs(minOverflow);
maxOverflow = Math.abs(maxOverflow);
var totalOverFlow = minOverflow + maxOverflow;
// Calulate required buffer based on old range and overflow
var oldRange = max - min;
var oldRangePercentOfNew = (1 - (minOverflow + maxOverflow) / axisLength);
var overflowBuffer = ((oldRange / oldRangePercentOfNew) - oldRange);
max += overflowBuffer * (maxOverflow / totalOverFlow);
min -= overflowBuffer * (minOverflow / totalOverFlow);
return {min: min, max: max};
}
|
@param {module:echarts/coord/Axis} axis
@return {module:zrender/core/BoundingRect} Be null/undefined if no labels.
|
adjustScaleForOverflow
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function niceScaleExtent(scale, model) {
var extent = getScaleExtent(scale, model);
var fixMin = model.getMin() != null;
var fixMax = model.getMax() != null;
var splitNumber = model.get('splitNumber');
if (scale.type === 'log') {
scale.base = model.get('logBase');
}
var scaleType = scale.type;
scale.setExtent(extent[0], extent[1]);
scale.niceExtent({
splitNumber: splitNumber,
fixMin: fixMin,
fixMax: fixMax,
minInterval: (scaleType === 'interval' || scaleType === 'time')
? model.get('minInterval') : null,
maxInterval: (scaleType === 'interval' || scaleType === 'time')
? model.get('maxInterval') : null
});
// If some one specified the min, max. And the default calculated interval
// is not good enough. He can specify the interval. It is often appeared
// in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
// to be 60.
// FIXME
var interval = model.get('interval');
if (interval != null) {
scale.setInterval && scale.setInterval(interval);
}
}
|
@param {module:echarts/coord/Axis} axis
@return {module:zrender/core/BoundingRect} Be null/undefined if no labels.
|
niceScaleExtent
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function createScaleByModel(model, axisType) {
axisType = axisType || model.get('type');
if (axisType) {
switch (axisType) {
// Buildin scale
case 'category':
return new OrdinalScale(
model.getOrdinalMeta
? model.getOrdinalMeta()
: model.getCategories(),
[Infinity, -Infinity]
);
case 'value':
return new IntervalScale();
// Extended scale, like time and log
default:
return (Scale.getClass(axisType) || IntervalScale).create(model);
}
}
}
|
Set `categoryInterval` as 0 implicitly indicates that
show all labels reguardless of overlap.
@param {Object} axis axisModel.axis
@return {boolean}
|
createScaleByModel
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeLabelFormatter(axis) {
var labelFormatter = axis.getLabelModel().get('formatter');
var categoryTickStart = axis.type === 'category' ? axis.scale.getExtent()[0] : null;
if (typeof labelFormatter === 'string') {
labelFormatter = (function (tpl) {
return function (val) {
// For category axis, get raw value; for numeric axis,
// get foramtted label like '1,333,444'.
val = axis.scale.getLabel(val);
return tpl.replace('{value}', val != null ? val : '');
};
})(labelFormatter);
// Consider empty array
return labelFormatter;
}
else if (typeof labelFormatter === 'function') {
return function (tickValue, idx) {
// The original intention of `idx` is "the index of the tick in all ticks".
// But the previous implementation of category axis do not consider the
// `axisLabel.interval`, which cause that, for example, the `interval` is
// `1`, then the ticks "name5", "name7", "name9" are displayed, where the
// corresponding `idx` are `0`, `2`, `4`, but not `0`, `1`, `2`. So we keep
// the definition here for back compatibility.
if (categoryTickStart != null) {
idx = tickValue - categoryTickStart;
}
return labelFormatter(getAxisRawValue(axis, tickValue), idx);
};
}
else {
return function (tick) {
return axis.scale.getLabel(tick);
};
}
}
|
Get axes list
@return {Array.<module:echarts/coord/Cartesian~Axis>}
|
makeLabelFormatter
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getAxisRawValue(axis, value) {
// In category axis with data zoom, tick is not the original
// index of axis.data. So tick should not be exposed to user
// in category axis.
return axis.type === 'category' ? axis.scale.getLabel(value) : value;
}
|
Convert coord in nd space to data
@param {Array.<number>|Object.<string, number>} val
@return {Array.<number>|Object.<string, number>}
|
getAxisRawValue
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function estimateLabelUnionRect(axis) {
var axisModel = axis.model;
var scale = axis.scale;
if (!axisModel.get('axisLabel.show') || scale.isBlank()) {
return;
}
var isCategory = axis.type === 'category';
var realNumberScaleTicks;
var tickCount;
var categoryScaleExtent = scale.getExtent();
// Optimize for large category data, avoid call `getTicks()`.
if (isCategory) {
tickCount = scale.count();
}
else {
realNumberScaleTicks = scale.getTicks();
tickCount = realNumberScaleTicks.length;
}
var axisLabelModel = axis.getLabelModel();
var labelFormatter = makeLabelFormatter(axis);
var rect;
var step = 1;
// Simple optimization for large amount of labels
if (tickCount > 40) {
step = Math.ceil(tickCount / 40);
}
for (var i = 0; i < tickCount; i += step) {
var tickValue = realNumberScaleTicks ? realNumberScaleTicks[i] : categoryScaleExtent[0] + i;
var label = labelFormatter(tickValue);
var unrotatedSingleRect = axisLabelModel.getTextRect(label);
var singleRect = rotateTextRect(unrotatedSingleRect, axisLabelModel.get('rotate') || 0);
rect ? rect.union(singleRect) : (rect = singleRect);
}
return rect;
}
|
Convert coord in nd space to data
@param {Array.<number>|Object.<string, number>} val
@return {Array.<number>|Object.<string, number>}
|
estimateLabelUnionRect
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function rotateTextRect(textRect, rotate) {
var rotateRadians = rotate * Math.PI / 180;
var boundingBox = textRect.plain();
var beforeWidth = boundingBox.width;
var beforeHeight = boundingBox.height;
var afterWidth = beforeWidth * Math.cos(rotateRadians) + beforeHeight * Math.sin(rotateRadians);
var afterHeight = beforeWidth * Math.sin(rotateRadians) + beforeHeight * Math.cos(rotateRadians);
var rotatedRect = new BoundingRect(boundingBox.x, boundingBox.y, afterWidth, afterHeight);
return rotatedRect;
}
|
If contain data
@param {Array.<number>} data
@return {boolean}
|
rotateTextRect
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getOptionCategoryInterval(model) {
var interval = model.get('interval');
return interval == null ? 'auto' : interval;
}
|
@param {Array.<number>} data
@param {Array.<number>} out
@return {Array.<number>}
|
getOptionCategoryInterval
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function shouldShowAllLabels(axis) {
return axis.type === 'category'
&& getOptionCategoryInterval(axis.getLabelModel()) === 0;
}
|
@param {Array.<number>} data
@param {Array.<number>} out
@return {Array.<number>}
|
shouldShowAllLabels
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function dimAxisMapper(dim) {
return this._axes[dim];
}
|
Get other axis
@param {module:echarts/coord/cartesian/Axis2D} axis
|
dimAxisMapper
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
Cartesian = function (name) {
this._axes = {};
this._dimList = [];
/**
* @type {string}
*/
this.name = name || '';
}
|
Get rect area of cartesian.
Area will have a contain function to determine if a point is in the coordinate system.
@return {BoundingRect}
|
Cartesian
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function Cartesian2D(name) {
Cartesian.call(this, name);
}
|
@param {module:echats/coord/Axis} axis
@param {module:echarts/model/Model} tickModel For example, can be axisTick, splitLine, splitArea.
@return {Object} {
ticks: Array.<number>
tickCategoryInterval: number
}
|
Cartesian2D
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function createAxisLabels(axis) {
// Only ordinal scale support tick interval
return axis.type === 'category'
? makeCategoryLabels(axis)
: makeRealNumberLabels(axis);
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
createAxisLabels
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function createAxisTicks(axis, tickModel) {
// Only ordinal scale support tick interval
return axis.type === 'category'
? makeCategoryTicks(axis, tickModel)
: {ticks: axis.scale.getTicks()};
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
createAxisTicks
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeCategoryLabels(axis) {
var labelModel = axis.getLabelModel();
var result = makeCategoryLabelsActually(axis, labelModel);
return (!labelModel.get('show') || axis.scale.isBlank())
? {labels: [], labelCategoryInterval: result.labelCategoryInterval}
: result;
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
makeCategoryLabels
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeCategoryLabelsActually(axis, labelModel) {
var labelsCache = getListCache(axis, 'labels');
var optionLabelInterval = getOptionCategoryInterval(labelModel);
var result = listCacheGet(labelsCache, optionLabelInterval);
if (result) {
return result;
}
var labels;
var numericLabelInterval;
if (isFunction$1(optionLabelInterval)) {
labels = makeLabelsByCustomizedCategoryInterval(axis, optionLabelInterval);
}
else {
numericLabelInterval = optionLabelInterval === 'auto'
? makeAutoCategoryInterval(axis) : optionLabelInterval;
labels = makeLabelsByNumericCategoryInterval(axis, numericLabelInterval);
}
// Cache to avoid calling interval function repeatly.
return listCacheSet(labelsCache, optionLabelInterval, {
labels: labels, labelCategoryInterval: numericLabelInterval
});
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
makeCategoryLabelsActually
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeCategoryTicks(axis, tickModel) {
var ticksCache = getListCache(axis, 'ticks');
var optionTickInterval = getOptionCategoryInterval(tickModel);
var result = listCacheGet(ticksCache, optionTickInterval);
if (result) {
return result;
}
var ticks;
var tickCategoryInterval;
// Optimize for the case that large category data and no label displayed,
// we should not return all ticks.
if (!tickModel.get('show') || axis.scale.isBlank()) {
ticks = [];
}
if (isFunction$1(optionTickInterval)) {
ticks = makeLabelsByCustomizedCategoryInterval(axis, optionTickInterval, true);
}
// Always use label interval by default despite label show. Consider this
// scenario, Use multiple grid with the xAxis sync, and only one xAxis shows
// labels. `splitLine` and `axisTick` should be consistent in this case.
else if (optionTickInterval === 'auto') {
var labelsResult = makeCategoryLabelsActually(axis, axis.getLabelModel());
tickCategoryInterval = labelsResult.labelCategoryInterval;
ticks = map(labelsResult.labels, function (labelItem) {
return labelItem.tickValue;
});
}
else {
tickCategoryInterval = optionTickInterval;
ticks = makeLabelsByNumericCategoryInterval(axis, tickCategoryInterval, true);
}
// Cache to avoid calling interval function repeatly.
return listCacheSet(ticksCache, optionTickInterval, {
ticks: ticks, tickCategoryInterval: tickCategoryInterval
});
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
makeCategoryTicks
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeRealNumberLabels(axis) {
var ticks = axis.scale.getTicks();
var labelFormatter = makeLabelFormatter(axis);
return {
labels: map(ticks, function (tickValue, idx) {
return {
formattedLabel: labelFormatter(tickValue, idx),
rawLabel: axis.scale.getLabel(tickValue),
tickValue: tickValue
};
})
};
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
makeRealNumberLabels
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function getListCache(axis, prop) {
// Because key can be funciton, and cache size always be small, we use array cache.
return inner$6(axis)[prop] || (inner$6(axis)[prop] = []);
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
getListCache
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function listCacheGet(cache, key) {
for (var i = 0; i < cache.length; i++) {
if (cache[i].key === key) {
return cache[i].value;
}
}
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
listCacheGet
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function listCacheSet(cache, key, value) {
cache.push({key: key, value: value});
return value;
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
listCacheSet
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeAutoCategoryInterval(axis) {
var result = inner$6(axis).autoInterval;
return result != null
? result
: (inner$6(axis).autoInterval = axis.calculateCategoryInterval());
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
makeAutoCategoryInterval
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function calculateCategoryInterval(axis) {
var params = fetchAutoCategoryIntervalCalculationParams(axis);
var labelFormatter = makeLabelFormatter(axis);
var rotation = (params.axisRotate - params.labelRotate) / 180 * Math.PI;
var ordinalScale = axis.scale;
var ordinalExtent = ordinalScale.getExtent();
// Providing this method is for optimization:
// avoid generating a long array by `getTicks`
// in large category data case.
var tickCount = ordinalScale.count();
if (ordinalExtent[1] - ordinalExtent[0] < 1) {
return 0;
}
var step = 1;
// Simple optimization. Empirical value: tick count should less than 40.
if (tickCount > 40) {
step = Math.max(1, Math.floor(tickCount / 40));
}
var tickValue = ordinalExtent[0];
var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
var unitW = Math.abs(unitSpan * Math.cos(rotation));
var unitH = Math.abs(unitSpan * Math.sin(rotation));
var maxW = 0;
var maxH = 0;
// Caution: Performance sensitive for large category data.
// Consider dataZoom, we should make appropriate step to avoid O(n) loop.
for (; tickValue <= ordinalExtent[1]; tickValue += step) {
var width = 0;
var height = 0;
// Not precise, do not consider align and vertical align
// and each distance from axis line yet.
var rect = getBoundingRect(
labelFormatter(tickValue), params.font, 'center', 'top'
);
// Magic number
width = rect.width * 1.3;
height = rect.height * 1.3;
// Min size, void long loop.
maxW = Math.max(maxW, width, 7);
maxH = Math.max(maxH, height, 7);
}
var dw = maxW / unitW;
var dh = maxH / unitH;
// 0/0 is NaN, 1/0 is Infinity.
isNaN(dw) && (dw = Infinity);
isNaN(dh) && (dh = Infinity);
var interval = Math.max(0, Math.floor(Math.min(dw, dh)));
var cache = inner$6(axis.model);
var axisExtent = axis.getExtent();
var lastAutoInterval = cache.lastAutoInterval;
var lastTickCount = cache.lastTickCount;
// Use cache to keep interval stable while moving zoom window,
// otherwise the calculated interval might jitter when the zoom
// window size is close to the interval-changing size.
// For example, if all of the axis labels are `a, b, c, d, e, f, g`.
// The jitter will cause that sometimes the displayed labels are
// `a, d, g` (interval: 2) sometimes `a, c, e`(interval: 1).
if (lastAutoInterval != null
&& lastTickCount != null
&& Math.abs(lastAutoInterval - interval) <= 1
&& Math.abs(lastTickCount - tickCount) <= 1
// Always choose the bigger one, otherwise the critical
// point is not the same when zooming in or zooming out.
&& lastAutoInterval > interval
// If the axis change is caused by chart resize, the cache should not
// be used. Otherwise some hiden labels might not be shown again.
&& cache.axisExtend0 === axisExtent[0]
&& cache.axisExtend1 === axisExtent[1]
) {
interval = lastAutoInterval;
}
// Only update cache if cache not used, otherwise the
// changing of interval is too insensitive.
else {
cache.lastTickCount = tickCount;
cache.lastAutoInterval = interval;
cache.axisExtend0 = axisExtent[0];
cache.axisExtend1 = axisExtent[1];
}
return interval;
}
|
Calculate interval for category axis ticks and labels.
To get precise result, at least one of `getRotate` and `isHorizontal`
should be implemented in axis.
|
calculateCategoryInterval
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function fetchAutoCategoryIntervalCalculationParams(axis) {
var labelModel = axis.getLabelModel();
return {
axisRotate: axis.getRotate
? axis.getRotate()
: (axis.isHorizontal && !axis.isHorizontal())
? 90
: 0,
labelRotate: labelModel.get('rotate') || 0,
font: labelModel.getFont()
};
}
|
Set coord extent
@param {number} start
@param {number} end
|
fetchAutoCategoryIntervalCalculationParams
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeLabelsByNumericCategoryInterval(axis, categoryInterval, onlyTick) {
var labelFormatter = makeLabelFormatter(axis);
var ordinalScale = axis.scale;
var ordinalExtent = ordinalScale.getExtent();
var labelModel = axis.getLabelModel();
var result = [];
// TODO: axisType: ordinalTime, pick the tick from each month/day/year/...
var step = Math.max((categoryInterval || 0) + 1, 1);
var startTick = ordinalExtent[0];
var tickCount = ordinalScale.count();
// Calculate start tick based on zero if possible to keep label consistent
// while zooming and moving while interval > 0. Otherwise the selection
// of displayable ticks and symbols probably keep changing.
// 3 is empirical value.
if (startTick !== 0 && step > 1 && tickCount / step > 2) {
startTick = Math.round(Math.ceil(startTick / step) * step);
}
// (1) Only add min max label here but leave overlap checking
// to render stage, which also ensure the returned list
// suitable for splitLine and splitArea rendering.
// (2) Scales except category always contain min max label so
// do not need to perform this process.
var showAllLabel = shouldShowAllLabels(axis);
var includeMinLabel = labelModel.get('showMinLabel') || showAllLabel;
var includeMaxLabel = labelModel.get('showMaxLabel') || showAllLabel;
if (includeMinLabel && startTick !== ordinalExtent[0]) {
addItem(ordinalExtent[0]);
}
// Optimize: avoid generating large array by `ordinalScale.getTicks()`.
var tickValue = startTick;
for (; tickValue <= ordinalExtent[1]; tickValue += step) {
addItem(tickValue);
}
if (includeMaxLabel && tickValue - step !== ordinalExtent[1]) {
addItem(ordinalExtent[1]);
}
function addItem(tVal) {
result.push(onlyTick
? tVal
: {
formattedLabel: labelFormatter(tVal),
rawLabel: ordinalScale.getLabel(tVal),
tickValue: tVal
}
);
}
return result;
}
|
Convert data to coord. Data is the rank if it has an ordinal scale
@param {number} data
@param {boolean} clamp
@return {number}
|
makeLabelsByNumericCategoryInterval
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function addItem(tVal) {
result.push(onlyTick
? tVal
: {
formattedLabel: labelFormatter(tVal),
rawLabel: ordinalScale.getLabel(tVal),
tickValue: tVal
}
);
}
|
Different from `zrUtil.map(axis.getTicks(), axis.dataToCoord, axis)`,
`axis.getTicksCoords` considers `onBand`, which is used by
`boundaryGap:true` of category axis and splitLine and splitArea.
@param {Object} [opt]
@param {Model} [opt.tickModel=axis.model.getModel('axisTick')]
@param {boolean} [opt.clamp] If `true`, the first and the last
tick must be at the axis end points. Otherwise, clip ticks
that outside the axis extent.
@return {Array.<Object>} [{
coord: ...,
tickValue: ...
}, ...]
|
addItem
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick) {
var ordinalScale = axis.scale;
var labelFormatter = makeLabelFormatter(axis);
var result = [];
each$1(ordinalScale.getTicks(), function (tickValue) {
var rawLabel = ordinalScale.getLabel(tickValue);
if (categoryInterval(tickValue, rawLabel)) {
result.push(onlyTick
? tickValue
: {
formattedLabel: labelFormatter(tickValue),
rawLabel: rawLabel,
tickValue: tickValue
}
);
}
});
return result;
}
|
Different from `zrUtil.map(axis.getTicks(), axis.dataToCoord, axis)`,
`axis.getTicksCoords` considers `onBand`, which is used by
`boundaryGap:true` of category axis and splitLine and splitArea.
@param {Object} [opt]
@param {Model} [opt.tickModel=axis.model.getModel('axisTick')]
@param {boolean} [opt.clamp] If `true`, the first and the last
tick must be at the axis end points. Otherwise, clip ticks
that outside the axis extent.
@return {Array.<Object>} [{
coord: ...,
tickValue: ...
}, ...]
|
makeLabelsByCustomizedCategoryInterval
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
Axis = function (dim, scale, extent) {
/**
* Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'.
* @type {string}
*/
this.dim = dim;
/**
* Axis scale
* @type {module:echarts/coord/scale/*}
*/
this.scale = scale;
/**
* @type {Array.<number>}
* @private
*/
this._extent = extent || [0, 0];
/**
* @type {boolean}
*/
this.inverse = false;
/**
* Usually true when axis has a ordinal scale
* @type {boolean}
*/
this.onBand = false;
}
|
@return {module:echarts/coord/model/Model}
|
Axis
|
javascript
|
douyu/juno
|
assets/public/js/echarts/v4.7.0/echarts.simple.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts.simple.js
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.