id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
200 | apache/incubator-echarts | src/util/symbol.js | symbolPathSetColor | function symbolPathSetColor(color, innerColor) {
if (this.type !== 'image') {
var symbolStyle = this.style;
var symbolShape = this.shape;
if (symbolShape && symbolShape.symbolType === 'line') {
symbolStyle.stroke = color;
}
else if (this.__isEmptyBrush) {
symbolStyle.stroke = color;
symbolStyle.fill = innerColor || '#fff';
}
else {
// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
symbolStyle.fill && (symbolStyle.fill = color);
symbolStyle.stroke && (symbolStyle.stroke = color);
}
this.dirty(false);
}
} | javascript | function symbolPathSetColor(color, innerColor) {
if (this.type !== 'image') {
var symbolStyle = this.style;
var symbolShape = this.shape;
if (symbolShape && symbolShape.symbolType === 'line') {
symbolStyle.stroke = color;
}
else if (this.__isEmptyBrush) {
symbolStyle.stroke = color;
symbolStyle.fill = innerColor || '#fff';
}
else {
// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
symbolStyle.fill && (symbolStyle.fill = color);
symbolStyle.stroke && (symbolStyle.stroke = color);
}
this.dirty(false);
}
} | [
"function",
"symbolPathSetColor",
"(",
"color",
",",
"innerColor",
")",
"{",
"if",
"(",
"this",
".",
"type",
"!==",
"'image'",
")",
"{",
"var",
"symbolStyle",
"=",
"this",
".",
"style",
";",
"var",
"symbolShape",
"=",
"this",
".",
"shape",
";",
"if",
"(",
"symbolShape",
"&&",
"symbolShape",
".",
"symbolType",
"===",
"'line'",
")",
"{",
"symbolStyle",
".",
"stroke",
"=",
"color",
";",
"}",
"else",
"if",
"(",
"this",
".",
"__isEmptyBrush",
")",
"{",
"symbolStyle",
".",
"stroke",
"=",
"color",
";",
"symbolStyle",
".",
"fill",
"=",
"innerColor",
"||",
"'#fff'",
";",
"}",
"else",
"{",
"// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?",
"symbolStyle",
".",
"fill",
"&&",
"(",
"symbolStyle",
".",
"fill",
"=",
"color",
")",
";",
"symbolStyle",
".",
"stroke",
"&&",
"(",
"symbolStyle",
".",
"stroke",
"=",
"color",
")",
";",
"}",
"this",
".",
"dirty",
"(",
"false",
")",
";",
"}",
"}"
] | Provide setColor helper method to avoid determine if set the fill or stroke outside | [
"Provide",
"setColor",
"helper",
"method",
"to",
"avoid",
"determine",
"if",
"set",
"the",
"fill",
"or",
"stroke",
"outside"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/util/symbol.js#L301-L319 |
201 | apache/incubator-echarts | build/amd2common.js | parse | function parse(raw) {
var output = '';
var ast = esprima.parse(raw, {
range: true,
raw: true
});
var defines = ast.body.filter(isDefine);
if (defines.length > 1) {
throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
}
else if (!defines.length) {
return raw;
}
var def = defines[0];
var args = def.expression['arguments'];
var factory = getFactory(args);
var useStrict = getUseStrict(factory);
// do replacements in-place to avoid modifying the code more than needed
if (useStrict) {
output += useStrict.expression.raw + ';\n';
}
output += raw.substring(0, def.range[0]); // anything before define
output += getRequires(args, factory); // add requires
output += getBody(raw, factory.body, useStrict); // module body
output += raw.substring(def.range[1], raw.length); // anything after define
return output;
} | javascript | function parse(raw) {
var output = '';
var ast = esprima.parse(raw, {
range: true,
raw: true
});
var defines = ast.body.filter(isDefine);
if (defines.length > 1) {
throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
}
else if (!defines.length) {
return raw;
}
var def = defines[0];
var args = def.expression['arguments'];
var factory = getFactory(args);
var useStrict = getUseStrict(factory);
// do replacements in-place to avoid modifying the code more than needed
if (useStrict) {
output += useStrict.expression.raw + ';\n';
}
output += raw.substring(0, def.range[0]); // anything before define
output += getRequires(args, factory); // add requires
output += getBody(raw, factory.body, useStrict); // module body
output += raw.substring(def.range[1], raw.length); // anything after define
return output;
} | [
"function",
"parse",
"(",
"raw",
")",
"{",
"var",
"output",
"=",
"''",
";",
"var",
"ast",
"=",
"esprima",
".",
"parse",
"(",
"raw",
",",
"{",
"range",
":",
"true",
",",
"raw",
":",
"true",
"}",
")",
";",
"var",
"defines",
"=",
"ast",
".",
"body",
".",
"filter",
"(",
"isDefine",
")",
";",
"if",
"(",
"defines",
".",
"length",
">",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Each file can have only a single define call. Found \"'",
"+",
"defines",
".",
"length",
"+",
"'\"'",
")",
";",
"}",
"else",
"if",
"(",
"!",
"defines",
".",
"length",
")",
"{",
"return",
"raw",
";",
"}",
"var",
"def",
"=",
"defines",
"[",
"0",
"]",
";",
"var",
"args",
"=",
"def",
".",
"expression",
"[",
"'arguments'",
"]",
";",
"var",
"factory",
"=",
"getFactory",
"(",
"args",
")",
";",
"var",
"useStrict",
"=",
"getUseStrict",
"(",
"factory",
")",
";",
"// do replacements in-place to avoid modifying the code more than needed",
"if",
"(",
"useStrict",
")",
"{",
"output",
"+=",
"useStrict",
".",
"expression",
".",
"raw",
"+",
"';\\n'",
";",
"}",
"output",
"+=",
"raw",
".",
"substring",
"(",
"0",
",",
"def",
".",
"range",
"[",
"0",
"]",
")",
";",
"// anything before define",
"output",
"+=",
"getRequires",
"(",
"args",
",",
"factory",
")",
";",
"// add requires",
"output",
"+=",
"getBody",
"(",
"raw",
",",
"factory",
".",
"body",
",",
"useStrict",
")",
";",
"// module body",
"output",
"+=",
"raw",
".",
"substring",
"(",
"def",
".",
"range",
"[",
"1",
"]",
",",
"raw",
".",
"length",
")",
";",
"// anything after define",
"return",
"output",
";",
"}"
] | Convert AMD-style JavaScript string into node.js compatible module | [
"Convert",
"AMD",
"-",
"style",
"JavaScript",
"string",
"into",
"node",
".",
"js",
"compatible",
"module"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/build/amd2common.js#L57-L89 |
202 | apache/incubator-echarts | src/visual/VisualMapping.js | function () {
var thisOption = this.option;
return zrUtil.bind(
thisOption.mappingMethod === 'category'
? function (value, isNormalized) {
!isNormalized && (value = this._normalizeData(value));
return doMapCategory.call(this, value);
}
: function (value, isNormalized, out) {
// If output rgb array
// which will be much faster and useful in pixel manipulation
var returnRGBArray = !!out;
!isNormalized && (value = this._normalizeData(value));
out = zrColor.fastLerp(value, thisOption.parsedVisual, out);
return returnRGBArray ? out : zrColor.stringify(out, 'rgba');
},
this
);
} | javascript | function () {
var thisOption = this.option;
return zrUtil.bind(
thisOption.mappingMethod === 'category'
? function (value, isNormalized) {
!isNormalized && (value = this._normalizeData(value));
return doMapCategory.call(this, value);
}
: function (value, isNormalized, out) {
// If output rgb array
// which will be much faster and useful in pixel manipulation
var returnRGBArray = !!out;
!isNormalized && (value = this._normalizeData(value));
out = zrColor.fastLerp(value, thisOption.parsedVisual, out);
return returnRGBArray ? out : zrColor.stringify(out, 'rgba');
},
this
);
} | [
"function",
"(",
")",
"{",
"var",
"thisOption",
"=",
"this",
".",
"option",
";",
"return",
"zrUtil",
".",
"bind",
"(",
"thisOption",
".",
"mappingMethod",
"===",
"'category'",
"?",
"function",
"(",
"value",
",",
"isNormalized",
")",
"{",
"!",
"isNormalized",
"&&",
"(",
"value",
"=",
"this",
".",
"_normalizeData",
"(",
"value",
")",
")",
";",
"return",
"doMapCategory",
".",
"call",
"(",
"this",
",",
"value",
")",
";",
"}",
":",
"function",
"(",
"value",
",",
"isNormalized",
",",
"out",
")",
"{",
"// If output rgb array",
"// which will be much faster and useful in pixel manipulation",
"var",
"returnRGBArray",
"=",
"!",
"!",
"out",
";",
"!",
"isNormalized",
"&&",
"(",
"value",
"=",
"this",
".",
"_normalizeData",
"(",
"value",
")",
")",
";",
"out",
"=",
"zrColor",
".",
"fastLerp",
"(",
"value",
",",
"thisOption",
".",
"parsedVisual",
",",
"out",
")",
";",
"return",
"returnRGBArray",
"?",
"out",
":",
"zrColor",
".",
"stringify",
"(",
"out",
",",
"'rgba'",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] | Create a mapper function
@return {Function} | [
"Create",
"a",
"mapper",
"function"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/visual/VisualMapping.js#L146-L165 |
|
203 | apache/incubator-echarts | src/component/helper/BrushController.js | function (brushOptionList) {
if (__DEV__) {
zrUtil.assert(this._mounted);
}
brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
});
var tmpIdPrefix = '\0-brush-index-';
var oldCovers = this._covers;
var newCovers = this._covers = [];
var controller = this;
var creatingCover = this._creatingCover;
(new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
.add(addOrUpdate)
.update(addOrUpdate)
.remove(remove)
.execute();
return this;
function getKey(brushOption, index) {
return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
+ '-' + brushOption.brushType;
}
function oldGetKey(cover, index) {
return getKey(cover.__brushOption, index);
}
function addOrUpdate(newIndex, oldIndex) {
var newBrushOption = brushOptionList[newIndex];
// Consider setOption in event listener of brushSelect,
// where updating cover when creating should be forbiden.
if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
newCovers[newIndex] = oldCovers[oldIndex];
}
else {
var cover = newCovers[newIndex] = oldIndex != null
? (
oldCovers[oldIndex].__brushOption = newBrushOption,
oldCovers[oldIndex]
)
: endCreating(controller, createCover(controller, newBrushOption));
updateCoverAfterCreation(controller, cover);
}
}
function remove(oldIndex) {
if (oldCovers[oldIndex] !== creatingCover) {
controller.group.remove(oldCovers[oldIndex]);
}
}
} | javascript | function (brushOptionList) {
if (__DEV__) {
zrUtil.assert(this._mounted);
}
brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
});
var tmpIdPrefix = '\0-brush-index-';
var oldCovers = this._covers;
var newCovers = this._covers = [];
var controller = this;
var creatingCover = this._creatingCover;
(new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
.add(addOrUpdate)
.update(addOrUpdate)
.remove(remove)
.execute();
return this;
function getKey(brushOption, index) {
return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
+ '-' + brushOption.brushType;
}
function oldGetKey(cover, index) {
return getKey(cover.__brushOption, index);
}
function addOrUpdate(newIndex, oldIndex) {
var newBrushOption = brushOptionList[newIndex];
// Consider setOption in event listener of brushSelect,
// where updating cover when creating should be forbiden.
if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
newCovers[newIndex] = oldCovers[oldIndex];
}
else {
var cover = newCovers[newIndex] = oldIndex != null
? (
oldCovers[oldIndex].__brushOption = newBrushOption,
oldCovers[oldIndex]
)
: endCreating(controller, createCover(controller, newBrushOption));
updateCoverAfterCreation(controller, cover);
}
}
function remove(oldIndex) {
if (oldCovers[oldIndex] !== creatingCover) {
controller.group.remove(oldCovers[oldIndex]);
}
}
} | [
"function",
"(",
"brushOptionList",
")",
"{",
"if",
"(",
"__DEV__",
")",
"{",
"zrUtil",
".",
"assert",
"(",
"this",
".",
"_mounted",
")",
";",
"}",
"brushOptionList",
"=",
"zrUtil",
".",
"map",
"(",
"brushOptionList",
",",
"function",
"(",
"brushOption",
")",
"{",
"return",
"zrUtil",
".",
"merge",
"(",
"zrUtil",
".",
"clone",
"(",
"DEFAULT_BRUSH_OPT",
")",
",",
"brushOption",
",",
"true",
")",
";",
"}",
")",
";",
"var",
"tmpIdPrefix",
"=",
"'\\0-brush-index-'",
";",
"var",
"oldCovers",
"=",
"this",
".",
"_covers",
";",
"var",
"newCovers",
"=",
"this",
".",
"_covers",
"=",
"[",
"]",
";",
"var",
"controller",
"=",
"this",
";",
"var",
"creatingCover",
"=",
"this",
".",
"_creatingCover",
";",
"(",
"new",
"DataDiffer",
"(",
"oldCovers",
",",
"brushOptionList",
",",
"oldGetKey",
",",
"getKey",
")",
")",
".",
"add",
"(",
"addOrUpdate",
")",
".",
"update",
"(",
"addOrUpdate",
")",
".",
"remove",
"(",
"remove",
")",
".",
"execute",
"(",
")",
";",
"return",
"this",
";",
"function",
"getKey",
"(",
"brushOption",
",",
"index",
")",
"{",
"return",
"(",
"brushOption",
".",
"id",
"!=",
"null",
"?",
"brushOption",
".",
"id",
":",
"tmpIdPrefix",
"+",
"index",
")",
"+",
"'-'",
"+",
"brushOption",
".",
"brushType",
";",
"}",
"function",
"oldGetKey",
"(",
"cover",
",",
"index",
")",
"{",
"return",
"getKey",
"(",
"cover",
".",
"__brushOption",
",",
"index",
")",
";",
"}",
"function",
"addOrUpdate",
"(",
"newIndex",
",",
"oldIndex",
")",
"{",
"var",
"newBrushOption",
"=",
"brushOptionList",
"[",
"newIndex",
"]",
";",
"// Consider setOption in event listener of brushSelect,",
"// where updating cover when creating should be forbiden.",
"if",
"(",
"oldIndex",
"!=",
"null",
"&&",
"oldCovers",
"[",
"oldIndex",
"]",
"===",
"creatingCover",
")",
"{",
"newCovers",
"[",
"newIndex",
"]",
"=",
"oldCovers",
"[",
"oldIndex",
"]",
";",
"}",
"else",
"{",
"var",
"cover",
"=",
"newCovers",
"[",
"newIndex",
"]",
"=",
"oldIndex",
"!=",
"null",
"?",
"(",
"oldCovers",
"[",
"oldIndex",
"]",
".",
"__brushOption",
"=",
"newBrushOption",
",",
"oldCovers",
"[",
"oldIndex",
"]",
")",
":",
"endCreating",
"(",
"controller",
",",
"createCover",
"(",
"controller",
",",
"newBrushOption",
")",
")",
";",
"updateCoverAfterCreation",
"(",
"controller",
",",
"cover",
")",
";",
"}",
"}",
"function",
"remove",
"(",
"oldIndex",
")",
"{",
"if",
"(",
"oldCovers",
"[",
"oldIndex",
"]",
"!==",
"creatingCover",
")",
"{",
"controller",
".",
"group",
".",
"remove",
"(",
"oldCovers",
"[",
"oldIndex",
"]",
")",
";",
"}",
"}",
"}"
] | Update covers.
@param {Array.<Object>} brushOptionList Like:
[
{id: 'xx', brushType: 'line', range: [23, 44], brushStyle, transformable},
{id: 'yy', brushType: 'rect', range: [[23, 44], [23, 54]]},
...
]
`brushType` is required in each cover info. (can not be 'auto')
`id` is not mandatory.
`brushStyle`, `transformable` is not mandatory, use DEFAULT_BRUSH_OPT by default.
If brushOptionList is null/undefined, all covers removed. | [
"Update",
"covers",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/helper/BrushController.js#L286-L341 |
|
204 | apache/incubator-echarts | src/component/helper/BrushController.js | getPanelByCover | function getPanelByCover(controller, cover) {
var panels = controller._panels;
if (!panels) {
return true; // Global panel
}
var panelId = cover.__brushOption.panelId;
// User may give cover without coord sys info,
// which is then treated as global panel.
return panelId != null ? panels[panelId] : true;
} | javascript | function getPanelByCover(controller, cover) {
var panels = controller._panels;
if (!panels) {
return true; // Global panel
}
var panelId = cover.__brushOption.panelId;
// User may give cover without coord sys info,
// which is then treated as global panel.
return panelId != null ? panels[panelId] : true;
} | [
"function",
"getPanelByCover",
"(",
"controller",
",",
"cover",
")",
"{",
"var",
"panels",
"=",
"controller",
".",
"_panels",
";",
"if",
"(",
"!",
"panels",
")",
"{",
"return",
"true",
";",
"// Global panel",
"}",
"var",
"panelId",
"=",
"cover",
".",
"__brushOption",
".",
"panelId",
";",
"// User may give cover without coord sys info,",
"// which is then treated as global panel.",
"return",
"panelId",
"!=",
"null",
"?",
"panels",
"[",
"panelId",
"]",
":",
"true",
";",
"}"
] | Return a panel or true | [
"Return",
"a",
"panel",
"or",
"true"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/helper/BrushController.js#L456-L465 |
205 | apache/incubator-echarts | src/coord/geo/Geo.js | function (coord) {
var regions = this.regions;
for (var i = 0; i < regions.length; i++) {
if (regions[i].contain(coord)) {
return true;
}
}
return false;
} | javascript | function (coord) {
var regions = this.regions;
for (var i = 0; i < regions.length; i++) {
if (regions[i].contain(coord)) {
return true;
}
}
return false;
} | [
"function",
"(",
"coord",
")",
"{",
"var",
"regions",
"=",
"this",
".",
"regions",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"regions",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"regions",
"[",
"i",
"]",
".",
"contain",
"(",
"coord",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | If contain given lng,lat coord
@param {Array.<number>}
@readOnly | [
"If",
"contain",
"given",
"lng",
"lat",
"coord"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/geo/Geo.js#L82-L90 |
|
206 | apache/incubator-echarts | src/chart/treemap/TreemapView.js | prepareAnimationWhenNoOld | function prepareAnimationWhenNoOld(lasts, element, storageName) {
var lastCfg = lasts[thisRawIndex] = {};
var parentNode = thisNode.parentNode;
if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
var parentOldX = 0;
var parentOldY = 0;
// New nodes appear from right-bottom corner in 'zoomToNode' animation.
// For convenience, get old bounding rect from background.
var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
if (!reRoot && parentOldBg && parentOldBg.old) {
parentOldX = parentOldBg.old.width;
parentOldY = parentOldBg.old.height;
}
// When no parent old shape found, its parent is new too,
// so we can just use {x:0, y:0}.
lastCfg.old = storageName === 'nodeGroup'
? [0, parentOldY]
: {x: parentOldX, y: parentOldY, width: 0, height: 0};
}
// Fade in, user can be aware that these nodes are new.
lastCfg.fadein = storageName !== 'nodeGroup';
} | javascript | function prepareAnimationWhenNoOld(lasts, element, storageName) {
var lastCfg = lasts[thisRawIndex] = {};
var parentNode = thisNode.parentNode;
if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
var parentOldX = 0;
var parentOldY = 0;
// New nodes appear from right-bottom corner in 'zoomToNode' animation.
// For convenience, get old bounding rect from background.
var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
if (!reRoot && parentOldBg && parentOldBg.old) {
parentOldX = parentOldBg.old.width;
parentOldY = parentOldBg.old.height;
}
// When no parent old shape found, its parent is new too,
// so we can just use {x:0, y:0}.
lastCfg.old = storageName === 'nodeGroup'
? [0, parentOldY]
: {x: parentOldX, y: parentOldY, width: 0, height: 0};
}
// Fade in, user can be aware that these nodes are new.
lastCfg.fadein = storageName !== 'nodeGroup';
} | [
"function",
"prepareAnimationWhenNoOld",
"(",
"lasts",
",",
"element",
",",
"storageName",
")",
"{",
"var",
"lastCfg",
"=",
"lasts",
"[",
"thisRawIndex",
"]",
"=",
"{",
"}",
";",
"var",
"parentNode",
"=",
"thisNode",
".",
"parentNode",
";",
"if",
"(",
"parentNode",
"&&",
"(",
"!",
"reRoot",
"||",
"reRoot",
".",
"direction",
"===",
"'drillDown'",
")",
")",
"{",
"var",
"parentOldX",
"=",
"0",
";",
"var",
"parentOldY",
"=",
"0",
";",
"// New nodes appear from right-bottom corner in 'zoomToNode' animation.",
"// For convenience, get old bounding rect from background.",
"var",
"parentOldBg",
"=",
"lastsForAnimation",
".",
"background",
"[",
"parentNode",
".",
"getRawIndex",
"(",
")",
"]",
";",
"if",
"(",
"!",
"reRoot",
"&&",
"parentOldBg",
"&&",
"parentOldBg",
".",
"old",
")",
"{",
"parentOldX",
"=",
"parentOldBg",
".",
"old",
".",
"width",
";",
"parentOldY",
"=",
"parentOldBg",
".",
"old",
".",
"height",
";",
"}",
"// When no parent old shape found, its parent is new too,",
"// so we can just use {x:0, y:0}.",
"lastCfg",
".",
"old",
"=",
"storageName",
"===",
"'nodeGroup'",
"?",
"[",
"0",
",",
"parentOldY",
"]",
":",
"{",
"x",
":",
"parentOldX",
",",
"y",
":",
"parentOldY",
",",
"width",
":",
"0",
",",
"height",
":",
"0",
"}",
";",
"}",
"// Fade in, user can be aware that these nodes are new.",
"lastCfg",
".",
"fadein",
"=",
"storageName",
"!==",
"'nodeGroup'",
";",
"}"
] | If a element is new, we need to find the animation start point carefully, otherwise it will looks strange when 'zoomToNode'. | [
"If",
"a",
"element",
"is",
"new",
"we",
"need",
"to",
"find",
"the",
"animation",
"start",
"point",
"carefully",
"otherwise",
"it",
"will",
"looks",
"strange",
"when",
"zoomToNode",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/TreemapView.js#L899-L924 |
207 | apache/incubator-echarts | src/coord/Axis.js | 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;
} | javascript | 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;
} | [
"function",
"(",
"dim",
",",
"scale",
",",
"extent",
")",
"{",
"/**\n * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'.\n * @type {string}\n */",
"this",
".",
"dim",
"=",
"dim",
";",
"/**\n * Axis scale\n * @type {module:echarts/coord/scale/*}\n */",
"this",
".",
"scale",
"=",
"scale",
";",
"/**\n * @type {Array.<number>}\n * @private\n */",
"this",
".",
"_extent",
"=",
"extent",
"||",
"[",
"0",
",",
"0",
"]",
";",
"/**\n * @type {boolean}\n */",
"this",
".",
"inverse",
"=",
"false",
";",
"/**\n * Usually true when axis has a ordinal scale\n * @type {boolean}\n */",
"this",
".",
"onBand",
"=",
"false",
";",
"}"
] | Base class of Axis.
@constructor | [
"Base",
"class",
"of",
"Axis",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L34-L64 |
|
208 | apache/incubator-echarts | src/coord/Axis.js | function (coord) {
var extent = this._extent;
var min = Math.min(extent[0], extent[1]);
var max = Math.max(extent[0], extent[1]);
return coord >= min && coord <= max;
} | javascript | function (coord) {
var extent = this._extent;
var min = Math.min(extent[0], extent[1]);
var max = Math.max(extent[0], extent[1]);
return coord >= min && coord <= max;
} | [
"function",
"(",
"coord",
")",
"{",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"min",
"=",
"Math",
".",
"min",
"(",
"extent",
"[",
"0",
"]",
",",
"extent",
"[",
"1",
"]",
")",
";",
"var",
"max",
"=",
"Math",
".",
"max",
"(",
"extent",
"[",
"0",
"]",
",",
"extent",
"[",
"1",
"]",
")",
";",
"return",
"coord",
">=",
"min",
"&&",
"coord",
"<=",
"max",
";",
"}"
] | If axis extent contain given coord
@param {number} coord
@return {boolean} | [
"If",
"axis",
"extent",
"contain",
"given",
"coord"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L75-L80 |
|
209 | apache/incubator-echarts | src/coord/Axis.js | function (data, clamp) {
var extent = this._extent;
var scale = this.scale;
data = scale.normalize(data);
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
return linearMap(data, NORMALIZED_EXTENT, extent, clamp);
} | javascript | function (data, clamp) {
var extent = this._extent;
var scale = this.scale;
data = scale.normalize(data);
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
return linearMap(data, NORMALIZED_EXTENT, extent, clamp);
} | [
"function",
"(",
"data",
",",
"clamp",
")",
"{",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"scale",
"=",
"this",
".",
"scale",
";",
"data",
"=",
"scale",
".",
"normalize",
"(",
"data",
")",
";",
"if",
"(",
"this",
".",
"onBand",
"&&",
"scale",
".",
"type",
"===",
"'ordinal'",
")",
"{",
"extent",
"=",
"extent",
".",
"slice",
"(",
")",
";",
"fixExtentWithBands",
"(",
"extent",
",",
"scale",
".",
"count",
"(",
")",
")",
";",
"}",
"return",
"linearMap",
"(",
"data",
",",
"NORMALIZED_EXTENT",
",",
"extent",
",",
"clamp",
")",
";",
"}"
] | Convert data to coord. Data is the rank if it has an ordinal scale
@param {number} data
@param {boolean} clamp
@return {number} | [
"Convert",
"data",
"to",
"coord",
".",
"Data",
"is",
"the",
"rank",
"if",
"it",
"has",
"an",
"ordinal",
"scale"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L128-L139 |
|
210 | apache/incubator-echarts | src/coord/Axis.js | function (coord, clamp) {
var extent = this._extent;
var scale = this.scale;
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
return this.scale.scale(t);
} | javascript | function (coord, clamp) {
var extent = this._extent;
var scale = this.scale;
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
return this.scale.scale(t);
} | [
"function",
"(",
"coord",
",",
"clamp",
")",
"{",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"scale",
"=",
"this",
".",
"scale",
";",
"if",
"(",
"this",
".",
"onBand",
"&&",
"scale",
".",
"type",
"===",
"'ordinal'",
")",
"{",
"extent",
"=",
"extent",
".",
"slice",
"(",
")",
";",
"fixExtentWithBands",
"(",
"extent",
",",
"scale",
".",
"count",
"(",
")",
")",
";",
"}",
"var",
"t",
"=",
"linearMap",
"(",
"coord",
",",
"extent",
",",
"NORMALIZED_EXTENT",
",",
"clamp",
")",
";",
"return",
"this",
".",
"scale",
".",
"scale",
"(",
"t",
")",
";",
"}"
] | Convert coord to data. Data is the rank if it has an ordinal scale
@param {number} coord
@param {boolean} clamp
@return {number} | [
"Convert",
"coord",
"to",
"data",
".",
"Data",
"is",
"the",
"rank",
"if",
"it",
"has",
"an",
"ordinal",
"scale"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L147-L159 |
|
211 | apache/incubator-echarts | src/coord/Axis.js | function () {
var axisExtent = this._extent;
var dataExtent = this.scale.getExtent();
var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
// Fix #2728, avoid NaN when only one data.
len === 0 && (len = 1);
var size = Math.abs(axisExtent[1] - axisExtent[0]);
return Math.abs(size) / len;
} | javascript | function () {
var axisExtent = this._extent;
var dataExtent = this.scale.getExtent();
var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
// Fix #2728, avoid NaN when only one data.
len === 0 && (len = 1);
var size = Math.abs(axisExtent[1] - axisExtent[0]);
return Math.abs(size) / len;
} | [
"function",
"(",
")",
"{",
"var",
"axisExtent",
"=",
"this",
".",
"_extent",
";",
"var",
"dataExtent",
"=",
"this",
".",
"scale",
".",
"getExtent",
"(",
")",
";",
"var",
"len",
"=",
"dataExtent",
"[",
"1",
"]",
"-",
"dataExtent",
"[",
"0",
"]",
"+",
"(",
"this",
".",
"onBand",
"?",
"1",
":",
"0",
")",
";",
"// Fix #2728, avoid NaN when only one data.",
"len",
"===",
"0",
"&&",
"(",
"len",
"=",
"1",
")",
";",
"var",
"size",
"=",
"Math",
".",
"abs",
"(",
"axisExtent",
"[",
"1",
"]",
"-",
"axisExtent",
"[",
"0",
"]",
")",
";",
"return",
"Math",
".",
"abs",
"(",
"size",
")",
"/",
"len",
";",
"}"
] | Get width of band
@return {number} | [
"Get",
"width",
"of",
"band"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L242-L253 |
|
212 | apache/incubator-echarts | src/component/dataZoom/roams.js | mergeControllerParams | function mergeControllerParams(dataZoomInfos) {
var controlType;
// DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated
// as string, it is probably revert to reserved word by compress tool. See #7411.
var prefix = 'type_';
var typePriority = {
'type_true': 2,
'type_move': 1,
'type_false': 0,
'type_undefined': -1
};
var preventDefaultMouseMove = true;
zrUtil.each(dataZoomInfos, function (dataZoomInfo) {
var dataZoomModel = dataZoomInfo.dataZoomModel;
var oneType = dataZoomModel.get('disabled', true)
? false
: dataZoomModel.get('zoomLock', true)
? 'move'
: true;
if (typePriority[prefix + oneType] > typePriority[prefix + controlType]) {
controlType = oneType;
}
// Prevent default move event by default. If one false, do not prevent. Otherwise
// users may be confused why it does not work when multiple insideZooms exist.
preventDefaultMouseMove &= dataZoomModel.get('preventDefaultMouseMove', true);
});
return {
controlType: controlType,
opt: {
// RoamController will enable all of these functionalities,
// and the final behavior is determined by its event listener
// provided by each inside zoom.
zoomOnMouseWheel: true,
moveOnMouseMove: true,
moveOnMouseWheel: true,
preventDefaultMouseMove: !!preventDefaultMouseMove
}
};
} | javascript | function mergeControllerParams(dataZoomInfos) {
var controlType;
// DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated
// as string, it is probably revert to reserved word by compress tool. See #7411.
var prefix = 'type_';
var typePriority = {
'type_true': 2,
'type_move': 1,
'type_false': 0,
'type_undefined': -1
};
var preventDefaultMouseMove = true;
zrUtil.each(dataZoomInfos, function (dataZoomInfo) {
var dataZoomModel = dataZoomInfo.dataZoomModel;
var oneType = dataZoomModel.get('disabled', true)
? false
: dataZoomModel.get('zoomLock', true)
? 'move'
: true;
if (typePriority[prefix + oneType] > typePriority[prefix + controlType]) {
controlType = oneType;
}
// Prevent default move event by default. If one false, do not prevent. Otherwise
// users may be confused why it does not work when multiple insideZooms exist.
preventDefaultMouseMove &= dataZoomModel.get('preventDefaultMouseMove', true);
});
return {
controlType: controlType,
opt: {
// RoamController will enable all of these functionalities,
// and the final behavior is determined by its event listener
// provided by each inside zoom.
zoomOnMouseWheel: true,
moveOnMouseMove: true,
moveOnMouseWheel: true,
preventDefaultMouseMove: !!preventDefaultMouseMove
}
};
} | [
"function",
"mergeControllerParams",
"(",
"dataZoomInfos",
")",
"{",
"var",
"controlType",
";",
"// DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated",
"// as string, it is probably revert to reserved word by compress tool. See #7411.",
"var",
"prefix",
"=",
"'type_'",
";",
"var",
"typePriority",
"=",
"{",
"'type_true'",
":",
"2",
",",
"'type_move'",
":",
"1",
",",
"'type_false'",
":",
"0",
",",
"'type_undefined'",
":",
"-",
"1",
"}",
";",
"var",
"preventDefaultMouseMove",
"=",
"true",
";",
"zrUtil",
".",
"each",
"(",
"dataZoomInfos",
",",
"function",
"(",
"dataZoomInfo",
")",
"{",
"var",
"dataZoomModel",
"=",
"dataZoomInfo",
".",
"dataZoomModel",
";",
"var",
"oneType",
"=",
"dataZoomModel",
".",
"get",
"(",
"'disabled'",
",",
"true",
")",
"?",
"false",
":",
"dataZoomModel",
".",
"get",
"(",
"'zoomLock'",
",",
"true",
")",
"?",
"'move'",
":",
"true",
";",
"if",
"(",
"typePriority",
"[",
"prefix",
"+",
"oneType",
"]",
">",
"typePriority",
"[",
"prefix",
"+",
"controlType",
"]",
")",
"{",
"controlType",
"=",
"oneType",
";",
"}",
"// Prevent default move event by default. If one false, do not prevent. Otherwise",
"// users may be confused why it does not work when multiple insideZooms exist.",
"preventDefaultMouseMove",
"&=",
"dataZoomModel",
".",
"get",
"(",
"'preventDefaultMouseMove'",
",",
"true",
")",
";",
"}",
")",
";",
"return",
"{",
"controlType",
":",
"controlType",
",",
"opt",
":",
"{",
"// RoamController will enable all of these functionalities,",
"// and the final behavior is determined by its event listener",
"// provided by each inside zoom.",
"zoomOnMouseWheel",
":",
"true",
",",
"moveOnMouseMove",
":",
"true",
",",
"moveOnMouseWheel",
":",
"true",
",",
"preventDefaultMouseMove",
":",
"!",
"!",
"preventDefaultMouseMove",
"}",
"}",
";",
"}"
] | Merge roamController settings when multiple dataZooms share one roamController. | [
"Merge",
"roamController",
"settings",
"when",
"multiple",
"dataZooms",
"share",
"one",
"roamController",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/dataZoom/roams.js#L189-L230 |
213 | apache/incubator-echarts | src/coord/polar/AngleAxis.js | function () {
var axis = this;
var labelModel = axis.getLabelModel();
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 tickValue = ordinalExtent[0];
var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
var unitH = Math.abs(unitSpan);
// Not precise, just use height as text width
// and each distance from axis line yet.
var rect = textContain.getBoundingRect(
tickValue, labelModel.getFont(), 'center', 'top'
);
var maxH = Math.max(rect.height, 7);
var dh = maxH / unitH;
// 0/0 is NaN, 1/0 is Infinity.
isNaN(dh) && (dh = Infinity);
var interval = Math.max(0, Math.floor(dh));
var cache = inner(axis.model);
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.
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
) {
interval = lastAutoInterval;
}
// Only update cache if cache not used, otherwise the
// changing of interval is too insensitive.
else {
cache.lastTickCount = tickCount;
cache.lastAutoInterval = interval;
}
return interval;
} | javascript | function () {
var axis = this;
var labelModel = axis.getLabelModel();
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 tickValue = ordinalExtent[0];
var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
var unitH = Math.abs(unitSpan);
// Not precise, just use height as text width
// and each distance from axis line yet.
var rect = textContain.getBoundingRect(
tickValue, labelModel.getFont(), 'center', 'top'
);
var maxH = Math.max(rect.height, 7);
var dh = maxH / unitH;
// 0/0 is NaN, 1/0 is Infinity.
isNaN(dh) && (dh = Infinity);
var interval = Math.max(0, Math.floor(dh));
var cache = inner(axis.model);
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.
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
) {
interval = lastAutoInterval;
}
// Only update cache if cache not used, otherwise the
// changing of interval is too insensitive.
else {
cache.lastTickCount = tickCount;
cache.lastAutoInterval = interval;
}
return interval;
} | [
"function",
"(",
")",
"{",
"var",
"axis",
"=",
"this",
";",
"var",
"labelModel",
"=",
"axis",
".",
"getLabelModel",
"(",
")",
";",
"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",
"tickValue",
"=",
"ordinalExtent",
"[",
"0",
"]",
";",
"var",
"unitSpan",
"=",
"axis",
".",
"dataToCoord",
"(",
"tickValue",
"+",
"1",
")",
"-",
"axis",
".",
"dataToCoord",
"(",
"tickValue",
")",
";",
"var",
"unitH",
"=",
"Math",
".",
"abs",
"(",
"unitSpan",
")",
";",
"// Not precise, just use height as text width",
"// and each distance from axis line yet.",
"var",
"rect",
"=",
"textContain",
".",
"getBoundingRect",
"(",
"tickValue",
",",
"labelModel",
".",
"getFont",
"(",
")",
",",
"'center'",
",",
"'top'",
")",
";",
"var",
"maxH",
"=",
"Math",
".",
"max",
"(",
"rect",
".",
"height",
",",
"7",
")",
";",
"var",
"dh",
"=",
"maxH",
"/",
"unitH",
";",
"// 0/0 is NaN, 1/0 is Infinity.",
"isNaN",
"(",
"dh",
")",
"&&",
"(",
"dh",
"=",
"Infinity",
")",
";",
"var",
"interval",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"floor",
"(",
"dh",
")",
")",
";",
"var",
"cache",
"=",
"inner",
"(",
"axis",
".",
"model",
")",
";",
"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.",
"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",
")",
"{",
"interval",
"=",
"lastAutoInterval",
";",
"}",
"// Only update cache if cache not used, otherwise the",
"// changing of interval is too insensitive.",
"else",
"{",
"cache",
".",
"lastTickCount",
"=",
"tickCount",
";",
"cache",
".",
"lastAutoInterval",
"=",
"interval",
";",
"}",
"return",
"interval",
";",
"}"
] | Only be called in category axis.
Angle axis uses text height to decide interval
@override
@return {number} Auto interval for cateogry axis tick and label | [
"Only",
"be",
"called",
"in",
"category",
"axis",
".",
"Angle",
"axis",
"uses",
"text",
"height",
"to",
"decide",
"interval"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/AngleAxis.js#L66-L122 |
|
214 | apache/incubator-echarts | src/coord/single/singleCreator.js | create | function create(ecModel, api) {
var singles = [];
ecModel.eachComponent('singleAxis', function (axisModel, idx) {
var single = new Single(axisModel, ecModel, api);
single.name = 'single_' + idx;
single.resize(axisModel, api);
axisModel.coordinateSystem = single;
singles.push(single);
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'singleAxis') {
var singleAxisModel = ecModel.queryComponents({
mainType: 'singleAxis',
index: seriesModel.get('singleAxisIndex'),
id: seriesModel.get('singleAxisId')
})[0];
seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
}
});
return singles;
} | javascript | function create(ecModel, api) {
var singles = [];
ecModel.eachComponent('singleAxis', function (axisModel, idx) {
var single = new Single(axisModel, ecModel, api);
single.name = 'single_' + idx;
single.resize(axisModel, api);
axisModel.coordinateSystem = single;
singles.push(single);
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'singleAxis') {
var singleAxisModel = ecModel.queryComponents({
mainType: 'singleAxis',
index: seriesModel.get('singleAxisIndex'),
id: seriesModel.get('singleAxisId')
})[0];
seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
}
});
return singles;
} | [
"function",
"create",
"(",
"ecModel",
",",
"api",
")",
"{",
"var",
"singles",
"=",
"[",
"]",
";",
"ecModel",
".",
"eachComponent",
"(",
"'singleAxis'",
",",
"function",
"(",
"axisModel",
",",
"idx",
")",
"{",
"var",
"single",
"=",
"new",
"Single",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
")",
";",
"single",
".",
"name",
"=",
"'single_'",
"+",
"idx",
";",
"single",
".",
"resize",
"(",
"axisModel",
",",
"api",
")",
";",
"axisModel",
".",
"coordinateSystem",
"=",
"single",
";",
"singles",
".",
"push",
"(",
"single",
")",
";",
"}",
")",
";",
"ecModel",
".",
"eachSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"if",
"(",
"seriesModel",
".",
"get",
"(",
"'coordinateSystem'",
")",
"===",
"'singleAxis'",
")",
"{",
"var",
"singleAxisModel",
"=",
"ecModel",
".",
"queryComponents",
"(",
"{",
"mainType",
":",
"'singleAxis'",
",",
"index",
":",
"seriesModel",
".",
"get",
"(",
"'singleAxisIndex'",
")",
",",
"id",
":",
"seriesModel",
".",
"get",
"(",
"'singleAxisId'",
")",
"}",
")",
"[",
"0",
"]",
";",
"seriesModel",
".",
"coordinateSystem",
"=",
"singleAxisModel",
"&&",
"singleAxisModel",
".",
"coordinateSystem",
";",
"}",
"}",
")",
";",
"return",
"singles",
";",
"}"
] | Create single coordinate system and inject it into seriesModel.
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api
@return {Array.<module:echarts/coord/single/Single>} | [
"Create",
"single",
"coordinate",
"system",
"and",
"inject",
"it",
"into",
"seriesModel",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/singleCreator.js#L34-L59 |
215 | apache/incubator-echarts | src/coord/single/Single.js | Single | function Single(axisModel, ecModel, api) {
/**
* @type {string}
* @readOnly
*/
this.dimension = 'single';
/**
* Add it just for draw tooltip.
*
* @type {Array.<string>}
* @readOnly
*/
this.dimensions = ['single'];
/**
* @private
* @type {module:echarts/coord/single/SingleAxis}.
*/
this._axis = null;
/**
* @private
* @type {module:zrender/core/BoundingRect}
*/
this._rect;
this._init(axisModel, ecModel, api);
/**
* @type {module:echarts/coord/single/AxisModel}
*/
this.model = axisModel;
} | javascript | function Single(axisModel, ecModel, api) {
/**
* @type {string}
* @readOnly
*/
this.dimension = 'single';
/**
* Add it just for draw tooltip.
*
* @type {Array.<string>}
* @readOnly
*/
this.dimensions = ['single'];
/**
* @private
* @type {module:echarts/coord/single/SingleAxis}.
*/
this._axis = null;
/**
* @private
* @type {module:zrender/core/BoundingRect}
*/
this._rect;
this._init(axisModel, ecModel, api);
/**
* @type {module:echarts/coord/single/AxisModel}
*/
this.model = axisModel;
} | [
"function",
"Single",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
")",
"{",
"/**\n * @type {string}\n * @readOnly\n */",
"this",
".",
"dimension",
"=",
"'single'",
";",
"/**\n * Add it just for draw tooltip.\n *\n * @type {Array.<string>}\n * @readOnly\n */",
"this",
".",
"dimensions",
"=",
"[",
"'single'",
"]",
";",
"/**\n * @private\n * @type {module:echarts/coord/single/SingleAxis}.\n */",
"this",
".",
"_axis",
"=",
"null",
";",
"/**\n * @private\n * @type {module:zrender/core/BoundingRect}\n */",
"this",
".",
"_rect",
";",
"this",
".",
"_init",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
")",
";",
"/**\n * @type {module:echarts/coord/single/AxisModel}\n */",
"this",
".",
"model",
"=",
"axisModel",
";",
"}"
] | Create a single coordinates system.
@param {module:echarts/coord/single/AxisModel} axisModel
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api | [
"Create",
"a",
"single",
"coordinates",
"system",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L36-L70 |
216 | apache/incubator-echarts | src/coord/single/Single.js | function (axisModel, ecModel, api) {
var dim = this.dimension;
var axis = new SingleAxis(
dim,
axisHelper.createScaleByModel(axisModel),
[0, 0],
axisModel.get('type'),
axisModel.get('position')
);
var isCategory = axis.type === 'category';
axis.onBand = isCategory && axisModel.get('boundaryGap');
axis.inverse = axisModel.get('inverse');
axis.orient = axisModel.get('orient');
axisModel.axis = axis;
axis.model = axisModel;
axis.coordinateSystem = this;
this._axis = axis;
} | javascript | function (axisModel, ecModel, api) {
var dim = this.dimension;
var axis = new SingleAxis(
dim,
axisHelper.createScaleByModel(axisModel),
[0, 0],
axisModel.get('type'),
axisModel.get('position')
);
var isCategory = axis.type === 'category';
axis.onBand = isCategory && axisModel.get('boundaryGap');
axis.inverse = axisModel.get('inverse');
axis.orient = axisModel.get('orient');
axisModel.axis = axis;
axis.model = axisModel;
axis.coordinateSystem = this;
this._axis = axis;
} | [
"function",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
")",
"{",
"var",
"dim",
"=",
"this",
".",
"dimension",
";",
"var",
"axis",
"=",
"new",
"SingleAxis",
"(",
"dim",
",",
"axisHelper",
".",
"createScaleByModel",
"(",
"axisModel",
")",
",",
"[",
"0",
",",
"0",
"]",
",",
"axisModel",
".",
"get",
"(",
"'type'",
")",
",",
"axisModel",
".",
"get",
"(",
"'position'",
")",
")",
";",
"var",
"isCategory",
"=",
"axis",
".",
"type",
"===",
"'category'",
";",
"axis",
".",
"onBand",
"=",
"isCategory",
"&&",
"axisModel",
".",
"get",
"(",
"'boundaryGap'",
")",
";",
"axis",
".",
"inverse",
"=",
"axisModel",
".",
"get",
"(",
"'inverse'",
")",
";",
"axis",
".",
"orient",
"=",
"axisModel",
".",
"get",
"(",
"'orient'",
")",
";",
"axisModel",
".",
"axis",
"=",
"axis",
";",
"axis",
".",
"model",
"=",
"axisModel",
";",
"axis",
".",
"coordinateSystem",
"=",
"this",
";",
"this",
".",
"_axis",
"=",
"axis",
";",
"}"
] | Initialize single coordinate system.
@param {module:echarts/coord/single/AxisModel} axisModel
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api
@private | [
"Initialize",
"single",
"coordinate",
"system",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L88-L109 |
|
217 | apache/incubator-echarts | src/coord/single/Single.js | function (ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === this) {
var data = seriesModel.getData();
each(data.mapDimension(this.dimension, true), function (dim) {
this._axis.scale.unionExtentFromData(data, dim);
}, this);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
} | javascript | function (ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === this) {
var data = seriesModel.getData();
each(data.mapDimension(this.dimension, true), function (dim) {
this._axis.scale.unionExtentFromData(data, dim);
}, this);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
} | [
"function",
"(",
"ecModel",
",",
"api",
")",
"{",
"ecModel",
".",
"eachSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"if",
"(",
"seriesModel",
".",
"coordinateSystem",
"===",
"this",
")",
"{",
"var",
"data",
"=",
"seriesModel",
".",
"getData",
"(",
")",
";",
"each",
"(",
"data",
".",
"mapDimension",
"(",
"this",
".",
"dimension",
",",
"true",
")",
",",
"function",
"(",
"dim",
")",
"{",
"this",
".",
"_axis",
".",
"scale",
".",
"unionExtentFromData",
"(",
"data",
",",
"dim",
")",
";",
"}",
",",
"this",
")",
";",
"axisHelper",
".",
"niceScaleExtent",
"(",
"this",
".",
"_axis",
".",
"scale",
",",
"this",
".",
"_axis",
".",
"model",
")",
";",
"}",
"}",
",",
"this",
")",
";",
"}"
] | Update axis scale after data processed
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api | [
"Update",
"axis",
"scale",
"after",
"data",
"processed"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L116-L126 |
|
218 | apache/incubator-echarts | src/coord/single/Single.js | function (axisModel, api) {
this._rect = getLayoutRect(
{
left: axisModel.get('left'),
top: axisModel.get('top'),
right: axisModel.get('right'),
bottom: axisModel.get('bottom'),
width: axisModel.get('width'),
height: axisModel.get('height')
},
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._adjustAxis();
} | javascript | function (axisModel, api) {
this._rect = getLayoutRect(
{
left: axisModel.get('left'),
top: axisModel.get('top'),
right: axisModel.get('right'),
bottom: axisModel.get('bottom'),
width: axisModel.get('width'),
height: axisModel.get('height')
},
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._adjustAxis();
} | [
"function",
"(",
"axisModel",
",",
"api",
")",
"{",
"this",
".",
"_rect",
"=",
"getLayoutRect",
"(",
"{",
"left",
":",
"axisModel",
".",
"get",
"(",
"'left'",
")",
",",
"top",
":",
"axisModel",
".",
"get",
"(",
"'top'",
")",
",",
"right",
":",
"axisModel",
".",
"get",
"(",
"'right'",
")",
",",
"bottom",
":",
"axisModel",
".",
"get",
"(",
"'bottom'",
")",
",",
"width",
":",
"axisModel",
".",
"get",
"(",
"'width'",
")",
",",
"height",
":",
"axisModel",
".",
"get",
"(",
"'height'",
")",
"}",
",",
"{",
"width",
":",
"api",
".",
"getWidth",
"(",
")",
",",
"height",
":",
"api",
".",
"getHeight",
"(",
")",
"}",
")",
";",
"this",
".",
"_adjustAxis",
"(",
")",
";",
"}"
] | Resize the single coordinate system.
@param {module:echarts/coord/single/AxisModel} axisModel
@param {module:echarts/ExtensionAPI} api | [
"Resize",
"the",
"single",
"coordinate",
"system",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L134-L151 |
|
219 | apache/incubator-echarts | src/coord/single/Single.js | function (point) {
var rect = this.getRect();
var axis = this.getAxis();
var orient = axis.orient;
if (orient === 'horizontal') {
return axis.contain(axis.toLocalCoord(point[0]))
&& (point[1] >= rect.y && point[1] <= (rect.y + rect.height));
}
else {
return axis.contain(axis.toLocalCoord(point[1]))
&& (point[0] >= rect.y && point[0] <= (rect.y + rect.height));
}
} | javascript | function (point) {
var rect = this.getRect();
var axis = this.getAxis();
var orient = axis.orient;
if (orient === 'horizontal') {
return axis.contain(axis.toLocalCoord(point[0]))
&& (point[1] >= rect.y && point[1] <= (rect.y + rect.height));
}
else {
return axis.contain(axis.toLocalCoord(point[1]))
&& (point[0] >= rect.y && point[0] <= (rect.y + rect.height));
}
} | [
"function",
"(",
"point",
")",
"{",
"var",
"rect",
"=",
"this",
".",
"getRect",
"(",
")",
";",
"var",
"axis",
"=",
"this",
".",
"getAxis",
"(",
")",
";",
"var",
"orient",
"=",
"axis",
".",
"orient",
";",
"if",
"(",
"orient",
"===",
"'horizontal'",
")",
"{",
"return",
"axis",
".",
"contain",
"(",
"axis",
".",
"toLocalCoord",
"(",
"point",
"[",
"0",
"]",
")",
")",
"&&",
"(",
"point",
"[",
"1",
"]",
">=",
"rect",
".",
"y",
"&&",
"point",
"[",
"1",
"]",
"<=",
"(",
"rect",
".",
"y",
"+",
"rect",
".",
"height",
")",
")",
";",
"}",
"else",
"{",
"return",
"axis",
".",
"contain",
"(",
"axis",
".",
"toLocalCoord",
"(",
"point",
"[",
"1",
"]",
")",
")",
"&&",
"(",
"point",
"[",
"0",
"]",
">=",
"rect",
".",
"y",
"&&",
"point",
"[",
"0",
"]",
"<=",
"(",
"rect",
".",
"y",
"+",
"rect",
".",
"height",
")",
")",
";",
"}",
"}"
] | If contain point.
@param {Array.<number>} point
@return {boolean} | [
"If",
"contain",
"point",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L243-L255 |
|
220 | apache/incubator-echarts | src/coord/single/Single.js | function (val) {
var axis = this.getAxis();
var rect = this.getRect();
var pt = [];
var idx = axis.orient === 'horizontal' ? 0 : 1;
if (val instanceof Array) {
val = val[0];
}
pt[idx] = axis.toGlobalCoord(axis.dataToCoord(+val));
pt[1 - idx] = idx === 0 ? (rect.y + rect.height / 2) : (rect.x + rect.width / 2);
return pt;
} | javascript | function (val) {
var axis = this.getAxis();
var rect = this.getRect();
var pt = [];
var idx = axis.orient === 'horizontal' ? 0 : 1;
if (val instanceof Array) {
val = val[0];
}
pt[idx] = axis.toGlobalCoord(axis.dataToCoord(+val));
pt[1 - idx] = idx === 0 ? (rect.y + rect.height / 2) : (rect.x + rect.width / 2);
return pt;
} | [
"function",
"(",
"val",
")",
"{",
"var",
"axis",
"=",
"this",
".",
"getAxis",
"(",
")",
";",
"var",
"rect",
"=",
"this",
".",
"getRect",
"(",
")",
";",
"var",
"pt",
"=",
"[",
"]",
";",
"var",
"idx",
"=",
"axis",
".",
"orient",
"===",
"'horizontal'",
"?",
"0",
":",
"1",
";",
"if",
"(",
"val",
"instanceof",
"Array",
")",
"{",
"val",
"=",
"val",
"[",
"0",
"]",
";",
"}",
"pt",
"[",
"idx",
"]",
"=",
"axis",
".",
"toGlobalCoord",
"(",
"axis",
".",
"dataToCoord",
"(",
"+",
"val",
")",
")",
";",
"pt",
"[",
"1",
"-",
"idx",
"]",
"=",
"idx",
"===",
"0",
"?",
"(",
"rect",
".",
"y",
"+",
"rect",
".",
"height",
"/",
"2",
")",
":",
"(",
"rect",
".",
"x",
"+",
"rect",
".",
"width",
"/",
"2",
")",
";",
"return",
"pt",
";",
"}"
] | Convert the series data to concrete point.
@param {number|Array.<number>} val
@return {Array.<number>} | [
"Convert",
"the",
"series",
"data",
"to",
"concrete",
"point",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L274-L287 |
|
221 | apache/incubator-echarts | src/chart/heatmap/HeatmapLayer.js | function (data, width, height, normalize, colorFunc, isInRange) {
var brush = this._getBrush();
var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
var r = this.pointSize + this.blurSize;
var canvas = this.canvas;
var ctx = canvas.getContext('2d');
var len = data.length;
canvas.width = width;
canvas.height = height;
for (var i = 0; i < len; ++i) {
var p = data[i];
var x = p[0];
var y = p[1];
var value = p[2];
// calculate alpha using value
var alpha = normalize(value);
// draw with the circle brush with alpha
ctx.globalAlpha = alpha;
ctx.drawImage(brush, x - r, y - r);
}
if (!canvas.width || !canvas.height) {
// Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
// 'CanvasRenderingContext2D': The source height is 0."
return canvas;
}
// colorize the canvas using alpha value and set with gradient
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var pixels = imageData.data;
var offset = 0;
var pixelLen = pixels.length;
var minOpacity = this.minOpacity;
var maxOpacity = this.maxOpacity;
var diffOpacity = maxOpacity - minOpacity;
while (offset < pixelLen) {
var alpha = pixels[offset + 3] / 256;
var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
// Simple optimize to ignore the empty data
if (alpha > 0) {
var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
// Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
pixels[offset++] = gradient[gradientOffset];
pixels[offset++] = gradient[gradientOffset + 1];
pixels[offset++] = gradient[gradientOffset + 2];
pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
}
else {
offset += 4;
}
}
ctx.putImageData(imageData, 0, 0);
return canvas;
} | javascript | function (data, width, height, normalize, colorFunc, isInRange) {
var brush = this._getBrush();
var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
var r = this.pointSize + this.blurSize;
var canvas = this.canvas;
var ctx = canvas.getContext('2d');
var len = data.length;
canvas.width = width;
canvas.height = height;
for (var i = 0; i < len; ++i) {
var p = data[i];
var x = p[0];
var y = p[1];
var value = p[2];
// calculate alpha using value
var alpha = normalize(value);
// draw with the circle brush with alpha
ctx.globalAlpha = alpha;
ctx.drawImage(brush, x - r, y - r);
}
if (!canvas.width || !canvas.height) {
// Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
// 'CanvasRenderingContext2D': The source height is 0."
return canvas;
}
// colorize the canvas using alpha value and set with gradient
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var pixels = imageData.data;
var offset = 0;
var pixelLen = pixels.length;
var minOpacity = this.minOpacity;
var maxOpacity = this.maxOpacity;
var diffOpacity = maxOpacity - minOpacity;
while (offset < pixelLen) {
var alpha = pixels[offset + 3] / 256;
var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
// Simple optimize to ignore the empty data
if (alpha > 0) {
var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
// Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
pixels[offset++] = gradient[gradientOffset];
pixels[offset++] = gradient[gradientOffset + 1];
pixels[offset++] = gradient[gradientOffset + 2];
pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
}
else {
offset += 4;
}
}
ctx.putImageData(imageData, 0, 0);
return canvas;
} | [
"function",
"(",
"data",
",",
"width",
",",
"height",
",",
"normalize",
",",
"colorFunc",
",",
"isInRange",
")",
"{",
"var",
"brush",
"=",
"this",
".",
"_getBrush",
"(",
")",
";",
"var",
"gradientInRange",
"=",
"this",
".",
"_getGradient",
"(",
"data",
",",
"colorFunc",
",",
"'inRange'",
")",
";",
"var",
"gradientOutOfRange",
"=",
"this",
".",
"_getGradient",
"(",
"data",
",",
"colorFunc",
",",
"'outOfRange'",
")",
";",
"var",
"r",
"=",
"this",
".",
"pointSize",
"+",
"this",
".",
"blurSize",
";",
"var",
"canvas",
"=",
"this",
".",
"canvas",
";",
"var",
"ctx",
"=",
"canvas",
".",
"getContext",
"(",
"'2d'",
")",
";",
"var",
"len",
"=",
"data",
".",
"length",
";",
"canvas",
".",
"width",
"=",
"width",
";",
"canvas",
".",
"height",
"=",
"height",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"var",
"p",
"=",
"data",
"[",
"i",
"]",
";",
"var",
"x",
"=",
"p",
"[",
"0",
"]",
";",
"var",
"y",
"=",
"p",
"[",
"1",
"]",
";",
"var",
"value",
"=",
"p",
"[",
"2",
"]",
";",
"// calculate alpha using value",
"var",
"alpha",
"=",
"normalize",
"(",
"value",
")",
";",
"// draw with the circle brush with alpha",
"ctx",
".",
"globalAlpha",
"=",
"alpha",
";",
"ctx",
".",
"drawImage",
"(",
"brush",
",",
"x",
"-",
"r",
",",
"y",
"-",
"r",
")",
";",
"}",
"if",
"(",
"!",
"canvas",
".",
"width",
"||",
"!",
"canvas",
".",
"height",
")",
"{",
"// Avoid \"Uncaught DOMException: Failed to execute 'getImageData' on",
"// 'CanvasRenderingContext2D': The source height is 0.\"",
"return",
"canvas",
";",
"}",
"// colorize the canvas using alpha value and set with gradient",
"var",
"imageData",
"=",
"ctx",
".",
"getImageData",
"(",
"0",
",",
"0",
",",
"canvas",
".",
"width",
",",
"canvas",
".",
"height",
")",
";",
"var",
"pixels",
"=",
"imageData",
".",
"data",
";",
"var",
"offset",
"=",
"0",
";",
"var",
"pixelLen",
"=",
"pixels",
".",
"length",
";",
"var",
"minOpacity",
"=",
"this",
".",
"minOpacity",
";",
"var",
"maxOpacity",
"=",
"this",
".",
"maxOpacity",
";",
"var",
"diffOpacity",
"=",
"maxOpacity",
"-",
"minOpacity",
";",
"while",
"(",
"offset",
"<",
"pixelLen",
")",
"{",
"var",
"alpha",
"=",
"pixels",
"[",
"offset",
"+",
"3",
"]",
"/",
"256",
";",
"var",
"gradientOffset",
"=",
"Math",
".",
"floor",
"(",
"alpha",
"*",
"(",
"GRADIENT_LEVELS",
"-",
"1",
")",
")",
"*",
"4",
";",
"// Simple optimize to ignore the empty data",
"if",
"(",
"alpha",
">",
"0",
")",
"{",
"var",
"gradient",
"=",
"isInRange",
"(",
"alpha",
")",
"?",
"gradientInRange",
":",
"gradientOutOfRange",
";",
"// Any alpha > 0 will be mapped to [minOpacity, maxOpacity]",
"alpha",
">",
"0",
"&&",
"(",
"alpha",
"=",
"alpha",
"*",
"diffOpacity",
"+",
"minOpacity",
")",
";",
"pixels",
"[",
"offset",
"++",
"]",
"=",
"gradient",
"[",
"gradientOffset",
"]",
";",
"pixels",
"[",
"offset",
"++",
"]",
"=",
"gradient",
"[",
"gradientOffset",
"+",
"1",
"]",
";",
"pixels",
"[",
"offset",
"++",
"]",
"=",
"gradient",
"[",
"gradientOffset",
"+",
"2",
"]",
";",
"pixels",
"[",
"offset",
"++",
"]",
"=",
"gradient",
"[",
"gradientOffset",
"+",
"3",
"]",
"*",
"alpha",
"*",
"256",
";",
"}",
"else",
"{",
"offset",
"+=",
"4",
";",
"}",
"}",
"ctx",
".",
"putImageData",
"(",
"imageData",
",",
"0",
",",
"0",
")",
";",
"return",
"canvas",
";",
"}"
] | Renders Heatmap and returns the rendered canvas
@param {Array} data array of data, each has x, y, value
@param {number} width canvas width
@param {number} height canvas height | [
"Renders",
"Heatmap",
"and",
"returns",
"the",
"rendered",
"canvas"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/heatmap/HeatmapLayer.js#L59-L120 |
|
222 | apache/incubator-echarts | src/chart/heatmap/HeatmapLayer.js | function () {
var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas());
// set brush size
var r = this.pointSize + this.blurSize;
var d = r * 2;
brushCanvas.width = d;
brushCanvas.height = d;
var ctx = brushCanvas.getContext('2d');
ctx.clearRect(0, 0, d, d);
// in order to render shadow without the distinct circle,
// draw the distinct circle in an invisible place,
// and use shadowOffset to draw shadow in the center of the canvas
ctx.shadowOffsetX = d;
ctx.shadowBlur = this.blurSize;
// draw the shadow in black, and use alpha and shadow blur to generate
// color in color map
ctx.shadowColor = '#000';
// draw circle in the left to the canvas
ctx.beginPath();
ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
return brushCanvas;
} | javascript | function () {
var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas());
// set brush size
var r = this.pointSize + this.blurSize;
var d = r * 2;
brushCanvas.width = d;
brushCanvas.height = d;
var ctx = brushCanvas.getContext('2d');
ctx.clearRect(0, 0, d, d);
// in order to render shadow without the distinct circle,
// draw the distinct circle in an invisible place,
// and use shadowOffset to draw shadow in the center of the canvas
ctx.shadowOffsetX = d;
ctx.shadowBlur = this.blurSize;
// draw the shadow in black, and use alpha and shadow blur to generate
// color in color map
ctx.shadowColor = '#000';
// draw circle in the left to the canvas
ctx.beginPath();
ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
return brushCanvas;
} | [
"function",
"(",
")",
"{",
"var",
"brushCanvas",
"=",
"this",
".",
"_brushCanvas",
"||",
"(",
"this",
".",
"_brushCanvas",
"=",
"zrUtil",
".",
"createCanvas",
"(",
")",
")",
";",
"// set brush size",
"var",
"r",
"=",
"this",
".",
"pointSize",
"+",
"this",
".",
"blurSize",
";",
"var",
"d",
"=",
"r",
"*",
"2",
";",
"brushCanvas",
".",
"width",
"=",
"d",
";",
"brushCanvas",
".",
"height",
"=",
"d",
";",
"var",
"ctx",
"=",
"brushCanvas",
".",
"getContext",
"(",
"'2d'",
")",
";",
"ctx",
".",
"clearRect",
"(",
"0",
",",
"0",
",",
"d",
",",
"d",
")",
";",
"// in order to render shadow without the distinct circle,",
"// draw the distinct circle in an invisible place,",
"// and use shadowOffset to draw shadow in the center of the canvas",
"ctx",
".",
"shadowOffsetX",
"=",
"d",
";",
"ctx",
".",
"shadowBlur",
"=",
"this",
".",
"blurSize",
";",
"// draw the shadow in black, and use alpha and shadow blur to generate",
"// color in color map",
"ctx",
".",
"shadowColor",
"=",
"'#000'",
";",
"// draw circle in the left to the canvas",
"ctx",
".",
"beginPath",
"(",
")",
";",
"ctx",
".",
"arc",
"(",
"-",
"r",
",",
"r",
",",
"this",
".",
"pointSize",
",",
"0",
",",
"Math",
".",
"PI",
"*",
"2",
",",
"true",
")",
";",
"ctx",
".",
"closePath",
"(",
")",
";",
"ctx",
".",
"fill",
"(",
")",
";",
"return",
"brushCanvas",
";",
"}"
] | get canvas of a black circle brush used for canvas to draw later
@private
@returns {Object} circle brush canvas | [
"get",
"canvas",
"of",
"a",
"black",
"circle",
"brush",
"used",
"for",
"canvas",
"to",
"draw",
"later"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/heatmap/HeatmapLayer.js#L127-L153 |
|
223 | apache/incubator-echarts | src/chart/heatmap/HeatmapLayer.js | function (data, colorFunc, state) {
var gradientPixels = this._gradientPixels;
var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
var color = [0, 0, 0, 0];
var off = 0;
for (var i = 0; i < 256; i++) {
colorFunc[state](i / 255, true, color);
pixelsSingleState[off++] = color[0];
pixelsSingleState[off++] = color[1];
pixelsSingleState[off++] = color[2];
pixelsSingleState[off++] = color[3];
}
return pixelsSingleState;
} | javascript | function (data, colorFunc, state) {
var gradientPixels = this._gradientPixels;
var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
var color = [0, 0, 0, 0];
var off = 0;
for (var i = 0; i < 256; i++) {
colorFunc[state](i / 255, true, color);
pixelsSingleState[off++] = color[0];
pixelsSingleState[off++] = color[1];
pixelsSingleState[off++] = color[2];
pixelsSingleState[off++] = color[3];
}
return pixelsSingleState;
} | [
"function",
"(",
"data",
",",
"colorFunc",
",",
"state",
")",
"{",
"var",
"gradientPixels",
"=",
"this",
".",
"_gradientPixels",
";",
"var",
"pixelsSingleState",
"=",
"gradientPixels",
"[",
"state",
"]",
"||",
"(",
"gradientPixels",
"[",
"state",
"]",
"=",
"new",
"Uint8ClampedArray",
"(",
"256",
"*",
"4",
")",
")",
";",
"var",
"color",
"=",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
";",
"var",
"off",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"256",
";",
"i",
"++",
")",
"{",
"colorFunc",
"[",
"state",
"]",
"(",
"i",
"/",
"255",
",",
"true",
",",
"color",
")",
";",
"pixelsSingleState",
"[",
"off",
"++",
"]",
"=",
"color",
"[",
"0",
"]",
";",
"pixelsSingleState",
"[",
"off",
"++",
"]",
"=",
"color",
"[",
"1",
"]",
";",
"pixelsSingleState",
"[",
"off",
"++",
"]",
"=",
"color",
"[",
"2",
"]",
";",
"pixelsSingleState",
"[",
"off",
"++",
"]",
"=",
"color",
"[",
"3",
"]",
";",
"}",
"return",
"pixelsSingleState",
";",
"}"
] | get gradient color map
@private | [
"get",
"gradient",
"color",
"map"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/heatmap/HeatmapLayer.js#L159-L172 |
|
224 | apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | getViewRect | function getViewRect(seriesModel, api) {
return layout.getLayoutRect(
seriesModel.getBoxLayoutParams(), {
width: api.getWidth(),
height: api.getHeight()
}
);
} | javascript | function getViewRect(seriesModel, api) {
return layout.getLayoutRect(
seriesModel.getBoxLayoutParams(), {
width: api.getWidth(),
height: api.getHeight()
}
);
} | [
"function",
"getViewRect",
"(",
"seriesModel",
",",
"api",
")",
"{",
"return",
"layout",
".",
"getLayoutRect",
"(",
"seriesModel",
".",
"getBoxLayoutParams",
"(",
")",
",",
"{",
"width",
":",
"api",
".",
"getWidth",
"(",
")",
",",
"height",
":",
"api",
".",
"getHeight",
"(",
")",
"}",
")",
";",
"}"
] | Get the layout position of the whole view
@param {module:echarts/model/Series} seriesModel the model object of sankey series
@param {module:echarts/ExtensionAPI} api provide the API list that the developer can call
@return {module:zrender/core/BoundingRect} size of rect to draw the sankey view | [
"Get",
"the",
"layout",
"position",
"of",
"the",
"whole",
"view"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L71-L78 |
225 | apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | computeNodeValues | function computeNodeValues(nodes) {
zrUtil.each(nodes, function (node) {
var value1 = sum(node.outEdges, getEdgeValue);
var value2 = sum(node.inEdges, getEdgeValue);
var value = Math.max(value1, value2);
node.setLayout({value: value}, true);
});
} | javascript | function computeNodeValues(nodes) {
zrUtil.each(nodes, function (node) {
var value1 = sum(node.outEdges, getEdgeValue);
var value2 = sum(node.inEdges, getEdgeValue);
var value = Math.max(value1, value2);
node.setLayout({value: value}, true);
});
} | [
"function",
"computeNodeValues",
"(",
"nodes",
")",
"{",
"zrUtil",
".",
"each",
"(",
"nodes",
",",
"function",
"(",
"node",
")",
"{",
"var",
"value1",
"=",
"sum",
"(",
"node",
".",
"outEdges",
",",
"getEdgeValue",
")",
";",
"var",
"value2",
"=",
"sum",
"(",
"node",
".",
"inEdges",
",",
"getEdgeValue",
")",
";",
"var",
"value",
"=",
"Math",
".",
"max",
"(",
"value1",
",",
"value2",
")",
";",
"node",
".",
"setLayout",
"(",
"{",
"value",
":",
"value",
"}",
",",
"true",
")",
";",
"}",
")",
";",
"}"
] | Compute the value of each node by summing the associated edge's value
@param {module:echarts/data/Graph~Node} nodes node of sankey view | [
"Compute",
"the",
"value",
"of",
"each",
"node",
"by",
"summing",
"the",
"associated",
"edge",
"s",
"value"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L91-L98 |
226 | apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | computeNodeBreadths | function computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nodeAlign) {
// Used to mark whether the edge is deleted. if it is deleted,
// the value is 0, otherwise it is 1.
var remainEdges = [];
// Storage each node's indegree.
var indegreeArr = [];
//Used to storage the node with indegree is equal to 0.
var zeroIndegrees = [];
var nextTargetNode = [];
var x = 0;
var kx = 0;
for (var i = 0; i < edges.length; i++) {
remainEdges[i] = 1;
}
for (i = 0; i < nodes.length; i++) {
indegreeArr[i] = nodes[i].inEdges.length;
if (indegreeArr[i] === 0) {
zeroIndegrees.push(nodes[i]);
}
}
var maxNodeDepth = -1;
// Traversing nodes using topological sorting to calculate the
// horizontal(if orient === 'horizontal') or vertical(if orient === 'vertical')
// position of the nodes.
while (zeroIndegrees.length) {
for (var idx = 0; idx < zeroIndegrees.length; idx++) {
var node = zeroIndegrees[idx];
var item = node.hostGraph.data.getRawDataItem(node.dataIndex);
var isItemDepth = item.depth != null && item.depth >= 0;
if (isItemDepth && item.depth > maxNodeDepth) {
maxNodeDepth = item.depth;
}
node.setLayout({depth: isItemDepth ? item.depth : x}, true);
orient === 'vertical'
? node.setLayout({dy: nodeWidth}, true)
: node.setLayout({dx: nodeWidth}, true);
for (var edgeIdx = 0; edgeIdx < node.outEdges.length; edgeIdx++) {
var edge = node.outEdges[edgeIdx];
var indexEdge = edges.indexOf(edge);
remainEdges[indexEdge] = 0;
var targetNode = edge.node2;
var nodeIndex = nodes.indexOf(targetNode);
if (--indegreeArr[nodeIndex] === 0 && nextTargetNode.indexOf(targetNode) < 0) {
nextTargetNode.push(targetNode);
}
}
}
++x;
zeroIndegrees = nextTargetNode;
nextTargetNode = [];
}
for (i = 0; i < remainEdges.length; i++) {
if (remainEdges[i] === 1) {
throw new Error('Sankey is a DAG, the original data has cycle!');
}
}
var maxDepth = maxNodeDepth > x - 1 ? maxNodeDepth : x - 1;
if (nodeAlign && nodeAlign !== 'left') {
adjustNodeWithNodeAlign(nodes, nodeAlign, orient, maxDepth);
}
var kx = orient === 'vertical'
? (height - nodeWidth) / maxDepth
: (width - nodeWidth) / maxDepth;
scaleNodeBreadths(nodes, kx, orient);
} | javascript | function computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nodeAlign) {
// Used to mark whether the edge is deleted. if it is deleted,
// the value is 0, otherwise it is 1.
var remainEdges = [];
// Storage each node's indegree.
var indegreeArr = [];
//Used to storage the node with indegree is equal to 0.
var zeroIndegrees = [];
var nextTargetNode = [];
var x = 0;
var kx = 0;
for (var i = 0; i < edges.length; i++) {
remainEdges[i] = 1;
}
for (i = 0; i < nodes.length; i++) {
indegreeArr[i] = nodes[i].inEdges.length;
if (indegreeArr[i] === 0) {
zeroIndegrees.push(nodes[i]);
}
}
var maxNodeDepth = -1;
// Traversing nodes using topological sorting to calculate the
// horizontal(if orient === 'horizontal') or vertical(if orient === 'vertical')
// position of the nodes.
while (zeroIndegrees.length) {
for (var idx = 0; idx < zeroIndegrees.length; idx++) {
var node = zeroIndegrees[idx];
var item = node.hostGraph.data.getRawDataItem(node.dataIndex);
var isItemDepth = item.depth != null && item.depth >= 0;
if (isItemDepth && item.depth > maxNodeDepth) {
maxNodeDepth = item.depth;
}
node.setLayout({depth: isItemDepth ? item.depth : x}, true);
orient === 'vertical'
? node.setLayout({dy: nodeWidth}, true)
: node.setLayout({dx: nodeWidth}, true);
for (var edgeIdx = 0; edgeIdx < node.outEdges.length; edgeIdx++) {
var edge = node.outEdges[edgeIdx];
var indexEdge = edges.indexOf(edge);
remainEdges[indexEdge] = 0;
var targetNode = edge.node2;
var nodeIndex = nodes.indexOf(targetNode);
if (--indegreeArr[nodeIndex] === 0 && nextTargetNode.indexOf(targetNode) < 0) {
nextTargetNode.push(targetNode);
}
}
}
++x;
zeroIndegrees = nextTargetNode;
nextTargetNode = [];
}
for (i = 0; i < remainEdges.length; i++) {
if (remainEdges[i] === 1) {
throw new Error('Sankey is a DAG, the original data has cycle!');
}
}
var maxDepth = maxNodeDepth > x - 1 ? maxNodeDepth : x - 1;
if (nodeAlign && nodeAlign !== 'left') {
adjustNodeWithNodeAlign(nodes, nodeAlign, orient, maxDepth);
}
var kx = orient === 'vertical'
? (height - nodeWidth) / maxDepth
: (width - nodeWidth) / maxDepth;
scaleNodeBreadths(nodes, kx, orient);
} | [
"function",
"computeNodeBreadths",
"(",
"nodes",
",",
"edges",
",",
"nodeWidth",
",",
"width",
",",
"height",
",",
"orient",
",",
"nodeAlign",
")",
"{",
"// Used to mark whether the edge is deleted. if it is deleted,",
"// the value is 0, otherwise it is 1.",
"var",
"remainEdges",
"=",
"[",
"]",
";",
"// Storage each node's indegree.",
"var",
"indegreeArr",
"=",
"[",
"]",
";",
"//Used to storage the node with indegree is equal to 0.",
"var",
"zeroIndegrees",
"=",
"[",
"]",
";",
"var",
"nextTargetNode",
"=",
"[",
"]",
";",
"var",
"x",
"=",
"0",
";",
"var",
"kx",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"edges",
".",
"length",
";",
"i",
"++",
")",
"{",
"remainEdges",
"[",
"i",
"]",
"=",
"1",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"indegreeArr",
"[",
"i",
"]",
"=",
"nodes",
"[",
"i",
"]",
".",
"inEdges",
".",
"length",
";",
"if",
"(",
"indegreeArr",
"[",
"i",
"]",
"===",
"0",
")",
"{",
"zeroIndegrees",
".",
"push",
"(",
"nodes",
"[",
"i",
"]",
")",
";",
"}",
"}",
"var",
"maxNodeDepth",
"=",
"-",
"1",
";",
"// Traversing nodes using topological sorting to calculate the",
"// horizontal(if orient === 'horizontal') or vertical(if orient === 'vertical')",
"// position of the nodes.",
"while",
"(",
"zeroIndegrees",
".",
"length",
")",
"{",
"for",
"(",
"var",
"idx",
"=",
"0",
";",
"idx",
"<",
"zeroIndegrees",
".",
"length",
";",
"idx",
"++",
")",
"{",
"var",
"node",
"=",
"zeroIndegrees",
"[",
"idx",
"]",
";",
"var",
"item",
"=",
"node",
".",
"hostGraph",
".",
"data",
".",
"getRawDataItem",
"(",
"node",
".",
"dataIndex",
")",
";",
"var",
"isItemDepth",
"=",
"item",
".",
"depth",
"!=",
"null",
"&&",
"item",
".",
"depth",
">=",
"0",
";",
"if",
"(",
"isItemDepth",
"&&",
"item",
".",
"depth",
">",
"maxNodeDepth",
")",
"{",
"maxNodeDepth",
"=",
"item",
".",
"depth",
";",
"}",
"node",
".",
"setLayout",
"(",
"{",
"depth",
":",
"isItemDepth",
"?",
"item",
".",
"depth",
":",
"x",
"}",
",",
"true",
")",
";",
"orient",
"===",
"'vertical'",
"?",
"node",
".",
"setLayout",
"(",
"{",
"dy",
":",
"nodeWidth",
"}",
",",
"true",
")",
":",
"node",
".",
"setLayout",
"(",
"{",
"dx",
":",
"nodeWidth",
"}",
",",
"true",
")",
";",
"for",
"(",
"var",
"edgeIdx",
"=",
"0",
";",
"edgeIdx",
"<",
"node",
".",
"outEdges",
".",
"length",
";",
"edgeIdx",
"++",
")",
"{",
"var",
"edge",
"=",
"node",
".",
"outEdges",
"[",
"edgeIdx",
"]",
";",
"var",
"indexEdge",
"=",
"edges",
".",
"indexOf",
"(",
"edge",
")",
";",
"remainEdges",
"[",
"indexEdge",
"]",
"=",
"0",
";",
"var",
"targetNode",
"=",
"edge",
".",
"node2",
";",
"var",
"nodeIndex",
"=",
"nodes",
".",
"indexOf",
"(",
"targetNode",
")",
";",
"if",
"(",
"--",
"indegreeArr",
"[",
"nodeIndex",
"]",
"===",
"0",
"&&",
"nextTargetNode",
".",
"indexOf",
"(",
"targetNode",
")",
"<",
"0",
")",
"{",
"nextTargetNode",
".",
"push",
"(",
"targetNode",
")",
";",
"}",
"}",
"}",
"++",
"x",
";",
"zeroIndegrees",
"=",
"nextTargetNode",
";",
"nextTargetNode",
"=",
"[",
"]",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"remainEdges",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"remainEdges",
"[",
"i",
"]",
"===",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Sankey is a DAG, the original data has cycle!'",
")",
";",
"}",
"}",
"var",
"maxDepth",
"=",
"maxNodeDepth",
">",
"x",
"-",
"1",
"?",
"maxNodeDepth",
":",
"x",
"-",
"1",
";",
"if",
"(",
"nodeAlign",
"&&",
"nodeAlign",
"!==",
"'left'",
")",
"{",
"adjustNodeWithNodeAlign",
"(",
"nodes",
",",
"nodeAlign",
",",
"orient",
",",
"maxDepth",
")",
";",
"}",
"var",
"kx",
"=",
"orient",
"===",
"'vertical'",
"?",
"(",
"height",
"-",
"nodeWidth",
")",
"/",
"maxDepth",
":",
"(",
"width",
"-",
"nodeWidth",
")",
"/",
"maxDepth",
";",
"scaleNodeBreadths",
"(",
"nodes",
",",
"kx",
",",
"orient",
")",
";",
"}"
] | Compute the x-position for each node.
Here we use Kahn algorithm to detect cycle when we traverse
the node to computer the initial x position.
@param {module:echarts/data/Graph~Node} nodes node of sankey view
@param {number} nodeWidth the dx of the node
@param {number} width the whole width of the area to draw the view | [
"Compute",
"the",
"x",
"-",
"position",
"for",
"each",
"node",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L110-L179 |
227 | apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | moveSinksRight | function moveSinksRight(nodes, maxDepth) {
zrUtil.each(nodes, function (node) {
if (!isNodeDepth(node) && !node.outEdges.length) {
node.setLayout({depth: maxDepth}, true);
}
});
} | javascript | function moveSinksRight(nodes, maxDepth) {
zrUtil.each(nodes, function (node) {
if (!isNodeDepth(node) && !node.outEdges.length) {
node.setLayout({depth: maxDepth}, true);
}
});
} | [
"function",
"moveSinksRight",
"(",
"nodes",
",",
"maxDepth",
")",
"{",
"zrUtil",
".",
"each",
"(",
"nodes",
",",
"function",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"isNodeDepth",
"(",
"node",
")",
"&&",
"!",
"node",
".",
"outEdges",
".",
"length",
")",
"{",
"node",
".",
"setLayout",
"(",
"{",
"depth",
":",
"maxDepth",
"}",
",",
"true",
")",
";",
"}",
"}",
")",
";",
"}"
] | All the node without outEgdes are assigned maximum x-position and
be aligned in the last column.
@param {module:echarts/data/Graph~Node} nodes. node of sankey view.
@param {number} maxDepth. use to assign to node without outEdges as x-position. | [
"All",
"the",
"node",
"without",
"outEgdes",
"are",
"assigned",
"maximum",
"x",
"-",
"position",
"and",
"be",
"aligned",
"in",
"the",
"last",
"column",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L225-L231 |
228 | apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | scaleNodeBreadths | function scaleNodeBreadths(nodes, kx, orient) {
zrUtil.each(nodes, function (node) {
var nodeDepth = node.getLayout().depth * kx;
orient === 'vertical'
? node.setLayout({y: nodeDepth}, true)
: node.setLayout({x: nodeDepth}, true);
});
} | javascript | function scaleNodeBreadths(nodes, kx, orient) {
zrUtil.each(nodes, function (node) {
var nodeDepth = node.getLayout().depth * kx;
orient === 'vertical'
? node.setLayout({y: nodeDepth}, true)
: node.setLayout({x: nodeDepth}, true);
});
} | [
"function",
"scaleNodeBreadths",
"(",
"nodes",
",",
"kx",
",",
"orient",
")",
"{",
"zrUtil",
".",
"each",
"(",
"nodes",
",",
"function",
"(",
"node",
")",
"{",
"var",
"nodeDepth",
"=",
"node",
".",
"getLayout",
"(",
")",
".",
"depth",
"*",
"kx",
";",
"orient",
"===",
"'vertical'",
"?",
"node",
".",
"setLayout",
"(",
"{",
"y",
":",
"nodeDepth",
"}",
",",
"true",
")",
":",
"node",
".",
"setLayout",
"(",
"{",
"x",
":",
"nodeDepth",
"}",
",",
"true",
")",
";",
"}",
")",
";",
"}"
] | Scale node x-position to the width
@param {module:echarts/data/Graph~Node} nodes node of sankey view
@param {number} kx multiple used to scale nodes | [
"Scale",
"node",
"x",
"-",
"position",
"to",
"the",
"width"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L239-L246 |
229 | apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | initializeNodeDepth | function initializeNodeDepth(nodesByBreadth, edges, height, width, nodeGap, orient) {
var minKy = Infinity;
zrUtil.each(nodesByBreadth, function (nodes) {
var n = nodes.length;
var sum = 0;
zrUtil.each(nodes, function (node) {
sum += node.getLayout().value;
});
var ky = orient === 'vertical'
? (width - (n - 1) * nodeGap) / sum
: (height - (n - 1) * nodeGap) / sum;
if (ky < minKy) {
minKy = ky;
}
});
zrUtil.each(nodesByBreadth, function (nodes) {
zrUtil.each(nodes, function (node, i) {
var nodeDy = node.getLayout().value * minKy;
if (orient === 'vertical') {
node.setLayout({x: i}, true);
node.setLayout({dx: nodeDy}, true);
}
else {
node.setLayout({y: i}, true);
node.setLayout({dy: nodeDy}, true);
}
});
});
zrUtil.each(edges, function (edge) {
var edgeDy = +edge.getValue() * minKy;
edge.setLayout({dy: edgeDy}, true);
});
} | javascript | function initializeNodeDepth(nodesByBreadth, edges, height, width, nodeGap, orient) {
var minKy = Infinity;
zrUtil.each(nodesByBreadth, function (nodes) {
var n = nodes.length;
var sum = 0;
zrUtil.each(nodes, function (node) {
sum += node.getLayout().value;
});
var ky = orient === 'vertical'
? (width - (n - 1) * nodeGap) / sum
: (height - (n - 1) * nodeGap) / sum;
if (ky < minKy) {
minKy = ky;
}
});
zrUtil.each(nodesByBreadth, function (nodes) {
zrUtil.each(nodes, function (node, i) {
var nodeDy = node.getLayout().value * minKy;
if (orient === 'vertical') {
node.setLayout({x: i}, true);
node.setLayout({dx: nodeDy}, true);
}
else {
node.setLayout({y: i}, true);
node.setLayout({dy: nodeDy}, true);
}
});
});
zrUtil.each(edges, function (edge) {
var edgeDy = +edge.getValue() * minKy;
edge.setLayout({dy: edgeDy}, true);
});
} | [
"function",
"initializeNodeDepth",
"(",
"nodesByBreadth",
",",
"edges",
",",
"height",
",",
"width",
",",
"nodeGap",
",",
"orient",
")",
"{",
"var",
"minKy",
"=",
"Infinity",
";",
"zrUtil",
".",
"each",
"(",
"nodesByBreadth",
",",
"function",
"(",
"nodes",
")",
"{",
"var",
"n",
"=",
"nodes",
".",
"length",
";",
"var",
"sum",
"=",
"0",
";",
"zrUtil",
".",
"each",
"(",
"nodes",
",",
"function",
"(",
"node",
")",
"{",
"sum",
"+=",
"node",
".",
"getLayout",
"(",
")",
".",
"value",
";",
"}",
")",
";",
"var",
"ky",
"=",
"orient",
"===",
"'vertical'",
"?",
"(",
"width",
"-",
"(",
"n",
"-",
"1",
")",
"*",
"nodeGap",
")",
"/",
"sum",
":",
"(",
"height",
"-",
"(",
"n",
"-",
"1",
")",
"*",
"nodeGap",
")",
"/",
"sum",
";",
"if",
"(",
"ky",
"<",
"minKy",
")",
"{",
"minKy",
"=",
"ky",
";",
"}",
"}",
")",
";",
"zrUtil",
".",
"each",
"(",
"nodesByBreadth",
",",
"function",
"(",
"nodes",
")",
"{",
"zrUtil",
".",
"each",
"(",
"nodes",
",",
"function",
"(",
"node",
",",
"i",
")",
"{",
"var",
"nodeDy",
"=",
"node",
".",
"getLayout",
"(",
")",
".",
"value",
"*",
"minKy",
";",
"if",
"(",
"orient",
"===",
"'vertical'",
")",
"{",
"node",
".",
"setLayout",
"(",
"{",
"x",
":",
"i",
"}",
",",
"true",
")",
";",
"node",
".",
"setLayout",
"(",
"{",
"dx",
":",
"nodeDy",
"}",
",",
"true",
")",
";",
"}",
"else",
"{",
"node",
".",
"setLayout",
"(",
"{",
"y",
":",
"i",
"}",
",",
"true",
")",
";",
"node",
".",
"setLayout",
"(",
"{",
"dy",
":",
"nodeDy",
"}",
",",
"true",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"zrUtil",
".",
"each",
"(",
"edges",
",",
"function",
"(",
"edge",
")",
"{",
"var",
"edgeDy",
"=",
"+",
"edge",
".",
"getValue",
"(",
")",
"*",
"minKy",
";",
"edge",
".",
"setLayout",
"(",
"{",
"dy",
":",
"edgeDy",
"}",
",",
"true",
")",
";",
"}",
")",
";",
"}"
] | Compute the original y-position for each node
@param {module:echarts/data/Graph~Node} nodes node of sankey view
@param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
group by the array of all sankey nodes based on the nodes x-position.
@param {module:echarts/data/Graph~Edge} edges edge of sankey view
@param {number} height the whole height of the area to draw the view
@param {number} nodeGap the vertical distance between two nodes | [
"Compute",
"the",
"original",
"y",
"-",
"position",
"for",
"each",
"node"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L302-L337 |
230 | apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | relaxRightToLeft | function relaxRightToLeft(nodesByBreadth, alpha, orient) {
zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) {
zrUtil.each(nodes, function (node) {
if (node.outEdges.length) {
var y = sum(node.outEdges, weightedTarget, orient)
/ sum(node.outEdges, getEdgeValue, orient);
if (orient === 'vertical') {
var nodeX = node.getLayout().x + (y - center(node, orient)) * alpha;
node.setLayout({x: nodeX}, true);
}
else {
var nodeY = node.getLayout().y + (y - center(node, orient)) * alpha;
node.setLayout({y: nodeY}, true);
}
}
});
});
} | javascript | function relaxRightToLeft(nodesByBreadth, alpha, orient) {
zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) {
zrUtil.each(nodes, function (node) {
if (node.outEdges.length) {
var y = sum(node.outEdges, weightedTarget, orient)
/ sum(node.outEdges, getEdgeValue, orient);
if (orient === 'vertical') {
var nodeX = node.getLayout().x + (y - center(node, orient)) * alpha;
node.setLayout({x: nodeX}, true);
}
else {
var nodeY = node.getLayout().y + (y - center(node, orient)) * alpha;
node.setLayout({y: nodeY}, true);
}
}
});
});
} | [
"function",
"relaxRightToLeft",
"(",
"nodesByBreadth",
",",
"alpha",
",",
"orient",
")",
"{",
"zrUtil",
".",
"each",
"(",
"nodesByBreadth",
".",
"slice",
"(",
")",
".",
"reverse",
"(",
")",
",",
"function",
"(",
"nodes",
")",
"{",
"zrUtil",
".",
"each",
"(",
"nodes",
",",
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"outEdges",
".",
"length",
")",
"{",
"var",
"y",
"=",
"sum",
"(",
"node",
".",
"outEdges",
",",
"weightedTarget",
",",
"orient",
")",
"/",
"sum",
"(",
"node",
".",
"outEdges",
",",
"getEdgeValue",
",",
"orient",
")",
";",
"if",
"(",
"orient",
"===",
"'vertical'",
")",
"{",
"var",
"nodeX",
"=",
"node",
".",
"getLayout",
"(",
")",
".",
"x",
"+",
"(",
"y",
"-",
"center",
"(",
"node",
",",
"orient",
")",
")",
"*",
"alpha",
";",
"node",
".",
"setLayout",
"(",
"{",
"x",
":",
"nodeX",
"}",
",",
"true",
")",
";",
"}",
"else",
"{",
"var",
"nodeY",
"=",
"node",
".",
"getLayout",
"(",
")",
".",
"y",
"+",
"(",
"y",
"-",
"center",
"(",
"node",
",",
"orient",
")",
")",
"*",
"alpha",
";",
"node",
".",
"setLayout",
"(",
"{",
"y",
":",
"nodeY",
"}",
",",
"true",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Change the y-position of the nodes, except most the right side nodes
@param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
group by the array of all sankey nodes based on the node x-position.
@param {number} alpha parameter used to adjust the nodes y-position | [
"Change",
"the",
"y",
"-",
"position",
"of",
"the",
"nodes",
"except",
"most",
"the",
"right",
"side",
"nodes"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L402-L419 |
231 | apache/incubator-echarts | src/coord/calendar/Calendar.js | function (date) {
date = numberUtil.parseDate(date);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? '0' + m : m;
var d = date.getDate();
d = d < 10 ? '0' + d : d;
var day = date.getDay();
day = Math.abs((day + 7 - this.getFirstDayOfWeek()) % 7);
return {
y: y,
m: m,
d: d,
day: day,
time: date.getTime(),
formatedDate: y + '-' + m + '-' + d,
date: date
};
} | javascript | function (date) {
date = numberUtil.parseDate(date);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? '0' + m : m;
var d = date.getDate();
d = d < 10 ? '0' + d : d;
var day = date.getDay();
day = Math.abs((day + 7 - this.getFirstDayOfWeek()) % 7);
return {
y: y,
m: m,
d: d,
day: day,
time: date.getTime(),
formatedDate: y + '-' + m + '-' + d,
date: date
};
} | [
"function",
"(",
"date",
")",
"{",
"date",
"=",
"numberUtil",
".",
"parseDate",
"(",
"date",
")",
";",
"var",
"y",
"=",
"date",
".",
"getFullYear",
"(",
")",
";",
"var",
"m",
"=",
"date",
".",
"getMonth",
"(",
")",
"+",
"1",
";",
"m",
"=",
"m",
"<",
"10",
"?",
"'0'",
"+",
"m",
":",
"m",
";",
"var",
"d",
"=",
"date",
".",
"getDate",
"(",
")",
";",
"d",
"=",
"d",
"<",
"10",
"?",
"'0'",
"+",
"d",
":",
"d",
";",
"var",
"day",
"=",
"date",
".",
"getDay",
"(",
")",
";",
"day",
"=",
"Math",
".",
"abs",
"(",
"(",
"day",
"+",
"7",
"-",
"this",
".",
"getFirstDayOfWeek",
"(",
")",
")",
"%",
"7",
")",
";",
"return",
"{",
"y",
":",
"y",
",",
"m",
":",
"m",
",",
"d",
":",
"d",
",",
"day",
":",
"day",
",",
"time",
":",
"date",
".",
"getTime",
"(",
")",
",",
"formatedDate",
":",
"y",
"+",
"'-'",
"+",
"m",
"+",
"'-'",
"+",
"d",
",",
"date",
":",
"date",
"}",
";",
"}"
] | get date info
@param {string|number} date date
@return {Object}
{
y: string, local full year, eg., '1940',
m: string, local month, from '01' ot '12',
d: string, local date, from '01' to '31' (if exists),
day: It is not date.getDay(). It is the location of the cell in a week, from 0 to 6,
time: timestamp,
formatedDate: string, yyyy-MM-dd,
date: original date object.
} | [
"get",
"date",
"info"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/calendar/Calendar.js#L106-L131 |
|
232 | apache/incubator-echarts | src/coord/calendar/Calendar.js | function (nthWeek, day, range) {
var rangeInfo = this._getRangeInfo(range);
if (nthWeek > rangeInfo.weeks
|| (nthWeek === 0 && day < rangeInfo.fweek)
|| (nthWeek === rangeInfo.weeks && day > rangeInfo.lweek)
) {
return false;
}
var nthDay = (nthWeek - 1) * 7 - rangeInfo.fweek + day;
var date = new Date(rangeInfo.start.time);
date.setDate(rangeInfo.start.d + nthDay);
return this.getDateInfo(date);
} | javascript | function (nthWeek, day, range) {
var rangeInfo = this._getRangeInfo(range);
if (nthWeek > rangeInfo.weeks
|| (nthWeek === 0 && day < rangeInfo.fweek)
|| (nthWeek === rangeInfo.weeks && day > rangeInfo.lweek)
) {
return false;
}
var nthDay = (nthWeek - 1) * 7 - rangeInfo.fweek + day;
var date = new Date(rangeInfo.start.time);
date.setDate(rangeInfo.start.d + nthDay);
return this.getDateInfo(date);
} | [
"function",
"(",
"nthWeek",
",",
"day",
",",
"range",
")",
"{",
"var",
"rangeInfo",
"=",
"this",
".",
"_getRangeInfo",
"(",
"range",
")",
";",
"if",
"(",
"nthWeek",
">",
"rangeInfo",
".",
"weeks",
"||",
"(",
"nthWeek",
"===",
"0",
"&&",
"day",
"<",
"rangeInfo",
".",
"fweek",
")",
"||",
"(",
"nthWeek",
"===",
"rangeInfo",
".",
"weeks",
"&&",
"day",
">",
"rangeInfo",
".",
"lweek",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"nthDay",
"=",
"(",
"nthWeek",
"-",
"1",
")",
"*",
"7",
"-",
"rangeInfo",
".",
"fweek",
"+",
"day",
";",
"var",
"date",
"=",
"new",
"Date",
"(",
"rangeInfo",
".",
"start",
".",
"time",
")",
";",
"date",
".",
"setDate",
"(",
"rangeInfo",
".",
"start",
".",
"d",
"+",
"nthDay",
")",
";",
"return",
"this",
".",
"getDateInfo",
"(",
"date",
")",
";",
"}"
] | get date by nthWeeks and week day in range
@private
@param {number} nthWeek the week
@param {number} day the week day
@param {Array} range [d1, d2]
@return {Object} | [
"get",
"date",
"by",
"nthWeeks",
"and",
"week",
"day",
"in",
"range"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/calendar/Calendar.js#L426-L441 |
|
233 | apache/incubator-echarts | src/component/axis/AxisView.js | function (axisModel, ecModel, api, payload, force) {
updateAxisPointer(this, axisModel, ecModel, api, payload, false);
} | javascript | function (axisModel, ecModel, api, payload, force) {
updateAxisPointer(this, axisModel, ecModel, api, payload, false);
} | [
"function",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
",",
"payload",
",",
"force",
")",
"{",
"updateAxisPointer",
"(",
"this",
",",
"axisModel",
",",
"ecModel",
",",
"api",
",",
"payload",
",",
"false",
")",
";",
"}"
] | Action handler.
@public
@param {module:echarts/coord/cartesian/AxisModel} axisModel
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api
@param {Object} payload | [
"Action",
"handler",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/axis/AxisView.js#L66-L68 |
|
234 | apache/incubator-echarts | src/chart/bar/PictorialBarView.js | getSymbolMeta | function getSymbolMeta(data, dataIndex, itemModel, opt) {
var layout = data.getItemLayout(dataIndex);
var symbolRepeat = itemModel.get('symbolRepeat');
var symbolClip = itemModel.get('symbolClip');
var symbolPosition = itemModel.get('symbolPosition') || 'start';
var symbolRotate = itemModel.get('symbolRotate');
var rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
var symbolPatternSize = itemModel.get('symbolPatternSize') || 2;
var isAnimationEnabled = itemModel.isAnimationEnabled();
var symbolMeta = {
dataIndex: dataIndex,
layout: layout,
itemModel: itemModel,
symbolType: data.getItemVisual(dataIndex, 'symbol') || 'circle',
color: data.getItemVisual(dataIndex, 'color'),
symbolClip: symbolClip,
symbolRepeat: symbolRepeat,
symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
symbolPatternSize: symbolPatternSize,
rotation: rotation,
animationModel: isAnimationEnabled ? itemModel : null,
hoverAnimation: isAnimationEnabled && itemModel.get('hoverAnimation'),
z2: itemModel.getShallow('z', true) || 0
};
prepareBarLength(itemModel, symbolRepeat, layout, opt, symbolMeta);
prepareSymbolSize(
data, dataIndex, layout, symbolRepeat, symbolClip, symbolMeta.boundingLength,
symbolMeta.pxSign, symbolPatternSize, opt, symbolMeta
);
prepareLineWidth(itemModel, symbolMeta.symbolScale, rotation, opt, symbolMeta);
var symbolSize = symbolMeta.symbolSize;
var symbolOffset = itemModel.get('symbolOffset');
if (zrUtil.isArray(symbolOffset)) {
symbolOffset = [
parsePercent(symbolOffset[0], symbolSize[0]),
parsePercent(symbolOffset[1], symbolSize[1])
];
}
prepareLayoutInfo(
itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset,
symbolPosition, symbolMeta.valueLineWidth, symbolMeta.boundingLength, symbolMeta.repeatCutLength,
opt, symbolMeta
);
return symbolMeta;
} | javascript | function getSymbolMeta(data, dataIndex, itemModel, opt) {
var layout = data.getItemLayout(dataIndex);
var symbolRepeat = itemModel.get('symbolRepeat');
var symbolClip = itemModel.get('symbolClip');
var symbolPosition = itemModel.get('symbolPosition') || 'start';
var symbolRotate = itemModel.get('symbolRotate');
var rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
var symbolPatternSize = itemModel.get('symbolPatternSize') || 2;
var isAnimationEnabled = itemModel.isAnimationEnabled();
var symbolMeta = {
dataIndex: dataIndex,
layout: layout,
itemModel: itemModel,
symbolType: data.getItemVisual(dataIndex, 'symbol') || 'circle',
color: data.getItemVisual(dataIndex, 'color'),
symbolClip: symbolClip,
symbolRepeat: symbolRepeat,
symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
symbolPatternSize: symbolPatternSize,
rotation: rotation,
animationModel: isAnimationEnabled ? itemModel : null,
hoverAnimation: isAnimationEnabled && itemModel.get('hoverAnimation'),
z2: itemModel.getShallow('z', true) || 0
};
prepareBarLength(itemModel, symbolRepeat, layout, opt, symbolMeta);
prepareSymbolSize(
data, dataIndex, layout, symbolRepeat, symbolClip, symbolMeta.boundingLength,
symbolMeta.pxSign, symbolPatternSize, opt, symbolMeta
);
prepareLineWidth(itemModel, symbolMeta.symbolScale, rotation, opt, symbolMeta);
var symbolSize = symbolMeta.symbolSize;
var symbolOffset = itemModel.get('symbolOffset');
if (zrUtil.isArray(symbolOffset)) {
symbolOffset = [
parsePercent(symbolOffset[0], symbolSize[0]),
parsePercent(symbolOffset[1], symbolSize[1])
];
}
prepareLayoutInfo(
itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset,
symbolPosition, symbolMeta.valueLineWidth, symbolMeta.boundingLength, symbolMeta.repeatCutLength,
opt, symbolMeta
);
return symbolMeta;
} | [
"function",
"getSymbolMeta",
"(",
"data",
",",
"dataIndex",
",",
"itemModel",
",",
"opt",
")",
"{",
"var",
"layout",
"=",
"data",
".",
"getItemLayout",
"(",
"dataIndex",
")",
";",
"var",
"symbolRepeat",
"=",
"itemModel",
".",
"get",
"(",
"'symbolRepeat'",
")",
";",
"var",
"symbolClip",
"=",
"itemModel",
".",
"get",
"(",
"'symbolClip'",
")",
";",
"var",
"symbolPosition",
"=",
"itemModel",
".",
"get",
"(",
"'symbolPosition'",
")",
"||",
"'start'",
";",
"var",
"symbolRotate",
"=",
"itemModel",
".",
"get",
"(",
"'symbolRotate'",
")",
";",
"var",
"rotation",
"=",
"(",
"symbolRotate",
"||",
"0",
")",
"*",
"Math",
".",
"PI",
"/",
"180",
"||",
"0",
";",
"var",
"symbolPatternSize",
"=",
"itemModel",
".",
"get",
"(",
"'symbolPatternSize'",
")",
"||",
"2",
";",
"var",
"isAnimationEnabled",
"=",
"itemModel",
".",
"isAnimationEnabled",
"(",
")",
";",
"var",
"symbolMeta",
"=",
"{",
"dataIndex",
":",
"dataIndex",
",",
"layout",
":",
"layout",
",",
"itemModel",
":",
"itemModel",
",",
"symbolType",
":",
"data",
".",
"getItemVisual",
"(",
"dataIndex",
",",
"'symbol'",
")",
"||",
"'circle'",
",",
"color",
":",
"data",
".",
"getItemVisual",
"(",
"dataIndex",
",",
"'color'",
")",
",",
"symbolClip",
":",
"symbolClip",
",",
"symbolRepeat",
":",
"symbolRepeat",
",",
"symbolRepeatDirection",
":",
"itemModel",
".",
"get",
"(",
"'symbolRepeatDirection'",
")",
",",
"symbolPatternSize",
":",
"symbolPatternSize",
",",
"rotation",
":",
"rotation",
",",
"animationModel",
":",
"isAnimationEnabled",
"?",
"itemModel",
":",
"null",
",",
"hoverAnimation",
":",
"isAnimationEnabled",
"&&",
"itemModel",
".",
"get",
"(",
"'hoverAnimation'",
")",
",",
"z2",
":",
"itemModel",
".",
"getShallow",
"(",
"'z'",
",",
"true",
")",
"||",
"0",
"}",
";",
"prepareBarLength",
"(",
"itemModel",
",",
"symbolRepeat",
",",
"layout",
",",
"opt",
",",
"symbolMeta",
")",
";",
"prepareSymbolSize",
"(",
"data",
",",
"dataIndex",
",",
"layout",
",",
"symbolRepeat",
",",
"symbolClip",
",",
"symbolMeta",
".",
"boundingLength",
",",
"symbolMeta",
".",
"pxSign",
",",
"symbolPatternSize",
",",
"opt",
",",
"symbolMeta",
")",
";",
"prepareLineWidth",
"(",
"itemModel",
",",
"symbolMeta",
".",
"symbolScale",
",",
"rotation",
",",
"opt",
",",
"symbolMeta",
")",
";",
"var",
"symbolSize",
"=",
"symbolMeta",
".",
"symbolSize",
";",
"var",
"symbolOffset",
"=",
"itemModel",
".",
"get",
"(",
"'symbolOffset'",
")",
";",
"if",
"(",
"zrUtil",
".",
"isArray",
"(",
"symbolOffset",
")",
")",
"{",
"symbolOffset",
"=",
"[",
"parsePercent",
"(",
"symbolOffset",
"[",
"0",
"]",
",",
"symbolSize",
"[",
"0",
"]",
")",
",",
"parsePercent",
"(",
"symbolOffset",
"[",
"1",
"]",
",",
"symbolSize",
"[",
"1",
"]",
")",
"]",
";",
"}",
"prepareLayoutInfo",
"(",
"itemModel",
",",
"symbolSize",
",",
"layout",
",",
"symbolRepeat",
",",
"symbolClip",
",",
"symbolOffset",
",",
"symbolPosition",
",",
"symbolMeta",
".",
"valueLineWidth",
",",
"symbolMeta",
".",
"boundingLength",
",",
"symbolMeta",
".",
"repeatCutLength",
",",
"opt",
",",
"symbolMeta",
")",
";",
"return",
"symbolMeta",
";",
"}"
] | Set or calculate default value about symbol, and calculate layout info. | [
"Set",
"or",
"calculate",
"default",
"value",
"about",
"symbol",
"and",
"calculate",
"layout",
"info",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/bar/PictorialBarView.js#L144-L195 |
235 | apache/incubator-echarts | src/chart/bar/PictorialBarView.js | prepareBarLength | function prepareBarLength(itemModel, symbolRepeat, layout, opt, output) {
var valueDim = opt.valueDim;
var symbolBoundingData = itemModel.get('symbolBoundingData');
var valueAxis = opt.coordSys.getOtherAxis(opt.coordSys.getBaseAxis());
var zeroPx = valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
var pxSignIdx = 1 - +(layout[valueDim.wh] <= 0);
var boundingLength;
if (zrUtil.isArray(symbolBoundingData)) {
var symbolBoundingExtent = [
convertToCoordOnAxis(valueAxis, symbolBoundingData[0]) - zeroPx,
convertToCoordOnAxis(valueAxis, symbolBoundingData[1]) - zeroPx
];
symbolBoundingExtent[1] < symbolBoundingExtent[0] && (symbolBoundingExtent.reverse());
boundingLength = symbolBoundingExtent[pxSignIdx];
}
else if (symbolBoundingData != null) {
boundingLength = convertToCoordOnAxis(valueAxis, symbolBoundingData) - zeroPx;
}
else if (symbolRepeat) {
boundingLength = opt.coordSysExtent[valueDim.index][pxSignIdx] - zeroPx;
}
else {
boundingLength = layout[valueDim.wh];
}
output.boundingLength = boundingLength;
if (symbolRepeat) {
output.repeatCutLength = layout[valueDim.wh];
}
output.pxSign = boundingLength > 0 ? 1 : boundingLength < 0 ? -1 : 0;
} | javascript | function prepareBarLength(itemModel, symbolRepeat, layout, opt, output) {
var valueDim = opt.valueDim;
var symbolBoundingData = itemModel.get('symbolBoundingData');
var valueAxis = opt.coordSys.getOtherAxis(opt.coordSys.getBaseAxis());
var zeroPx = valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
var pxSignIdx = 1 - +(layout[valueDim.wh] <= 0);
var boundingLength;
if (zrUtil.isArray(symbolBoundingData)) {
var symbolBoundingExtent = [
convertToCoordOnAxis(valueAxis, symbolBoundingData[0]) - zeroPx,
convertToCoordOnAxis(valueAxis, symbolBoundingData[1]) - zeroPx
];
symbolBoundingExtent[1] < symbolBoundingExtent[0] && (symbolBoundingExtent.reverse());
boundingLength = symbolBoundingExtent[pxSignIdx];
}
else if (symbolBoundingData != null) {
boundingLength = convertToCoordOnAxis(valueAxis, symbolBoundingData) - zeroPx;
}
else if (symbolRepeat) {
boundingLength = opt.coordSysExtent[valueDim.index][pxSignIdx] - zeroPx;
}
else {
boundingLength = layout[valueDim.wh];
}
output.boundingLength = boundingLength;
if (symbolRepeat) {
output.repeatCutLength = layout[valueDim.wh];
}
output.pxSign = boundingLength > 0 ? 1 : boundingLength < 0 ? -1 : 0;
} | [
"function",
"prepareBarLength",
"(",
"itemModel",
",",
"symbolRepeat",
",",
"layout",
",",
"opt",
",",
"output",
")",
"{",
"var",
"valueDim",
"=",
"opt",
".",
"valueDim",
";",
"var",
"symbolBoundingData",
"=",
"itemModel",
".",
"get",
"(",
"'symbolBoundingData'",
")",
";",
"var",
"valueAxis",
"=",
"opt",
".",
"coordSys",
".",
"getOtherAxis",
"(",
"opt",
".",
"coordSys",
".",
"getBaseAxis",
"(",
")",
")",
";",
"var",
"zeroPx",
"=",
"valueAxis",
".",
"toGlobalCoord",
"(",
"valueAxis",
".",
"dataToCoord",
"(",
"0",
")",
")",
";",
"var",
"pxSignIdx",
"=",
"1",
"-",
"+",
"(",
"layout",
"[",
"valueDim",
".",
"wh",
"]",
"<=",
"0",
")",
";",
"var",
"boundingLength",
";",
"if",
"(",
"zrUtil",
".",
"isArray",
"(",
"symbolBoundingData",
")",
")",
"{",
"var",
"symbolBoundingExtent",
"=",
"[",
"convertToCoordOnAxis",
"(",
"valueAxis",
",",
"symbolBoundingData",
"[",
"0",
"]",
")",
"-",
"zeroPx",
",",
"convertToCoordOnAxis",
"(",
"valueAxis",
",",
"symbolBoundingData",
"[",
"1",
"]",
")",
"-",
"zeroPx",
"]",
";",
"symbolBoundingExtent",
"[",
"1",
"]",
"<",
"symbolBoundingExtent",
"[",
"0",
"]",
"&&",
"(",
"symbolBoundingExtent",
".",
"reverse",
"(",
")",
")",
";",
"boundingLength",
"=",
"symbolBoundingExtent",
"[",
"pxSignIdx",
"]",
";",
"}",
"else",
"if",
"(",
"symbolBoundingData",
"!=",
"null",
")",
"{",
"boundingLength",
"=",
"convertToCoordOnAxis",
"(",
"valueAxis",
",",
"symbolBoundingData",
")",
"-",
"zeroPx",
";",
"}",
"else",
"if",
"(",
"symbolRepeat",
")",
"{",
"boundingLength",
"=",
"opt",
".",
"coordSysExtent",
"[",
"valueDim",
".",
"index",
"]",
"[",
"pxSignIdx",
"]",
"-",
"zeroPx",
";",
"}",
"else",
"{",
"boundingLength",
"=",
"layout",
"[",
"valueDim",
".",
"wh",
"]",
";",
"}",
"output",
".",
"boundingLength",
"=",
"boundingLength",
";",
"if",
"(",
"symbolRepeat",
")",
"{",
"output",
".",
"repeatCutLength",
"=",
"layout",
"[",
"valueDim",
".",
"wh",
"]",
";",
"}",
"output",
".",
"pxSign",
"=",
"boundingLength",
">",
"0",
"?",
"1",
":",
"boundingLength",
"<",
"0",
"?",
"-",
"1",
":",
"0",
";",
"}"
] | bar length can be negative. | [
"bar",
"length",
"can",
"be",
"negative",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/bar/PictorialBarView.js#L198-L231 |
236 | apache/incubator-echarts | src/chart/bar/PictorialBarView.js | createOrUpdateBarRect | function createOrUpdateBarRect(bar, symbolMeta, isUpdate) {
var rectShape = zrUtil.extend({}, symbolMeta.barRectShape);
var barRect = bar.__pictorialBarRect;
if (!barRect) {
barRect = bar.__pictorialBarRect = new graphic.Rect({
z2: 2,
shape: rectShape,
silent: true,
style: {
stroke: 'transparent',
fill: 'transparent',
lineWidth: 0
}
});
bar.add(barRect);
}
else {
updateAttr(barRect, null, {shape: rectShape}, symbolMeta, isUpdate);
}
} | javascript | function createOrUpdateBarRect(bar, symbolMeta, isUpdate) {
var rectShape = zrUtil.extend({}, symbolMeta.barRectShape);
var barRect = bar.__pictorialBarRect;
if (!barRect) {
barRect = bar.__pictorialBarRect = new graphic.Rect({
z2: 2,
shape: rectShape,
silent: true,
style: {
stroke: 'transparent',
fill: 'transparent',
lineWidth: 0
}
});
bar.add(barRect);
}
else {
updateAttr(barRect, null, {shape: rectShape}, symbolMeta, isUpdate);
}
} | [
"function",
"createOrUpdateBarRect",
"(",
"bar",
",",
"symbolMeta",
",",
"isUpdate",
")",
"{",
"var",
"rectShape",
"=",
"zrUtil",
".",
"extend",
"(",
"{",
"}",
",",
"symbolMeta",
".",
"barRectShape",
")",
";",
"var",
"barRect",
"=",
"bar",
".",
"__pictorialBarRect",
";",
"if",
"(",
"!",
"barRect",
")",
"{",
"barRect",
"=",
"bar",
".",
"__pictorialBarRect",
"=",
"new",
"graphic",
".",
"Rect",
"(",
"{",
"z2",
":",
"2",
",",
"shape",
":",
"rectShape",
",",
"silent",
":",
"true",
",",
"style",
":",
"{",
"stroke",
":",
"'transparent'",
",",
"fill",
":",
"'transparent'",
",",
"lineWidth",
":",
"0",
"}",
"}",
")",
";",
"bar",
".",
"add",
"(",
"barRect",
")",
";",
"}",
"else",
"{",
"updateAttr",
"(",
"barRect",
",",
"null",
",",
"{",
"shape",
":",
"rectShape",
"}",
",",
"symbolMeta",
",",
"isUpdate",
")",
";",
"}",
"}"
] | bar rect is used for label. | [
"bar",
"rect",
"is",
"used",
"for",
"label",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/bar/PictorialBarView.js#L553-L574 |
237 | apache/incubator-echarts | src/util/graphic.js | centerGraphic | function centerGraphic(rect, boundingRect) {
// Set rect to center, keep width / height ratio.
var aspect = boundingRect.width / boundingRect.height;
var width = rect.height * aspect;
var height;
if (width <= rect.width) {
height = rect.height;
}
else {
width = rect.width;
height = width / aspect;
}
var cx = rect.x + rect.width / 2;
var cy = rect.y + rect.height / 2;
return {
x: cx - width / 2,
y: cy - height / 2,
width: width,
height: height
};
} | javascript | function centerGraphic(rect, boundingRect) {
// Set rect to center, keep width / height ratio.
var aspect = boundingRect.width / boundingRect.height;
var width = rect.height * aspect;
var height;
if (width <= rect.width) {
height = rect.height;
}
else {
width = rect.width;
height = width / aspect;
}
var cx = rect.x + rect.width / 2;
var cy = rect.y + rect.height / 2;
return {
x: cx - width / 2,
y: cy - height / 2,
width: width,
height: height
};
} | [
"function",
"centerGraphic",
"(",
"rect",
",",
"boundingRect",
")",
"{",
"// Set rect to center, keep width / height ratio.",
"var",
"aspect",
"=",
"boundingRect",
".",
"width",
"/",
"boundingRect",
".",
"height",
";",
"var",
"width",
"=",
"rect",
".",
"height",
"*",
"aspect",
";",
"var",
"height",
";",
"if",
"(",
"width",
"<=",
"rect",
".",
"width",
")",
"{",
"height",
"=",
"rect",
".",
"height",
";",
"}",
"else",
"{",
"width",
"=",
"rect",
".",
"width",
";",
"height",
"=",
"width",
"/",
"aspect",
";",
"}",
"var",
"cx",
"=",
"rect",
".",
"x",
"+",
"rect",
".",
"width",
"/",
"2",
";",
"var",
"cy",
"=",
"rect",
".",
"y",
"+",
"rect",
".",
"height",
"/",
"2",
";",
"return",
"{",
"x",
":",
"cx",
"-",
"width",
"/",
"2",
",",
"y",
":",
"cy",
"-",
"height",
"/",
"2",
",",
"width",
":",
"width",
",",
"height",
":",
"height",
"}",
";",
"}"
] | Get position of centered element in bounding box.
@param {Object} rect element local bounding box
@param {Object} boundingRect constraint bounding box
@return {Object} element position containing x, y, width, and height | [
"Get",
"position",
"of",
"centered",
"element",
"in",
"bounding",
"box",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/util/graphic.js#L130-L151 |
238 | apache/incubator-echarts | src/util/graphic.js | setTextStyleCommon | function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
// Consider there will be abnormal when merge hover style to normal style if given default value.
opt = opt || EMPTY_OBJ;
if (opt.isRectText) {
var textPosition = textStyleModel.getShallow('position')
|| (isEmphasis ? null : 'inside');
// 'outside' is not a valid zr textPostion value, but used
// in bar series, and magric type should be considered.
textPosition === 'outside' && (textPosition = 'top');
textStyle.textPosition = textPosition;
textStyle.textOffset = textStyleModel.getShallow('offset');
var labelRotate = textStyleModel.getShallow('rotate');
labelRotate != null && (labelRotate *= Math.PI / 180);
textStyle.textRotation = labelRotate;
textStyle.textDistance = zrUtil.retrieve2(
textStyleModel.getShallow('distance'), isEmphasis ? null : 5
);
}
var ecModel = textStyleModel.ecModel;
var globalTextStyle = ecModel && ecModel.option.textStyle;
// Consider case:
// {
// data: [{
// value: 12,
// label: {
// rich: {
// // no 'a' here but using parent 'a'.
// }
// }
// }],
// rich: {
// a: { ... }
// }
// }
var richItemNames = getRichItemNames(textStyleModel);
var richResult;
if (richItemNames) {
richResult = {};
for (var name in richItemNames) {
if (richItemNames.hasOwnProperty(name)) {
// Cascade is supported in rich.
var richTextStyle = textStyleModel.getModel(['rich', name]);
// In rich, never `disableBox`.
// FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
// the default color `'blue'` will not be adopted if no color declared in `rich`.
// That might confuses users. So probably we should put `textStyleModel` as the
// root ancestor of the `richTextStyle`. But that would be a break change.
setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
}
}
}
textStyle.rich = richResult;
setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);
if (opt.forceRich && !opt.textStyle) {
opt.textStyle = {};
}
return textStyle;
} | javascript | function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
// Consider there will be abnormal when merge hover style to normal style if given default value.
opt = opt || EMPTY_OBJ;
if (opt.isRectText) {
var textPosition = textStyleModel.getShallow('position')
|| (isEmphasis ? null : 'inside');
// 'outside' is not a valid zr textPostion value, but used
// in bar series, and magric type should be considered.
textPosition === 'outside' && (textPosition = 'top');
textStyle.textPosition = textPosition;
textStyle.textOffset = textStyleModel.getShallow('offset');
var labelRotate = textStyleModel.getShallow('rotate');
labelRotate != null && (labelRotate *= Math.PI / 180);
textStyle.textRotation = labelRotate;
textStyle.textDistance = zrUtil.retrieve2(
textStyleModel.getShallow('distance'), isEmphasis ? null : 5
);
}
var ecModel = textStyleModel.ecModel;
var globalTextStyle = ecModel && ecModel.option.textStyle;
// Consider case:
// {
// data: [{
// value: 12,
// label: {
// rich: {
// // no 'a' here but using parent 'a'.
// }
// }
// }],
// rich: {
// a: { ... }
// }
// }
var richItemNames = getRichItemNames(textStyleModel);
var richResult;
if (richItemNames) {
richResult = {};
for (var name in richItemNames) {
if (richItemNames.hasOwnProperty(name)) {
// Cascade is supported in rich.
var richTextStyle = textStyleModel.getModel(['rich', name]);
// In rich, never `disableBox`.
// FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
// the default color `'blue'` will not be adopted if no color declared in `rich`.
// That might confuses users. So probably we should put `textStyleModel` as the
// root ancestor of the `richTextStyle`. But that would be a break change.
setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
}
}
}
textStyle.rich = richResult;
setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);
if (opt.forceRich && !opt.textStyle) {
opt.textStyle = {};
}
return textStyle;
} | [
"function",
"setTextStyleCommon",
"(",
"textStyle",
",",
"textStyleModel",
",",
"opt",
",",
"isEmphasis",
")",
"{",
"// Consider there will be abnormal when merge hover style to normal style if given default value.",
"opt",
"=",
"opt",
"||",
"EMPTY_OBJ",
";",
"if",
"(",
"opt",
".",
"isRectText",
")",
"{",
"var",
"textPosition",
"=",
"textStyleModel",
".",
"getShallow",
"(",
"'position'",
")",
"||",
"(",
"isEmphasis",
"?",
"null",
":",
"'inside'",
")",
";",
"// 'outside' is not a valid zr textPostion value, but used",
"// in bar series, and magric type should be considered.",
"textPosition",
"===",
"'outside'",
"&&",
"(",
"textPosition",
"=",
"'top'",
")",
";",
"textStyle",
".",
"textPosition",
"=",
"textPosition",
";",
"textStyle",
".",
"textOffset",
"=",
"textStyleModel",
".",
"getShallow",
"(",
"'offset'",
")",
";",
"var",
"labelRotate",
"=",
"textStyleModel",
".",
"getShallow",
"(",
"'rotate'",
")",
";",
"labelRotate",
"!=",
"null",
"&&",
"(",
"labelRotate",
"*=",
"Math",
".",
"PI",
"/",
"180",
")",
";",
"textStyle",
".",
"textRotation",
"=",
"labelRotate",
";",
"textStyle",
".",
"textDistance",
"=",
"zrUtil",
".",
"retrieve2",
"(",
"textStyleModel",
".",
"getShallow",
"(",
"'distance'",
")",
",",
"isEmphasis",
"?",
"null",
":",
"5",
")",
";",
"}",
"var",
"ecModel",
"=",
"textStyleModel",
".",
"ecModel",
";",
"var",
"globalTextStyle",
"=",
"ecModel",
"&&",
"ecModel",
".",
"option",
".",
"textStyle",
";",
"// Consider case:",
"// {",
"// data: [{",
"// value: 12,",
"// label: {",
"// rich: {",
"// // no 'a' here but using parent 'a'.",
"// }",
"// }",
"// }],",
"// rich: {",
"// a: { ... }",
"// }",
"// }",
"var",
"richItemNames",
"=",
"getRichItemNames",
"(",
"textStyleModel",
")",
";",
"var",
"richResult",
";",
"if",
"(",
"richItemNames",
")",
"{",
"richResult",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"name",
"in",
"richItemNames",
")",
"{",
"if",
"(",
"richItemNames",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"// Cascade is supported in rich.",
"var",
"richTextStyle",
"=",
"textStyleModel",
".",
"getModel",
"(",
"[",
"'rich'",
",",
"name",
"]",
")",
";",
"// In rich, never `disableBox`.",
"// FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,",
"// the default color `'blue'` will not be adopted if no color declared in `rich`.",
"// That might confuses users. So probably we should put `textStyleModel` as the",
"// root ancestor of the `richTextStyle`. But that would be a break change.",
"setTokenTextStyle",
"(",
"richResult",
"[",
"name",
"]",
"=",
"{",
"}",
",",
"richTextStyle",
",",
"globalTextStyle",
",",
"opt",
",",
"isEmphasis",
")",
";",
"}",
"}",
"}",
"textStyle",
".",
"rich",
"=",
"richResult",
";",
"setTokenTextStyle",
"(",
"textStyle",
",",
"textStyleModel",
",",
"globalTextStyle",
",",
"opt",
",",
"isEmphasis",
",",
"true",
")",
";",
"if",
"(",
"opt",
".",
"forceRich",
"&&",
"!",
"opt",
".",
"textStyle",
")",
"{",
"opt",
".",
"textStyle",
"=",
"{",
"}",
";",
"}",
"return",
"textStyle",
";",
"}"
] | The uniform entry of set text style, that is, retrieve style definitions
from `model` and set to `textStyle` object.
Never in merge mode, but in overwrite mode, that is, all of the text style
properties will be set. (Consider the states of normal and emphasis and
default value can be adopted, merge would make the logic too complicated
to manage.)
The `textStyle` object can either be a plain object or an instance of
`zrender/src/graphic/Style`, and either be the style of normal or emphasis.
After this mothod called, the `textStyle` object can then be used in
`el.setStyle(textStyle)` or `el.hoverStyle = textStyle`.
Default value will be adopted and `insideRollbackOpt` will be created.
See `applyDefaultTextStyle` `rollbackDefaultTextStyle` for more details.
opt: {
disableBox: boolean, Whether diable drawing box of block (outer most).
isRectText: boolean,
autoColor: string, specify a color when color is 'auto',
for textFill, textStroke, textBackgroundColor, and textBorderColor.
If autoColor specified, it is used as default textFill.
useInsideStyle:
`true`: Use inside style (textFill, textStroke, textStrokeWidth)
if `textFill` is not specified.
`false`: Do not use inside style.
`null/undefined`: use inside style if `isRectText` is true and
`textFill` is not specified and textPosition contains `'inside'`.
forceRich: boolean
} | [
"The",
"uniform",
"entry",
"of",
"set",
"text",
"style",
"that",
"is",
"retrieve",
"style",
"definitions",
"from",
"model",
"and",
"set",
"to",
"textStyle",
"object",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/util/graphic.js#L735-L798 |
239 | apache/incubator-echarts | src/util/graphic.js | applyDefaultTextStyle | function applyDefaultTextStyle(textStyle) {
var opt = textStyle.insideRollbackOpt;
// Only `insideRollbackOpt` created (in `setTextStyleCommon`),
// applyDefaultTextStyle works.
if (!opt || textStyle.textFill != null) {
return;
}
var useInsideStyle = opt.useInsideStyle;
var textPosition = textStyle.insideRawTextPosition;
var insideRollback;
var autoColor = opt.autoColor;
if (useInsideStyle !== false
&& (useInsideStyle === true
|| (opt.isRectText
&& textPosition
// textPosition can be [10, 30]
&& typeof textPosition === 'string'
&& textPosition.indexOf('inside') >= 0
)
)
) {
insideRollback = {
textFill: null,
textStroke: textStyle.textStroke,
textStrokeWidth: textStyle.textStrokeWidth
};
textStyle.textFill = '#fff';
// Consider text with #fff overflow its container.
if (textStyle.textStroke == null) {
textStyle.textStroke = autoColor;
textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
}
}
else if (autoColor != null) {
insideRollback = {textFill: null};
textStyle.textFill = autoColor;
}
// Always set `insideRollback`, for clearing previous.
if (insideRollback) {
textStyle.insideRollback = insideRollback;
}
} | javascript | function applyDefaultTextStyle(textStyle) {
var opt = textStyle.insideRollbackOpt;
// Only `insideRollbackOpt` created (in `setTextStyleCommon`),
// applyDefaultTextStyle works.
if (!opt || textStyle.textFill != null) {
return;
}
var useInsideStyle = opt.useInsideStyle;
var textPosition = textStyle.insideRawTextPosition;
var insideRollback;
var autoColor = opt.autoColor;
if (useInsideStyle !== false
&& (useInsideStyle === true
|| (opt.isRectText
&& textPosition
// textPosition can be [10, 30]
&& typeof textPosition === 'string'
&& textPosition.indexOf('inside') >= 0
)
)
) {
insideRollback = {
textFill: null,
textStroke: textStyle.textStroke,
textStrokeWidth: textStyle.textStrokeWidth
};
textStyle.textFill = '#fff';
// Consider text with #fff overflow its container.
if (textStyle.textStroke == null) {
textStyle.textStroke = autoColor;
textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
}
}
else if (autoColor != null) {
insideRollback = {textFill: null};
textStyle.textFill = autoColor;
}
// Always set `insideRollback`, for clearing previous.
if (insideRollback) {
textStyle.insideRollback = insideRollback;
}
} | [
"function",
"applyDefaultTextStyle",
"(",
"textStyle",
")",
"{",
"var",
"opt",
"=",
"textStyle",
".",
"insideRollbackOpt",
";",
"// Only `insideRollbackOpt` created (in `setTextStyleCommon`),",
"// applyDefaultTextStyle works.",
"if",
"(",
"!",
"opt",
"||",
"textStyle",
".",
"textFill",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"var",
"useInsideStyle",
"=",
"opt",
".",
"useInsideStyle",
";",
"var",
"textPosition",
"=",
"textStyle",
".",
"insideRawTextPosition",
";",
"var",
"insideRollback",
";",
"var",
"autoColor",
"=",
"opt",
".",
"autoColor",
";",
"if",
"(",
"useInsideStyle",
"!==",
"false",
"&&",
"(",
"useInsideStyle",
"===",
"true",
"||",
"(",
"opt",
".",
"isRectText",
"&&",
"textPosition",
"// textPosition can be [10, 30]",
"&&",
"typeof",
"textPosition",
"===",
"'string'",
"&&",
"textPosition",
".",
"indexOf",
"(",
"'inside'",
")",
">=",
"0",
")",
")",
")",
"{",
"insideRollback",
"=",
"{",
"textFill",
":",
"null",
",",
"textStroke",
":",
"textStyle",
".",
"textStroke",
",",
"textStrokeWidth",
":",
"textStyle",
".",
"textStrokeWidth",
"}",
";",
"textStyle",
".",
"textFill",
"=",
"'#fff'",
";",
"// Consider text with #fff overflow its container.",
"if",
"(",
"textStyle",
".",
"textStroke",
"==",
"null",
")",
"{",
"textStyle",
".",
"textStroke",
"=",
"autoColor",
";",
"textStyle",
".",
"textStrokeWidth",
"==",
"null",
"&&",
"(",
"textStyle",
".",
"textStrokeWidth",
"=",
"2",
")",
";",
"}",
"}",
"else",
"if",
"(",
"autoColor",
"!=",
"null",
")",
"{",
"insideRollback",
"=",
"{",
"textFill",
":",
"null",
"}",
";",
"textStyle",
".",
"textFill",
"=",
"autoColor",
";",
"}",
"// Always set `insideRollback`, for clearing previous.",
"if",
"(",
"insideRollback",
")",
"{",
"textStyle",
".",
"insideRollback",
"=",
"insideRollback",
";",
"}",
"}"
] | Give some default value to the input `textStyle` object, based on the current settings
in this `textStyle` object.
The Scenario:
when text position is `inside` and `textFill` is not specified, we show
text border by default for better view. But it should be considered that text position
might be changed when hovering or being emphasis, where the `insideRollback` is used to
restore the style.
Usage (& NOTICE):
When a style object (eithor plain object or instance of `zrender/src/graphic/Style`) is
about to be modified on its text related properties, `rollbackDefaultTextStyle` should
be called before the modification and `applyDefaultTextStyle` should be called after that.
(For the case that all of the text related properties is reset, like `setTextStyleCommon`
does, `rollbackDefaultTextStyle` is not needed to be called). | [
"Give",
"some",
"default",
"value",
"to",
"the",
"input",
"textStyle",
"object",
"based",
"on",
"the",
"current",
"settings",
"in",
"this",
"textStyle",
"object",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/util/graphic.js#L922-L967 |
240 | apache/incubator-echarts | src/component/toolbox/feature/DataView.js | groupSeries | function groupSeries(ecModel) {
var seriesGroupByCategoryAxis = {};
var otherSeries = [];
var meta = [];
ecModel.eachRawSeries(function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
var baseAxis = coordSys.getBaseAxis();
if (baseAxis.type === 'category') {
var key = baseAxis.dim + '_' + baseAxis.index;
if (!seriesGroupByCategoryAxis[key]) {
seriesGroupByCategoryAxis[key] = {
categoryAxis: baseAxis,
valueAxis: coordSys.getOtherAxis(baseAxis),
series: []
};
meta.push({
axisDim: baseAxis.dim,
axisIndex: baseAxis.index
});
}
seriesGroupByCategoryAxis[key].series.push(seriesModel);
}
else {
otherSeries.push(seriesModel);
}
}
else {
otherSeries.push(seriesModel);
}
});
return {
seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
other: otherSeries,
meta: meta
};
} | javascript | function groupSeries(ecModel) {
var seriesGroupByCategoryAxis = {};
var otherSeries = [];
var meta = [];
ecModel.eachRawSeries(function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
var baseAxis = coordSys.getBaseAxis();
if (baseAxis.type === 'category') {
var key = baseAxis.dim + '_' + baseAxis.index;
if (!seriesGroupByCategoryAxis[key]) {
seriesGroupByCategoryAxis[key] = {
categoryAxis: baseAxis,
valueAxis: coordSys.getOtherAxis(baseAxis),
series: []
};
meta.push({
axisDim: baseAxis.dim,
axisIndex: baseAxis.index
});
}
seriesGroupByCategoryAxis[key].series.push(seriesModel);
}
else {
otherSeries.push(seriesModel);
}
}
else {
otherSeries.push(seriesModel);
}
});
return {
seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
other: otherSeries,
meta: meta
};
} | [
"function",
"groupSeries",
"(",
"ecModel",
")",
"{",
"var",
"seriesGroupByCategoryAxis",
"=",
"{",
"}",
";",
"var",
"otherSeries",
"=",
"[",
"]",
";",
"var",
"meta",
"=",
"[",
"]",
";",
"ecModel",
".",
"eachRawSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"var",
"coordSys",
"=",
"seriesModel",
".",
"coordinateSystem",
";",
"if",
"(",
"coordSys",
"&&",
"(",
"coordSys",
".",
"type",
"===",
"'cartesian2d'",
"||",
"coordSys",
".",
"type",
"===",
"'polar'",
")",
")",
"{",
"var",
"baseAxis",
"=",
"coordSys",
".",
"getBaseAxis",
"(",
")",
";",
"if",
"(",
"baseAxis",
".",
"type",
"===",
"'category'",
")",
"{",
"var",
"key",
"=",
"baseAxis",
".",
"dim",
"+",
"'_'",
"+",
"baseAxis",
".",
"index",
";",
"if",
"(",
"!",
"seriesGroupByCategoryAxis",
"[",
"key",
"]",
")",
"{",
"seriesGroupByCategoryAxis",
"[",
"key",
"]",
"=",
"{",
"categoryAxis",
":",
"baseAxis",
",",
"valueAxis",
":",
"coordSys",
".",
"getOtherAxis",
"(",
"baseAxis",
")",
",",
"series",
":",
"[",
"]",
"}",
";",
"meta",
".",
"push",
"(",
"{",
"axisDim",
":",
"baseAxis",
".",
"dim",
",",
"axisIndex",
":",
"baseAxis",
".",
"index",
"}",
")",
";",
"}",
"seriesGroupByCategoryAxis",
"[",
"key",
"]",
".",
"series",
".",
"push",
"(",
"seriesModel",
")",
";",
"}",
"else",
"{",
"otherSeries",
".",
"push",
"(",
"seriesModel",
")",
";",
"}",
"}",
"else",
"{",
"otherSeries",
".",
"push",
"(",
"seriesModel",
")",
";",
"}",
"}",
")",
";",
"return",
"{",
"seriesGroupByCategoryAxis",
":",
"seriesGroupByCategoryAxis",
",",
"other",
":",
"otherSeries",
",",
"meta",
":",
"meta",
"}",
";",
"}"
] | Group series into two types
1. on category axis, like line, bar
2. others, like scatter, pie
@param {module:echarts/model/Global} ecModel
@return {Object}
@inner | [
"Group",
"series",
"into",
"two",
"types",
"1",
".",
"on",
"category",
"axis",
"like",
"line",
"bar",
"2",
".",
"others",
"like",
"scatter",
"pie"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/toolbox/feature/DataView.js#L38-L76 |
241 | apache/incubator-echarts | src/component/toolbox/feature/DataView.js | assembleSeriesWithCategoryAxis | function assembleSeriesWithCategoryAxis(series) {
var tables = [];
zrUtil.each(series, function (group, key) {
var categoryAxis = group.categoryAxis;
var valueAxis = group.valueAxis;
var valueAxisDim = valueAxis.dim;
var headers = [' '].concat(zrUtil.map(group.series, function (series) {
return series.name;
}));
var columns = [categoryAxis.model.getCategories()];
zrUtil.each(group.series, function (series) {
columns.push(series.getRawData().mapArray(valueAxisDim, function (val) {
return val;
}));
});
// Assemble table content
var lines = [headers.join(ITEM_SPLITER)];
for (var i = 0; i < columns[0].length; i++) {
var items = [];
for (var j = 0; j < columns.length; j++) {
items.push(columns[j][i]);
}
lines.push(items.join(ITEM_SPLITER));
}
tables.push(lines.join('\n'));
});
return tables.join('\n\n' + BLOCK_SPLITER + '\n\n');
} | javascript | function assembleSeriesWithCategoryAxis(series) {
var tables = [];
zrUtil.each(series, function (group, key) {
var categoryAxis = group.categoryAxis;
var valueAxis = group.valueAxis;
var valueAxisDim = valueAxis.dim;
var headers = [' '].concat(zrUtil.map(group.series, function (series) {
return series.name;
}));
var columns = [categoryAxis.model.getCategories()];
zrUtil.each(group.series, function (series) {
columns.push(series.getRawData().mapArray(valueAxisDim, function (val) {
return val;
}));
});
// Assemble table content
var lines = [headers.join(ITEM_SPLITER)];
for (var i = 0; i < columns[0].length; i++) {
var items = [];
for (var j = 0; j < columns.length; j++) {
items.push(columns[j][i]);
}
lines.push(items.join(ITEM_SPLITER));
}
tables.push(lines.join('\n'));
});
return tables.join('\n\n' + BLOCK_SPLITER + '\n\n');
} | [
"function",
"assembleSeriesWithCategoryAxis",
"(",
"series",
")",
"{",
"var",
"tables",
"=",
"[",
"]",
";",
"zrUtil",
".",
"each",
"(",
"series",
",",
"function",
"(",
"group",
",",
"key",
")",
"{",
"var",
"categoryAxis",
"=",
"group",
".",
"categoryAxis",
";",
"var",
"valueAxis",
"=",
"group",
".",
"valueAxis",
";",
"var",
"valueAxisDim",
"=",
"valueAxis",
".",
"dim",
";",
"var",
"headers",
"=",
"[",
"' '",
"]",
".",
"concat",
"(",
"zrUtil",
".",
"map",
"(",
"group",
".",
"series",
",",
"function",
"(",
"series",
")",
"{",
"return",
"series",
".",
"name",
";",
"}",
")",
")",
";",
"var",
"columns",
"=",
"[",
"categoryAxis",
".",
"model",
".",
"getCategories",
"(",
")",
"]",
";",
"zrUtil",
".",
"each",
"(",
"group",
".",
"series",
",",
"function",
"(",
"series",
")",
"{",
"columns",
".",
"push",
"(",
"series",
".",
"getRawData",
"(",
")",
".",
"mapArray",
"(",
"valueAxisDim",
",",
"function",
"(",
"val",
")",
"{",
"return",
"val",
";",
"}",
")",
")",
";",
"}",
")",
";",
"// Assemble table content",
"var",
"lines",
"=",
"[",
"headers",
".",
"join",
"(",
"ITEM_SPLITER",
")",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"columns",
"[",
"0",
"]",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"items",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"columns",
".",
"length",
";",
"j",
"++",
")",
"{",
"items",
".",
"push",
"(",
"columns",
"[",
"j",
"]",
"[",
"i",
"]",
")",
";",
"}",
"lines",
".",
"push",
"(",
"items",
".",
"join",
"(",
"ITEM_SPLITER",
")",
")",
";",
"}",
"tables",
".",
"push",
"(",
"lines",
".",
"join",
"(",
"'\\n'",
")",
")",
";",
"}",
")",
";",
"return",
"tables",
".",
"join",
"(",
"'\\n\\n'",
"+",
"BLOCK_SPLITER",
"+",
"'\\n\\n'",
")",
";",
"}"
] | Assemble content of series on cateogory axis
@param {Array.<module:echarts/model/Series>} series
@return {string}
@inner | [
"Assemble",
"content",
"of",
"series",
"on",
"cateogory",
"axis"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/toolbox/feature/DataView.js#L84-L112 |
242 | apache/incubator-echarts | src/component/toolbox/feature/DataView.js | assembleOtherSeries | function assembleOtherSeries(series) {
return zrUtil.map(series, function (series) {
var data = series.getRawData();
var lines = [series.name];
var vals = [];
data.each(data.dimensions, function () {
var argLen = arguments.length;
var dataIndex = arguments[argLen - 1];
var name = data.getName(dataIndex);
for (var i = 0; i < argLen - 1; i++) {
vals[i] = arguments[i];
}
lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER));
});
return lines.join('\n');
}).join('\n\n' + BLOCK_SPLITER + '\n\n');
} | javascript | function assembleOtherSeries(series) {
return zrUtil.map(series, function (series) {
var data = series.getRawData();
var lines = [series.name];
var vals = [];
data.each(data.dimensions, function () {
var argLen = arguments.length;
var dataIndex = arguments[argLen - 1];
var name = data.getName(dataIndex);
for (var i = 0; i < argLen - 1; i++) {
vals[i] = arguments[i];
}
lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER));
});
return lines.join('\n');
}).join('\n\n' + BLOCK_SPLITER + '\n\n');
} | [
"function",
"assembleOtherSeries",
"(",
"series",
")",
"{",
"return",
"zrUtil",
".",
"map",
"(",
"series",
",",
"function",
"(",
"series",
")",
"{",
"var",
"data",
"=",
"series",
".",
"getRawData",
"(",
")",
";",
"var",
"lines",
"=",
"[",
"series",
".",
"name",
"]",
";",
"var",
"vals",
"=",
"[",
"]",
";",
"data",
".",
"each",
"(",
"data",
".",
"dimensions",
",",
"function",
"(",
")",
"{",
"var",
"argLen",
"=",
"arguments",
".",
"length",
";",
"var",
"dataIndex",
"=",
"arguments",
"[",
"argLen",
"-",
"1",
"]",
";",
"var",
"name",
"=",
"data",
".",
"getName",
"(",
"dataIndex",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"argLen",
"-",
"1",
";",
"i",
"++",
")",
"{",
"vals",
"[",
"i",
"]",
"=",
"arguments",
"[",
"i",
"]",
";",
"}",
"lines",
".",
"push",
"(",
"(",
"name",
"?",
"(",
"name",
"+",
"ITEM_SPLITER",
")",
":",
"''",
")",
"+",
"vals",
".",
"join",
"(",
"ITEM_SPLITER",
")",
")",
";",
"}",
")",
";",
"return",
"lines",
".",
"join",
"(",
"'\\n'",
")",
";",
"}",
")",
".",
"join",
"(",
"'\\n\\n'",
"+",
"BLOCK_SPLITER",
"+",
"'\\n\\n'",
")",
";",
"}"
] | Assemble content of other series
@param {Array.<module:echarts/model/Series>} series
@return {string}
@inner | [
"Assemble",
"content",
"of",
"other",
"series"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/toolbox/feature/DataView.js#L120-L136 |
243 | apache/incubator-echarts | src/component/toolbox/feature/DataView.js | isTSVFormat | function isTSVFormat(block) {
// Simple method to find out if a block is tsv format
var firstLine = block.slice(0, block.indexOf('\n'));
if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
return true;
}
} | javascript | function isTSVFormat(block) {
// Simple method to find out if a block is tsv format
var firstLine = block.slice(0, block.indexOf('\n'));
if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
return true;
}
} | [
"function",
"isTSVFormat",
"(",
"block",
")",
"{",
"// Simple method to find out if a block is tsv format",
"var",
"firstLine",
"=",
"block",
".",
"slice",
"(",
"0",
",",
"block",
".",
"indexOf",
"(",
"'\\n'",
")",
")",
";",
"if",
"(",
"firstLine",
".",
"indexOf",
"(",
"ITEM_SPLITER",
")",
">=",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}"
] | If a block is tsv format | [
"If",
"a",
"block",
"is",
"tsv",
"format"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/toolbox/feature/DataView.js#L166-L172 |
244 | apache/incubator-echarts | src/data/List.js | cloneListForMapAndSample | function cloneListForMapAndSample(original, excludeDimensions) {
var allDimensions = original.dimensions;
var list = new List(
zrUtil.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 (zrUtil.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;
} | javascript | function cloneListForMapAndSample(original, excludeDimensions) {
var allDimensions = original.dimensions;
var list = new List(
zrUtil.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 (zrUtil.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;
} | [
"function",
"cloneListForMapAndSample",
"(",
"original",
",",
"excludeDimensions",
")",
"{",
"var",
"allDimensions",
"=",
"original",
".",
"dimensions",
";",
"var",
"list",
"=",
"new",
"List",
"(",
"zrUtil",
".",
"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",
"(",
"zrUtil",
".",
"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",
";",
"}"
] | Data in excludeDimensions is copied, otherwise transfered. | [
"Data",
"in",
"excludeDimensions",
"is",
"copied",
"otherwise",
"transfered",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/List.js#L1556-L1586 |
245 | apache/incubator-echarts | src/coord/View.js | function (x, y, width, height) {
this._rect = new BoundingRect(x, y, width, height);
return this._rect;
} | javascript | function (x, y, width, height) {
this._rect = new BoundingRect(x, y, width, height);
return this._rect;
} | [
"function",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"{",
"this",
".",
"_rect",
"=",
"new",
"BoundingRect",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
";",
"return",
"this",
".",
"_rect",
";",
"}"
] | Set bounding rect
@param {number} x
@param {number} y
@param {number} width
@param {number} height
PENDING to getRect | [
"Set",
"bounding",
"rect"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/View.js#L81-L84 |
|
246 | apache/incubator-echarts | src/coord/View.js | function (x, y, width, height) {
var rect = this.getBoundingRect();
var rawTransform = this._rawTransformable;
rawTransform.transform = rect.calculateTransform(
new BoundingRect(x, y, width, height)
);
rawTransform.decomposeTransform();
this._updateTransform();
} | javascript | function (x, y, width, height) {
var rect = this.getBoundingRect();
var rawTransform = this._rawTransformable;
rawTransform.transform = rect.calculateTransform(
new BoundingRect(x, y, width, height)
);
rawTransform.decomposeTransform();
this._updateTransform();
} | [
"function",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"{",
"var",
"rect",
"=",
"this",
".",
"getBoundingRect",
"(",
")",
";",
"var",
"rawTransform",
"=",
"this",
".",
"_rawTransformable",
";",
"rawTransform",
".",
"transform",
"=",
"rect",
".",
"calculateTransform",
"(",
"new",
"BoundingRect",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
")",
";",
"rawTransform",
".",
"decomposeTransform",
"(",
")",
";",
"this",
".",
"_updateTransform",
"(",
")",
";",
"}"
] | Transformed to particular position and size
@param {number} x
@param {number} y
@param {number} width
@param {number} height | [
"Transformed",
"to",
"particular",
"position",
"and",
"size"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/View.js#L112-L123 |
|
247 | apache/incubator-echarts | src/coord/View.js | function () {
// Rect before any transform
var rawRect = this.getBoundingRect();
var cx = rawRect.x + rawRect.width / 2;
var cy = rawRect.y + rawRect.height / 2;
return [cx, cy];
} | javascript | function () {
// Rect before any transform
var rawRect = this.getBoundingRect();
var cx = rawRect.x + rawRect.width / 2;
var cy = rawRect.y + rawRect.height / 2;
return [cx, cy];
} | [
"function",
"(",
")",
"{",
"// Rect before any transform",
"var",
"rawRect",
"=",
"this",
".",
"getBoundingRect",
"(",
")",
";",
"var",
"cx",
"=",
"rawRect",
".",
"x",
"+",
"rawRect",
".",
"width",
"/",
"2",
";",
"var",
"cy",
"=",
"rawRect",
".",
"y",
"+",
"rawRect",
".",
"height",
"/",
"2",
";",
"return",
"[",
"cx",
",",
"cy",
"]",
";",
"}"
] | Get default center without roam | [
"Get",
"default",
"center",
"without",
"roam"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/View.js#L161-L168 |
|
248 | apache/incubator-echarts | src/coord/View.js | function () {
var roamTransformable = this._roamTransformable;
var rawTransformable = this._rawTransformable;
rawTransformable.parent = roamTransformable;
roamTransformable.updateTransform();
rawTransformable.updateTransform();
matrix.copy(this.transform || (this.transform = []), rawTransformable.transform || matrix.create());
this._rawTransform = rawTransformable.getLocalTransform();
this.invTransform = this.invTransform || [];
matrix.invert(this.invTransform, this.transform);
this.decomposeTransform();
} | javascript | function () {
var roamTransformable = this._roamTransformable;
var rawTransformable = this._rawTransformable;
rawTransformable.parent = roamTransformable;
roamTransformable.updateTransform();
rawTransformable.updateTransform();
matrix.copy(this.transform || (this.transform = []), rawTransformable.transform || matrix.create());
this._rawTransform = rawTransformable.getLocalTransform();
this.invTransform = this.invTransform || [];
matrix.invert(this.invTransform, this.transform);
this.decomposeTransform();
} | [
"function",
"(",
")",
"{",
"var",
"roamTransformable",
"=",
"this",
".",
"_roamTransformable",
";",
"var",
"rawTransformable",
"=",
"this",
".",
"_rawTransformable",
";",
"rawTransformable",
".",
"parent",
"=",
"roamTransformable",
";",
"roamTransformable",
".",
"updateTransform",
"(",
")",
";",
"rawTransformable",
".",
"updateTransform",
"(",
")",
";",
"matrix",
".",
"copy",
"(",
"this",
".",
"transform",
"||",
"(",
"this",
".",
"transform",
"=",
"[",
"]",
")",
",",
"rawTransformable",
".",
"transform",
"||",
"matrix",
".",
"create",
"(",
")",
")",
";",
"this",
".",
"_rawTransform",
"=",
"rawTransformable",
".",
"getLocalTransform",
"(",
")",
";",
"this",
".",
"invTransform",
"=",
"this",
".",
"invTransform",
"||",
"[",
"]",
";",
"matrix",
".",
"invert",
"(",
"this",
".",
"invTransform",
",",
"this",
".",
"transform",
")",
";",
"this",
".",
"decomposeTransform",
"(",
")",
";",
"}"
] | Update transform from roam and mapLocation
@private | [
"Update",
"transform",
"from",
"roam",
"and",
"mapLocation"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/View.js#L214-L230 |
|
249 | apache/incubator-echarts | src/chart/sunburst/sunburstLayout.js | function (node, startAngle) {
if (!node) {
return;
}
var endAngle = startAngle;
// Render self
if (node !== virtualRoot) {
// Tree node is virtual, so it doesn't need to be drawn
var value = node.getValue();
var angle = (sum === 0 && stillShowZeroSum)
? unitRadian : (value * unitRadian);
if (angle < minAngle) {
angle = minAngle;
restAngle -= minAngle;
}
else {
valueSumLargerThanMinAngle += value;
}
endAngle = startAngle + dir * angle;
var depth = node.depth - rootDepth
- (renderRollupNode ? -1 : 1);
var rStart = r0 + rPerLevel * depth;
var rEnd = r0 + rPerLevel * (depth + 1);
var itemModel = node.getModel();
if (itemModel.get('r0') != null) {
rStart = parsePercent(itemModel.get('r0'), size / 2);
}
if (itemModel.get('r') != null) {
rEnd = parsePercent(itemModel.get('r'), size / 2);
}
node.setLayout({
angle: angle,
startAngle: startAngle,
endAngle: endAngle,
clockwise: clockwise,
cx: cx,
cy: cy,
r0: rStart,
r: rEnd
});
}
// Render children
if (node.children && node.children.length) {
// currentAngle = startAngle;
var siblingAngle = 0;
zrUtil.each(node.children, function (node) {
siblingAngle += renderNode(node, startAngle + siblingAngle);
});
}
return endAngle - startAngle;
} | javascript | function (node, startAngle) {
if (!node) {
return;
}
var endAngle = startAngle;
// Render self
if (node !== virtualRoot) {
// Tree node is virtual, so it doesn't need to be drawn
var value = node.getValue();
var angle = (sum === 0 && stillShowZeroSum)
? unitRadian : (value * unitRadian);
if (angle < minAngle) {
angle = minAngle;
restAngle -= minAngle;
}
else {
valueSumLargerThanMinAngle += value;
}
endAngle = startAngle + dir * angle;
var depth = node.depth - rootDepth
- (renderRollupNode ? -1 : 1);
var rStart = r0 + rPerLevel * depth;
var rEnd = r0 + rPerLevel * (depth + 1);
var itemModel = node.getModel();
if (itemModel.get('r0') != null) {
rStart = parsePercent(itemModel.get('r0'), size / 2);
}
if (itemModel.get('r') != null) {
rEnd = parsePercent(itemModel.get('r'), size / 2);
}
node.setLayout({
angle: angle,
startAngle: startAngle,
endAngle: endAngle,
clockwise: clockwise,
cx: cx,
cy: cy,
r0: rStart,
r: rEnd
});
}
// Render children
if (node.children && node.children.length) {
// currentAngle = startAngle;
var siblingAngle = 0;
zrUtil.each(node.children, function (node) {
siblingAngle += renderNode(node, startAngle + siblingAngle);
});
}
return endAngle - startAngle;
} | [
"function",
"(",
"node",
",",
"startAngle",
")",
"{",
"if",
"(",
"!",
"node",
")",
"{",
"return",
";",
"}",
"var",
"endAngle",
"=",
"startAngle",
";",
"// Render self",
"if",
"(",
"node",
"!==",
"virtualRoot",
")",
"{",
"// Tree node is virtual, so it doesn't need to be drawn",
"var",
"value",
"=",
"node",
".",
"getValue",
"(",
")",
";",
"var",
"angle",
"=",
"(",
"sum",
"===",
"0",
"&&",
"stillShowZeroSum",
")",
"?",
"unitRadian",
":",
"(",
"value",
"*",
"unitRadian",
")",
";",
"if",
"(",
"angle",
"<",
"minAngle",
")",
"{",
"angle",
"=",
"minAngle",
";",
"restAngle",
"-=",
"minAngle",
";",
"}",
"else",
"{",
"valueSumLargerThanMinAngle",
"+=",
"value",
";",
"}",
"endAngle",
"=",
"startAngle",
"+",
"dir",
"*",
"angle",
";",
"var",
"depth",
"=",
"node",
".",
"depth",
"-",
"rootDepth",
"-",
"(",
"renderRollupNode",
"?",
"-",
"1",
":",
"1",
")",
";",
"var",
"rStart",
"=",
"r0",
"+",
"rPerLevel",
"*",
"depth",
";",
"var",
"rEnd",
"=",
"r0",
"+",
"rPerLevel",
"*",
"(",
"depth",
"+",
"1",
")",
";",
"var",
"itemModel",
"=",
"node",
".",
"getModel",
"(",
")",
";",
"if",
"(",
"itemModel",
".",
"get",
"(",
"'r0'",
")",
"!=",
"null",
")",
"{",
"rStart",
"=",
"parsePercent",
"(",
"itemModel",
".",
"get",
"(",
"'r0'",
")",
",",
"size",
"/",
"2",
")",
";",
"}",
"if",
"(",
"itemModel",
".",
"get",
"(",
"'r'",
")",
"!=",
"null",
")",
"{",
"rEnd",
"=",
"parsePercent",
"(",
"itemModel",
".",
"get",
"(",
"'r'",
")",
",",
"size",
"/",
"2",
")",
";",
"}",
"node",
".",
"setLayout",
"(",
"{",
"angle",
":",
"angle",
",",
"startAngle",
":",
"startAngle",
",",
"endAngle",
":",
"endAngle",
",",
"clockwise",
":",
"clockwise",
",",
"cx",
":",
"cx",
",",
"cy",
":",
"cy",
",",
"r0",
":",
"rStart",
",",
"r",
":",
"rEnd",
"}",
")",
";",
"}",
"// Render children",
"if",
"(",
"node",
".",
"children",
"&&",
"node",
".",
"children",
".",
"length",
")",
"{",
"// currentAngle = startAngle;",
"var",
"siblingAngle",
"=",
"0",
";",
"zrUtil",
".",
"each",
"(",
"node",
".",
"children",
",",
"function",
"(",
"node",
")",
"{",
"siblingAngle",
"+=",
"renderNode",
"(",
"node",
",",
"startAngle",
"+",
"siblingAngle",
")",
";",
"}",
")",
";",
"}",
"return",
"endAngle",
"-",
"startAngle",
";",
"}"
] | Render a tree
@return increased angle | [
"Render",
"a",
"tree"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/sunburstLayout.js#L86-L145 |
|
250 | apache/incubator-echarts | src/chart/sunburst/sunburstLayout.js | initChildren | function initChildren(node, isAsc) {
var children = node.children || [];
node.children = sort(children, isAsc);
// Init children recursively
if (children.length) {
zrUtil.each(node.children, function (child) {
initChildren(child, isAsc);
});
}
} | javascript | function initChildren(node, isAsc) {
var children = node.children || [];
node.children = sort(children, isAsc);
// Init children recursively
if (children.length) {
zrUtil.each(node.children, function (child) {
initChildren(child, isAsc);
});
}
} | [
"function",
"initChildren",
"(",
"node",
",",
"isAsc",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
"||",
"[",
"]",
";",
"node",
".",
"children",
"=",
"sort",
"(",
"children",
",",
"isAsc",
")",
";",
"// Init children recursively",
"if",
"(",
"children",
".",
"length",
")",
"{",
"zrUtil",
".",
"each",
"(",
"node",
".",
"children",
",",
"function",
"(",
"child",
")",
"{",
"initChildren",
"(",
"child",
",",
"isAsc",
")",
";",
"}",
")",
";",
"}",
"}"
] | Init node children by order and update visual
@param {TreeNode} node root node
@param {boolean} isAsc if is in ascendant order | [
"Init",
"node",
"children",
"by",
"order",
"and",
"update",
"visual"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/sunburstLayout.js#L175-L186 |
251 | apache/incubator-echarts | src/chart/sunburst/sunburstLayout.js | sort | function sort(children, sortOrder) {
if (typeof sortOrder === 'function') {
return children.sort(sortOrder);
}
else {
var isAsc = sortOrder === 'asc';
return children.sort(function (a, b) {
var diff = (a.getValue() - b.getValue()) * (isAsc ? 1 : -1);
return diff === 0
? (a.dataIndex - b.dataIndex) * (isAsc ? -1 : 1)
: diff;
});
}
} | javascript | function sort(children, sortOrder) {
if (typeof sortOrder === 'function') {
return children.sort(sortOrder);
}
else {
var isAsc = sortOrder === 'asc';
return children.sort(function (a, b) {
var diff = (a.getValue() - b.getValue()) * (isAsc ? 1 : -1);
return diff === 0
? (a.dataIndex - b.dataIndex) * (isAsc ? -1 : 1)
: diff;
});
}
} | [
"function",
"sort",
"(",
"children",
",",
"sortOrder",
")",
"{",
"if",
"(",
"typeof",
"sortOrder",
"===",
"'function'",
")",
"{",
"return",
"children",
".",
"sort",
"(",
"sortOrder",
")",
";",
"}",
"else",
"{",
"var",
"isAsc",
"=",
"sortOrder",
"===",
"'asc'",
";",
"return",
"children",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"diff",
"=",
"(",
"a",
".",
"getValue",
"(",
")",
"-",
"b",
".",
"getValue",
"(",
")",
")",
"*",
"(",
"isAsc",
"?",
"1",
":",
"-",
"1",
")",
";",
"return",
"diff",
"===",
"0",
"?",
"(",
"a",
".",
"dataIndex",
"-",
"b",
".",
"dataIndex",
")",
"*",
"(",
"isAsc",
"?",
"-",
"1",
":",
"1",
")",
":",
"diff",
";",
"}",
")",
";",
"}",
"}"
] | Sort children nodes
@param {TreeNode[]} children children of node to be sorted
@param {string | function | null} sort sort method
See SunburstSeries.js for details. | [
"Sort",
"children",
"nodes"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/sunburstLayout.js#L195-L208 |
252 | apache/incubator-echarts | src/chart/treemap/treemapLayout.js | initChildren | function initChildren(node, nodeModel, totalArea, options, hideChildren, depth) {
var viewChildren = node.children || [];
var orderBy = options.sort;
orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null);
var overLeafDepth = options.leafDepth != null && options.leafDepth <= depth;
// leafDepth has higher priority.
if (hideChildren && !overLeafDepth) {
return (node.viewChildren = []);
}
// Sort children, order by desc.
viewChildren = zrUtil.filter(viewChildren, function (child) {
return !child.isRemoved();
});
sort(viewChildren, orderBy);
var info = statistic(nodeModel, viewChildren, orderBy);
if (info.sum === 0) {
return (node.viewChildren = []);
}
info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren);
if (info.sum === 0) {
return (node.viewChildren = []);
}
// Set area to each child.
for (var i = 0, len = viewChildren.length; i < len; i++) {
var area = viewChildren[i].getValue() / info.sum * totalArea;
// Do not use setLayout({...}, true), because it is needed to clear last layout.
viewChildren[i].setLayout({area: area});
}
if (overLeafDepth) {
viewChildren.length && node.setLayout({isLeafRoot: true}, true);
viewChildren.length = 0;
}
node.viewChildren = viewChildren;
node.setLayout({dataExtent: info.dataExtent}, true);
return viewChildren;
} | javascript | function initChildren(node, nodeModel, totalArea, options, hideChildren, depth) {
var viewChildren = node.children || [];
var orderBy = options.sort;
orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null);
var overLeafDepth = options.leafDepth != null && options.leafDepth <= depth;
// leafDepth has higher priority.
if (hideChildren && !overLeafDepth) {
return (node.viewChildren = []);
}
// Sort children, order by desc.
viewChildren = zrUtil.filter(viewChildren, function (child) {
return !child.isRemoved();
});
sort(viewChildren, orderBy);
var info = statistic(nodeModel, viewChildren, orderBy);
if (info.sum === 0) {
return (node.viewChildren = []);
}
info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren);
if (info.sum === 0) {
return (node.viewChildren = []);
}
// Set area to each child.
for (var i = 0, len = viewChildren.length; i < len; i++) {
var area = viewChildren[i].getValue() / info.sum * totalArea;
// Do not use setLayout({...}, true), because it is needed to clear last layout.
viewChildren[i].setLayout({area: area});
}
if (overLeafDepth) {
viewChildren.length && node.setLayout({isLeafRoot: true}, true);
viewChildren.length = 0;
}
node.viewChildren = viewChildren;
node.setLayout({dataExtent: info.dataExtent}, true);
return viewChildren;
} | [
"function",
"initChildren",
"(",
"node",
",",
"nodeModel",
",",
"totalArea",
",",
"options",
",",
"hideChildren",
",",
"depth",
")",
"{",
"var",
"viewChildren",
"=",
"node",
".",
"children",
"||",
"[",
"]",
";",
"var",
"orderBy",
"=",
"options",
".",
"sort",
";",
"orderBy",
"!==",
"'asc'",
"&&",
"orderBy",
"!==",
"'desc'",
"&&",
"(",
"orderBy",
"=",
"null",
")",
";",
"var",
"overLeafDepth",
"=",
"options",
".",
"leafDepth",
"!=",
"null",
"&&",
"options",
".",
"leafDepth",
"<=",
"depth",
";",
"// leafDepth has higher priority.",
"if",
"(",
"hideChildren",
"&&",
"!",
"overLeafDepth",
")",
"{",
"return",
"(",
"node",
".",
"viewChildren",
"=",
"[",
"]",
")",
";",
"}",
"// Sort children, order by desc.",
"viewChildren",
"=",
"zrUtil",
".",
"filter",
"(",
"viewChildren",
",",
"function",
"(",
"child",
")",
"{",
"return",
"!",
"child",
".",
"isRemoved",
"(",
")",
";",
"}",
")",
";",
"sort",
"(",
"viewChildren",
",",
"orderBy",
")",
";",
"var",
"info",
"=",
"statistic",
"(",
"nodeModel",
",",
"viewChildren",
",",
"orderBy",
")",
";",
"if",
"(",
"info",
".",
"sum",
"===",
"0",
")",
"{",
"return",
"(",
"node",
".",
"viewChildren",
"=",
"[",
"]",
")",
";",
"}",
"info",
".",
"sum",
"=",
"filterByThreshold",
"(",
"nodeModel",
",",
"totalArea",
",",
"info",
".",
"sum",
",",
"orderBy",
",",
"viewChildren",
")",
";",
"if",
"(",
"info",
".",
"sum",
"===",
"0",
")",
"{",
"return",
"(",
"node",
".",
"viewChildren",
"=",
"[",
"]",
")",
";",
"}",
"// Set area to each child.",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"viewChildren",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"area",
"=",
"viewChildren",
"[",
"i",
"]",
".",
"getValue",
"(",
")",
"/",
"info",
".",
"sum",
"*",
"totalArea",
";",
"// Do not use setLayout({...}, true), because it is needed to clear last layout.",
"viewChildren",
"[",
"i",
"]",
".",
"setLayout",
"(",
"{",
"area",
":",
"area",
"}",
")",
";",
"}",
"if",
"(",
"overLeafDepth",
")",
"{",
"viewChildren",
".",
"length",
"&&",
"node",
".",
"setLayout",
"(",
"{",
"isLeafRoot",
":",
"true",
"}",
",",
"true",
")",
";",
"viewChildren",
".",
"length",
"=",
"0",
";",
"}",
"node",
".",
"viewChildren",
"=",
"viewChildren",
";",
"node",
".",
"setLayout",
"(",
"{",
"dataExtent",
":",
"info",
".",
"dataExtent",
"}",
",",
"true",
")",
";",
"return",
"viewChildren",
";",
"}"
] | Set area to each child, and calculate data extent for visual coding. | [
"Set",
"area",
"to",
"each",
"child",
"and",
"calculate",
"data",
"extent",
"for",
"visual",
"coding",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L259-L306 |
253 | apache/incubator-echarts | src/chart/treemap/treemapLayout.js | filterByThreshold | function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
// visibleMin is not supported yet when no option.sort.
if (!orderBy) {
return sum;
}
var visibleMin = nodeModel.get('visibleMin');
var len = orderedChildren.length;
var deletePoint = len;
// Always travel from little value to big value.
for (var i = len - 1; i >= 0; i--) {
var value = orderedChildren[
orderBy === 'asc' ? len - i - 1 : i
].getValue();
if (value / sum * totalArea < visibleMin) {
deletePoint = i;
sum -= value;
}
}
orderBy === 'asc'
? orderedChildren.splice(0, len - deletePoint)
: orderedChildren.splice(deletePoint, len - deletePoint);
return sum;
} | javascript | function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
// visibleMin is not supported yet when no option.sort.
if (!orderBy) {
return sum;
}
var visibleMin = nodeModel.get('visibleMin');
var len = orderedChildren.length;
var deletePoint = len;
// Always travel from little value to big value.
for (var i = len - 1; i >= 0; i--) {
var value = orderedChildren[
orderBy === 'asc' ? len - i - 1 : i
].getValue();
if (value / sum * totalArea < visibleMin) {
deletePoint = i;
sum -= value;
}
}
orderBy === 'asc'
? orderedChildren.splice(0, len - deletePoint)
: orderedChildren.splice(deletePoint, len - deletePoint);
return sum;
} | [
"function",
"filterByThreshold",
"(",
"nodeModel",
",",
"totalArea",
",",
"sum",
",",
"orderBy",
",",
"orderedChildren",
")",
"{",
"// visibleMin is not supported yet when no option.sort.",
"if",
"(",
"!",
"orderBy",
")",
"{",
"return",
"sum",
";",
"}",
"var",
"visibleMin",
"=",
"nodeModel",
".",
"get",
"(",
"'visibleMin'",
")",
";",
"var",
"len",
"=",
"orderedChildren",
".",
"length",
";",
"var",
"deletePoint",
"=",
"len",
";",
"// Always travel from little value to big value.",
"for",
"(",
"var",
"i",
"=",
"len",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"value",
"=",
"orderedChildren",
"[",
"orderBy",
"===",
"'asc'",
"?",
"len",
"-",
"i",
"-",
"1",
":",
"i",
"]",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
"/",
"sum",
"*",
"totalArea",
"<",
"visibleMin",
")",
"{",
"deletePoint",
"=",
"i",
";",
"sum",
"-=",
"value",
";",
"}",
"}",
"orderBy",
"===",
"'asc'",
"?",
"orderedChildren",
".",
"splice",
"(",
"0",
",",
"len",
"-",
"deletePoint",
")",
":",
"orderedChildren",
".",
"splice",
"(",
"deletePoint",
",",
"len",
"-",
"deletePoint",
")",
";",
"return",
"sum",
";",
"}"
] | Consider 'visibleMin'. Modify viewChildren and get new sum. | [
"Consider",
"visibleMin",
".",
"Modify",
"viewChildren",
"and",
"get",
"new",
"sum",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L311-L339 |
254 | apache/incubator-echarts | src/chart/treemap/treemapLayout.js | position | function position(row, rowFixedLength, rect, halfGapWidth, flush) {
// When rowFixedLength === rect.width,
// it is horizontal subdivision,
// rowFixedLength is the width of the subdivision,
// rowOtherLength is the height of the subdivision,
// and nodes will be positioned from left to right.
// wh[idx0WhenH] means: when horizontal,
// wh[idx0WhenH] => wh[0] => 'width'.
// xy[idx1WhenH] => xy[1] => 'y'.
var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
var idx1WhenH = 1 - idx0WhenH;
var xy = ['x', 'y'];
var wh = ['width', 'height'];
var last = rect[xy[idx0WhenH]];
var rowOtherLength = rowFixedLength
? row.area / rowFixedLength : 0;
if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
}
for (var i = 0, rowLen = row.length; i < rowLen; i++) {
var node = row[i];
var nodeLayout = {};
var step = rowOtherLength
? node.getLayout().area / rowOtherLength : 0;
var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);
// We use Math.max/min to avoid negative width/height when considering gap width.
var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);
nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);
last += modWH;
node.setLayout(nodeLayout, true);
}
rect[xy[idx1WhenH]] += rowOtherLength;
rect[wh[idx1WhenH]] -= rowOtherLength;
} | javascript | function position(row, rowFixedLength, rect, halfGapWidth, flush) {
// When rowFixedLength === rect.width,
// it is horizontal subdivision,
// rowFixedLength is the width of the subdivision,
// rowOtherLength is the height of the subdivision,
// and nodes will be positioned from left to right.
// wh[idx0WhenH] means: when horizontal,
// wh[idx0WhenH] => wh[0] => 'width'.
// xy[idx1WhenH] => xy[1] => 'y'.
var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
var idx1WhenH = 1 - idx0WhenH;
var xy = ['x', 'y'];
var wh = ['width', 'height'];
var last = rect[xy[idx0WhenH]];
var rowOtherLength = rowFixedLength
? row.area / rowFixedLength : 0;
if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
}
for (var i = 0, rowLen = row.length; i < rowLen; i++) {
var node = row[i];
var nodeLayout = {};
var step = rowOtherLength
? node.getLayout().area / rowOtherLength : 0;
var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);
// We use Math.max/min to avoid negative width/height when considering gap width.
var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);
nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);
last += modWH;
node.setLayout(nodeLayout, true);
}
rect[xy[idx1WhenH]] += rowOtherLength;
rect[wh[idx1WhenH]] -= rowOtherLength;
} | [
"function",
"position",
"(",
"row",
",",
"rowFixedLength",
",",
"rect",
",",
"halfGapWidth",
",",
"flush",
")",
"{",
"// When rowFixedLength === rect.width,",
"// it is horizontal subdivision,",
"// rowFixedLength is the width of the subdivision,",
"// rowOtherLength is the height of the subdivision,",
"// and nodes will be positioned from left to right.",
"// wh[idx0WhenH] means: when horizontal,",
"// wh[idx0WhenH] => wh[0] => 'width'.",
"// xy[idx1WhenH] => xy[1] => 'y'.",
"var",
"idx0WhenH",
"=",
"rowFixedLength",
"===",
"rect",
".",
"width",
"?",
"0",
":",
"1",
";",
"var",
"idx1WhenH",
"=",
"1",
"-",
"idx0WhenH",
";",
"var",
"xy",
"=",
"[",
"'x'",
",",
"'y'",
"]",
";",
"var",
"wh",
"=",
"[",
"'width'",
",",
"'height'",
"]",
";",
"var",
"last",
"=",
"rect",
"[",
"xy",
"[",
"idx0WhenH",
"]",
"]",
";",
"var",
"rowOtherLength",
"=",
"rowFixedLength",
"?",
"row",
".",
"area",
"/",
"rowFixedLength",
":",
"0",
";",
"if",
"(",
"flush",
"||",
"rowOtherLength",
">",
"rect",
"[",
"wh",
"[",
"idx1WhenH",
"]",
"]",
")",
"{",
"rowOtherLength",
"=",
"rect",
"[",
"wh",
"[",
"idx1WhenH",
"]",
"]",
";",
"// over+underflow",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"rowLen",
"=",
"row",
".",
"length",
";",
"i",
"<",
"rowLen",
";",
"i",
"++",
")",
"{",
"var",
"node",
"=",
"row",
"[",
"i",
"]",
";",
"var",
"nodeLayout",
"=",
"{",
"}",
";",
"var",
"step",
"=",
"rowOtherLength",
"?",
"node",
".",
"getLayout",
"(",
")",
".",
"area",
"/",
"rowOtherLength",
":",
"0",
";",
"var",
"wh1",
"=",
"nodeLayout",
"[",
"wh",
"[",
"idx1WhenH",
"]",
"]",
"=",
"mathMax",
"(",
"rowOtherLength",
"-",
"2",
"*",
"halfGapWidth",
",",
"0",
")",
";",
"// We use Math.max/min to avoid negative width/height when considering gap width.",
"var",
"remain",
"=",
"rect",
"[",
"xy",
"[",
"idx0WhenH",
"]",
"]",
"+",
"rect",
"[",
"wh",
"[",
"idx0WhenH",
"]",
"]",
"-",
"last",
";",
"var",
"modWH",
"=",
"(",
"i",
"===",
"rowLen",
"-",
"1",
"||",
"remain",
"<",
"step",
")",
"?",
"remain",
":",
"step",
";",
"var",
"wh0",
"=",
"nodeLayout",
"[",
"wh",
"[",
"idx0WhenH",
"]",
"]",
"=",
"mathMax",
"(",
"modWH",
"-",
"2",
"*",
"halfGapWidth",
",",
"0",
")",
";",
"nodeLayout",
"[",
"xy",
"[",
"idx1WhenH",
"]",
"]",
"=",
"rect",
"[",
"xy",
"[",
"idx1WhenH",
"]",
"]",
"+",
"mathMin",
"(",
"halfGapWidth",
",",
"wh1",
"/",
"2",
")",
";",
"nodeLayout",
"[",
"xy",
"[",
"idx0WhenH",
"]",
"]",
"=",
"last",
"+",
"mathMin",
"(",
"halfGapWidth",
",",
"wh0",
"/",
"2",
")",
";",
"last",
"+=",
"modWH",
";",
"node",
".",
"setLayout",
"(",
"nodeLayout",
",",
"true",
")",
";",
"}",
"rect",
"[",
"xy",
"[",
"idx1WhenH",
"]",
"]",
"+=",
"rowOtherLength",
";",
"rect",
"[",
"wh",
"[",
"idx1WhenH",
"]",
"]",
"-=",
"rowOtherLength",
";",
"}"
] | Positions the specified row of nodes. Modifies `rect`. | [
"Positions",
"the",
"specified",
"row",
"of",
"nodes",
".",
"Modifies",
"rect",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L431-L475 |
255 | apache/incubator-echarts | src/chart/treemap/treemapLayout.js | calculateRootPosition | function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
if (rootRect) {
return {x: rootRect.x, y: rootRect.y};
}
var defaultPosition = {x: 0, y: 0};
if (!targetInfo) {
return defaultPosition;
}
// If targetInfo is fetched by 'retrieveTargetInfo',
// old tree and new tree are the same tree,
// so the node still exists and we can visit it.
var targetNode = targetInfo.node;
var layout = targetNode.getLayout();
if (!layout) {
return defaultPosition;
}
// Transform coord from local to container.
var targetCenter = [layout.width / 2, layout.height / 2];
var node = targetNode;
while (node) {
var nodeLayout = node.getLayout();
targetCenter[0] += nodeLayout.x;
targetCenter[1] += nodeLayout.y;
node = node.parentNode;
}
return {
x: layoutInfo.width / 2 - targetCenter[0],
y: layoutInfo.height / 2 - targetCenter[1]
};
} | javascript | function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
if (rootRect) {
return {x: rootRect.x, y: rootRect.y};
}
var defaultPosition = {x: 0, y: 0};
if (!targetInfo) {
return defaultPosition;
}
// If targetInfo is fetched by 'retrieveTargetInfo',
// old tree and new tree are the same tree,
// so the node still exists and we can visit it.
var targetNode = targetInfo.node;
var layout = targetNode.getLayout();
if (!layout) {
return defaultPosition;
}
// Transform coord from local to container.
var targetCenter = [layout.width / 2, layout.height / 2];
var node = targetNode;
while (node) {
var nodeLayout = node.getLayout();
targetCenter[0] += nodeLayout.x;
targetCenter[1] += nodeLayout.y;
node = node.parentNode;
}
return {
x: layoutInfo.width / 2 - targetCenter[0],
y: layoutInfo.height / 2 - targetCenter[1]
};
} | [
"function",
"calculateRootPosition",
"(",
"layoutInfo",
",",
"rootRect",
",",
"targetInfo",
")",
"{",
"if",
"(",
"rootRect",
")",
"{",
"return",
"{",
"x",
":",
"rootRect",
".",
"x",
",",
"y",
":",
"rootRect",
".",
"y",
"}",
";",
"}",
"var",
"defaultPosition",
"=",
"{",
"x",
":",
"0",
",",
"y",
":",
"0",
"}",
";",
"if",
"(",
"!",
"targetInfo",
")",
"{",
"return",
"defaultPosition",
";",
"}",
"// If targetInfo is fetched by 'retrieveTargetInfo',",
"// old tree and new tree are the same tree,",
"// so the node still exists and we can visit it.",
"var",
"targetNode",
"=",
"targetInfo",
".",
"node",
";",
"var",
"layout",
"=",
"targetNode",
".",
"getLayout",
"(",
")",
";",
"if",
"(",
"!",
"layout",
")",
"{",
"return",
"defaultPosition",
";",
"}",
"// Transform coord from local to container.",
"var",
"targetCenter",
"=",
"[",
"layout",
".",
"width",
"/",
"2",
",",
"layout",
".",
"height",
"/",
"2",
"]",
";",
"var",
"node",
"=",
"targetNode",
";",
"while",
"(",
"node",
")",
"{",
"var",
"nodeLayout",
"=",
"node",
".",
"getLayout",
"(",
")",
";",
"targetCenter",
"[",
"0",
"]",
"+=",
"nodeLayout",
".",
"x",
";",
"targetCenter",
"[",
"1",
"]",
"+=",
"nodeLayout",
".",
"y",
";",
"node",
"=",
"node",
".",
"parentNode",
";",
"}",
"return",
"{",
"x",
":",
"layoutInfo",
".",
"width",
"/",
"2",
"-",
"targetCenter",
"[",
"0",
"]",
",",
"y",
":",
"layoutInfo",
".",
"height",
"/",
"2",
"-",
"targetCenter",
"[",
"1",
"]",
"}",
";",
"}"
] | Root postion base on coord of containerGroup | [
"Root",
"postion",
"base",
"on",
"coord",
"of",
"containerGroup"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L524-L559 |
256 | apache/incubator-echarts | src/chart/treemap/treemapLayout.js | prunning | function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
var nodeLayout = node.getLayout();
var nodeInViewAbovePath = viewAbovePath[depth];
var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;
if (
(nodeInViewAbovePath && !isAboveViewRoot)
|| (depth === viewAbovePath.length && node !== viewRoot)
) {
return;
}
node.setLayout({
// isInView means: viewRoot sub tree + viewAbovePath
isInView: true,
// invisible only means: outside view clip so that the node can not
// see but still layout for animation preparation but not render.
invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
isAboveViewRoot: isAboveViewRoot
}, true);
// Transform to child coordinate.
var childClipRect = new BoundingRect(
clipRect.x - nodeLayout.x,
clipRect.y - nodeLayout.y,
clipRect.width,
clipRect.height
);
each(node.viewChildren || [], function (child) {
prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
});
} | javascript | function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
var nodeLayout = node.getLayout();
var nodeInViewAbovePath = viewAbovePath[depth];
var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;
if (
(nodeInViewAbovePath && !isAboveViewRoot)
|| (depth === viewAbovePath.length && node !== viewRoot)
) {
return;
}
node.setLayout({
// isInView means: viewRoot sub tree + viewAbovePath
isInView: true,
// invisible only means: outside view clip so that the node can not
// see but still layout for animation preparation but not render.
invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
isAboveViewRoot: isAboveViewRoot
}, true);
// Transform to child coordinate.
var childClipRect = new BoundingRect(
clipRect.x - nodeLayout.x,
clipRect.y - nodeLayout.y,
clipRect.width,
clipRect.height
);
each(node.viewChildren || [], function (child) {
prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
});
} | [
"function",
"prunning",
"(",
"node",
",",
"clipRect",
",",
"viewAbovePath",
",",
"viewRoot",
",",
"depth",
")",
"{",
"var",
"nodeLayout",
"=",
"node",
".",
"getLayout",
"(",
")",
";",
"var",
"nodeInViewAbovePath",
"=",
"viewAbovePath",
"[",
"depth",
"]",
";",
"var",
"isAboveViewRoot",
"=",
"nodeInViewAbovePath",
"&&",
"nodeInViewAbovePath",
"===",
"node",
";",
"if",
"(",
"(",
"nodeInViewAbovePath",
"&&",
"!",
"isAboveViewRoot",
")",
"||",
"(",
"depth",
"===",
"viewAbovePath",
".",
"length",
"&&",
"node",
"!==",
"viewRoot",
")",
")",
"{",
"return",
";",
"}",
"node",
".",
"setLayout",
"(",
"{",
"// isInView means: viewRoot sub tree + viewAbovePath",
"isInView",
":",
"true",
",",
"// invisible only means: outside view clip so that the node can not",
"// see but still layout for animation preparation but not render.",
"invisible",
":",
"!",
"isAboveViewRoot",
"&&",
"!",
"clipRect",
".",
"intersect",
"(",
"nodeLayout",
")",
",",
"isAboveViewRoot",
":",
"isAboveViewRoot",
"}",
",",
"true",
")",
";",
"// Transform to child coordinate.",
"var",
"childClipRect",
"=",
"new",
"BoundingRect",
"(",
"clipRect",
".",
"x",
"-",
"nodeLayout",
".",
"x",
",",
"clipRect",
".",
"y",
"-",
"nodeLayout",
".",
"y",
",",
"clipRect",
".",
"width",
",",
"clipRect",
".",
"height",
")",
";",
"each",
"(",
"node",
".",
"viewChildren",
"||",
"[",
"]",
",",
"function",
"(",
"child",
")",
"{",
"prunning",
"(",
"child",
",",
"childClipRect",
",",
"viewAbovePath",
",",
"viewRoot",
",",
"depth",
"+",
"1",
")",
";",
"}",
")",
";",
"}"
] | Mark nodes visible for prunning when visual coding and rendering. Prunning depends on layout and root position, so we have to do it after layout. | [
"Mark",
"nodes",
"visible",
"for",
"prunning",
"when",
"visual",
"coding",
"and",
"rendering",
".",
"Prunning",
"depends",
"on",
"layout",
"and",
"root",
"position",
"so",
"we",
"have",
"to",
"do",
"it",
"after",
"layout",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L563-L595 |
257 | apache/incubator-echarts | src/chart/tree/layoutHelper.js | executeShifts | function executeShifts(node) {
var children = node.children;
var n = children.length;
var shift = 0;
var change = 0;
while (--n >= 0) {
var child = children[n];
child.hierNode.prelim += shift;
child.hierNode.modifier += shift;
change += child.hierNode.change;
shift += child.hierNode.shift + change;
}
} | javascript | function executeShifts(node) {
var children = node.children;
var n = children.length;
var shift = 0;
var change = 0;
while (--n >= 0) {
var child = children[n];
child.hierNode.prelim += shift;
child.hierNode.modifier += shift;
change += child.hierNode.change;
shift += child.hierNode.shift + change;
}
} | [
"function",
"executeShifts",
"(",
"node",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
";",
"var",
"n",
"=",
"children",
".",
"length",
";",
"var",
"shift",
"=",
"0",
";",
"var",
"change",
"=",
"0",
";",
"while",
"(",
"--",
"n",
">=",
"0",
")",
"{",
"var",
"child",
"=",
"children",
"[",
"n",
"]",
";",
"child",
".",
"hierNode",
".",
"prelim",
"+=",
"shift",
";",
"child",
".",
"hierNode",
".",
"modifier",
"+=",
"shift",
";",
"change",
"+=",
"child",
".",
"hierNode",
".",
"change",
";",
"shift",
"+=",
"child",
".",
"hierNode",
".",
"shift",
"+",
"change",
";",
"}",
"}"
] | All other shifts, applied to the smaller subtrees between w- and w+, are
performed by this function.
The implementation of this function was originally copied from "d3.js"
<https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
with some modifications made for this program.
See the license statement at the head of this file.
@param {module:echarts/data/Tree~TreeNode} node | [
"All",
"other",
"shifts",
"applied",
"to",
"the",
"smaller",
"subtrees",
"between",
"w",
"-",
"and",
"w",
"+",
"are",
"performed",
"by",
"this",
"function",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/tree/layoutHelper.js#L185-L197 |
258 | apache/incubator-echarts | src/chart/tree/layoutHelper.js | nextRight | function nextRight(node) {
var children = node.children;
return children.length && node.isExpand ? children[children.length - 1] : node.hierNode.thread;
} | javascript | function nextRight(node) {
var children = node.children;
return children.length && node.isExpand ? children[children.length - 1] : node.hierNode.thread;
} | [
"function",
"nextRight",
"(",
"node",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
";",
"return",
"children",
".",
"length",
"&&",
"node",
".",
"isExpand",
"?",
"children",
"[",
"children",
".",
"length",
"-",
"1",
"]",
":",
"node",
".",
"hierNode",
".",
"thread",
";",
"}"
] | This function is used to traverse the right contour of a subtree.
It returns the rightmost child of node or the thread of node. The function
returns null if and only if node is on the highest depth of its subtree.
@param {module:echarts/data/Tree~TreeNode} node
@return {module:echarts/data/Tree~TreeNode} | [
"This",
"function",
"is",
"used",
"to",
"traverse",
"the",
"right",
"contour",
"of",
"a",
"subtree",
".",
"It",
"returns",
"the",
"rightmost",
"child",
"of",
"node",
"or",
"the",
"thread",
"of",
"node",
".",
"The",
"function",
"returns",
"null",
"if",
"and",
"only",
"if",
"node",
"is",
"on",
"the",
"highest",
"depth",
"of",
"its",
"subtree",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/tree/layoutHelper.js#L270-L273 |
259 | apache/incubator-echarts | src/view/Chart.js | elSetState | function elSetState(el, state, highlightDigit) {
if (el) {
el.trigger(state, highlightDigit);
if (el.isGroup
// Simple optimize.
&& !graphicUtil.isHighDownDispatcher(el)
) {
for (var i = 0, len = el.childCount(); i < len; i++) {
elSetState(el.childAt(i), state, highlightDigit);
}
}
}
} | javascript | function elSetState(el, state, highlightDigit) {
if (el) {
el.trigger(state, highlightDigit);
if (el.isGroup
// Simple optimize.
&& !graphicUtil.isHighDownDispatcher(el)
) {
for (var i = 0, len = el.childCount(); i < len; i++) {
elSetState(el.childAt(i), state, highlightDigit);
}
}
}
} | [
"function",
"elSetState",
"(",
"el",
",",
"state",
",",
"highlightDigit",
")",
"{",
"if",
"(",
"el",
")",
"{",
"el",
".",
"trigger",
"(",
"state",
",",
"highlightDigit",
")",
";",
"if",
"(",
"el",
".",
"isGroup",
"// Simple optimize.",
"&&",
"!",
"graphicUtil",
".",
"isHighDownDispatcher",
"(",
"el",
")",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"el",
".",
"childCount",
"(",
")",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"elSetState",
"(",
"el",
".",
"childAt",
"(",
"i",
")",
",",
"state",
",",
"highlightDigit",
")",
";",
"}",
"}",
"}",
"}"
] | Set state of single element
@param {module:zrender/Element} el
@param {string} state 'normal'|'emphasis'
@param {number} highlightDigit | [
"Set",
"state",
"of",
"single",
"element"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/view/Chart.js#L173-L185 |
260 | apache/incubator-echarts | src/coord/parallel/Parallel.js | function (parallelModel, ecModel, api) {
var dimensions = parallelModel.dimensions;
var parallelAxisIndex = parallelModel.parallelAxisIndex;
each(dimensions, function (dim, idx) {
var axisIndex = parallelAxisIndex[idx];
var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
var axis = this._axesMap.set(dim, new ParallelAxis(
dim,
axisHelper.createScaleByModel(axisModel),
[0, 0],
axisModel.get('type'),
axisIndex
));
var isCategory = axis.type === 'category';
axis.onBand = isCategory && axisModel.get('boundaryGap');
axis.inverse = axisModel.get('inverse');
// Injection
axisModel.axis = axis;
axis.model = axisModel;
axis.coordinateSystem = axisModel.coordinateSystem = this;
}, this);
} | javascript | function (parallelModel, ecModel, api) {
var dimensions = parallelModel.dimensions;
var parallelAxisIndex = parallelModel.parallelAxisIndex;
each(dimensions, function (dim, idx) {
var axisIndex = parallelAxisIndex[idx];
var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
var axis = this._axesMap.set(dim, new ParallelAxis(
dim,
axisHelper.createScaleByModel(axisModel),
[0, 0],
axisModel.get('type'),
axisIndex
));
var isCategory = axis.type === 'category';
axis.onBand = isCategory && axisModel.get('boundaryGap');
axis.inverse = axisModel.get('inverse');
// Injection
axisModel.axis = axis;
axis.model = axisModel;
axis.coordinateSystem = axisModel.coordinateSystem = this;
}, this);
} | [
"function",
"(",
"parallelModel",
",",
"ecModel",
",",
"api",
")",
"{",
"var",
"dimensions",
"=",
"parallelModel",
".",
"dimensions",
";",
"var",
"parallelAxisIndex",
"=",
"parallelModel",
".",
"parallelAxisIndex",
";",
"each",
"(",
"dimensions",
",",
"function",
"(",
"dim",
",",
"idx",
")",
"{",
"var",
"axisIndex",
"=",
"parallelAxisIndex",
"[",
"idx",
"]",
";",
"var",
"axisModel",
"=",
"ecModel",
".",
"getComponent",
"(",
"'parallelAxis'",
",",
"axisIndex",
")",
";",
"var",
"axis",
"=",
"this",
".",
"_axesMap",
".",
"set",
"(",
"dim",
",",
"new",
"ParallelAxis",
"(",
"dim",
",",
"axisHelper",
".",
"createScaleByModel",
"(",
"axisModel",
")",
",",
"[",
"0",
",",
"0",
"]",
",",
"axisModel",
".",
"get",
"(",
"'type'",
")",
",",
"axisIndex",
")",
")",
";",
"var",
"isCategory",
"=",
"axis",
".",
"type",
"===",
"'category'",
";",
"axis",
".",
"onBand",
"=",
"isCategory",
"&&",
"axisModel",
".",
"get",
"(",
"'boundaryGap'",
")",
";",
"axis",
".",
"inverse",
"=",
"axisModel",
".",
"get",
"(",
"'inverse'",
")",
";",
"// Injection",
"axisModel",
".",
"axis",
"=",
"axis",
";",
"axis",
".",
"model",
"=",
"axisModel",
";",
"axis",
".",
"coordinateSystem",
"=",
"axisModel",
".",
"coordinateSystem",
"=",
"this",
";",
"}",
",",
"this",
")",
";",
"}"
] | Initialize cartesian coordinate systems
@private | [
"Initialize",
"cartesian",
"coordinate",
"systems"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/Parallel.js#L90-L118 |
|
261 | apache/incubator-echarts | src/coord/parallel/Parallel.js | function (parallelModel, ecModel) {
ecModel.eachSeries(function (seriesModel) {
if (!parallelModel.contains(seriesModel, ecModel)) {
return;
}
var data = seriesModel.getData();
each(this.dimensions, function (dim) {
var axis = this._axesMap.get(dim);
axis.scale.unionExtentFromData(data, data.mapDimension(dim));
axisHelper.niceScaleExtent(axis.scale, axis.model);
}, this);
}, this);
} | javascript | function (parallelModel, ecModel) {
ecModel.eachSeries(function (seriesModel) {
if (!parallelModel.contains(seriesModel, ecModel)) {
return;
}
var data = seriesModel.getData();
each(this.dimensions, function (dim) {
var axis = this._axesMap.get(dim);
axis.scale.unionExtentFromData(data, data.mapDimension(dim));
axisHelper.niceScaleExtent(axis.scale, axis.model);
}, this);
}, this);
} | [
"function",
"(",
"parallelModel",
",",
"ecModel",
")",
"{",
"ecModel",
".",
"eachSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"if",
"(",
"!",
"parallelModel",
".",
"contains",
"(",
"seriesModel",
",",
"ecModel",
")",
")",
"{",
"return",
";",
"}",
"var",
"data",
"=",
"seriesModel",
".",
"getData",
"(",
")",
";",
"each",
"(",
"this",
".",
"dimensions",
",",
"function",
"(",
"dim",
")",
"{",
"var",
"axis",
"=",
"this",
".",
"_axesMap",
".",
"get",
"(",
"dim",
")",
";",
"axis",
".",
"scale",
".",
"unionExtentFromData",
"(",
"data",
",",
"data",
".",
"mapDimension",
"(",
"dim",
")",
")",
";",
"axisHelper",
".",
"niceScaleExtent",
"(",
"axis",
".",
"scale",
",",
"axis",
".",
"model",
")",
";",
"}",
",",
"this",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] | Update properties from series
@private | [
"Update",
"properties",
"from",
"series"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/Parallel.js#L154-L169 |
|
262 | apache/incubator-echarts | src/coord/parallel/Parallel.js | function (parallelModel, api) {
this._rect = layoutUtil.getLayoutRect(
parallelModel.getBoxLayoutParams(),
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._layoutAxes();
} | javascript | function (parallelModel, api) {
this._rect = layoutUtil.getLayoutRect(
parallelModel.getBoxLayoutParams(),
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._layoutAxes();
} | [
"function",
"(",
"parallelModel",
",",
"api",
")",
"{",
"this",
".",
"_rect",
"=",
"layoutUtil",
".",
"getLayoutRect",
"(",
"parallelModel",
".",
"getBoxLayoutParams",
"(",
")",
",",
"{",
"width",
":",
"api",
".",
"getWidth",
"(",
")",
",",
"height",
":",
"api",
".",
"getHeight",
"(",
")",
"}",
")",
";",
"this",
".",
"_layoutAxes",
"(",
")",
";",
"}"
] | Resize the parallel coordinate system.
@param {module:echarts/coord/parallel/ParallelModel} parallelModel
@param {module:echarts/ExtensionAPI} api | [
"Resize",
"the",
"parallel",
"coordinate",
"system",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/Parallel.js#L176-L186 |
|
263 | apache/incubator-echarts | src/coord/parallel/Parallel.js | function (data, callback, start, end) {
start == null && (start = 0);
end == null && (end = data.count());
var axesMap = this._axesMap;
var dimensions = this.dimensions;
var dataDimensions = [];
var axisModels = [];
zrUtil.each(dimensions, function (axisDim) {
dataDimensions.push(data.mapDimension(axisDim));
axisModels.push(axesMap.get(axisDim).model);
});
var hasActiveSet = this.hasAxisBrushed();
for (var dataIndex = start; dataIndex < end; dataIndex++) {
var activeState;
if (!hasActiveSet) {
activeState = 'normal';
}
else {
activeState = 'active';
var values = data.getValues(dataDimensions, dataIndex);
for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
var state = axisModels[j].getActiveState(values[j]);
if (state === 'inactive') {
activeState = 'inactive';
break;
}
}
}
callback(activeState, dataIndex);
}
} | javascript | function (data, callback, start, end) {
start == null && (start = 0);
end == null && (end = data.count());
var axesMap = this._axesMap;
var dimensions = this.dimensions;
var dataDimensions = [];
var axisModels = [];
zrUtil.each(dimensions, function (axisDim) {
dataDimensions.push(data.mapDimension(axisDim));
axisModels.push(axesMap.get(axisDim).model);
});
var hasActiveSet = this.hasAxisBrushed();
for (var dataIndex = start; dataIndex < end; dataIndex++) {
var activeState;
if (!hasActiveSet) {
activeState = 'normal';
}
else {
activeState = 'active';
var values = data.getValues(dataDimensions, dataIndex);
for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
var state = axisModels[j].getActiveState(values[j]);
if (state === 'inactive') {
activeState = 'inactive';
break;
}
}
}
callback(activeState, dataIndex);
}
} | [
"function",
"(",
"data",
",",
"callback",
",",
"start",
",",
"end",
")",
"{",
"start",
"==",
"null",
"&&",
"(",
"start",
"=",
"0",
")",
";",
"end",
"==",
"null",
"&&",
"(",
"end",
"=",
"data",
".",
"count",
"(",
")",
")",
";",
"var",
"axesMap",
"=",
"this",
".",
"_axesMap",
";",
"var",
"dimensions",
"=",
"this",
".",
"dimensions",
";",
"var",
"dataDimensions",
"=",
"[",
"]",
";",
"var",
"axisModels",
"=",
"[",
"]",
";",
"zrUtil",
".",
"each",
"(",
"dimensions",
",",
"function",
"(",
"axisDim",
")",
"{",
"dataDimensions",
".",
"push",
"(",
"data",
".",
"mapDimension",
"(",
"axisDim",
")",
")",
";",
"axisModels",
".",
"push",
"(",
"axesMap",
".",
"get",
"(",
"axisDim",
")",
".",
"model",
")",
";",
"}",
")",
";",
"var",
"hasActiveSet",
"=",
"this",
".",
"hasAxisBrushed",
"(",
")",
";",
"for",
"(",
"var",
"dataIndex",
"=",
"start",
";",
"dataIndex",
"<",
"end",
";",
"dataIndex",
"++",
")",
"{",
"var",
"activeState",
";",
"if",
"(",
"!",
"hasActiveSet",
")",
"{",
"activeState",
"=",
"'normal'",
";",
"}",
"else",
"{",
"activeState",
"=",
"'active'",
";",
"var",
"values",
"=",
"data",
".",
"getValues",
"(",
"dataDimensions",
",",
"dataIndex",
")",
";",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"lenj",
"=",
"dimensions",
".",
"length",
";",
"j",
"<",
"lenj",
";",
"j",
"++",
")",
"{",
"var",
"state",
"=",
"axisModels",
"[",
"j",
"]",
".",
"getActiveState",
"(",
"values",
"[",
"j",
"]",
")",
";",
"if",
"(",
"state",
"===",
"'inactive'",
")",
"{",
"activeState",
"=",
"'inactive'",
";",
"break",
";",
"}",
"}",
"}",
"callback",
"(",
"activeState",
",",
"dataIndex",
")",
";",
"}",
"}"
] | Travel data for one time, get activeState of each data item.
@param {module:echarts/data/List} data
@param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal'
{number} dataIndex
@param {number} [start=0] the start dataIndex that travel from.
@param {number} [end=data.count()] the next dataIndex of the last dataIndex will be travel. | [
"Travel",
"data",
"for",
"one",
"time",
"get",
"activeState",
"of",
"each",
"data",
"item",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/Parallel.js#L359-L396 |
|
264 | apache/incubator-echarts | src/coord/parallel/Parallel.js | function () {
var dimensions = this.dimensions;
var axesMap = this._axesMap;
var hasActiveSet = false;
for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
if (axesMap.get(dimensions[j]).model.getActiveState() !== 'normal') {
hasActiveSet = true;
}
}
return hasActiveSet;
} | javascript | function () {
var dimensions = this.dimensions;
var axesMap = this._axesMap;
var hasActiveSet = false;
for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
if (axesMap.get(dimensions[j]).model.getActiveState() !== 'normal') {
hasActiveSet = true;
}
}
return hasActiveSet;
} | [
"function",
"(",
")",
"{",
"var",
"dimensions",
"=",
"this",
".",
"dimensions",
";",
"var",
"axesMap",
"=",
"this",
".",
"_axesMap",
";",
"var",
"hasActiveSet",
"=",
"false",
";",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"lenj",
"=",
"dimensions",
".",
"length",
";",
"j",
"<",
"lenj",
";",
"j",
"++",
")",
"{",
"if",
"(",
"axesMap",
".",
"get",
"(",
"dimensions",
"[",
"j",
"]",
")",
".",
"model",
".",
"getActiveState",
"(",
")",
"!==",
"'normal'",
")",
"{",
"hasActiveSet",
"=",
"true",
";",
"}",
"}",
"return",
"hasActiveSet",
";",
"}"
] | Whether has any activeSet.
@return {boolean} | [
"Whether",
"has",
"any",
"activeSet",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/Parallel.js#L402-L414 |
|
265 | apache/incubator-echarts | src/component/dataZoom/DataZoomModel.js | function (opt, ignoreUpdateRangeUsg) {
var option = this.option;
each([['start', 'startValue'], ['end', 'endValue']], function (names) {
// If only one of 'start' and 'startValue' is not null/undefined, the other
// should be cleared, which enable clear the option.
// If both of them are not set, keep option with the original value, which
// enable use only set start but not set end when calling `dispatchAction`.
// The same as 'end' and 'endValue'.
if (opt[names[0]] != null || opt[names[1]] != null) {
option[names[0]] = opt[names[0]];
option[names[1]] = opt[names[1]];
}
}, this);
!ignoreUpdateRangeUsg && updateRangeUse(this, opt);
} | javascript | function (opt, ignoreUpdateRangeUsg) {
var option = this.option;
each([['start', 'startValue'], ['end', 'endValue']], function (names) {
// If only one of 'start' and 'startValue' is not null/undefined, the other
// should be cleared, which enable clear the option.
// If both of them are not set, keep option with the original value, which
// enable use only set start but not set end when calling `dispatchAction`.
// The same as 'end' and 'endValue'.
if (opt[names[0]] != null || opt[names[1]] != null) {
option[names[0]] = opt[names[0]];
option[names[1]] = opt[names[1]];
}
}, this);
!ignoreUpdateRangeUsg && updateRangeUse(this, opt);
} | [
"function",
"(",
"opt",
",",
"ignoreUpdateRangeUsg",
")",
"{",
"var",
"option",
"=",
"this",
".",
"option",
";",
"each",
"(",
"[",
"[",
"'start'",
",",
"'startValue'",
"]",
",",
"[",
"'end'",
",",
"'endValue'",
"]",
"]",
",",
"function",
"(",
"names",
")",
"{",
"// If only one of 'start' and 'startValue' is not null/undefined, the other",
"// should be cleared, which enable clear the option.",
"// If both of them are not set, keep option with the original value, which",
"// enable use only set start but not set end when calling `dispatchAction`.",
"// The same as 'end' and 'endValue'.",
"if",
"(",
"opt",
"[",
"names",
"[",
"0",
"]",
"]",
"!=",
"null",
"||",
"opt",
"[",
"names",
"[",
"1",
"]",
"]",
"!=",
"null",
")",
"{",
"option",
"[",
"names",
"[",
"0",
"]",
"]",
"=",
"opt",
"[",
"names",
"[",
"0",
"]",
"]",
";",
"option",
"[",
"names",
"[",
"1",
"]",
"]",
"=",
"opt",
"[",
"names",
"[",
"1",
"]",
"]",
";",
"}",
"}",
",",
"this",
")",
";",
"!",
"ignoreUpdateRangeUsg",
"&&",
"updateRangeUse",
"(",
"this",
",",
"opt",
")",
";",
"}"
] | If not specified, set to undefined.
@public
@param {Object} opt
@param {number} [opt.start]
@param {number} [opt.end]
@param {number} [opt.startValue]
@param {number} [opt.endValue]
@param {boolean} [ignoreUpdateRangeUsg=false] | [
"If",
"not",
"specified",
"set",
"to",
"undefined",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/dataZoom/DataZoomModel.js#L455-L470 |
|
266 | apache/incubator-echarts | src/coord/polar/polarCreator.js | resizePolar | function resizePolar(polar, polarModel, api) {
var center = polarModel.get('center');
var width = api.getWidth();
var height = api.getHeight();
polar.cx = parsePercent(center[0], width);
polar.cy = parsePercent(center[1], height);
var radiusAxis = polar.getRadiusAxis();
var size = Math.min(width, height) / 2;
var radius = parsePercent(polarModel.get('radius'), size);
radiusAxis.inverse
? radiusAxis.setExtent(radius, 0)
: radiusAxis.setExtent(0, radius);
} | javascript | function resizePolar(polar, polarModel, api) {
var center = polarModel.get('center');
var width = api.getWidth();
var height = api.getHeight();
polar.cx = parsePercent(center[0], width);
polar.cy = parsePercent(center[1], height);
var radiusAxis = polar.getRadiusAxis();
var size = Math.min(width, height) / 2;
var radius = parsePercent(polarModel.get('radius'), size);
radiusAxis.inverse
? radiusAxis.setExtent(radius, 0)
: radiusAxis.setExtent(0, radius);
} | [
"function",
"resizePolar",
"(",
"polar",
",",
"polarModel",
",",
"api",
")",
"{",
"var",
"center",
"=",
"polarModel",
".",
"get",
"(",
"'center'",
")",
";",
"var",
"width",
"=",
"api",
".",
"getWidth",
"(",
")",
";",
"var",
"height",
"=",
"api",
".",
"getHeight",
"(",
")",
";",
"polar",
".",
"cx",
"=",
"parsePercent",
"(",
"center",
"[",
"0",
"]",
",",
"width",
")",
";",
"polar",
".",
"cy",
"=",
"parsePercent",
"(",
"center",
"[",
"1",
"]",
",",
"height",
")",
";",
"var",
"radiusAxis",
"=",
"polar",
".",
"getRadiusAxis",
"(",
")",
";",
"var",
"size",
"=",
"Math",
".",
"min",
"(",
"width",
",",
"height",
")",
"/",
"2",
";",
"var",
"radius",
"=",
"parsePercent",
"(",
"polarModel",
".",
"get",
"(",
"'radius'",
")",
",",
"size",
")",
";",
"radiusAxis",
".",
"inverse",
"?",
"radiusAxis",
".",
"setExtent",
"(",
"radius",
",",
"0",
")",
":",
"radiusAxis",
".",
"setExtent",
"(",
"0",
",",
"radius",
")",
";",
"}"
] | Resize method bound to the polar
@param {module:echarts/coord/polar/PolarModel} polarModel
@param {module:echarts/ExtensionAPI} api | [
"Resize",
"method",
"bound",
"to",
"the",
"polar"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/polarCreator.js#L40-L54 |
267 | apache/incubator-echarts | src/coord/polar/polarCreator.js | setAxis | function setAxis(axis, axisModel) {
axis.type = axisModel.get('type');
axis.scale = createScaleByModel(axisModel);
axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
axis.inverse = axisModel.get('inverse');
if (axisModel.mainType === 'angleAxis') {
axis.inverse ^= axisModel.get('clockwise');
var startAngle = axisModel.get('startAngle');
axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
}
// Inject axis instance
axisModel.axis = axis;
axis.model = axisModel;
} | javascript | function setAxis(axis, axisModel) {
axis.type = axisModel.get('type');
axis.scale = createScaleByModel(axisModel);
axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
axis.inverse = axisModel.get('inverse');
if (axisModel.mainType === 'angleAxis') {
axis.inverse ^= axisModel.get('clockwise');
var startAngle = axisModel.get('startAngle');
axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
}
// Inject axis instance
axisModel.axis = axis;
axis.model = axisModel;
} | [
"function",
"setAxis",
"(",
"axis",
",",
"axisModel",
")",
"{",
"axis",
".",
"type",
"=",
"axisModel",
".",
"get",
"(",
"'type'",
")",
";",
"axis",
".",
"scale",
"=",
"createScaleByModel",
"(",
"axisModel",
")",
";",
"axis",
".",
"onBand",
"=",
"axisModel",
".",
"get",
"(",
"'boundaryGap'",
")",
"&&",
"axis",
".",
"type",
"===",
"'category'",
";",
"axis",
".",
"inverse",
"=",
"axisModel",
".",
"get",
"(",
"'inverse'",
")",
";",
"if",
"(",
"axisModel",
".",
"mainType",
"===",
"'angleAxis'",
")",
"{",
"axis",
".",
"inverse",
"^=",
"axisModel",
".",
"get",
"(",
"'clockwise'",
")",
";",
"var",
"startAngle",
"=",
"axisModel",
".",
"get",
"(",
"'startAngle'",
")",
";",
"axis",
".",
"setExtent",
"(",
"startAngle",
",",
"startAngle",
"+",
"(",
"axis",
".",
"inverse",
"?",
"-",
"360",
":",
"360",
")",
")",
";",
"}",
"// Inject axis instance",
"axisModel",
".",
"axis",
"=",
"axis",
";",
"axis",
".",
"model",
"=",
"axisModel",
";",
"}"
] | Set common axis properties
@param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
@param {module:echarts/coord/polar/AxisModel}
@inner | [
"Set",
"common",
"axis",
"properties"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/polarCreator.js#L101-L116 |
268 | apache/incubator-echarts | src/coord/parallel/parallelPreprocessor.js | createParallelIfNeeded | function createParallelIfNeeded(option) {
if (option.parallel) {
return;
}
var hasParallelSeries = false;
zrUtil.each(option.series, function (seriesOpt) {
if (seriesOpt && seriesOpt.type === 'parallel') {
hasParallelSeries = true;
}
});
if (hasParallelSeries) {
option.parallel = [{}];
}
} | javascript | function createParallelIfNeeded(option) {
if (option.parallel) {
return;
}
var hasParallelSeries = false;
zrUtil.each(option.series, function (seriesOpt) {
if (seriesOpt && seriesOpt.type === 'parallel') {
hasParallelSeries = true;
}
});
if (hasParallelSeries) {
option.parallel = [{}];
}
} | [
"function",
"createParallelIfNeeded",
"(",
"option",
")",
"{",
"if",
"(",
"option",
".",
"parallel",
")",
"{",
"return",
";",
"}",
"var",
"hasParallelSeries",
"=",
"false",
";",
"zrUtil",
".",
"each",
"(",
"option",
".",
"series",
",",
"function",
"(",
"seriesOpt",
")",
"{",
"if",
"(",
"seriesOpt",
"&&",
"seriesOpt",
".",
"type",
"===",
"'parallel'",
")",
"{",
"hasParallelSeries",
"=",
"true",
";",
"}",
"}",
")",
";",
"if",
"(",
"hasParallelSeries",
")",
"{",
"option",
".",
"parallel",
"=",
"[",
"{",
"}",
"]",
";",
"}",
"}"
] | Create a parallel coordinate if not exists.
@inner | [
"Create",
"a",
"parallel",
"coordinate",
"if",
"not",
"exists",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/parallelPreprocessor.js#L32-L48 |
269 | apache/incubator-echarts | src/chart/custom.js | updateCache | function updateCache(dataIndexInside) {
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
if (currDirty) {
currItemModel = data.getItemModel(dataIndexInside);
currLabelNormalModel = currItemModel.getModel(LABEL_NORMAL);
currLabelEmphasisModel = currItemModel.getModel(LABEL_EMPHASIS);
currVisualColor = data.getItemVisual(dataIndexInside, 'color');
currDirty = false;
}
} | javascript | function updateCache(dataIndexInside) {
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
if (currDirty) {
currItemModel = data.getItemModel(dataIndexInside);
currLabelNormalModel = currItemModel.getModel(LABEL_NORMAL);
currLabelEmphasisModel = currItemModel.getModel(LABEL_EMPHASIS);
currVisualColor = data.getItemVisual(dataIndexInside, 'color');
currDirty = false;
}
} | [
"function",
"updateCache",
"(",
"dataIndexInside",
")",
"{",
"dataIndexInside",
"==",
"null",
"&&",
"(",
"dataIndexInside",
"=",
"currDataIndexInside",
")",
";",
"if",
"(",
"currDirty",
")",
"{",
"currItemModel",
"=",
"data",
".",
"getItemModel",
"(",
"dataIndexInside",
")",
";",
"currLabelNormalModel",
"=",
"currItemModel",
".",
"getModel",
"(",
"LABEL_NORMAL",
")",
";",
"currLabelEmphasisModel",
"=",
"currItemModel",
".",
"getModel",
"(",
"LABEL_EMPHASIS",
")",
";",
"currVisualColor",
"=",
"data",
".",
"getItemVisual",
"(",
"dataIndexInside",
",",
"'color'",
")",
";",
"currDirty",
"=",
"false",
";",
"}",
"}"
] | Do not update cache until api called. | [
"Do",
"not",
"update",
"cache",
"until",
"api",
"called",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/custom.js#L412-L422 |
270 | apache/incubator-echarts | src/component/axisPointer/BaseAxisPointer.js | function () {
var handle = this._handle;
if (!handle) {
return;
}
var payloadInfo = this._payloadInfo;
var axisModel = this._axisModel;
this._api.dispatchAction({
type: 'updateAxisPointer',
x: payloadInfo.cursorPoint[0],
y: payloadInfo.cursorPoint[1],
tooltipOption: payloadInfo.tooltipOption,
axesInfo: [{
axisDim: axisModel.axis.dim,
axisIndex: axisModel.componentIndex
}]
});
} | javascript | function () {
var handle = this._handle;
if (!handle) {
return;
}
var payloadInfo = this._payloadInfo;
var axisModel = this._axisModel;
this._api.dispatchAction({
type: 'updateAxisPointer',
x: payloadInfo.cursorPoint[0],
y: payloadInfo.cursorPoint[1],
tooltipOption: payloadInfo.tooltipOption,
axesInfo: [{
axisDim: axisModel.axis.dim,
axisIndex: axisModel.componentIndex
}]
});
} | [
"function",
"(",
")",
"{",
"var",
"handle",
"=",
"this",
".",
"_handle",
";",
"if",
"(",
"!",
"handle",
")",
"{",
"return",
";",
"}",
"var",
"payloadInfo",
"=",
"this",
".",
"_payloadInfo",
";",
"var",
"axisModel",
"=",
"this",
".",
"_axisModel",
";",
"this",
".",
"_api",
".",
"dispatchAction",
"(",
"{",
"type",
":",
"'updateAxisPointer'",
",",
"x",
":",
"payloadInfo",
".",
"cursorPoint",
"[",
"0",
"]",
",",
"y",
":",
"payloadInfo",
".",
"cursorPoint",
"[",
"1",
"]",
",",
"tooltipOption",
":",
"payloadInfo",
".",
"tooltipOption",
",",
"axesInfo",
":",
"[",
"{",
"axisDim",
":",
"axisModel",
".",
"axis",
".",
"dim",
",",
"axisIndex",
":",
"axisModel",
".",
"componentIndex",
"}",
"]",
"}",
")",
";",
"}"
] | Throttled method.
@private | [
"Throttled",
"method",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/axisPointer/BaseAxisPointer.js#L376-L394 |
|
271 | apache/incubator-echarts | src/chart/helper/Symbol.js | getLabelDefaultText | function getLabelDefaultText(idx, opt) {
return useNameLabel ? data.getName(idx) : getDefaultLabel(data, idx);
} | javascript | function getLabelDefaultText(idx, opt) {
return useNameLabel ? data.getName(idx) : getDefaultLabel(data, idx);
} | [
"function",
"getLabelDefaultText",
"(",
"idx",
",",
"opt",
")",
"{",
"return",
"useNameLabel",
"?",
"data",
".",
"getName",
"(",
"idx",
")",
":",
"getDefaultLabel",
"(",
"data",
",",
"idx",
")",
";",
"}"
] | Do not execute util needed. | [
"Do",
"not",
"execute",
"util",
"needed",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/helper/Symbol.js#L320-L322 |
272 | apache/incubator-echarts | src/chart/parallel/ParallelSeries.js | function (activeState) {
var coordSys = this.coordinateSystem;
var data = this.getData();
var indices = [];
coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
if (activeState === theActiveState) {
indices.push(data.getRawIndex(dataIndex));
}
});
return indices;
} | javascript | function (activeState) {
var coordSys = this.coordinateSystem;
var data = this.getData();
var indices = [];
coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
if (activeState === theActiveState) {
indices.push(data.getRawIndex(dataIndex));
}
});
return indices;
} | [
"function",
"(",
"activeState",
")",
"{",
"var",
"coordSys",
"=",
"this",
".",
"coordinateSystem",
";",
"var",
"data",
"=",
"this",
".",
"getData",
"(",
")",
";",
"var",
"indices",
"=",
"[",
"]",
";",
"coordSys",
".",
"eachActiveState",
"(",
"data",
",",
"function",
"(",
"theActiveState",
",",
"dataIndex",
")",
"{",
"if",
"(",
"activeState",
"===",
"theActiveState",
")",
"{",
"indices",
".",
"push",
"(",
"data",
".",
"getRawIndex",
"(",
"dataIndex",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"indices",
";",
"}"
] | User can get data raw indices on 'axisAreaSelected' event received.
@public
@param {string} activeState 'active' or 'inactive' or 'normal'
@return {Array.<number>} Raw indices | [
"User",
"can",
"get",
"data",
"raw",
"indices",
"on",
"axisAreaSelected",
"event",
"received",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/parallel/ParallelSeries.js#L47-L59 |
|
273 | apache/incubator-echarts | src/component/helper/BrushTargetManager.js | getScales | function getScales(xyMinMaxCurr, xyMinMaxOrigin) {
var sizeCurr = getSize(xyMinMaxCurr);
var sizeOrigin = getSize(xyMinMaxOrigin);
var scales = [sizeCurr[0] / sizeOrigin[0], sizeCurr[1] / sizeOrigin[1]];
isNaN(scales[0]) && (scales[0] = 1);
isNaN(scales[1]) && (scales[1] = 1);
return scales;
} | javascript | function getScales(xyMinMaxCurr, xyMinMaxOrigin) {
var sizeCurr = getSize(xyMinMaxCurr);
var sizeOrigin = getSize(xyMinMaxOrigin);
var scales = [sizeCurr[0] / sizeOrigin[0], sizeCurr[1] / sizeOrigin[1]];
isNaN(scales[0]) && (scales[0] = 1);
isNaN(scales[1]) && (scales[1] = 1);
return scales;
} | [
"function",
"getScales",
"(",
"xyMinMaxCurr",
",",
"xyMinMaxOrigin",
")",
"{",
"var",
"sizeCurr",
"=",
"getSize",
"(",
"xyMinMaxCurr",
")",
";",
"var",
"sizeOrigin",
"=",
"getSize",
"(",
"xyMinMaxOrigin",
")",
";",
"var",
"scales",
"=",
"[",
"sizeCurr",
"[",
"0",
"]",
"/",
"sizeOrigin",
"[",
"0",
"]",
",",
"sizeCurr",
"[",
"1",
"]",
"/",
"sizeOrigin",
"[",
"1",
"]",
"]",
";",
"isNaN",
"(",
"scales",
"[",
"0",
"]",
")",
"&&",
"(",
"scales",
"[",
"0",
"]",
"=",
"1",
")",
";",
"isNaN",
"(",
"scales",
"[",
"1",
"]",
")",
"&&",
"(",
"scales",
"[",
"1",
"]",
"=",
"1",
")",
";",
"return",
"scales",
";",
"}"
] | We have to process scale caused by dataZoom manually, although it might be not accurate. | [
"We",
"have",
"to",
"process",
"scale",
"caused",
"by",
"dataZoom",
"manually",
"although",
"it",
"might",
"be",
"not",
"accurate",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/helper/BrushTargetManager.js#L445-L452 |
274 | apache/incubator-echarts | src/data/helper/dataProvider.js | converDataValue | function converDataValue(value, dimInfo) {
// Performance sensitive.
var dimType = dimInfo && dimInfo.type;
if (dimType === 'ordinal') {
// If given value is a category string
var ordinalMeta = dimInfo && dimInfo.ordinalMeta;
return ordinalMeta
? ordinalMeta.parseAndCollect(value)
: value;
}
if (dimType === 'time'
// spead up when using timestamp
&& typeof value !== 'number'
&& value != null
&& value !== '-'
) {
value = +parseDate(value);
}
// dimType defaults 'number'.
// If dimType is not ordinal and value is null or undefined or NaN or '-',
// parse to NaN.
return (value == null || value === '')
? NaN
// If string (like '-'), using '+' parse to NaN
// If object, also parse to NaN
: +value;
} | javascript | function converDataValue(value, dimInfo) {
// Performance sensitive.
var dimType = dimInfo && dimInfo.type;
if (dimType === 'ordinal') {
// If given value is a category string
var ordinalMeta = dimInfo && dimInfo.ordinalMeta;
return ordinalMeta
? ordinalMeta.parseAndCollect(value)
: value;
}
if (dimType === 'time'
// spead up when using timestamp
&& typeof value !== 'number'
&& value != null
&& value !== '-'
) {
value = +parseDate(value);
}
// dimType defaults 'number'.
// If dimType is not ordinal and value is null or undefined or NaN or '-',
// parse to NaN.
return (value == null || value === '')
? NaN
// If string (like '-'), using '+' parse to NaN
// If object, also parse to NaN
: +value;
} | [
"function",
"converDataValue",
"(",
"value",
",",
"dimInfo",
")",
"{",
"// Performance sensitive.",
"var",
"dimType",
"=",
"dimInfo",
"&&",
"dimInfo",
".",
"type",
";",
"if",
"(",
"dimType",
"===",
"'ordinal'",
")",
"{",
"// If given value is a category string",
"var",
"ordinalMeta",
"=",
"dimInfo",
"&&",
"dimInfo",
".",
"ordinalMeta",
";",
"return",
"ordinalMeta",
"?",
"ordinalMeta",
".",
"parseAndCollect",
"(",
"value",
")",
":",
"value",
";",
"}",
"if",
"(",
"dimType",
"===",
"'time'",
"// spead up when using timestamp",
"&&",
"typeof",
"value",
"!==",
"'number'",
"&&",
"value",
"!=",
"null",
"&&",
"value",
"!==",
"'-'",
")",
"{",
"value",
"=",
"+",
"parseDate",
"(",
"value",
")",
";",
"}",
"// dimType defaults 'number'.",
"// If dimType is not ordinal and value is null or undefined or NaN or '-',",
"// parse to NaN.",
"return",
"(",
"value",
"==",
"null",
"||",
"value",
"===",
"''",
")",
"?",
"NaN",
"// If string (like '-'), using '+' parse to NaN",
"// If object, also parse to NaN",
":",
"+",
"value",
";",
"}"
] | This helper method convert value in data.
@param {string|number|Date} value
@param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'.
If "dimInfo.ordinalParseAndSave", ordinal value can be parsed. | [
"This",
"helper",
"method",
"convert",
"value",
"in",
"data",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/helper/dataProvider.js#L282-L310 |
275 | apache/incubator-echarts | src/model/Global.js | function (condition) {
var mainType = condition.mainType;
if (!mainType) {
return [];
}
var index = condition.index;
var id = condition.id;
var name = condition.name;
var cpts = this._componentsMap.get(mainType);
if (!cpts || !cpts.length) {
return [];
}
var result;
if (index != null) {
if (!isArray(index)) {
index = [index];
}
result = filter(map(index, function (idx) {
return cpts[idx];
}), function (val) {
return !!val;
});
}
else if (id != null) {
var isIdArray = isArray(id);
result = filter(cpts, function (cpt) {
return (isIdArray && indexOf(id, cpt.id) >= 0)
|| (!isIdArray && cpt.id === id);
});
}
else if (name != null) {
var isNameArray = isArray(name);
result = filter(cpts, function (cpt) {
return (isNameArray && indexOf(name, cpt.name) >= 0)
|| (!isNameArray && cpt.name === name);
});
}
else {
// Return all components with mainType
result = cpts.slice();
}
return filterBySubType(result, condition);
} | javascript | function (condition) {
var mainType = condition.mainType;
if (!mainType) {
return [];
}
var index = condition.index;
var id = condition.id;
var name = condition.name;
var cpts = this._componentsMap.get(mainType);
if (!cpts || !cpts.length) {
return [];
}
var result;
if (index != null) {
if (!isArray(index)) {
index = [index];
}
result = filter(map(index, function (idx) {
return cpts[idx];
}), function (val) {
return !!val;
});
}
else if (id != null) {
var isIdArray = isArray(id);
result = filter(cpts, function (cpt) {
return (isIdArray && indexOf(id, cpt.id) >= 0)
|| (!isIdArray && cpt.id === id);
});
}
else if (name != null) {
var isNameArray = isArray(name);
result = filter(cpts, function (cpt) {
return (isNameArray && indexOf(name, cpt.name) >= 0)
|| (!isNameArray && cpt.name === name);
});
}
else {
// Return all components with mainType
result = cpts.slice();
}
return filterBySubType(result, condition);
} | [
"function",
"(",
"condition",
")",
"{",
"var",
"mainType",
"=",
"condition",
".",
"mainType",
";",
"if",
"(",
"!",
"mainType",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"index",
"=",
"condition",
".",
"index",
";",
"var",
"id",
"=",
"condition",
".",
"id",
";",
"var",
"name",
"=",
"condition",
".",
"name",
";",
"var",
"cpts",
"=",
"this",
".",
"_componentsMap",
".",
"get",
"(",
"mainType",
")",
";",
"if",
"(",
"!",
"cpts",
"||",
"!",
"cpts",
".",
"length",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"result",
";",
"if",
"(",
"index",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"isArray",
"(",
"index",
")",
")",
"{",
"index",
"=",
"[",
"index",
"]",
";",
"}",
"result",
"=",
"filter",
"(",
"map",
"(",
"index",
",",
"function",
"(",
"idx",
")",
"{",
"return",
"cpts",
"[",
"idx",
"]",
";",
"}",
")",
",",
"function",
"(",
"val",
")",
"{",
"return",
"!",
"!",
"val",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"id",
"!=",
"null",
")",
"{",
"var",
"isIdArray",
"=",
"isArray",
"(",
"id",
")",
";",
"result",
"=",
"filter",
"(",
"cpts",
",",
"function",
"(",
"cpt",
")",
"{",
"return",
"(",
"isIdArray",
"&&",
"indexOf",
"(",
"id",
",",
"cpt",
".",
"id",
")",
">=",
"0",
")",
"||",
"(",
"!",
"isIdArray",
"&&",
"cpt",
".",
"id",
"===",
"id",
")",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"var",
"isNameArray",
"=",
"isArray",
"(",
"name",
")",
";",
"result",
"=",
"filter",
"(",
"cpts",
",",
"function",
"(",
"cpt",
")",
"{",
"return",
"(",
"isNameArray",
"&&",
"indexOf",
"(",
"name",
",",
"cpt",
".",
"name",
")",
">=",
"0",
")",
"||",
"(",
"!",
"isNameArray",
"&&",
"cpt",
".",
"name",
"===",
"name",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"// Return all components with mainType",
"result",
"=",
"cpts",
".",
"slice",
"(",
")",
";",
"}",
"return",
"filterBySubType",
"(",
"result",
",",
"condition",
")",
";",
"}"
] | If none of index and id and name used, return all components with mainType.
@param {Object} condition
@param {string} condition.mainType
@param {string} [condition.subType] If ignore, only query by mainType
@param {number|Array.<number>} [condition.index] Either input index or id or name.
@param {string|Array.<string>} [condition.id] Either input index or id or name.
@param {string|Array.<string>} [condition.name] Either input index or id or name.
@return {Array.<module:echarts/model/Component>} | [
"If",
"none",
"of",
"index",
"and",
"id",
"and",
"name",
"used",
"return",
"all",
"components",
"with",
"mainType",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/model/Global.js#L314-L362 |
|
276 | apache/incubator-echarts | src/model/Global.js | function (condition) {
var query = condition.query;
var mainType = condition.mainType;
var queryCond = getQueryCond(query);
var result = queryCond
? this.queryComponents(queryCond)
: this._componentsMap.get(mainType);
return doFilter(filterBySubType(result, condition));
function getQueryCond(q) {
var indexAttr = mainType + 'Index';
var idAttr = mainType + 'Id';
var nameAttr = mainType + 'Name';
return q && (
q[indexAttr] != null
|| q[idAttr] != null
|| q[nameAttr] != null
)
? {
mainType: mainType,
// subType will be filtered finally.
index: q[indexAttr],
id: q[idAttr],
name: q[nameAttr]
}
: null;
}
function doFilter(res) {
return condition.filter
? filter(res, condition.filter)
: res;
}
} | javascript | function (condition) {
var query = condition.query;
var mainType = condition.mainType;
var queryCond = getQueryCond(query);
var result = queryCond
? this.queryComponents(queryCond)
: this._componentsMap.get(mainType);
return doFilter(filterBySubType(result, condition));
function getQueryCond(q) {
var indexAttr = mainType + 'Index';
var idAttr = mainType + 'Id';
var nameAttr = mainType + 'Name';
return q && (
q[indexAttr] != null
|| q[idAttr] != null
|| q[nameAttr] != null
)
? {
mainType: mainType,
// subType will be filtered finally.
index: q[indexAttr],
id: q[idAttr],
name: q[nameAttr]
}
: null;
}
function doFilter(res) {
return condition.filter
? filter(res, condition.filter)
: res;
}
} | [
"function",
"(",
"condition",
")",
"{",
"var",
"query",
"=",
"condition",
".",
"query",
";",
"var",
"mainType",
"=",
"condition",
".",
"mainType",
";",
"var",
"queryCond",
"=",
"getQueryCond",
"(",
"query",
")",
";",
"var",
"result",
"=",
"queryCond",
"?",
"this",
".",
"queryComponents",
"(",
"queryCond",
")",
":",
"this",
".",
"_componentsMap",
".",
"get",
"(",
"mainType",
")",
";",
"return",
"doFilter",
"(",
"filterBySubType",
"(",
"result",
",",
"condition",
")",
")",
";",
"function",
"getQueryCond",
"(",
"q",
")",
"{",
"var",
"indexAttr",
"=",
"mainType",
"+",
"'Index'",
";",
"var",
"idAttr",
"=",
"mainType",
"+",
"'Id'",
";",
"var",
"nameAttr",
"=",
"mainType",
"+",
"'Name'",
";",
"return",
"q",
"&&",
"(",
"q",
"[",
"indexAttr",
"]",
"!=",
"null",
"||",
"q",
"[",
"idAttr",
"]",
"!=",
"null",
"||",
"q",
"[",
"nameAttr",
"]",
"!=",
"null",
")",
"?",
"{",
"mainType",
":",
"mainType",
",",
"// subType will be filtered finally.",
"index",
":",
"q",
"[",
"indexAttr",
"]",
",",
"id",
":",
"q",
"[",
"idAttr",
"]",
",",
"name",
":",
"q",
"[",
"nameAttr",
"]",
"}",
":",
"null",
";",
"}",
"function",
"doFilter",
"(",
"res",
")",
"{",
"return",
"condition",
".",
"filter",
"?",
"filter",
"(",
"res",
",",
"condition",
".",
"filter",
")",
":",
"res",
";",
"}",
"}"
] | The interface is different from queryComponents,
which is convenient for inner usage.
@usage
var result = findComponents(
{mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
);
var result = findComponents(
{mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
);
var result = findComponents(
{mainType: 'series'},
function (model, index) {...}
);
// result like [component0, componnet1, ...]
@param {Object} condition
@param {string} condition.mainType Mandatory.
@param {string} [condition.subType] Optional.
@param {Object} [condition.query] like {xxxIndex, xxxId, xxxName},
where xxx is mainType.
If query attribute is null/undefined or has no index/id/name,
do not filtering by query conditions, which is convenient for
no-payload situations or when target of action is global.
@param {Function} [condition.filter] parameter: component, return boolean.
@return {Array.<module:echarts/model/Component>} | [
"The",
"interface",
"is",
"different",
"from",
"queryComponents",
"which",
"is",
"convenient",
"for",
"inner",
"usage",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/model/Global.js#L392-L427 |
|
277 | apache/incubator-echarts | src/model/Global.js | function (cb, context) {
assertSeriesInitialized(this);
each(this._seriesIndices, function (rawSeriesIndex) {
var series = this._componentsMap.get('series')[rawSeriesIndex];
cb.call(context, series, rawSeriesIndex);
}, this);
} | javascript | function (cb, context) {
assertSeriesInitialized(this);
each(this._seriesIndices, function (rawSeriesIndex) {
var series = this._componentsMap.get('series')[rawSeriesIndex];
cb.call(context, series, rawSeriesIndex);
}, this);
} | [
"function",
"(",
"cb",
",",
"context",
")",
"{",
"assertSeriesInitialized",
"(",
"this",
")",
";",
"each",
"(",
"this",
".",
"_seriesIndices",
",",
"function",
"(",
"rawSeriesIndex",
")",
"{",
"var",
"series",
"=",
"this",
".",
"_componentsMap",
".",
"get",
"(",
"'series'",
")",
"[",
"rawSeriesIndex",
"]",
";",
"cb",
".",
"call",
"(",
"context",
",",
"series",
",",
"rawSeriesIndex",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] | After filtering, series may be different
frome raw series.
@param {Function} cb
@param {*} context | [
"After",
"filtering",
"series",
"may",
"be",
"different",
"frome",
"raw",
"series",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/model/Global.js#L527-L533 |
|
278 | apache/incubator-echarts | src/chart/treemap/Breadcrumb.js | function (targetNode, layoutParam, textStyleModel) {
for (var node = targetNode; node; node = node.parentNode) {
var text = node.getModel().get('name');
var textRect = textStyleModel.getTextRect(text);
var itemWidth = Math.max(
textRect.width + TEXT_PADDING * 2,
layoutParam.emptyItemWidth
);
layoutParam.totalWidth += itemWidth + ITEM_GAP;
layoutParam.renderList.push({node: node, text: text, width: itemWidth});
}
} | javascript | function (targetNode, layoutParam, textStyleModel) {
for (var node = targetNode; node; node = node.parentNode) {
var text = node.getModel().get('name');
var textRect = textStyleModel.getTextRect(text);
var itemWidth = Math.max(
textRect.width + TEXT_PADDING * 2,
layoutParam.emptyItemWidth
);
layoutParam.totalWidth += itemWidth + ITEM_GAP;
layoutParam.renderList.push({node: node, text: text, width: itemWidth});
}
} | [
"function",
"(",
"targetNode",
",",
"layoutParam",
",",
"textStyleModel",
")",
"{",
"for",
"(",
"var",
"node",
"=",
"targetNode",
";",
"node",
";",
"node",
"=",
"node",
".",
"parentNode",
")",
"{",
"var",
"text",
"=",
"node",
".",
"getModel",
"(",
")",
".",
"get",
"(",
"'name'",
")",
";",
"var",
"textRect",
"=",
"textStyleModel",
".",
"getTextRect",
"(",
"text",
")",
";",
"var",
"itemWidth",
"=",
"Math",
".",
"max",
"(",
"textRect",
".",
"width",
"+",
"TEXT_PADDING",
"*",
"2",
",",
"layoutParam",
".",
"emptyItemWidth",
")",
";",
"layoutParam",
".",
"totalWidth",
"+=",
"itemWidth",
"+",
"ITEM_GAP",
";",
"layoutParam",
".",
"renderList",
".",
"push",
"(",
"{",
"node",
":",
"node",
",",
"text",
":",
"text",
",",
"width",
":",
"itemWidth",
"}",
")",
";",
"}",
"}"
] | Prepare render list and total width
@private | [
"Prepare",
"render",
"list",
"and",
"total",
"width"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/Breadcrumb.js#L83-L94 |
|
279 | apache/incubator-echarts | src/chart/treemap/Breadcrumb.js | packEventData | function packEventData(el, seriesModel, itemNode) {
el.eventData = {
componentType: 'series',
componentSubType: 'treemap',
componentIndex: seriesModel.componentIndex,
seriesIndex: seriesModel.componentIndex,
seriesName: seriesModel.name,
seriesType: 'treemap',
selfType: 'breadcrumb', // Distinguish with click event on treemap node.
nodeData: {
dataIndex: itemNode && itemNode.dataIndex,
name: itemNode && itemNode.name
},
treePathInfo: itemNode && wrapTreePathInfo(itemNode, seriesModel)
};
} | javascript | function packEventData(el, seriesModel, itemNode) {
el.eventData = {
componentType: 'series',
componentSubType: 'treemap',
componentIndex: seriesModel.componentIndex,
seriesIndex: seriesModel.componentIndex,
seriesName: seriesModel.name,
seriesType: 'treemap',
selfType: 'breadcrumb', // Distinguish with click event on treemap node.
nodeData: {
dataIndex: itemNode && itemNode.dataIndex,
name: itemNode && itemNode.name
},
treePathInfo: itemNode && wrapTreePathInfo(itemNode, seriesModel)
};
} | [
"function",
"packEventData",
"(",
"el",
",",
"seriesModel",
",",
"itemNode",
")",
"{",
"el",
".",
"eventData",
"=",
"{",
"componentType",
":",
"'series'",
",",
"componentSubType",
":",
"'treemap'",
",",
"componentIndex",
":",
"seriesModel",
".",
"componentIndex",
",",
"seriesIndex",
":",
"seriesModel",
".",
"componentIndex",
",",
"seriesName",
":",
"seriesModel",
".",
"name",
",",
"seriesType",
":",
"'treemap'",
",",
"selfType",
":",
"'breadcrumb'",
",",
"// Distinguish with click event on treemap node.",
"nodeData",
":",
"{",
"dataIndex",
":",
"itemNode",
"&&",
"itemNode",
".",
"dataIndex",
",",
"name",
":",
"itemNode",
"&&",
"itemNode",
".",
"name",
"}",
",",
"treePathInfo",
":",
"itemNode",
"&&",
"wrapTreePathInfo",
"(",
"itemNode",
",",
"seriesModel",
")",
"}",
";",
"}"
] | Package custom mouse event. | [
"Package",
"custom",
"mouse",
"event",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/Breadcrumb.js#L171-L186 |
280 | apache/incubator-echarts | src/component/dataZoom/AxisProxy.js | function (opt) {
var dataExtent = this._dataExtent;
var axisModel = this.getAxisModel();
var scale = axisModel.axis.scale;
var rangePropMode = this._dataZoomModel.getRangePropMode();
var percentExtent = [0, 100];
var percentWindow = [];
var valueWindow = [];
var hasPropModeValue;
each(['start', 'end'], function (prop, idx) {
var boundPercent = opt[prop];
var boundValue = opt[prop + 'Value'];
// Notice: dataZoom is based either on `percentProp` ('start', 'end') or
// on `valueProp` ('startValue', 'endValue'). (They are based on the data extent
// but not min/max of axis, which will be calculated by data window then).
// The former one is suitable for cases that a dataZoom component controls multiple
// axes with different unit or extent, and the latter one is suitable for accurate
// zoom by pixel (e.g., in dataZoomSelect).
// we use `getRangePropMode()` to mark which prop is used. `rangePropMode` is updated
// only when setOption or dispatchAction, otherwise it remains its original value.
// (Why not only record `percentProp` and always map to `valueProp`? Because
// the map `valueProp` -> `percentProp` -> `valueProp` probably not the original
// `valueProp`. consider two axes constrolled by one dataZoom. They have different
// data extent. All of values that are overflow the `dataExtent` will be calculated
// to percent '100%').
if (rangePropMode[idx] === 'percent') {
boundPercent == null && (boundPercent = percentExtent[idx]);
// Use scale.parse to math round for category or time axis.
boundValue = scale.parse(numberUtil.linearMap(
boundPercent, percentExtent, dataExtent
));
}
else {
hasPropModeValue = true;
boundValue = boundValue == null ? dataExtent[idx] : scale.parse(boundValue);
// Calculating `percent` from `value` may be not accurate, because
// This calculation can not be inversed, because all of values that
// are overflow the `dataExtent` will be calculated to percent '100%'
boundPercent = numberUtil.linearMap(
boundValue, dataExtent, percentExtent
);
}
// valueWindow[idx] = round(boundValue);
// percentWindow[idx] = round(boundPercent);
valueWindow[idx] = boundValue;
percentWindow[idx] = boundPercent;
});
asc(valueWindow);
asc(percentWindow);
// The windows from user calling of `dispatchAction` might be out of the extent,
// or do not obey the `min/maxSpan`, `min/maxValueSpan`. But we dont restrict window
// by `zoomLock` here, because we see `zoomLock` just as a interaction constraint,
// where API is able to initialize/modify the window size even though `zoomLock`
// specified.
var spans = this._minMaxSpan;
hasPropModeValue
? restrictSet(valueWindow, percentWindow, dataExtent, percentExtent, false)
: restrictSet(percentWindow, valueWindow, percentExtent, dataExtent, true);
function restrictSet(fromWindow, toWindow, fromExtent, toExtent, toValue) {
var suffix = toValue ? 'Span' : 'ValueSpan';
sliderMove(0, fromWindow, fromExtent, 'all', spans['min' + suffix], spans['max' + suffix]);
for (var i = 0; i < 2; i++) {
toWindow[i] = numberUtil.linearMap(fromWindow[i], fromExtent, toExtent, true);
toValue && (toWindow[i] = scale.parse(toWindow[i]));
}
}
return {
valueWindow: valueWindow,
percentWindow: percentWindow
};
} | javascript | function (opt) {
var dataExtent = this._dataExtent;
var axisModel = this.getAxisModel();
var scale = axisModel.axis.scale;
var rangePropMode = this._dataZoomModel.getRangePropMode();
var percentExtent = [0, 100];
var percentWindow = [];
var valueWindow = [];
var hasPropModeValue;
each(['start', 'end'], function (prop, idx) {
var boundPercent = opt[prop];
var boundValue = opt[prop + 'Value'];
// Notice: dataZoom is based either on `percentProp` ('start', 'end') or
// on `valueProp` ('startValue', 'endValue'). (They are based on the data extent
// but not min/max of axis, which will be calculated by data window then).
// The former one is suitable for cases that a dataZoom component controls multiple
// axes with different unit or extent, and the latter one is suitable for accurate
// zoom by pixel (e.g., in dataZoomSelect).
// we use `getRangePropMode()` to mark which prop is used. `rangePropMode` is updated
// only when setOption or dispatchAction, otherwise it remains its original value.
// (Why not only record `percentProp` and always map to `valueProp`? Because
// the map `valueProp` -> `percentProp` -> `valueProp` probably not the original
// `valueProp`. consider two axes constrolled by one dataZoom. They have different
// data extent. All of values that are overflow the `dataExtent` will be calculated
// to percent '100%').
if (rangePropMode[idx] === 'percent') {
boundPercent == null && (boundPercent = percentExtent[idx]);
// Use scale.parse to math round for category or time axis.
boundValue = scale.parse(numberUtil.linearMap(
boundPercent, percentExtent, dataExtent
));
}
else {
hasPropModeValue = true;
boundValue = boundValue == null ? dataExtent[idx] : scale.parse(boundValue);
// Calculating `percent` from `value` may be not accurate, because
// This calculation can not be inversed, because all of values that
// are overflow the `dataExtent` will be calculated to percent '100%'
boundPercent = numberUtil.linearMap(
boundValue, dataExtent, percentExtent
);
}
// valueWindow[idx] = round(boundValue);
// percentWindow[idx] = round(boundPercent);
valueWindow[idx] = boundValue;
percentWindow[idx] = boundPercent;
});
asc(valueWindow);
asc(percentWindow);
// The windows from user calling of `dispatchAction` might be out of the extent,
// or do not obey the `min/maxSpan`, `min/maxValueSpan`. But we dont restrict window
// by `zoomLock` here, because we see `zoomLock` just as a interaction constraint,
// where API is able to initialize/modify the window size even though `zoomLock`
// specified.
var spans = this._minMaxSpan;
hasPropModeValue
? restrictSet(valueWindow, percentWindow, dataExtent, percentExtent, false)
: restrictSet(percentWindow, valueWindow, percentExtent, dataExtent, true);
function restrictSet(fromWindow, toWindow, fromExtent, toExtent, toValue) {
var suffix = toValue ? 'Span' : 'ValueSpan';
sliderMove(0, fromWindow, fromExtent, 'all', spans['min' + suffix], spans['max' + suffix]);
for (var i = 0; i < 2; i++) {
toWindow[i] = numberUtil.linearMap(fromWindow[i], fromExtent, toExtent, true);
toValue && (toWindow[i] = scale.parse(toWindow[i]));
}
}
return {
valueWindow: valueWindow,
percentWindow: percentWindow
};
} | [
"function",
"(",
"opt",
")",
"{",
"var",
"dataExtent",
"=",
"this",
".",
"_dataExtent",
";",
"var",
"axisModel",
"=",
"this",
".",
"getAxisModel",
"(",
")",
";",
"var",
"scale",
"=",
"axisModel",
".",
"axis",
".",
"scale",
";",
"var",
"rangePropMode",
"=",
"this",
".",
"_dataZoomModel",
".",
"getRangePropMode",
"(",
")",
";",
"var",
"percentExtent",
"=",
"[",
"0",
",",
"100",
"]",
";",
"var",
"percentWindow",
"=",
"[",
"]",
";",
"var",
"valueWindow",
"=",
"[",
"]",
";",
"var",
"hasPropModeValue",
";",
"each",
"(",
"[",
"'start'",
",",
"'end'",
"]",
",",
"function",
"(",
"prop",
",",
"idx",
")",
"{",
"var",
"boundPercent",
"=",
"opt",
"[",
"prop",
"]",
";",
"var",
"boundValue",
"=",
"opt",
"[",
"prop",
"+",
"'Value'",
"]",
";",
"// Notice: dataZoom is based either on `percentProp` ('start', 'end') or",
"// on `valueProp` ('startValue', 'endValue'). (They are based on the data extent",
"// but not min/max of axis, which will be calculated by data window then).",
"// The former one is suitable for cases that a dataZoom component controls multiple",
"// axes with different unit or extent, and the latter one is suitable for accurate",
"// zoom by pixel (e.g., in dataZoomSelect).",
"// we use `getRangePropMode()` to mark which prop is used. `rangePropMode` is updated",
"// only when setOption or dispatchAction, otherwise it remains its original value.",
"// (Why not only record `percentProp` and always map to `valueProp`? Because",
"// the map `valueProp` -> `percentProp` -> `valueProp` probably not the original",
"// `valueProp`. consider two axes constrolled by one dataZoom. They have different",
"// data extent. All of values that are overflow the `dataExtent` will be calculated",
"// to percent '100%').",
"if",
"(",
"rangePropMode",
"[",
"idx",
"]",
"===",
"'percent'",
")",
"{",
"boundPercent",
"==",
"null",
"&&",
"(",
"boundPercent",
"=",
"percentExtent",
"[",
"idx",
"]",
")",
";",
"// Use scale.parse to math round for category or time axis.",
"boundValue",
"=",
"scale",
".",
"parse",
"(",
"numberUtil",
".",
"linearMap",
"(",
"boundPercent",
",",
"percentExtent",
",",
"dataExtent",
")",
")",
";",
"}",
"else",
"{",
"hasPropModeValue",
"=",
"true",
";",
"boundValue",
"=",
"boundValue",
"==",
"null",
"?",
"dataExtent",
"[",
"idx",
"]",
":",
"scale",
".",
"parse",
"(",
"boundValue",
")",
";",
"// Calculating `percent` from `value` may be not accurate, because",
"// This calculation can not be inversed, because all of values that",
"// are overflow the `dataExtent` will be calculated to percent '100%'",
"boundPercent",
"=",
"numberUtil",
".",
"linearMap",
"(",
"boundValue",
",",
"dataExtent",
",",
"percentExtent",
")",
";",
"}",
"// valueWindow[idx] = round(boundValue);",
"// percentWindow[idx] = round(boundPercent);",
"valueWindow",
"[",
"idx",
"]",
"=",
"boundValue",
";",
"percentWindow",
"[",
"idx",
"]",
"=",
"boundPercent",
";",
"}",
")",
";",
"asc",
"(",
"valueWindow",
")",
";",
"asc",
"(",
"percentWindow",
")",
";",
"// The windows from user calling of `dispatchAction` might be out of the extent,",
"// or do not obey the `min/maxSpan`, `min/maxValueSpan`. But we dont restrict window",
"// by `zoomLock` here, because we see `zoomLock` just as a interaction constraint,",
"// where API is able to initialize/modify the window size even though `zoomLock`",
"// specified.",
"var",
"spans",
"=",
"this",
".",
"_minMaxSpan",
";",
"hasPropModeValue",
"?",
"restrictSet",
"(",
"valueWindow",
",",
"percentWindow",
",",
"dataExtent",
",",
"percentExtent",
",",
"false",
")",
":",
"restrictSet",
"(",
"percentWindow",
",",
"valueWindow",
",",
"percentExtent",
",",
"dataExtent",
",",
"true",
")",
";",
"function",
"restrictSet",
"(",
"fromWindow",
",",
"toWindow",
",",
"fromExtent",
",",
"toExtent",
",",
"toValue",
")",
"{",
"var",
"suffix",
"=",
"toValue",
"?",
"'Span'",
":",
"'ValueSpan'",
";",
"sliderMove",
"(",
"0",
",",
"fromWindow",
",",
"fromExtent",
",",
"'all'",
",",
"spans",
"[",
"'min'",
"+",
"suffix",
"]",
",",
"spans",
"[",
"'max'",
"+",
"suffix",
"]",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"2",
";",
"i",
"++",
")",
"{",
"toWindow",
"[",
"i",
"]",
"=",
"numberUtil",
".",
"linearMap",
"(",
"fromWindow",
"[",
"i",
"]",
",",
"fromExtent",
",",
"toExtent",
",",
"true",
")",
";",
"toValue",
"&&",
"(",
"toWindow",
"[",
"i",
"]",
"=",
"scale",
".",
"parse",
"(",
"toWindow",
"[",
"i",
"]",
")",
")",
";",
"}",
"}",
"return",
"{",
"valueWindow",
":",
"valueWindow",
",",
"percentWindow",
":",
"percentWindow",
"}",
";",
"}"
] | Only calculate by given range and this._dataExtent, do not change anything.
@param {Object} opt
@param {number} [opt.start]
@param {number} [opt.end]
@param {number} [opt.startValue]
@param {number} [opt.endValue] | [
"Only",
"calculate",
"by",
"given",
"range",
"and",
"this",
".",
"_dataExtent",
"do",
"not",
"change",
"anything",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/dataZoom/AxisProxy.js#L192-L270 |
|
281 | apache/incubator-echarts | src/echarts.js | prepareView | function prepareView(ecIns, type, ecModel, scheduler) {
var isComponent = type === 'component';
var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews;
var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap;
var zr = ecIns._zr;
var api = ecIns._api;
for (var i = 0; i < viewList.length; i++) {
viewList[i].__alive = false;
}
isComponent
? ecModel.eachComponent(function (componentType, model) {
componentType !== 'series' && doPrepare(model);
})
: ecModel.eachSeries(doPrepare);
function doPrepare(model) {
// Consider: id same and type changed.
var viewId = '_ec_' + model.id + '_' + model.type;
var view = viewMap[viewId];
if (!view) {
var classType = parseClassType(model.type);
var Clazz = isComponent
? ComponentView.getClass(classType.main, classType.sub)
: ChartView.getClass(classType.sub);
if (__DEV__) {
assert(Clazz, classType.sub + ' does not exist.');
}
view = new Clazz();
view.init(ecModel, api);
viewMap[viewId] = view;
viewList.push(view);
zr.add(view.group);
}
model.__viewId = view.__id = viewId;
view.__alive = true;
view.__model = model;
view.group.__ecComponentInfo = {
mainType: model.mainType,
index: model.componentIndex
};
!isComponent && scheduler.prepareView(view, model, ecModel, api);
}
for (var i = 0; i < viewList.length;) {
var view = viewList[i];
if (!view.__alive) {
!isComponent && view.renderTask.dispose();
zr.remove(view.group);
view.dispose(ecModel, api);
viewList.splice(i, 1);
delete viewMap[view.__id];
view.__id = view.group.__ecComponentInfo = null;
}
else {
i++;
}
}
} | javascript | function prepareView(ecIns, type, ecModel, scheduler) {
var isComponent = type === 'component';
var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews;
var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap;
var zr = ecIns._zr;
var api = ecIns._api;
for (var i = 0; i < viewList.length; i++) {
viewList[i].__alive = false;
}
isComponent
? ecModel.eachComponent(function (componentType, model) {
componentType !== 'series' && doPrepare(model);
})
: ecModel.eachSeries(doPrepare);
function doPrepare(model) {
// Consider: id same and type changed.
var viewId = '_ec_' + model.id + '_' + model.type;
var view = viewMap[viewId];
if (!view) {
var classType = parseClassType(model.type);
var Clazz = isComponent
? ComponentView.getClass(classType.main, classType.sub)
: ChartView.getClass(classType.sub);
if (__DEV__) {
assert(Clazz, classType.sub + ' does not exist.');
}
view = new Clazz();
view.init(ecModel, api);
viewMap[viewId] = view;
viewList.push(view);
zr.add(view.group);
}
model.__viewId = view.__id = viewId;
view.__alive = true;
view.__model = model;
view.group.__ecComponentInfo = {
mainType: model.mainType,
index: model.componentIndex
};
!isComponent && scheduler.prepareView(view, model, ecModel, api);
}
for (var i = 0; i < viewList.length;) {
var view = viewList[i];
if (!view.__alive) {
!isComponent && view.renderTask.dispose();
zr.remove(view.group);
view.dispose(ecModel, api);
viewList.splice(i, 1);
delete viewMap[view.__id];
view.__id = view.group.__ecComponentInfo = null;
}
else {
i++;
}
}
} | [
"function",
"prepareView",
"(",
"ecIns",
",",
"type",
",",
"ecModel",
",",
"scheduler",
")",
"{",
"var",
"isComponent",
"=",
"type",
"===",
"'component'",
";",
"var",
"viewList",
"=",
"isComponent",
"?",
"ecIns",
".",
"_componentsViews",
":",
"ecIns",
".",
"_chartsViews",
";",
"var",
"viewMap",
"=",
"isComponent",
"?",
"ecIns",
".",
"_componentsMap",
":",
"ecIns",
".",
"_chartsMap",
";",
"var",
"zr",
"=",
"ecIns",
".",
"_zr",
";",
"var",
"api",
"=",
"ecIns",
".",
"_api",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"viewList",
".",
"length",
";",
"i",
"++",
")",
"{",
"viewList",
"[",
"i",
"]",
".",
"__alive",
"=",
"false",
";",
"}",
"isComponent",
"?",
"ecModel",
".",
"eachComponent",
"(",
"function",
"(",
"componentType",
",",
"model",
")",
"{",
"componentType",
"!==",
"'series'",
"&&",
"doPrepare",
"(",
"model",
")",
";",
"}",
")",
":",
"ecModel",
".",
"eachSeries",
"(",
"doPrepare",
")",
";",
"function",
"doPrepare",
"(",
"model",
")",
"{",
"// Consider: id same and type changed.",
"var",
"viewId",
"=",
"'_ec_'",
"+",
"model",
".",
"id",
"+",
"'_'",
"+",
"model",
".",
"type",
";",
"var",
"view",
"=",
"viewMap",
"[",
"viewId",
"]",
";",
"if",
"(",
"!",
"view",
")",
"{",
"var",
"classType",
"=",
"parseClassType",
"(",
"model",
".",
"type",
")",
";",
"var",
"Clazz",
"=",
"isComponent",
"?",
"ComponentView",
".",
"getClass",
"(",
"classType",
".",
"main",
",",
"classType",
".",
"sub",
")",
":",
"ChartView",
".",
"getClass",
"(",
"classType",
".",
"sub",
")",
";",
"if",
"(",
"__DEV__",
")",
"{",
"assert",
"(",
"Clazz",
",",
"classType",
".",
"sub",
"+",
"' does not exist.'",
")",
";",
"}",
"view",
"=",
"new",
"Clazz",
"(",
")",
";",
"view",
".",
"init",
"(",
"ecModel",
",",
"api",
")",
";",
"viewMap",
"[",
"viewId",
"]",
"=",
"view",
";",
"viewList",
".",
"push",
"(",
"view",
")",
";",
"zr",
".",
"add",
"(",
"view",
".",
"group",
")",
";",
"}",
"model",
".",
"__viewId",
"=",
"view",
".",
"__id",
"=",
"viewId",
";",
"view",
".",
"__alive",
"=",
"true",
";",
"view",
".",
"__model",
"=",
"model",
";",
"view",
".",
"group",
".",
"__ecComponentInfo",
"=",
"{",
"mainType",
":",
"model",
".",
"mainType",
",",
"index",
":",
"model",
".",
"componentIndex",
"}",
";",
"!",
"isComponent",
"&&",
"scheduler",
".",
"prepareView",
"(",
"view",
",",
"model",
",",
"ecModel",
",",
"api",
")",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"viewList",
".",
"length",
";",
")",
"{",
"var",
"view",
"=",
"viewList",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"view",
".",
"__alive",
")",
"{",
"!",
"isComponent",
"&&",
"view",
".",
"renderTask",
".",
"dispose",
"(",
")",
";",
"zr",
".",
"remove",
"(",
"view",
".",
"group",
")",
";",
"view",
".",
"dispose",
"(",
"ecModel",
",",
"api",
")",
";",
"viewList",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"delete",
"viewMap",
"[",
"view",
".",
"__id",
"]",
";",
"view",
".",
"__id",
"=",
"view",
".",
"group",
".",
"__ecComponentInfo",
"=",
"null",
";",
"}",
"else",
"{",
"i",
"++",
";",
"}",
"}",
"}"
] | Prepare view instances of charts and components
@param {module:echarts/model/Global} ecModel
@private | [
"Prepare",
"view",
"instances",
"of",
"charts",
"and",
"components"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/echarts.js#L1352-L1414 |
282 | apache/incubator-echarts | src/echarts.js | renderSeries | function renderSeries(ecIns, ecModel, api, payload, dirtyMap) {
// Render all charts
var scheduler = ecIns._scheduler;
var unfinished;
ecModel.eachSeries(function (seriesModel) {
var chartView = ecIns._chartsMap[seriesModel.__viewId];
chartView.__alive = true;
var renderTask = chartView.renderTask;
scheduler.updatePayload(renderTask, payload);
if (dirtyMap && dirtyMap.get(seriesModel.uid)) {
renderTask.dirty();
}
unfinished |= renderTask.perform(scheduler.getPerformArgs(renderTask));
chartView.group.silent = !!seriesModel.get('silent');
updateZ(seriesModel, chartView);
updateBlend(seriesModel, chartView);
});
scheduler.unfinished |= unfinished;
// If use hover layer
updateHoverLayerStatus(ecIns._zr, ecModel);
// Add aria
aria(ecIns._zr.dom, ecModel);
} | javascript | function renderSeries(ecIns, ecModel, api, payload, dirtyMap) {
// Render all charts
var scheduler = ecIns._scheduler;
var unfinished;
ecModel.eachSeries(function (seriesModel) {
var chartView = ecIns._chartsMap[seriesModel.__viewId];
chartView.__alive = true;
var renderTask = chartView.renderTask;
scheduler.updatePayload(renderTask, payload);
if (dirtyMap && dirtyMap.get(seriesModel.uid)) {
renderTask.dirty();
}
unfinished |= renderTask.perform(scheduler.getPerformArgs(renderTask));
chartView.group.silent = !!seriesModel.get('silent');
updateZ(seriesModel, chartView);
updateBlend(seriesModel, chartView);
});
scheduler.unfinished |= unfinished;
// If use hover layer
updateHoverLayerStatus(ecIns._zr, ecModel);
// Add aria
aria(ecIns._zr.dom, ecModel);
} | [
"function",
"renderSeries",
"(",
"ecIns",
",",
"ecModel",
",",
"api",
",",
"payload",
",",
"dirtyMap",
")",
"{",
"// Render all charts",
"var",
"scheduler",
"=",
"ecIns",
".",
"_scheduler",
";",
"var",
"unfinished",
";",
"ecModel",
".",
"eachSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"var",
"chartView",
"=",
"ecIns",
".",
"_chartsMap",
"[",
"seriesModel",
".",
"__viewId",
"]",
";",
"chartView",
".",
"__alive",
"=",
"true",
";",
"var",
"renderTask",
"=",
"chartView",
".",
"renderTask",
";",
"scheduler",
".",
"updatePayload",
"(",
"renderTask",
",",
"payload",
")",
";",
"if",
"(",
"dirtyMap",
"&&",
"dirtyMap",
".",
"get",
"(",
"seriesModel",
".",
"uid",
")",
")",
"{",
"renderTask",
".",
"dirty",
"(",
")",
";",
"}",
"unfinished",
"|=",
"renderTask",
".",
"perform",
"(",
"scheduler",
".",
"getPerformArgs",
"(",
"renderTask",
")",
")",
";",
"chartView",
".",
"group",
".",
"silent",
"=",
"!",
"!",
"seriesModel",
".",
"get",
"(",
"'silent'",
")",
";",
"updateZ",
"(",
"seriesModel",
",",
"chartView",
")",
";",
"updateBlend",
"(",
"seriesModel",
",",
"chartView",
")",
";",
"}",
")",
";",
"scheduler",
".",
"unfinished",
"|=",
"unfinished",
";",
"// If use hover layer",
"updateHoverLayerStatus",
"(",
"ecIns",
".",
"_zr",
",",
"ecModel",
")",
";",
"// Add aria",
"aria",
"(",
"ecIns",
".",
"_zr",
".",
"dom",
",",
"ecModel",
")",
";",
"}"
] | Render each chart and component
@private | [
"Render",
"each",
"chart",
"and",
"component"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/echarts.js#L1477-L1507 |
283 | apache/incubator-echarts | src/echarts.js | updateBlend | function updateBlend(seriesModel, chartView) {
var blendMode = seriesModel.get('blendMode') || null;
if (__DEV__) {
if (!env.canvasSupported && blendMode && blendMode !== 'source-over') {
console.warn('Only canvas support blendMode');
}
}
chartView.group.traverse(function (el) {
// FIXME marker and other components
if (!el.isGroup) {
// Only set if blendMode is changed. In case element is incremental and don't wan't to rerender.
if (el.style.blend !== blendMode) {
el.setStyle('blend', blendMode);
}
}
if (el.eachPendingDisplayable) {
el.eachPendingDisplayable(function (displayable) {
displayable.setStyle('blend', blendMode);
});
}
});
} | javascript | function updateBlend(seriesModel, chartView) {
var blendMode = seriesModel.get('blendMode') || null;
if (__DEV__) {
if (!env.canvasSupported && blendMode && blendMode !== 'source-over') {
console.warn('Only canvas support blendMode');
}
}
chartView.group.traverse(function (el) {
// FIXME marker and other components
if (!el.isGroup) {
// Only set if blendMode is changed. In case element is incremental and don't wan't to rerender.
if (el.style.blend !== blendMode) {
el.setStyle('blend', blendMode);
}
}
if (el.eachPendingDisplayable) {
el.eachPendingDisplayable(function (displayable) {
displayable.setStyle('blend', blendMode);
});
}
});
} | [
"function",
"updateBlend",
"(",
"seriesModel",
",",
"chartView",
")",
"{",
"var",
"blendMode",
"=",
"seriesModel",
".",
"get",
"(",
"'blendMode'",
")",
"||",
"null",
";",
"if",
"(",
"__DEV__",
")",
"{",
"if",
"(",
"!",
"env",
".",
"canvasSupported",
"&&",
"blendMode",
"&&",
"blendMode",
"!==",
"'source-over'",
")",
"{",
"console",
".",
"warn",
"(",
"'Only canvas support blendMode'",
")",
";",
"}",
"}",
"chartView",
".",
"group",
".",
"traverse",
"(",
"function",
"(",
"el",
")",
"{",
"// FIXME marker and other components",
"if",
"(",
"!",
"el",
".",
"isGroup",
")",
"{",
"// Only set if blendMode is changed. In case element is incremental and don't wan't to rerender.",
"if",
"(",
"el",
".",
"style",
".",
"blend",
"!==",
"blendMode",
")",
"{",
"el",
".",
"setStyle",
"(",
"'blend'",
",",
"blendMode",
")",
";",
"}",
"}",
"if",
"(",
"el",
".",
"eachPendingDisplayable",
")",
"{",
"el",
".",
"eachPendingDisplayable",
"(",
"function",
"(",
"displayable",
")",
"{",
"displayable",
".",
"setStyle",
"(",
"'blend'",
",",
"blendMode",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"}"
] | Update chart progressive and blend.
@param {module:echarts/model/Series|module:echarts/model/Component} model
@param {module:echarts/view/Component|module:echarts/view/Chart} view | [
"Update",
"chart",
"progressive",
"and",
"blend",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/echarts.js#L1681-L1702 |
284 | apache/incubator-echarts | src/chart/themeRiver/themeRiverLayout.js | themeRiverLayout | function themeRiverLayout(data, seriesModel, height) {
if (!data.count()) {
return;
}
var coordSys = seriesModel.coordinateSystem;
// the data in each layer are organized into a series.
var layerSeries = seriesModel.getLayerSeries();
// the points in each layer.
var timeDim = data.mapDimension('single');
var valueDim = data.mapDimension('value');
var layerPoints = zrUtil.map(layerSeries, function (singleLayer) {
return zrUtil.map(singleLayer.indices, function (idx) {
var pt = coordSys.dataToPoint(data.get(timeDim, idx));
pt[1] = data.get(valueDim, idx);
return pt;
});
});
var base = computeBaseline(layerPoints);
var baseLine = base.y0;
var ky = height / base.max;
// set layout information for each item.
var n = layerSeries.length;
var m = layerSeries[0].indices.length;
var baseY0;
for (var j = 0; j < m; ++j) {
baseY0 = baseLine[j] * ky;
data.setItemLayout(layerSeries[0].indices[j], {
layerIndex: 0,
x: layerPoints[0][j][0],
y0: baseY0,
y: layerPoints[0][j][1] * ky
});
for (var i = 1; i < n; ++i) {
baseY0 += layerPoints[i - 1][j][1] * ky;
data.setItemLayout(layerSeries[i].indices[j], {
layerIndex: i,
x: layerPoints[i][j][0],
y0: baseY0,
y: layerPoints[i][j][1] * ky
});
}
}
} | javascript | function themeRiverLayout(data, seriesModel, height) {
if (!data.count()) {
return;
}
var coordSys = seriesModel.coordinateSystem;
// the data in each layer are organized into a series.
var layerSeries = seriesModel.getLayerSeries();
// the points in each layer.
var timeDim = data.mapDimension('single');
var valueDim = data.mapDimension('value');
var layerPoints = zrUtil.map(layerSeries, function (singleLayer) {
return zrUtil.map(singleLayer.indices, function (idx) {
var pt = coordSys.dataToPoint(data.get(timeDim, idx));
pt[1] = data.get(valueDim, idx);
return pt;
});
});
var base = computeBaseline(layerPoints);
var baseLine = base.y0;
var ky = height / base.max;
// set layout information for each item.
var n = layerSeries.length;
var m = layerSeries[0].indices.length;
var baseY0;
for (var j = 0; j < m; ++j) {
baseY0 = baseLine[j] * ky;
data.setItemLayout(layerSeries[0].indices[j], {
layerIndex: 0,
x: layerPoints[0][j][0],
y0: baseY0,
y: layerPoints[0][j][1] * ky
});
for (var i = 1; i < n; ++i) {
baseY0 += layerPoints[i - 1][j][1] * ky;
data.setItemLayout(layerSeries[i].indices[j], {
layerIndex: i,
x: layerPoints[i][j][0],
y0: baseY0,
y: layerPoints[i][j][1] * ky
});
}
}
} | [
"function",
"themeRiverLayout",
"(",
"data",
",",
"seriesModel",
",",
"height",
")",
"{",
"if",
"(",
"!",
"data",
".",
"count",
"(",
")",
")",
"{",
"return",
";",
"}",
"var",
"coordSys",
"=",
"seriesModel",
".",
"coordinateSystem",
";",
"// the data in each layer are organized into a series.",
"var",
"layerSeries",
"=",
"seriesModel",
".",
"getLayerSeries",
"(",
")",
";",
"// the points in each layer.",
"var",
"timeDim",
"=",
"data",
".",
"mapDimension",
"(",
"'single'",
")",
";",
"var",
"valueDim",
"=",
"data",
".",
"mapDimension",
"(",
"'value'",
")",
";",
"var",
"layerPoints",
"=",
"zrUtil",
".",
"map",
"(",
"layerSeries",
",",
"function",
"(",
"singleLayer",
")",
"{",
"return",
"zrUtil",
".",
"map",
"(",
"singleLayer",
".",
"indices",
",",
"function",
"(",
"idx",
")",
"{",
"var",
"pt",
"=",
"coordSys",
".",
"dataToPoint",
"(",
"data",
".",
"get",
"(",
"timeDim",
",",
"idx",
")",
")",
";",
"pt",
"[",
"1",
"]",
"=",
"data",
".",
"get",
"(",
"valueDim",
",",
"idx",
")",
";",
"return",
"pt",
";",
"}",
")",
";",
"}",
")",
";",
"var",
"base",
"=",
"computeBaseline",
"(",
"layerPoints",
")",
";",
"var",
"baseLine",
"=",
"base",
".",
"y0",
";",
"var",
"ky",
"=",
"height",
"/",
"base",
".",
"max",
";",
"// set layout information for each item.",
"var",
"n",
"=",
"layerSeries",
".",
"length",
";",
"var",
"m",
"=",
"layerSeries",
"[",
"0",
"]",
".",
"indices",
".",
"length",
";",
"var",
"baseY0",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"m",
";",
"++",
"j",
")",
"{",
"baseY0",
"=",
"baseLine",
"[",
"j",
"]",
"*",
"ky",
";",
"data",
".",
"setItemLayout",
"(",
"layerSeries",
"[",
"0",
"]",
".",
"indices",
"[",
"j",
"]",
",",
"{",
"layerIndex",
":",
"0",
",",
"x",
":",
"layerPoints",
"[",
"0",
"]",
"[",
"j",
"]",
"[",
"0",
"]",
",",
"y0",
":",
"baseY0",
",",
"y",
":",
"layerPoints",
"[",
"0",
"]",
"[",
"j",
"]",
"[",
"1",
"]",
"*",
"ky",
"}",
")",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"baseY0",
"+=",
"layerPoints",
"[",
"i",
"-",
"1",
"]",
"[",
"j",
"]",
"[",
"1",
"]",
"*",
"ky",
";",
"data",
".",
"setItemLayout",
"(",
"layerSeries",
"[",
"i",
"]",
".",
"indices",
"[",
"j",
"]",
",",
"{",
"layerIndex",
":",
"i",
",",
"x",
":",
"layerPoints",
"[",
"i",
"]",
"[",
"j",
"]",
"[",
"0",
"]",
",",
"y0",
":",
"baseY0",
",",
"y",
":",
"layerPoints",
"[",
"i",
"]",
"[",
"j",
"]",
"[",
"1",
"]",
"*",
"ky",
"}",
")",
";",
"}",
"}",
"}"
] | The layout information about themeriver
@param {module:echarts/data/List} data data in the series
@param {module:echarts/model/Series} seriesModel the model object of themeRiver series
@param {number} height value used to compute every series height | [
"The",
"layout",
"information",
"about",
"themeriver"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/themeRiver/themeRiverLayout.js#L73-L118 |
285 | apache/incubator-echarts | src/chart/themeRiver/themeRiverLayout.js | computeBaseline | function computeBaseline(data) {
var layerNum = data.length;
var pointNum = data[0].length;
var sums = [];
var y0 = [];
var max = 0;
var temp;
var base = {};
for (var i = 0; i < pointNum; ++i) {
for (var j = 0, temp = 0; j < layerNum; ++j) {
temp += data[j][i][1];
}
if (temp > max) {
max = temp;
}
sums.push(temp);
}
for (var k = 0; k < pointNum; ++k) {
y0[k] = (max - sums[k]) / 2;
}
max = 0;
for (var l = 0; l < pointNum; ++l) {
var sum = sums[l] + y0[l];
if (sum > max) {
max = sum;
}
}
base.y0 = y0;
base.max = max;
return base;
} | javascript | function computeBaseline(data) {
var layerNum = data.length;
var pointNum = data[0].length;
var sums = [];
var y0 = [];
var max = 0;
var temp;
var base = {};
for (var i = 0; i < pointNum; ++i) {
for (var j = 0, temp = 0; j < layerNum; ++j) {
temp += data[j][i][1];
}
if (temp > max) {
max = temp;
}
sums.push(temp);
}
for (var k = 0; k < pointNum; ++k) {
y0[k] = (max - sums[k]) / 2;
}
max = 0;
for (var l = 0; l < pointNum; ++l) {
var sum = sums[l] + y0[l];
if (sum > max) {
max = sum;
}
}
base.y0 = y0;
base.max = max;
return base;
} | [
"function",
"computeBaseline",
"(",
"data",
")",
"{",
"var",
"layerNum",
"=",
"data",
".",
"length",
";",
"var",
"pointNum",
"=",
"data",
"[",
"0",
"]",
".",
"length",
";",
"var",
"sums",
"=",
"[",
"]",
";",
"var",
"y0",
"=",
"[",
"]",
";",
"var",
"max",
"=",
"0",
";",
"var",
"temp",
";",
"var",
"base",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"pointNum",
";",
"++",
"i",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"temp",
"=",
"0",
";",
"j",
"<",
"layerNum",
";",
"++",
"j",
")",
"{",
"temp",
"+=",
"data",
"[",
"j",
"]",
"[",
"i",
"]",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"temp",
">",
"max",
")",
"{",
"max",
"=",
"temp",
";",
"}",
"sums",
".",
"push",
"(",
"temp",
")",
";",
"}",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"pointNum",
";",
"++",
"k",
")",
"{",
"y0",
"[",
"k",
"]",
"=",
"(",
"max",
"-",
"sums",
"[",
"k",
"]",
")",
"/",
"2",
";",
"}",
"max",
"=",
"0",
";",
"for",
"(",
"var",
"l",
"=",
"0",
";",
"l",
"<",
"pointNum",
";",
"++",
"l",
")",
"{",
"var",
"sum",
"=",
"sums",
"[",
"l",
"]",
"+",
"y0",
"[",
"l",
"]",
";",
"if",
"(",
"sum",
">",
"max",
")",
"{",
"max",
"=",
"sum",
";",
"}",
"}",
"base",
".",
"y0",
"=",
"y0",
";",
"base",
".",
"max",
"=",
"max",
";",
"return",
"base",
";",
"}"
] | Compute the baseLine of the rawdata
Inspired by Lee Byron's paper Stacked Graphs - Geometry & Aesthetics
@param {Array.<Array>} data the points in each layer
@return {Object} | [
"Compute",
"the",
"baseLine",
"of",
"the",
"rawdata",
"Inspired",
"by",
"Lee",
"Byron",
"s",
"paper",
"Stacked",
"Graphs",
"-",
"Geometry",
"&",
"Aesthetics"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/themeRiver/themeRiverLayout.js#L127-L161 |
286 | apache/incubator-echarts | src/chart/tree/TreeView.js | function (ecModel, api) {
/**
* @private
* @type {module:echarts/data/Tree}
*/
this._oldTree;
/**
* @private
* @type {module:zrender/container/Group}
*/
this._mainGroup = new graphic.Group();
/**
* @private
* @type {module:echarts/componet/helper/RoamController}
*/
this._controller = new RoamController(api.getZr());
this._controllerHost = {target: this.group};
this.group.add(this._mainGroup);
} | javascript | function (ecModel, api) {
/**
* @private
* @type {module:echarts/data/Tree}
*/
this._oldTree;
/**
* @private
* @type {module:zrender/container/Group}
*/
this._mainGroup = new graphic.Group();
/**
* @private
* @type {module:echarts/componet/helper/RoamController}
*/
this._controller = new RoamController(api.getZr());
this._controllerHost = {target: this.group};
this.group.add(this._mainGroup);
} | [
"function",
"(",
"ecModel",
",",
"api",
")",
"{",
"/**\n * @private\n * @type {module:echarts/data/Tree}\n */",
"this",
".",
"_oldTree",
";",
"/**\n * @private\n * @type {module:zrender/container/Group}\n */",
"this",
".",
"_mainGroup",
"=",
"new",
"graphic",
".",
"Group",
"(",
")",
";",
"/**\n * @private\n * @type {module:echarts/componet/helper/RoamController}\n */",
"this",
".",
"_controller",
"=",
"new",
"RoamController",
"(",
"api",
".",
"getZr",
"(",
")",
")",
";",
"this",
".",
"_controllerHost",
"=",
"{",
"target",
":",
"this",
".",
"group",
"}",
";",
"this",
".",
"group",
".",
"add",
"(",
"this",
".",
"_mainGroup",
")",
";",
"}"
] | Init the chart
@override
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api | [
"Init",
"the",
"chart"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/tree/TreeView.js#L46-L69 |
|
287 | apache/incubator-echarts | src/data/helper/sourceHelper.js | doGuessOrdinal | function doGuessOrdinal(
data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex
) {
var result;
// Experience value.
var maxLoop = 5;
if (isTypedArray(data)) {
return false;
}
// When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
// always exists in source.
var dimName;
if (dimensionsDefine) {
dimName = dimensionsDefine[dimIndex];
dimName = isObject(dimName) ? dimName.name : dimName;
}
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
var sample = data[dimIndex];
for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
if ((result = detectValue(sample[startIndex + i])) != null) {
return result;
}
}
}
else {
for (var i = 0; i < data.length && i < maxLoop; i++) {
var row = data[startIndex + i];
if (row && (result = detectValue(row[dimIndex])) != null) {
return result;
}
}
}
}
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
if (!dimName) {
return;
}
for (var i = 0; i < data.length && i < maxLoop; i++) {
var item = data[i];
if (item && (result = detectValue(item[dimName])) != null) {
return result;
}
}
}
else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
if (!dimName) {
return;
}
var sample = data[dimName];
if (!sample || isTypedArray(sample)) {
return false;
}
for (var i = 0; i < sample.length && i < maxLoop; i++) {
if ((result = detectValue(sample[i])) != null) {
return result;
}
}
}
else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
for (var i = 0; i < data.length && i < maxLoop; i++) {
var item = data[i];
var val = getDataItemValue(item);
if (!isArray(val)) {
return false;
}
if ((result = detectValue(val[dimIndex])) != null) {
return result;
}
}
}
function detectValue(val) {
// Consider usage convenience, '1', '2' will be treated as "number".
// `isFinit('')` get `true`.
if (val != null && isFinite(val) && val !== '') {
return false;
}
else if (isString(val) && val !== '-') {
return true;
}
}
return false;
} | javascript | function doGuessOrdinal(
data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex
) {
var result;
// Experience value.
var maxLoop = 5;
if (isTypedArray(data)) {
return false;
}
// When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
// always exists in source.
var dimName;
if (dimensionsDefine) {
dimName = dimensionsDefine[dimIndex];
dimName = isObject(dimName) ? dimName.name : dimName;
}
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
var sample = data[dimIndex];
for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
if ((result = detectValue(sample[startIndex + i])) != null) {
return result;
}
}
}
else {
for (var i = 0; i < data.length && i < maxLoop; i++) {
var row = data[startIndex + i];
if (row && (result = detectValue(row[dimIndex])) != null) {
return result;
}
}
}
}
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
if (!dimName) {
return;
}
for (var i = 0; i < data.length && i < maxLoop; i++) {
var item = data[i];
if (item && (result = detectValue(item[dimName])) != null) {
return result;
}
}
}
else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
if (!dimName) {
return;
}
var sample = data[dimName];
if (!sample || isTypedArray(sample)) {
return false;
}
for (var i = 0; i < sample.length && i < maxLoop; i++) {
if ((result = detectValue(sample[i])) != null) {
return result;
}
}
}
else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
for (var i = 0; i < data.length && i < maxLoop; i++) {
var item = data[i];
var val = getDataItemValue(item);
if (!isArray(val)) {
return false;
}
if ((result = detectValue(val[dimIndex])) != null) {
return result;
}
}
}
function detectValue(val) {
// Consider usage convenience, '1', '2' will be treated as "number".
// `isFinit('')` get `true`.
if (val != null && isFinite(val) && val !== '') {
return false;
}
else if (isString(val) && val !== '-') {
return true;
}
}
return false;
} | [
"function",
"doGuessOrdinal",
"(",
"data",
",",
"sourceFormat",
",",
"seriesLayoutBy",
",",
"dimensionsDefine",
",",
"startIndex",
",",
"dimIndex",
")",
"{",
"var",
"result",
";",
"// Experience value.",
"var",
"maxLoop",
"=",
"5",
";",
"if",
"(",
"isTypedArray",
"(",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"// When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine",
"// always exists in source.",
"var",
"dimName",
";",
"if",
"(",
"dimensionsDefine",
")",
"{",
"dimName",
"=",
"dimensionsDefine",
"[",
"dimIndex",
"]",
";",
"dimName",
"=",
"isObject",
"(",
"dimName",
")",
"?",
"dimName",
".",
"name",
":",
"dimName",
";",
"}",
"if",
"(",
"sourceFormat",
"===",
"SOURCE_FORMAT_ARRAY_ROWS",
")",
"{",
"if",
"(",
"seriesLayoutBy",
"===",
"SERIES_LAYOUT_BY_ROW",
")",
"{",
"var",
"sample",
"=",
"data",
"[",
"dimIndex",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"(",
"sample",
"||",
"[",
"]",
")",
".",
"length",
"&&",
"i",
"<",
"maxLoop",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"result",
"=",
"detectValue",
"(",
"sample",
"[",
"startIndex",
"+",
"i",
"]",
")",
")",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"else",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
"&&",
"i",
"<",
"maxLoop",
";",
"i",
"++",
")",
"{",
"var",
"row",
"=",
"data",
"[",
"startIndex",
"+",
"i",
"]",
";",
"if",
"(",
"row",
"&&",
"(",
"result",
"=",
"detectValue",
"(",
"row",
"[",
"dimIndex",
"]",
")",
")",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"sourceFormat",
"===",
"SOURCE_FORMAT_OBJECT_ROWS",
")",
"{",
"if",
"(",
"!",
"dimName",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
"&&",
"i",
"<",
"maxLoop",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"data",
"[",
"i",
"]",
";",
"if",
"(",
"item",
"&&",
"(",
"result",
"=",
"detectValue",
"(",
"item",
"[",
"dimName",
"]",
")",
")",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"sourceFormat",
"===",
"SOURCE_FORMAT_KEYED_COLUMNS",
")",
"{",
"if",
"(",
"!",
"dimName",
")",
"{",
"return",
";",
"}",
"var",
"sample",
"=",
"data",
"[",
"dimName",
"]",
";",
"if",
"(",
"!",
"sample",
"||",
"isTypedArray",
"(",
"sample",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"sample",
".",
"length",
"&&",
"i",
"<",
"maxLoop",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"result",
"=",
"detectValue",
"(",
"sample",
"[",
"i",
"]",
")",
")",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"sourceFormat",
"===",
"SOURCE_FORMAT_ORIGINAL",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
"&&",
"i",
"<",
"maxLoop",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"data",
"[",
"i",
"]",
";",
"var",
"val",
"=",
"getDataItemValue",
"(",
"item",
")",
";",
"if",
"(",
"!",
"isArray",
"(",
"val",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"result",
"=",
"detectValue",
"(",
"val",
"[",
"dimIndex",
"]",
")",
")",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"function",
"detectValue",
"(",
"val",
")",
"{",
"// Consider usage convenience, '1', '2' will be treated as \"number\".",
"// `isFinit('')` get `true`.",
"if",
"(",
"val",
"!=",
"null",
"&&",
"isFinite",
"(",
"val",
")",
"&&",
"val",
"!==",
"''",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"isString",
"(",
"val",
")",
"&&",
"val",
"!==",
"'-'",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | dimIndex may be overflow source data. | [
"dimIndex",
"may",
"be",
"overflow",
"source",
"data",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/helper/sourceHelper.js#L500-L587 |
288 | apache/incubator-echarts | src/component/tooltip/TooltipView.js | function (tooltipModel, ecModel, api, payload) {
var seriesIndex = payload.seriesIndex;
var dataIndex = payload.dataIndex;
var coordSysAxesInfo = ecModel.getComponent('axisPointer').coordSysAxesInfo;
if (seriesIndex == null || dataIndex == null || coordSysAxesInfo == null) {
return;
}
var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
if (!seriesModel) {
return;
}
var data = seriesModel.getData();
var tooltipModel = buildTooltipModel([
data.getItemModel(dataIndex),
seriesModel,
(seriesModel.coordinateSystem || {}).model,
tooltipModel
]);
if (tooltipModel.get('trigger') !== 'axis') {
return;
}
api.dispatchAction({
type: 'updateAxisPointer',
seriesIndex: seriesIndex,
dataIndex: dataIndex,
position: payload.position
});
return true;
} | javascript | function (tooltipModel, ecModel, api, payload) {
var seriesIndex = payload.seriesIndex;
var dataIndex = payload.dataIndex;
var coordSysAxesInfo = ecModel.getComponent('axisPointer').coordSysAxesInfo;
if (seriesIndex == null || dataIndex == null || coordSysAxesInfo == null) {
return;
}
var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
if (!seriesModel) {
return;
}
var data = seriesModel.getData();
var tooltipModel = buildTooltipModel([
data.getItemModel(dataIndex),
seriesModel,
(seriesModel.coordinateSystem || {}).model,
tooltipModel
]);
if (tooltipModel.get('trigger') !== 'axis') {
return;
}
api.dispatchAction({
type: 'updateAxisPointer',
seriesIndex: seriesIndex,
dataIndex: dataIndex,
position: payload.position
});
return true;
} | [
"function",
"(",
"tooltipModel",
",",
"ecModel",
",",
"api",
",",
"payload",
")",
"{",
"var",
"seriesIndex",
"=",
"payload",
".",
"seriesIndex",
";",
"var",
"dataIndex",
"=",
"payload",
".",
"dataIndex",
";",
"var",
"coordSysAxesInfo",
"=",
"ecModel",
".",
"getComponent",
"(",
"'axisPointer'",
")",
".",
"coordSysAxesInfo",
";",
"if",
"(",
"seriesIndex",
"==",
"null",
"||",
"dataIndex",
"==",
"null",
"||",
"coordSysAxesInfo",
"==",
"null",
")",
"{",
"return",
";",
"}",
"var",
"seriesModel",
"=",
"ecModel",
".",
"getSeriesByIndex",
"(",
"seriesIndex",
")",
";",
"if",
"(",
"!",
"seriesModel",
")",
"{",
"return",
";",
"}",
"var",
"data",
"=",
"seriesModel",
".",
"getData",
"(",
")",
";",
"var",
"tooltipModel",
"=",
"buildTooltipModel",
"(",
"[",
"data",
".",
"getItemModel",
"(",
"dataIndex",
")",
",",
"seriesModel",
",",
"(",
"seriesModel",
".",
"coordinateSystem",
"||",
"{",
"}",
")",
".",
"model",
",",
"tooltipModel",
"]",
")",
";",
"if",
"(",
"tooltipModel",
".",
"get",
"(",
"'trigger'",
")",
"!==",
"'axis'",
")",
"{",
"return",
";",
"}",
"api",
".",
"dispatchAction",
"(",
"{",
"type",
":",
"'updateAxisPointer'",
",",
"seriesIndex",
":",
"seriesIndex",
",",
"dataIndex",
":",
"dataIndex",
",",
"position",
":",
"payload",
".",
"position",
"}",
")",
";",
"return",
"true",
";",
"}"
] | Be compatible with previous design, that is, when tooltip.type is 'axis' and dispatchAction 'showTip' with seriesIndex and dataIndex will trigger axis pointer and tooltip. | [
"Be",
"compatible",
"with",
"previous",
"design",
"that",
"is",
"when",
"tooltip",
".",
"type",
"is",
"axis",
"and",
"dispatchAction",
"showTip",
"with",
"seriesIndex",
"and",
"dataIndex",
"will",
"trigger",
"axis",
"pointer",
"and",
"tooltip",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/tooltip/TooltipView.js#L272-L306 |
|
289 | apache/incubator-echarts | src/component/tooltip/TooltipView.js | function (dataByCoordSys) {
var lastCoordSys = this._lastDataByCoordSys;
var contentNotChanged = !!lastCoordSys
&& lastCoordSys.length === dataByCoordSys.length;
contentNotChanged && each(lastCoordSys, function (lastItemCoordSys, indexCoordSys) {
var lastDataByAxis = lastItemCoordSys.dataByAxis || {};
var thisItemCoordSys = dataByCoordSys[indexCoordSys] || {};
var thisDataByAxis = thisItemCoordSys.dataByAxis || [];
contentNotChanged &= lastDataByAxis.length === thisDataByAxis.length;
contentNotChanged && each(lastDataByAxis, function (lastItem, indexAxis) {
var thisItem = thisDataByAxis[indexAxis] || {};
var lastIndices = lastItem.seriesDataIndices || [];
var newIndices = thisItem.seriesDataIndices || [];
contentNotChanged
&= lastItem.value === thisItem.value
&& lastItem.axisType === thisItem.axisType
&& lastItem.axisId === thisItem.axisId
&& lastIndices.length === newIndices.length;
contentNotChanged && each(lastIndices, function (lastIdxItem, j) {
var newIdxItem = newIndices[j];
contentNotChanged
&= lastIdxItem.seriesIndex === newIdxItem.seriesIndex
&& lastIdxItem.dataIndex === newIdxItem.dataIndex;
});
});
});
this._lastDataByCoordSys = dataByCoordSys;
return !!contentNotChanged;
} | javascript | function (dataByCoordSys) {
var lastCoordSys = this._lastDataByCoordSys;
var contentNotChanged = !!lastCoordSys
&& lastCoordSys.length === dataByCoordSys.length;
contentNotChanged && each(lastCoordSys, function (lastItemCoordSys, indexCoordSys) {
var lastDataByAxis = lastItemCoordSys.dataByAxis || {};
var thisItemCoordSys = dataByCoordSys[indexCoordSys] || {};
var thisDataByAxis = thisItemCoordSys.dataByAxis || [];
contentNotChanged &= lastDataByAxis.length === thisDataByAxis.length;
contentNotChanged && each(lastDataByAxis, function (lastItem, indexAxis) {
var thisItem = thisDataByAxis[indexAxis] || {};
var lastIndices = lastItem.seriesDataIndices || [];
var newIndices = thisItem.seriesDataIndices || [];
contentNotChanged
&= lastItem.value === thisItem.value
&& lastItem.axisType === thisItem.axisType
&& lastItem.axisId === thisItem.axisId
&& lastIndices.length === newIndices.length;
contentNotChanged && each(lastIndices, function (lastIdxItem, j) {
var newIdxItem = newIndices[j];
contentNotChanged
&= lastIdxItem.seriesIndex === newIdxItem.seriesIndex
&& lastIdxItem.dataIndex === newIdxItem.dataIndex;
});
});
});
this._lastDataByCoordSys = dataByCoordSys;
return !!contentNotChanged;
} | [
"function",
"(",
"dataByCoordSys",
")",
"{",
"var",
"lastCoordSys",
"=",
"this",
".",
"_lastDataByCoordSys",
";",
"var",
"contentNotChanged",
"=",
"!",
"!",
"lastCoordSys",
"&&",
"lastCoordSys",
".",
"length",
"===",
"dataByCoordSys",
".",
"length",
";",
"contentNotChanged",
"&&",
"each",
"(",
"lastCoordSys",
",",
"function",
"(",
"lastItemCoordSys",
",",
"indexCoordSys",
")",
"{",
"var",
"lastDataByAxis",
"=",
"lastItemCoordSys",
".",
"dataByAxis",
"||",
"{",
"}",
";",
"var",
"thisItemCoordSys",
"=",
"dataByCoordSys",
"[",
"indexCoordSys",
"]",
"||",
"{",
"}",
";",
"var",
"thisDataByAxis",
"=",
"thisItemCoordSys",
".",
"dataByAxis",
"||",
"[",
"]",
";",
"contentNotChanged",
"&=",
"lastDataByAxis",
".",
"length",
"===",
"thisDataByAxis",
".",
"length",
";",
"contentNotChanged",
"&&",
"each",
"(",
"lastDataByAxis",
",",
"function",
"(",
"lastItem",
",",
"indexAxis",
")",
"{",
"var",
"thisItem",
"=",
"thisDataByAxis",
"[",
"indexAxis",
"]",
"||",
"{",
"}",
";",
"var",
"lastIndices",
"=",
"lastItem",
".",
"seriesDataIndices",
"||",
"[",
"]",
";",
"var",
"newIndices",
"=",
"thisItem",
".",
"seriesDataIndices",
"||",
"[",
"]",
";",
"contentNotChanged",
"&=",
"lastItem",
".",
"value",
"===",
"thisItem",
".",
"value",
"&&",
"lastItem",
".",
"axisType",
"===",
"thisItem",
".",
"axisType",
"&&",
"lastItem",
".",
"axisId",
"===",
"thisItem",
".",
"axisId",
"&&",
"lastIndices",
".",
"length",
"===",
"newIndices",
".",
"length",
";",
"contentNotChanged",
"&&",
"each",
"(",
"lastIndices",
",",
"function",
"(",
"lastIdxItem",
",",
"j",
")",
"{",
"var",
"newIdxItem",
"=",
"newIndices",
"[",
"j",
"]",
";",
"contentNotChanged",
"&=",
"lastIdxItem",
".",
"seriesIndex",
"===",
"newIdxItem",
".",
"seriesIndex",
"&&",
"lastIdxItem",
".",
"dataIndex",
"===",
"newIdxItem",
".",
"dataIndex",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"this",
".",
"_lastDataByCoordSys",
"=",
"dataByCoordSys",
";",
"return",
"!",
"!",
"contentNotChanged",
";",
"}"
] | FIXME Should we remove this but leave this to user? | [
"FIXME",
"Should",
"we",
"remove",
"this",
"but",
"leave",
"this",
"to",
"user?"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/tooltip/TooltipView.js#L677-L711 |
|
290 | apache/incubator-echarts | src/chart/sunburst/SunburstPiece.js | SunburstPiece | function SunburstPiece(node, seriesModel, ecModel) {
graphic.Group.call(this);
var sector = new graphic.Sector({
z2: DEFAULT_SECTOR_Z
});
sector.seriesIndex = seriesModel.seriesIndex;
var text = new graphic.Text({
z2: DEFAULT_TEXT_Z,
silent: node.getModel('label').get('silent')
});
this.add(sector);
this.add(text);
this.updateData(true, node, 'normal', seriesModel, ecModel);
// Hover to change label and labelLine
function onEmphasis() {
text.ignore = text.hoverIgnore;
}
function onNormal() {
text.ignore = text.normalIgnore;
}
this.on('emphasis', onEmphasis)
.on('normal', onNormal)
.on('mouseover', onEmphasis)
.on('mouseout', onNormal);
} | javascript | function SunburstPiece(node, seriesModel, ecModel) {
graphic.Group.call(this);
var sector = new graphic.Sector({
z2: DEFAULT_SECTOR_Z
});
sector.seriesIndex = seriesModel.seriesIndex;
var text = new graphic.Text({
z2: DEFAULT_TEXT_Z,
silent: node.getModel('label').get('silent')
});
this.add(sector);
this.add(text);
this.updateData(true, node, 'normal', seriesModel, ecModel);
// Hover to change label and labelLine
function onEmphasis() {
text.ignore = text.hoverIgnore;
}
function onNormal() {
text.ignore = text.normalIgnore;
}
this.on('emphasis', onEmphasis)
.on('normal', onNormal)
.on('mouseover', onEmphasis)
.on('mouseout', onNormal);
} | [
"function",
"SunburstPiece",
"(",
"node",
",",
"seriesModel",
",",
"ecModel",
")",
"{",
"graphic",
".",
"Group",
".",
"call",
"(",
"this",
")",
";",
"var",
"sector",
"=",
"new",
"graphic",
".",
"Sector",
"(",
"{",
"z2",
":",
"DEFAULT_SECTOR_Z",
"}",
")",
";",
"sector",
".",
"seriesIndex",
"=",
"seriesModel",
".",
"seriesIndex",
";",
"var",
"text",
"=",
"new",
"graphic",
".",
"Text",
"(",
"{",
"z2",
":",
"DEFAULT_TEXT_Z",
",",
"silent",
":",
"node",
".",
"getModel",
"(",
"'label'",
")",
".",
"get",
"(",
"'silent'",
")",
"}",
")",
";",
"this",
".",
"add",
"(",
"sector",
")",
";",
"this",
".",
"add",
"(",
"text",
")",
";",
"this",
".",
"updateData",
"(",
"true",
",",
"node",
",",
"'normal'",
",",
"seriesModel",
",",
"ecModel",
")",
";",
"// Hover to change label and labelLine",
"function",
"onEmphasis",
"(",
")",
"{",
"text",
".",
"ignore",
"=",
"text",
".",
"hoverIgnore",
";",
"}",
"function",
"onNormal",
"(",
")",
"{",
"text",
".",
"ignore",
"=",
"text",
".",
"normalIgnore",
";",
"}",
"this",
".",
"on",
"(",
"'emphasis'",
",",
"onEmphasis",
")",
".",
"on",
"(",
"'normal'",
",",
"onNormal",
")",
".",
"on",
"(",
"'mouseover'",
",",
"onEmphasis",
")",
".",
"on",
"(",
"'mouseout'",
",",
"onNormal",
")",
";",
"}"
] | Sunburstce of Sunburst including Sector, Label, LabelLine
@constructor
@extends {module:zrender/graphic/Group} | [
"Sunburstce",
"of",
"Sunburst",
"including",
"Sector",
"Label",
"LabelLine"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/SunburstPiece.js#L38-L67 |
291 | apache/incubator-echarts | src/chart/sunburst/SunburstPiece.js | getNodeColor | function getNodeColor(node, seriesModel, ecModel) {
// Color from visualMap
var visualColor = node.getVisual('color');
var visualMetaList = node.getVisual('visualMeta');
if (!visualMetaList || visualMetaList.length === 0) {
// Use first-generation color if has no visualMap
visualColor = null;
}
// Self color or level color
var color = node.getModel('itemStyle').get('color');
if (color) {
return color;
}
else if (visualColor) {
// Color mapping
return visualColor;
}
else if (node.depth === 0) {
// Virtual root node
return ecModel.option.color[0];
}
else {
// First-generation color
var length = ecModel.option.color.length;
color = ecModel.option.color[getRootId(node) % length];
}
return color;
} | javascript | function getNodeColor(node, seriesModel, ecModel) {
// Color from visualMap
var visualColor = node.getVisual('color');
var visualMetaList = node.getVisual('visualMeta');
if (!visualMetaList || visualMetaList.length === 0) {
// Use first-generation color if has no visualMap
visualColor = null;
}
// Self color or level color
var color = node.getModel('itemStyle').get('color');
if (color) {
return color;
}
else if (visualColor) {
// Color mapping
return visualColor;
}
else if (node.depth === 0) {
// Virtual root node
return ecModel.option.color[0];
}
else {
// First-generation color
var length = ecModel.option.color.length;
color = ecModel.option.color[getRootId(node) % length];
}
return color;
} | [
"function",
"getNodeColor",
"(",
"node",
",",
"seriesModel",
",",
"ecModel",
")",
"{",
"// Color from visualMap",
"var",
"visualColor",
"=",
"node",
".",
"getVisual",
"(",
"'color'",
")",
";",
"var",
"visualMetaList",
"=",
"node",
".",
"getVisual",
"(",
"'visualMeta'",
")",
";",
"if",
"(",
"!",
"visualMetaList",
"||",
"visualMetaList",
".",
"length",
"===",
"0",
")",
"{",
"// Use first-generation color if has no visualMap",
"visualColor",
"=",
"null",
";",
"}",
"// Self color or level color",
"var",
"color",
"=",
"node",
".",
"getModel",
"(",
"'itemStyle'",
")",
".",
"get",
"(",
"'color'",
")",
";",
"if",
"(",
"color",
")",
"{",
"return",
"color",
";",
"}",
"else",
"if",
"(",
"visualColor",
")",
"{",
"// Color mapping",
"return",
"visualColor",
";",
"}",
"else",
"if",
"(",
"node",
".",
"depth",
"===",
"0",
")",
"{",
"// Virtual root node",
"return",
"ecModel",
".",
"option",
".",
"color",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"// First-generation color",
"var",
"length",
"=",
"ecModel",
".",
"option",
".",
"color",
".",
"length",
";",
"color",
"=",
"ecModel",
".",
"option",
".",
"color",
"[",
"getRootId",
"(",
"node",
")",
"%",
"length",
"]",
";",
"}",
"return",
"color",
";",
"}"
] | Get node color
@param {TreeNode} node the node to get color
@param {module:echarts/model/Series} seriesModel series
@param {module:echarts/model/Global} ecModel echarts defaults | [
"Get",
"node",
"color"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/SunburstPiece.js#L356-L384 |
292 | apache/incubator-echarts | src/chart/sunburst/SunburstPiece.js | getRootId | function getRootId(node) {
var ancestor = node;
while (ancestor.depth > 1) {
ancestor = ancestor.parentNode;
}
var virtualRoot = node.getAncestors()[0];
return zrUtil.indexOf(virtualRoot.children, ancestor);
} | javascript | function getRootId(node) {
var ancestor = node;
while (ancestor.depth > 1) {
ancestor = ancestor.parentNode;
}
var virtualRoot = node.getAncestors()[0];
return zrUtil.indexOf(virtualRoot.children, ancestor);
} | [
"function",
"getRootId",
"(",
"node",
")",
"{",
"var",
"ancestor",
"=",
"node",
";",
"while",
"(",
"ancestor",
".",
"depth",
">",
"1",
")",
"{",
"ancestor",
"=",
"ancestor",
".",
"parentNode",
";",
"}",
"var",
"virtualRoot",
"=",
"node",
".",
"getAncestors",
"(",
")",
"[",
"0",
"]",
";",
"return",
"zrUtil",
".",
"indexOf",
"(",
"virtualRoot",
".",
"children",
",",
"ancestor",
")",
";",
"}"
] | Get index of root in sorted order
@param {TreeNode} node current node
@return {number} index in root | [
"Get",
"index",
"of",
"root",
"in",
"sorted",
"order"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/SunburstPiece.js#L392-L400 |
293 | apache/incubator-echarts | src/chart/sunburst/SunburstPiece.js | fillDefaultColor | function fillDefaultColor(node, seriesModel, color) {
var data = seriesModel.getData();
data.setItemVisual(node.dataIndex, 'color', color);
} | javascript | function fillDefaultColor(node, seriesModel, color) {
var data = seriesModel.getData();
data.setItemVisual(node.dataIndex, 'color', color);
} | [
"function",
"fillDefaultColor",
"(",
"node",
",",
"seriesModel",
",",
"color",
")",
"{",
"var",
"data",
"=",
"seriesModel",
".",
"getData",
"(",
")",
";",
"data",
".",
"setItemVisual",
"(",
"node",
".",
"dataIndex",
",",
"'color'",
",",
"color",
")",
";",
"}"
] | Fix tooltip callback function params.color incorrect when pick a default color | [
"Fix",
"tooltip",
"callback",
"function",
"params",
".",
"color",
"incorrect",
"when",
"pick",
"a",
"default",
"color"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/SunburstPiece.js#L418-L421 |
294 | apache/incubator-echarts | src/component/graphic.js | function (graphicModel) {
var elOptionsToUpdate = graphicModel.useElOptionsToUpdate();
if (!elOptionsToUpdate) {
return;
}
var elMap = this._elMap;
var rootGroup = this.group;
// Top-down tranverse to assign graphic settings to each elements.
zrUtil.each(elOptionsToUpdate, function (elOption) {
var $action = elOption.$action;
var id = elOption.id;
var existEl = elMap.get(id);
var parentId = elOption.parentId;
var targetElParent = parentId != null ? elMap.get(parentId) : rootGroup;
var elOptionStyle = elOption.style;
if (elOption.type === 'text' && elOptionStyle) {
// In top/bottom mode, textVerticalAlign should not be used, which cause
// inaccurately locating.
if (elOption.hv && elOption.hv[1]) {
elOptionStyle.textVerticalAlign = elOptionStyle.textBaseline = null;
}
// Compatible with previous setting: both support fill and textFill,
// stroke and textStroke.
!elOptionStyle.hasOwnProperty('textFill') && elOptionStyle.fill && (
elOptionStyle.textFill = elOptionStyle.fill
);
!elOptionStyle.hasOwnProperty('textStroke') && elOptionStyle.stroke && (
elOptionStyle.textStroke = elOptionStyle.stroke
);
}
// Remove unnecessary props to avoid potential problems.
var elOptionCleaned = getCleanedElOption(elOption);
// For simple, do not support parent change, otherwise reorder is needed.
if (__DEV__) {
existEl && zrUtil.assert(
targetElParent === existEl.parent,
'Changing parent is not supported.'
);
}
if (!$action || $action === 'merge') {
existEl
? existEl.attr(elOptionCleaned)
: createEl(id, targetElParent, elOptionCleaned, elMap);
}
else if ($action === 'replace') {
removeEl(existEl, elMap);
createEl(id, targetElParent, elOptionCleaned, elMap);
}
else if ($action === 'remove') {
removeEl(existEl, elMap);
}
var el = elMap.get(id);
if (el) {
el.__ecGraphicWidth = elOption.width;
el.__ecGraphicHeight = elOption.height;
setEventData(el, graphicModel, elOption);
}
});
} | javascript | function (graphicModel) {
var elOptionsToUpdate = graphicModel.useElOptionsToUpdate();
if (!elOptionsToUpdate) {
return;
}
var elMap = this._elMap;
var rootGroup = this.group;
// Top-down tranverse to assign graphic settings to each elements.
zrUtil.each(elOptionsToUpdate, function (elOption) {
var $action = elOption.$action;
var id = elOption.id;
var existEl = elMap.get(id);
var parentId = elOption.parentId;
var targetElParent = parentId != null ? elMap.get(parentId) : rootGroup;
var elOptionStyle = elOption.style;
if (elOption.type === 'text' && elOptionStyle) {
// In top/bottom mode, textVerticalAlign should not be used, which cause
// inaccurately locating.
if (elOption.hv && elOption.hv[1]) {
elOptionStyle.textVerticalAlign = elOptionStyle.textBaseline = null;
}
// Compatible with previous setting: both support fill and textFill,
// stroke and textStroke.
!elOptionStyle.hasOwnProperty('textFill') && elOptionStyle.fill && (
elOptionStyle.textFill = elOptionStyle.fill
);
!elOptionStyle.hasOwnProperty('textStroke') && elOptionStyle.stroke && (
elOptionStyle.textStroke = elOptionStyle.stroke
);
}
// Remove unnecessary props to avoid potential problems.
var elOptionCleaned = getCleanedElOption(elOption);
// For simple, do not support parent change, otherwise reorder is needed.
if (__DEV__) {
existEl && zrUtil.assert(
targetElParent === existEl.parent,
'Changing parent is not supported.'
);
}
if (!$action || $action === 'merge') {
existEl
? existEl.attr(elOptionCleaned)
: createEl(id, targetElParent, elOptionCleaned, elMap);
}
else if ($action === 'replace') {
removeEl(existEl, elMap);
createEl(id, targetElParent, elOptionCleaned, elMap);
}
else if ($action === 'remove') {
removeEl(existEl, elMap);
}
var el = elMap.get(id);
if (el) {
el.__ecGraphicWidth = elOption.width;
el.__ecGraphicHeight = elOption.height;
setEventData(el, graphicModel, elOption);
}
});
} | [
"function",
"(",
"graphicModel",
")",
"{",
"var",
"elOptionsToUpdate",
"=",
"graphicModel",
".",
"useElOptionsToUpdate",
"(",
")",
";",
"if",
"(",
"!",
"elOptionsToUpdate",
")",
"{",
"return",
";",
"}",
"var",
"elMap",
"=",
"this",
".",
"_elMap",
";",
"var",
"rootGroup",
"=",
"this",
".",
"group",
";",
"// Top-down tranverse to assign graphic settings to each elements.",
"zrUtil",
".",
"each",
"(",
"elOptionsToUpdate",
",",
"function",
"(",
"elOption",
")",
"{",
"var",
"$action",
"=",
"elOption",
".",
"$action",
";",
"var",
"id",
"=",
"elOption",
".",
"id",
";",
"var",
"existEl",
"=",
"elMap",
".",
"get",
"(",
"id",
")",
";",
"var",
"parentId",
"=",
"elOption",
".",
"parentId",
";",
"var",
"targetElParent",
"=",
"parentId",
"!=",
"null",
"?",
"elMap",
".",
"get",
"(",
"parentId",
")",
":",
"rootGroup",
";",
"var",
"elOptionStyle",
"=",
"elOption",
".",
"style",
";",
"if",
"(",
"elOption",
".",
"type",
"===",
"'text'",
"&&",
"elOptionStyle",
")",
"{",
"// In top/bottom mode, textVerticalAlign should not be used, which cause",
"// inaccurately locating.",
"if",
"(",
"elOption",
".",
"hv",
"&&",
"elOption",
".",
"hv",
"[",
"1",
"]",
")",
"{",
"elOptionStyle",
".",
"textVerticalAlign",
"=",
"elOptionStyle",
".",
"textBaseline",
"=",
"null",
";",
"}",
"// Compatible with previous setting: both support fill and textFill,",
"// stroke and textStroke.",
"!",
"elOptionStyle",
".",
"hasOwnProperty",
"(",
"'textFill'",
")",
"&&",
"elOptionStyle",
".",
"fill",
"&&",
"(",
"elOptionStyle",
".",
"textFill",
"=",
"elOptionStyle",
".",
"fill",
")",
";",
"!",
"elOptionStyle",
".",
"hasOwnProperty",
"(",
"'textStroke'",
")",
"&&",
"elOptionStyle",
".",
"stroke",
"&&",
"(",
"elOptionStyle",
".",
"textStroke",
"=",
"elOptionStyle",
".",
"stroke",
")",
";",
"}",
"// Remove unnecessary props to avoid potential problems.",
"var",
"elOptionCleaned",
"=",
"getCleanedElOption",
"(",
"elOption",
")",
";",
"// For simple, do not support parent change, otherwise reorder is needed.",
"if",
"(",
"__DEV__",
")",
"{",
"existEl",
"&&",
"zrUtil",
".",
"assert",
"(",
"targetElParent",
"===",
"existEl",
".",
"parent",
",",
"'Changing parent is not supported.'",
")",
";",
"}",
"if",
"(",
"!",
"$action",
"||",
"$action",
"===",
"'merge'",
")",
"{",
"existEl",
"?",
"existEl",
".",
"attr",
"(",
"elOptionCleaned",
")",
":",
"createEl",
"(",
"id",
",",
"targetElParent",
",",
"elOptionCleaned",
",",
"elMap",
")",
";",
"}",
"else",
"if",
"(",
"$action",
"===",
"'replace'",
")",
"{",
"removeEl",
"(",
"existEl",
",",
"elMap",
")",
";",
"createEl",
"(",
"id",
",",
"targetElParent",
",",
"elOptionCleaned",
",",
"elMap",
")",
";",
"}",
"else",
"if",
"(",
"$action",
"===",
"'remove'",
")",
"{",
"removeEl",
"(",
"existEl",
",",
"elMap",
")",
";",
"}",
"var",
"el",
"=",
"elMap",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"el",
")",
"{",
"el",
".",
"__ecGraphicWidth",
"=",
"elOption",
".",
"width",
";",
"el",
".",
"__ecGraphicHeight",
"=",
"elOption",
".",
"height",
";",
"setEventData",
"(",
"el",
",",
"graphicModel",
",",
"elOption",
")",
";",
"}",
"}",
")",
";",
"}"
] | Update graphic elements.
@private
@param {Object} graphicModel graphic model | [
"Update",
"graphic",
"elements",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/graphic.js#L279-L346 |
|
295 | apache/incubator-echarts | src/component/graphic.js | function (graphicModel, api) {
var elOptions = graphicModel.option.elements;
var rootGroup = this.group;
var elMap = this._elMap;
// Bottom-up tranvese all elements (consider ec resize) to locate elements.
for (var i = elOptions.length - 1; i >= 0; i--) {
var elOption = elOptions[i];
var el = elMap.get(elOption.id);
if (!el) {
continue;
}
var parentEl = el.parent;
var containerInfo = parentEl === rootGroup
? {
width: api.getWidth(),
height: api.getHeight()
}
: { // Like 'position:absolut' in css, default 0.
width: parentEl.__ecGraphicWidth || 0,
height: parentEl.__ecGraphicHeight || 0
};
layoutUtil.positionElement(
el, elOption, containerInfo, null,
{hv: elOption.hv, boundingMode: elOption.bounding}
);
}
} | javascript | function (graphicModel, api) {
var elOptions = graphicModel.option.elements;
var rootGroup = this.group;
var elMap = this._elMap;
// Bottom-up tranvese all elements (consider ec resize) to locate elements.
for (var i = elOptions.length - 1; i >= 0; i--) {
var elOption = elOptions[i];
var el = elMap.get(elOption.id);
if (!el) {
continue;
}
var parentEl = el.parent;
var containerInfo = parentEl === rootGroup
? {
width: api.getWidth(),
height: api.getHeight()
}
: { // Like 'position:absolut' in css, default 0.
width: parentEl.__ecGraphicWidth || 0,
height: parentEl.__ecGraphicHeight || 0
};
layoutUtil.positionElement(
el, elOption, containerInfo, null,
{hv: elOption.hv, boundingMode: elOption.bounding}
);
}
} | [
"function",
"(",
"graphicModel",
",",
"api",
")",
"{",
"var",
"elOptions",
"=",
"graphicModel",
".",
"option",
".",
"elements",
";",
"var",
"rootGroup",
"=",
"this",
".",
"group",
";",
"var",
"elMap",
"=",
"this",
".",
"_elMap",
";",
"// Bottom-up tranvese all elements (consider ec resize) to locate elements.",
"for",
"(",
"var",
"i",
"=",
"elOptions",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"elOption",
"=",
"elOptions",
"[",
"i",
"]",
";",
"var",
"el",
"=",
"elMap",
".",
"get",
"(",
"elOption",
".",
"id",
")",
";",
"if",
"(",
"!",
"el",
")",
"{",
"continue",
";",
"}",
"var",
"parentEl",
"=",
"el",
".",
"parent",
";",
"var",
"containerInfo",
"=",
"parentEl",
"===",
"rootGroup",
"?",
"{",
"width",
":",
"api",
".",
"getWidth",
"(",
")",
",",
"height",
":",
"api",
".",
"getHeight",
"(",
")",
"}",
":",
"{",
"// Like 'position:absolut' in css, default 0.",
"width",
":",
"parentEl",
".",
"__ecGraphicWidth",
"||",
"0",
",",
"height",
":",
"parentEl",
".",
"__ecGraphicHeight",
"||",
"0",
"}",
";",
"layoutUtil",
".",
"positionElement",
"(",
"el",
",",
"elOption",
",",
"containerInfo",
",",
"null",
",",
"{",
"hv",
":",
"elOption",
".",
"hv",
",",
"boundingMode",
":",
"elOption",
".",
"bounding",
"}",
")",
";",
"}",
"}"
] | Locate graphic elements.
@private
@param {Object} graphicModel graphic model
@param {module:echarts/ExtensionAPI} api extension API | [
"Locate",
"graphic",
"elements",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/graphic.js#L355-L385 |
|
296 | apache/incubator-echarts | src/component/graphic.js | function () {
var elMap = this._elMap;
elMap.each(function (el) {
removeEl(el, elMap);
});
this._elMap = zrUtil.createHashMap();
} | javascript | function () {
var elMap = this._elMap;
elMap.each(function (el) {
removeEl(el, elMap);
});
this._elMap = zrUtil.createHashMap();
} | [
"function",
"(",
")",
"{",
"var",
"elMap",
"=",
"this",
".",
"_elMap",
";",
"elMap",
".",
"each",
"(",
"function",
"(",
"el",
")",
"{",
"removeEl",
"(",
"el",
",",
"elMap",
")",
";",
"}",
")",
";",
"this",
".",
"_elMap",
"=",
"zrUtil",
".",
"createHashMap",
"(",
")",
";",
"}"
] | Clear all elements.
@private | [
"Clear",
"all",
"elements",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/graphic.js#L392-L398 |
|
297 | apache/incubator-echarts | src/component/graphic.js | getCleanedElOption | function getCleanedElOption(elOption) {
elOption = zrUtil.extend({}, elOption);
zrUtil.each(
['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS),
function (name) {
delete elOption[name];
}
);
return elOption;
} | javascript | function getCleanedElOption(elOption) {
elOption = zrUtil.extend({}, elOption);
zrUtil.each(
['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS),
function (name) {
delete elOption[name];
}
);
return elOption;
} | [
"function",
"getCleanedElOption",
"(",
"elOption",
")",
"{",
"elOption",
"=",
"zrUtil",
".",
"extend",
"(",
"{",
"}",
",",
"elOption",
")",
";",
"zrUtil",
".",
"each",
"(",
"[",
"'id'",
",",
"'parentId'",
",",
"'$action'",
",",
"'hv'",
",",
"'bounding'",
"]",
".",
"concat",
"(",
"layoutUtil",
".",
"LOCATION_PARAMS",
")",
",",
"function",
"(",
"name",
")",
"{",
"delete",
"elOption",
"[",
"name",
"]",
";",
"}",
")",
";",
"return",
"elOption",
";",
"}"
] | Remove unnecessary props to avoid potential problems. | [
"Remove",
"unnecessary",
"props",
"to",
"avoid",
"potential",
"problems",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/graphic.js#L439-L448 |
298 | apache/incubator-echarts | src/coord/axisTickLabelBuilder.js | makeLabelsByCustomizedCategoryInterval | function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick) {
var ordinalScale = axis.scale;
var labelFormatter = makeLabelFormatter(axis);
var result = [];
zrUtil.each(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;
} | javascript | function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick) {
var ordinalScale = axis.scale;
var labelFormatter = makeLabelFormatter(axis);
var result = [];
zrUtil.each(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;
} | [
"function",
"makeLabelsByCustomizedCategoryInterval",
"(",
"axis",
",",
"categoryInterval",
",",
"onlyTick",
")",
"{",
"var",
"ordinalScale",
"=",
"axis",
".",
"scale",
";",
"var",
"labelFormatter",
"=",
"makeLabelFormatter",
"(",
"axis",
")",
";",
"var",
"result",
"=",
"[",
"]",
";",
"zrUtil",
".",
"each",
"(",
"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",
";",
"}"
] | When interval is function, the result `false` means ignore the tick. It is time consuming for large category data. | [
"When",
"interval",
"is",
"function",
"the",
"result",
"false",
"means",
"ignore",
"the",
"tick",
".",
"It",
"is",
"time",
"consuming",
"for",
"large",
"category",
"data",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/axisTickLabelBuilder.js#L345-L365 |
299 | apache/incubator-echarts | src/component/axis/AngleAxisView.js | fixAngleOverlap | function fixAngleOverlap(list) {
var firstItem = list[0];
var lastItem = list[list.length - 1];
if (firstItem
&& lastItem
&& Math.abs(Math.abs(firstItem.coord - lastItem.coord) - 360) < 1e-4
) {
list.pop();
}
} | javascript | function fixAngleOverlap(list) {
var firstItem = list[0];
var lastItem = list[list.length - 1];
if (firstItem
&& lastItem
&& Math.abs(Math.abs(firstItem.coord - lastItem.coord) - 360) < 1e-4
) {
list.pop();
}
} | [
"function",
"fixAngleOverlap",
"(",
"list",
")",
"{",
"var",
"firstItem",
"=",
"list",
"[",
"0",
"]",
";",
"var",
"lastItem",
"=",
"list",
"[",
"list",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"firstItem",
"&&",
"lastItem",
"&&",
"Math",
".",
"abs",
"(",
"Math",
".",
"abs",
"(",
"firstItem",
".",
"coord",
"-",
"lastItem",
".",
"coord",
")",
"-",
"360",
")",
"<",
"1e-4",
")",
"{",
"list",
".",
"pop",
"(",
")",
";",
"}",
"}"
] | Remove the last tick which will overlap the first tick | [
"Remove",
"the",
"last",
"tick",
"which",
"will",
"overlap",
"the",
"first",
"tick"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/axis/AngleAxisView.js#L47-L56 |