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
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
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
train
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
train
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", "]", ";", "var", "alpha", "=", "normalize", "(", "value", ")", ";", "ctx", ".", "globalAlpha", "=", "alpha", ";", "ctx", ".", "drawImage", "(", "brush", ",", "x", "-", "r", ",", "y", "-", "r", ")", ";", "}", "if", "(", "!", "canvas", ".", "width", "||", "!", "canvas", ".", "height", ")", "{", "return", "canvas", ";", "}", "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", ";", "if", "(", "alpha", ">", "0", ")", "{", "var", "gradient", "=", "isInRange", "(", "alpha", ")", "?", "gradientInRange", ":", "gradientOutOfRange", ";", "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
train
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", "(", ")", ")", ";", "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", ")", ";", "ctx", ".", "shadowOffsetX", "=", "d", ";", "ctx", ".", "shadowBlur", "=", "this", ".", "blurSize", ";", "ctx", ".", "shadowColor", "=", "'#000'", ";", "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
train
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
train
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
train
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
train
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", ")", "{", "var", "remainEdges", "=", "[", "]", ";", "var", "indegreeArr", "=", "[", "]", ";", "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", ";", "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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", ")", "{", "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
train
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", ")", "{", "opt", "=", "opt", "||", "EMPTY_OBJ", ";", "if", "(", "opt", ".", "isRectText", ")", "{", "var", "textPosition", "=", "textStyleModel", ".", "getShallow", "(", "'position'", ")", "||", "(", "isEmphasis", "?", "null", ":", "'inside'", ")", ";", "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", ";", "var", "richItemNames", "=", "getRichItemNames", "(", "textStyleModel", ")", ";", "var", "richResult", ";", "if", "(", "richItemNames", ")", "{", "richResult", "=", "{", "}", ";", "for", "(", "var", "name", "in", "richItemNames", ")", "{", "if", "(", "richItemNames", ".", "hasOwnProperty", "(", "name", ")", ")", "{", "var", "richTextStyle", "=", "textStyleModel", ".", "getModel", "(", "[", "'rich'", ",", "name", "]", ")", ";", "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
train
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", ";", "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", "&&", "typeof", "textPosition", "===", "'string'", "&&", "textPosition", ".", "indexOf", "(", "'inside'", ")", ">=", "0", ")", ")", ")", "{", "insideRollback", "=", "{", "textFill", ":", "null", ",", "textStroke", ":", "textStyle", ".", "textStroke", ",", "textStrokeWidth", ":", "textStyle", ".", "textStrokeWidth", "}", ";", "textStyle", ".", "textFill", "=", "'#fff'", ";", "if", "(", "textStyle", ".", "textStroke", "==", "null", ")", "{", "textStyle", ".", "textStroke", "=", "autoColor", ";", "textStyle", ".", "textStrokeWidth", "==", "null", "&&", "(", "textStyle", ".", "textStrokeWidth", "=", "2", ")", ";", "}", "}", "else", "if", "(", "autoColor", "!=", "null", ")", "{", "insideRollback", "=", "{", "textFill", ":", "null", "}", ";", "textStyle", ".", "textFill", "=", "autoColor", ";", "}", "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
train
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
train
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", ";", "}", ")", ")", ";", "}", ")", ";", "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'", ")", ")", ";", "}", ")", ";", "\\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
train
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'", ")", ";", "}", ")", ".", "\\n", "join", ";", "}" ]
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
train
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", ")", "{", "var", "firstLine", "=", "block", ".", "slice", "(", "0", ",", "block", ".", "indexOf", "(", "'\\n'", ")", ")", ";", "\\n", "}" ]
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
train
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", ")", ";", "transferProperties", "(", "list", ",", "original", ")", ";", "var", "storage", "=", "list", ".", "_storage", "=", "{", "}", ";", "var", "originalStorage", "=", "original", ".", "_storage", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "allDimensions", ".", "length", ";", "i", "++", ")", "{", "var", "dim", "=", "allDimensions", "[", "i", "]", ";", "if", "(", "originalStorage", "[", "dim", "]", ")", "{", "if", "(", "zrUtil", ".", "indexOf", "(", "excludeDimensions", ",", "dim", ")", ">=", "0", ")", "{", "storage", "[", "dim", "]", "=", "cloneDimStore", "(", "originalStorage", "[", "dim", "]", ")", ";", "list", ".", "_rawExtent", "[", "dim", "]", "=", "getInitialExtent", "(", ")", ";", "list", ".", "_extent", "[", "dim", "]", "=", "null", ";", "}", "else", "{", "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
train
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
train
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
train
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", "(", ")", "{", "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
train
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
train
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", ";", "if", "(", "node", "!==", "virtualRoot", ")", "{", "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", "}", ")", ";", "}", "if", "(", "node", ".", "children", "&&", "node", ".", "children", ".", "length", ")", "{", "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
train
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", ")", ";", "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
train
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
train
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", ";", "if", "(", "hideChildren", "&&", "!", "overLeafDepth", ")", "{", "return", "(", "node", ".", "viewChildren", "=", "[", "]", ")", ";", "}", "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", "=", "[", "]", ")", ";", "}", "for", "(", "var", "i", "=", "0", ",", "len", "=", "viewChildren", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "area", "=", "viewChildren", "[", "i", "]", ".", "getValue", "(", ")", "/", "info", ".", "sum", "*", "totalArea", ";", "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
train
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", ")", "{", "if", "(", "!", "orderBy", ")", "{", "return", "sum", ";", "}", "var", "visibleMin", "=", "nodeModel", ".", "get", "(", "'visibleMin'", ")", ";", "var", "len", "=", "orderedChildren", ".", "length", ";", "var", "deletePoint", "=", "len", ";", "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
train
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", ")", "{", "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", "]", "]", ";", "}", "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", ")", ";", "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
train
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", ";", "}", "var", "targetNode", "=", "targetInfo", ".", "node", ";", "var", "layout", "=", "targetNode", ".", "getLayout", "(", ")", ";", "if", "(", "!", "layout", ")", "{", "return", "defaultPosition", ";", "}", "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
train
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", ":", "true", ",", "invisible", ":", "!", "isAboveViewRoot", "&&", "!", "clipRect", ".", "intersect", "(", "nodeLayout", ")", ",", "isAboveViewRoot", ":", "isAboveViewRoot", "}", ",", "true", ")", ";", "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
train
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
train
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
train
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", "&&", "!", "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
train
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'", ")", ";", "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
train
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
train
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
train
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
train
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
train
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", "(", "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
train
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
train
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", ")", ")", ";", "}", "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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", ")", "{", "var", "dimType", "=", "dimInfo", "&&", "dimInfo", ".", "type", ";", "if", "(", "dimType", "===", "'ordinal'", ")", "{", "var", "ordinalMeta", "=", "dimInfo", "&&", "dimInfo", ".", "ordinalMeta", ";", "return", "ordinalMeta", "?", "ordinalMeta", ".", "parseAndCollect", "(", "value", ")", ":", "value", ";", "}", "if", "(", "dimType", "===", "'time'", "&&", "typeof", "value", "!==", "'number'", "&&", "value", "!=", "null", "&&", "value", "!==", "'-'", ")", "{", "value", "=", "+", "parseDate", "(", "value", ")", ";", "}", "return", "(", "value", "==", "null", "||", "value", "===", "''", ")", "?", "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
train
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", "{", "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
train
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", ",", "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
train
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
train
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
train
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'", ",", "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
train
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'", "]", ";", "if", "(", "rangePropMode", "[", "idx", "]", "===", "'percent'", ")", "{", "boundPercent", "==", "null", "&&", "(", "boundPercent", "=", "percentExtent", "[", "idx", "]", ")", ";", "boundValue", "=", "scale", ".", "parse", "(", "numberUtil", ".", "linearMap", "(", "boundPercent", ",", "percentExtent", ",", "dataExtent", ")", ")", ";", "}", "else", "{", "hasPropModeValue", "=", "true", ";", "boundValue", "=", "boundValue", "==", "null", "?", "dataExtent", "[", "idx", "]", ":", "scale", ".", "parse", "(", "boundValue", ")", ";", "boundPercent", "=", "numberUtil", ".", "linearMap", "(", "boundValue", ",", "dataExtent", ",", "percentExtent", ")", ";", "}", "valueWindow", "[", "idx", "]", "=", "boundValue", ";", "percentWindow", "[", "idx", "]", "=", "boundPercent", ";", "}", ")", ";", "asc", "(", "valueWindow", ")", ";", "asc", "(", "percentWindow", ")", ";", "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
train
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", ")", "{", "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
train
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", ")", "{", "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", ";", "updateHoverLayerStatus", "(", "ecIns", ".", "_zr", ",", "ecModel", ")", ";", "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
train
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", ")", "{", "if", "(", "!", "el", ".", "isGroup", ")", "{", "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
train
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", ";", "var", "layerSeries", "=", "seriesModel", ".", "getLayerSeries", "(", ")", ";", "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", ";", "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
train
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
train
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", ")", "{", "this", ".", "_oldTree", ";", "this", ".", "_mainGroup", "=", "new", "graphic", ".", "Group", "(", ")", ";", "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
train
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", ";", "var", "maxLoop", "=", "5", ";", "if", "(", "isTypedArray", "(", "data", ")", ")", "{", "return", "false", ";", "}", "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", ")", "{", "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
train
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
train
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
train
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", ")", ";", "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
train
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", ")", "{", "var", "visualColor", "=", "node", ".", "getVisual", "(", "'color'", ")", ";", "var", "visualMetaList", "=", "node", ".", "getVisual", "(", "'visualMeta'", ")", ";", "if", "(", "!", "visualMetaList", "||", "visualMetaList", ".", "length", "===", "0", ")", "{", "visualColor", "=", "null", ";", "}", "var", "color", "=", "node", ".", "getModel", "(", "'itemStyle'", ")", ".", "get", "(", "'color'", ")", ";", "if", "(", "color", ")", "{", "return", "color", ";", "}", "else", "if", "(", "visualColor", ")", "{", "return", "visualColor", ";", "}", "else", "if", "(", "node", ".", "depth", "===", "0", ")", "{", "return", "ecModel", ".", "option", ".", "color", "[", "0", "]", ";", "}", "else", "{", "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
train
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
train
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
train
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", ";", "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", ")", "{", "if", "(", "elOption", ".", "hv", "&&", "elOption", ".", "hv", "[", "1", "]", ")", "{", "elOptionStyle", ".", "textVerticalAlign", "=", "elOptionStyle", ".", "textBaseline", "=", "null", ";", "}", "!", "elOptionStyle", ".", "hasOwnProperty", "(", "'textFill'", ")", "&&", "elOptionStyle", ".", "fill", "&&", "(", "elOptionStyle", ".", "textFill", "=", "elOptionStyle", ".", "fill", ")", ";", "!", "elOptionStyle", ".", "hasOwnProperty", "(", "'textStroke'", ")", "&&", "elOptionStyle", ".", "stroke", "&&", "(", "elOptionStyle", ".", "textStroke", "=", "elOptionStyle", ".", "stroke", ")", ";", "}", "var", "elOptionCleaned", "=", "getCleanedElOption", "(", "elOption", ")", ";", "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
train
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", ";", "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", "(", ")", "}", ":", "{", "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
train
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
train
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
train
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
train
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
train
apache/incubator-echarts
src/component/axis/AxisBuilder.js
function (axisModel, opt) { /** * @readOnly */ this.opt = opt; /** * @readOnly */ this.axisModel = axisModel; // Default value defaults( opt, { labelOffset: 0, nameDirection: 1, tickDirection: 1, labelDirection: 1, silent: true } ); /** * @readOnly */ this.group = new graphic.Group(); // FIXME Not use a seperate text group? var dumbGroup = new graphic.Group({ position: opt.position.slice(), rotation: opt.rotation }); // this.group.add(dumbGroup); // this._dumbGroup = dumbGroup; dumbGroup.updateTransform(); this._transform = dumbGroup.transform; this._dumbGroup = dumbGroup; }
javascript
function (axisModel, opt) { /** * @readOnly */ this.opt = opt; /** * @readOnly */ this.axisModel = axisModel; // Default value defaults( opt, { labelOffset: 0, nameDirection: 1, tickDirection: 1, labelDirection: 1, silent: true } ); /** * @readOnly */ this.group = new graphic.Group(); // FIXME Not use a seperate text group? var dumbGroup = new graphic.Group({ position: opt.position.slice(), rotation: opt.rotation }); // this.group.add(dumbGroup); // this._dumbGroup = dumbGroup; dumbGroup.updateTransform(); this._transform = dumbGroup.transform; this._dumbGroup = dumbGroup; }
[ "function", "(", "axisModel", ",", "opt", ")", "{", "this", ".", "opt", "=", "opt", ";", "this", ".", "axisModel", "=", "axisModel", ";", "defaults", "(", "opt", ",", "{", "labelOffset", ":", "0", ",", "nameDirection", ":", "1", ",", "tickDirection", ":", "1", ",", "labelDirection", ":", "1", ",", "silent", ":", "true", "}", ")", ";", "this", ".", "group", "=", "new", "graphic", ".", "Group", "(", ")", ";", "var", "dumbGroup", "=", "new", "graphic", ".", "Group", "(", "{", "position", ":", "opt", ".", "position", ".", "slice", "(", ")", ",", "rotation", ":", "opt", ".", "rotation", "}", ")", ";", "dumbGroup", ".", "updateTransform", "(", ")", ";", "this", ".", "_transform", "=", "dumbGroup", ".", "transform", ";", "this", ".", "_dumbGroup", "=", "dumbGroup", ";", "}" ]
A final axis is translated and rotated from a "standard axis". So opt.position and opt.rotation is required. A standard axis is and axis from [0, 0] to [0, axisExtent[1]], for example: (0, 0) ------------> (0, 50) nameDirection or tickDirection or labelDirection is 1 means tick or label is below the standard axis, whereas is -1 means above the standard axis. labelOffset means offset between label and axis, which is useful when 'onZero', where axisLabel is in the grid and label in outside grid. Tips: like always, positive rotation represents anticlockwise, and negative rotation represents clockwise. The direction of position coordinate is the same as the direction of screen coordinate. Do not need to consider axis 'inverse', which is auto processed by axis extent. @param {module:zrender/container/Group} group @param {Object} axisModel @param {Object} opt Standard axis parameters. @param {Array.<number>} opt.position [x, y] @param {number} opt.rotation by radian @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle' or 'center'. @param {number} [opt.tickDirection=1] 1 or -1 @param {number} [opt.labelDirection=1] 1 or -1 @param {number} [opt.labelOffset=0] Usefull when onZero. @param {string} [opt.axisLabelShow] default get from axisModel. @param {string} [opt.axisName] default get from axisModel. @param {number} [opt.axisNameAvailableWidth] @param {number} [opt.labelRotate] by degree, default get from axisModel. @param {number} [opt.strokeContainThreshold] Default label interval when label @param {number} [opt.nameTruncateMaxWidth]
[ "A", "final", "axis", "is", "translated", "and", "rotated", "from", "a", "standard", "axis", ".", "So", "opt", ".", "position", "and", "opt", ".", "rotation", "is", "required", "." ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/axis/AxisBuilder.js#L71-L113
train
apache/incubator-echarts
src/component/tooltip/TooltipContent.js
function () { // FIXME // Move this logic to ec main? var container = this._container; var stl = container.currentStyle || document.defaultView.getComputedStyle(container); var domStyle = container.style; if (domStyle.position !== 'absolute' && stl.position !== 'absolute') { domStyle.position = 'relative'; } // Hide the tooltip // PENDING // this.hide(); }
javascript
function () { // FIXME // Move this logic to ec main? var container = this._container; var stl = container.currentStyle || document.defaultView.getComputedStyle(container); var domStyle = container.style; if (domStyle.position !== 'absolute' && stl.position !== 'absolute') { domStyle.position = 'relative'; } // Hide the tooltip // PENDING // this.hide(); }
[ "function", "(", ")", "{", "var", "container", "=", "this", ".", "_container", ";", "var", "stl", "=", "container", ".", "currentStyle", "||", "document", ".", "defaultView", ".", "getComputedStyle", "(", "container", ")", ";", "var", "domStyle", "=", "container", ".", "style", ";", "if", "(", "domStyle", ".", "position", "!==", "'absolute'", "&&", "stl", ".", "position", "!==", "'absolute'", ")", "{", "domStyle", ".", "position", "=", "'relative'", ";", "}", "}" ]
Update when tooltip is rendered
[ "Update", "when", "tooltip", "is", "rendered" ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/tooltip/TooltipContent.js#L194-L207
train
apache/incubator-echarts
src/data/helper/linkList.js
getLinkedData
function getLinkedData(dataType) { var mainData = this[MAIN_DATA]; return (dataType == null || mainData == null) ? mainData : mainData[DATAS][dataType]; }
javascript
function getLinkedData(dataType) { var mainData = this[MAIN_DATA]; return (dataType == null || mainData == null) ? mainData : mainData[DATAS][dataType]; }
[ "function", "getLinkedData", "(", "dataType", ")", "{", "var", "mainData", "=", "this", "[", "MAIN_DATA", "]", ";", "return", "(", "dataType", "==", "null", "||", "mainData", "==", "null", ")", "?", "mainData", ":", "mainData", "[", "DATAS", "]", "[", "dataType", "]", ";", "}" ]
Supplement method to List. @public @param {string} [dataType] If not specified, return mainData. @return {module:echarts/data/List}
[ "Supplement", "method", "to", "List", "." ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/helper/linkList.js#L119-L124
train
apache/incubator-echarts
src/component/dataZoom/dataZoomProcessor.js
function (ecModel, api) { ecModel.eachComponent('dataZoom', function (dataZoomModel) { // We calculate window and reset axis here but not in model // init stage and not after action dispatch handler, because // reset should be called after seriesData.restoreData. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel, api); }); // Caution: data zoom filtering is order sensitive when using // percent range and no min/max/scale set on axis. // For example, we have dataZoom definition: // [ // {xAxisIndex: 0, start: 30, end: 70}, // {yAxisIndex: 0, start: 20, end: 80} // ] // In this case, [20, 80] of y-dataZoom should be based on data // that have filtered by x-dataZoom using range of [30, 70], // but should not be based on full raw data. Thus sliding // x-dataZoom will change both ranges of xAxis and yAxis, // while sliding y-dataZoom will only change the range of yAxis. // So we should filter x-axis after reset x-axis immediately, // and then reset y-axis and filter y-axis. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel, api); }); }); ecModel.eachComponent('dataZoom', function (dataZoomModel) { // Fullfill all of the range props so that user // is able to get them from chart.getOption(). var axisProxy = dataZoomModel.findRepresentativeAxisProxy(); var percentRange = axisProxy.getDataPercentWindow(); var valueRange = axisProxy.getDataValueWindow(); dataZoomModel.setRawRange({ start: percentRange[0], end: percentRange[1], startValue: valueRange[0], endValue: valueRange[1] }, true); }); }
javascript
function (ecModel, api) { ecModel.eachComponent('dataZoom', function (dataZoomModel) { // We calculate window and reset axis here but not in model // init stage and not after action dispatch handler, because // reset should be called after seriesData.restoreData. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel, api); }); // Caution: data zoom filtering is order sensitive when using // percent range and no min/max/scale set on axis. // For example, we have dataZoom definition: // [ // {xAxisIndex: 0, start: 30, end: 70}, // {yAxisIndex: 0, start: 20, end: 80} // ] // In this case, [20, 80] of y-dataZoom should be based on data // that have filtered by x-dataZoom using range of [30, 70], // but should not be based on full raw data. Thus sliding // x-dataZoom will change both ranges of xAxis and yAxis, // while sliding y-dataZoom will only change the range of yAxis. // So we should filter x-axis after reset x-axis immediately, // and then reset y-axis and filter y-axis. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel, api); }); }); ecModel.eachComponent('dataZoom', function (dataZoomModel) { // Fullfill all of the range props so that user // is able to get them from chart.getOption(). var axisProxy = dataZoomModel.findRepresentativeAxisProxy(); var percentRange = axisProxy.getDataPercentWindow(); var valueRange = axisProxy.getDataValueWindow(); dataZoomModel.setRawRange({ start: percentRange[0], end: percentRange[1], startValue: valueRange[0], endValue: valueRange[1] }, true); }); }
[ "function", "(", "ecModel", ",", "api", ")", "{", "ecModel", ".", "eachComponent", "(", "'dataZoom'", ",", "function", "(", "dataZoomModel", ")", "{", "dataZoomModel", ".", "eachTargetAxis", "(", "function", "(", "dimNames", ",", "axisIndex", ",", "dataZoomModel", ")", "{", "dataZoomModel", ".", "getAxisProxy", "(", "dimNames", ".", "name", ",", "axisIndex", ")", ".", "reset", "(", "dataZoomModel", ",", "api", ")", ";", "}", ")", ";", "dataZoomModel", ".", "eachTargetAxis", "(", "function", "(", "dimNames", ",", "axisIndex", ",", "dataZoomModel", ")", "{", "dataZoomModel", ".", "getAxisProxy", "(", "dimNames", ".", "name", ",", "axisIndex", ")", ".", "filterData", "(", "dataZoomModel", ",", "api", ")", ";", "}", ")", ";", "}", ")", ";", "ecModel", ".", "eachComponent", "(", "'dataZoom'", ",", "function", "(", "dataZoomModel", ")", "{", "var", "axisProxy", "=", "dataZoomModel", ".", "findRepresentativeAxisProxy", "(", ")", ";", "var", "percentRange", "=", "axisProxy", ".", "getDataPercentWindow", "(", ")", ";", "var", "valueRange", "=", "axisProxy", ".", "getDataValueWindow", "(", ")", ";", "dataZoomModel", ".", "setRawRange", "(", "{", "start", ":", "percentRange", "[", "0", "]", ",", "end", ":", "percentRange", "[", "1", "]", ",", "startValue", ":", "valueRange", "[", "0", "]", ",", "endValue", ":", "valueRange", "[", "1", "]", "}", ",", "true", ")", ";", "}", ")", ";", "}" ]
Consider appendData, where filter should be performed. Because data process is in block mode currently, it is not need to worry about that the overallProgress execute every frame.
[ "Consider", "appendData", "where", "filter", "should", "be", "performed", ".", "Because", "data", "process", "is", "in", "block", "mode", "currently", "it", "is", "not", "need", "to", "worry", "about", "that", "the", "overallProgress", "execute", "every", "frame", "." ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/dataZoom/dataZoomProcessor.js#L48-L91
train
apache/incubator-echarts
src/coord/polar/Polar.js
function (point) { var coord = this.pointToCoord(point); return this._radiusAxis.contain(coord[0]) && this._angleAxis.contain(coord[1]); }
javascript
function (point) { var coord = this.pointToCoord(point); return this._radiusAxis.contain(coord[0]) && this._angleAxis.contain(coord[1]); }
[ "function", "(", "point", ")", "{", "var", "coord", "=", "this", ".", "pointToCoord", "(", "point", ")", ";", "return", "this", ".", "_radiusAxis", ".", "contain", "(", "coord", "[", "0", "]", ")", "&&", "this", ".", "_angleAxis", ".", "contain", "(", "coord", "[", "1", "]", ")", ";", "}" ]
If contain coord @param {Array.<number>} point @return {boolean}
[ "If", "contain", "coord" ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/Polar.js#L90-L94
train
apache/incubator-echarts
src/coord/polar/Polar.js
function (scaleType) { var axes = []; var angleAxis = this._angleAxis; var radiusAxis = this._radiusAxis; angleAxis.scale.type === scaleType && axes.push(angleAxis); radiusAxis.scale.type === scaleType && axes.push(radiusAxis); return axes; }
javascript
function (scaleType) { var axes = []; var angleAxis = this._angleAxis; var radiusAxis = this._radiusAxis; angleAxis.scale.type === scaleType && axes.push(angleAxis); radiusAxis.scale.type === scaleType && axes.push(radiusAxis); return axes; }
[ "function", "(", "scaleType", ")", "{", "var", "axes", "=", "[", "]", ";", "var", "angleAxis", "=", "this", ".", "_angleAxis", ";", "var", "radiusAxis", "=", "this", ".", "_radiusAxis", ";", "angleAxis", ".", "scale", ".", "type", "===", "scaleType", "&&", "axes", ".", "push", "(", "angleAxis", ")", ";", "radiusAxis", ".", "scale", ".", "type", "===", "scaleType", "&&", "axes", ".", "push", "(", "radiusAxis", ")", ";", "return", "axes", ";", "}" ]
Get axes by type of scale @param {string} scaleType @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
[ "Get", "axes", "by", "type", "of", "scale" ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/Polar.js#L126-L134
train
apache/incubator-echarts
src/chart/line/poly.js
drawNonMono
function drawNonMono( ctx, points, start, segLen, allLen, dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls ) { var prevIdx = 0; var idx = start; for (var k = 0; k < segLen; k++) { var p = points[idx]; if (idx >= allLen || idx < 0) { break; } if (isPointNull(p)) { if (connectNulls) { idx += dir; continue; } break; } if (idx === start) { ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); v2Copy(cp0, p); } else { if (smooth > 0) { var nextIdx = idx + dir; var nextP = points[nextIdx]; if (connectNulls) { // Find next point not null while (nextP && isPointNull(points[nextIdx])) { nextIdx += dir; nextP = points[nextIdx]; } } var ratioNextSeg = 0.5; var prevP = points[prevIdx]; var nextP = points[nextIdx]; // Last point if (!nextP || isPointNull(nextP)) { v2Copy(cp1, p); } else { // If next data is null in not connect case if (isPointNull(nextP) && !connectNulls) { nextP = p; } vec2.sub(v, nextP, prevP); var lenPrevSeg; var lenNextSeg; if (smoothMonotone === 'x' || smoothMonotone === 'y') { var dim = smoothMonotone === 'x' ? 0 : 1; lenPrevSeg = Math.abs(p[dim] - prevP[dim]); lenNextSeg = Math.abs(p[dim] - nextP[dim]); } else { lenPrevSeg = vec2.dist(p, prevP); lenNextSeg = vec2.dist(p, nextP); } // Use ratio of seg length ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); } // Smooth constraint vec2Min(cp0, cp0, smoothMax); vec2Max(cp0, cp0, smoothMin); vec2Min(cp1, cp1, smoothMax); vec2Max(cp1, cp1, smoothMin); ctx.bezierCurveTo( cp0[0], cp0[1], cp1[0], cp1[1], p[0], p[1] ); // cp0 of next segment scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); } else { ctx.lineTo(p[0], p[1]); } } prevIdx = idx; idx += dir; } return k; }
javascript
function drawNonMono( ctx, points, start, segLen, allLen, dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls ) { var prevIdx = 0; var idx = start; for (var k = 0; k < segLen; k++) { var p = points[idx]; if (idx >= allLen || idx < 0) { break; } if (isPointNull(p)) { if (connectNulls) { idx += dir; continue; } break; } if (idx === start) { ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); v2Copy(cp0, p); } else { if (smooth > 0) { var nextIdx = idx + dir; var nextP = points[nextIdx]; if (connectNulls) { // Find next point not null while (nextP && isPointNull(points[nextIdx])) { nextIdx += dir; nextP = points[nextIdx]; } } var ratioNextSeg = 0.5; var prevP = points[prevIdx]; var nextP = points[nextIdx]; // Last point if (!nextP || isPointNull(nextP)) { v2Copy(cp1, p); } else { // If next data is null in not connect case if (isPointNull(nextP) && !connectNulls) { nextP = p; } vec2.sub(v, nextP, prevP); var lenPrevSeg; var lenNextSeg; if (smoothMonotone === 'x' || smoothMonotone === 'y') { var dim = smoothMonotone === 'x' ? 0 : 1; lenPrevSeg = Math.abs(p[dim] - prevP[dim]); lenNextSeg = Math.abs(p[dim] - nextP[dim]); } else { lenPrevSeg = vec2.dist(p, prevP); lenNextSeg = vec2.dist(p, nextP); } // Use ratio of seg length ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); } // Smooth constraint vec2Min(cp0, cp0, smoothMax); vec2Max(cp0, cp0, smoothMin); vec2Min(cp1, cp1, smoothMax); vec2Max(cp1, cp1, smoothMin); ctx.bezierCurveTo( cp0[0], cp0[1], cp1[0], cp1[1], p[0], p[1] ); // cp0 of next segment scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); } else { ctx.lineTo(p[0], p[1]); } } prevIdx = idx; idx += dir; } return k; }
[ "function", "drawNonMono", "(", "ctx", ",", "points", ",", "start", ",", "segLen", ",", "allLen", ",", "dir", ",", "smoothMin", ",", "smoothMax", ",", "smooth", ",", "smoothMonotone", ",", "connectNulls", ")", "{", "var", "prevIdx", "=", "0", ";", "var", "idx", "=", "start", ";", "for", "(", "var", "k", "=", "0", ";", "k", "<", "segLen", ";", "k", "++", ")", "{", "var", "p", "=", "points", "[", "idx", "]", ";", "if", "(", "idx", ">=", "allLen", "||", "idx", "<", "0", ")", "{", "break", ";", "}", "if", "(", "isPointNull", "(", "p", ")", ")", "{", "if", "(", "connectNulls", ")", "{", "idx", "+=", "dir", ";", "continue", ";", "}", "break", ";", "}", "if", "(", "idx", "===", "start", ")", "{", "ctx", "[", "dir", ">", "0", "?", "'moveTo'", ":", "'lineTo'", "]", "(", "p", "[", "0", "]", ",", "p", "[", "1", "]", ")", ";", "v2Copy", "(", "cp0", ",", "p", ")", ";", "}", "else", "{", "if", "(", "smooth", ">", "0", ")", "{", "var", "nextIdx", "=", "idx", "+", "dir", ";", "var", "nextP", "=", "points", "[", "nextIdx", "]", ";", "if", "(", "connectNulls", ")", "{", "while", "(", "nextP", "&&", "isPointNull", "(", "points", "[", "nextIdx", "]", ")", ")", "{", "nextIdx", "+=", "dir", ";", "nextP", "=", "points", "[", "nextIdx", "]", ";", "}", "}", "var", "ratioNextSeg", "=", "0.5", ";", "var", "prevP", "=", "points", "[", "prevIdx", "]", ";", "var", "nextP", "=", "points", "[", "nextIdx", "]", ";", "if", "(", "!", "nextP", "||", "isPointNull", "(", "nextP", ")", ")", "{", "v2Copy", "(", "cp1", ",", "p", ")", ";", "}", "else", "{", "if", "(", "isPointNull", "(", "nextP", ")", "&&", "!", "connectNulls", ")", "{", "nextP", "=", "p", ";", "}", "vec2", ".", "sub", "(", "v", ",", "nextP", ",", "prevP", ")", ";", "var", "lenPrevSeg", ";", "var", "lenNextSeg", ";", "if", "(", "smoothMonotone", "===", "'x'", "||", "smoothMonotone", "===", "'y'", ")", "{", "var", "dim", "=", "smoothMonotone", "===", "'x'", "?", "0", ":", "1", ";", "lenPrevSeg", "=", "Math", ".", "abs", "(", "p", "[", "dim", "]", "-", "prevP", "[", "dim", "]", ")", ";", "lenNextSeg", "=", "Math", ".", "abs", "(", "p", "[", "dim", "]", "-", "nextP", "[", "dim", "]", ")", ";", "}", "else", "{", "lenPrevSeg", "=", "vec2", ".", "dist", "(", "p", ",", "prevP", ")", ";", "lenNextSeg", "=", "vec2", ".", "dist", "(", "p", ",", "nextP", ")", ";", "}", "ratioNextSeg", "=", "lenNextSeg", "/", "(", "lenNextSeg", "+", "lenPrevSeg", ")", ";", "scaleAndAdd", "(", "cp1", ",", "p", ",", "v", ",", "-", "smooth", "*", "(", "1", "-", "ratioNextSeg", ")", ")", ";", "}", "vec2Min", "(", "cp0", ",", "cp0", ",", "smoothMax", ")", ";", "vec2Max", "(", "cp0", ",", "cp0", ",", "smoothMin", ")", ";", "vec2Min", "(", "cp1", ",", "cp1", ",", "smoothMax", ")", ";", "vec2Max", "(", "cp1", ",", "cp1", ",", "smoothMin", ")", ";", "ctx", ".", "bezierCurveTo", "(", "cp0", "[", "0", "]", ",", "cp0", "[", "1", "]", ",", "cp1", "[", "0", "]", ",", "cp1", "[", "1", "]", ",", "p", "[", "0", "]", ",", "p", "[", "1", "]", ")", ";", "scaleAndAdd", "(", "cp0", ",", "p", ",", "v", ",", "smooth", "*", "ratioNextSeg", ")", ";", "}", "else", "{", "ctx", ".", "lineTo", "(", "p", "[", "0", "]", ",", "p", "[", "1", "]", ")", ";", "}", "}", "prevIdx", "=", "idx", ";", "idx", "+=", "dir", ";", "}", "return", "k", ";", "}" ]
Draw smoothed line in non-monotone, in may cause undesired curve in extreme situations. This should be used when points are non-monotone neither in x or y dimension.
[ "Draw", "smoothed", "line", "in", "non", "-", "monotone", "in", "may", "cause", "undesired", "curve", "in", "extreme", "situations", ".", "This", "should", "be", "used", "when", "points", "are", "non", "-", "monotone", "neither", "in", "x", "or", "y", "dimension", "." ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/line/poly.js#L171-L262
train
apache/incubator-echarts
src/component/visualMap/visualEncoding.js
getColorVisual
function getColorVisual(seriesModel, visualMapModel, value, valueState) { var mappings = visualMapModel.targetVisuals[valueState]; var visualTypes = VisualMapping.prepareVisualTypes(mappings); var resultVisual = { color: seriesModel.getData().getVisual('color') // default color. }; for (var i = 0, len = visualTypes.length; i < len; i++) { var type = visualTypes[i]; var mapping = mappings[ type === 'opacity' ? '__alphaForOpacity' : type ]; mapping && mapping.applyVisual(value, getVisual, setVisual); } return resultVisual.color; function getVisual(key) { return resultVisual[key]; } function setVisual(key, value) { resultVisual[key] = value; } }
javascript
function getColorVisual(seriesModel, visualMapModel, value, valueState) { var mappings = visualMapModel.targetVisuals[valueState]; var visualTypes = VisualMapping.prepareVisualTypes(mappings); var resultVisual = { color: seriesModel.getData().getVisual('color') // default color. }; for (var i = 0, len = visualTypes.length; i < len; i++) { var type = visualTypes[i]; var mapping = mappings[ type === 'opacity' ? '__alphaForOpacity' : type ]; mapping && mapping.applyVisual(value, getVisual, setVisual); } return resultVisual.color; function getVisual(key) { return resultVisual[key]; } function setVisual(key, value) { resultVisual[key] = value; } }
[ "function", "getColorVisual", "(", "seriesModel", ",", "visualMapModel", ",", "value", ",", "valueState", ")", "{", "var", "mappings", "=", "visualMapModel", ".", "targetVisuals", "[", "valueState", "]", ";", "var", "visualTypes", "=", "VisualMapping", ".", "prepareVisualTypes", "(", "mappings", ")", ";", "var", "resultVisual", "=", "{", "color", ":", "seriesModel", ".", "getData", "(", ")", ".", "getVisual", "(", "'color'", ")", "}", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "visualTypes", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "type", "=", "visualTypes", "[", "i", "]", ";", "var", "mapping", "=", "mappings", "[", "type", "===", "'opacity'", "?", "'__alphaForOpacity'", ":", "type", "]", ";", "mapping", "&&", "mapping", ".", "applyVisual", "(", "value", ",", "getVisual", ",", "setVisual", ")", ";", "}", "return", "resultVisual", ".", "color", ";", "function", "getVisual", "(", "key", ")", "{", "return", "resultVisual", "[", "key", "]", ";", "}", "function", "setVisual", "(", "key", ",", "value", ")", "{", "resultVisual", "[", "key", "]", "=", "value", ";", "}", "}" ]
FIXME performance and export for heatmap? value can be Infinity or -Infinity
[ "FIXME", "performance", "and", "export", "for", "heatmap?", "value", "can", "be", "Infinity", "or", "-", "Infinity" ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/visualMap/visualEncoding.js#L82-L106
train
vuejs/vuex
dist/vuex.esm.js
vuexInit
function vuexInit () { var options = this.$options; // store injection if (options.store) { this.$store = typeof options.store === 'function' ? options.store() : options.store; } else if (options.parent && options.parent.$store) { this.$store = options.parent.$store; } }
javascript
function vuexInit () { var options = this.$options; // store injection if (options.store) { this.$store = typeof options.store === 'function' ? options.store() : options.store; } else if (options.parent && options.parent.$store) { this.$store = options.parent.$store; } }
[ "function", "vuexInit", "(", ")", "{", "var", "options", "=", "this", ".", "$options", ";", "if", "(", "options", ".", "store", ")", "{", "this", ".", "$store", "=", "typeof", "options", ".", "store", "===", "'function'", "?", "options", ".", "store", "(", ")", ":", "options", ".", "store", ";", "}", "else", "if", "(", "options", ".", "parent", "&&", "options", ".", "parent", ".", "$store", ")", "{", "this", ".", "$store", "=", "options", ".", "parent", ".", "$store", ";", "}", "}" ]
Vuex init hook, injected into each instances init hooks list.
[ "Vuex", "init", "hook", "injected", "into", "each", "instances", "init", "hooks", "list", "." ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/dist/vuex.esm.js#L29-L39
train
vuejs/vuex
dist/vuex.esm.js
forEachValue
function forEachValue (obj, fn) { Object.keys(obj).forEach(function (key) { return fn(obj[key], key); }); }
javascript
function forEachValue (obj, fn) { Object.keys(obj).forEach(function (key) { return fn(obj[key], key); }); }
[ "function", "forEachValue", "(", "obj", ",", "fn", ")", "{", "Object", ".", "keys", "(", "obj", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "return", "fn", "(", "obj", "[", "key", "]", ",", "key", ")", ";", "}", ")", ";", "}" ]
Get the first item that pass the test by second argument function @param {Array} list @param {Function} f @return {*} forEach for object
[ "Get", "the", "first", "item", "that", "pass", "the", "test", "by", "second", "argument", "function" ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/dist/vuex.esm.js#L74-L76
train
vuejs/vuex
dist/vuex.esm.js
Module
function Module (rawModule, runtime) { this.runtime = runtime; // Store some children item this._children = Object.create(null); // Store the origin module object which passed by programmer this._rawModule = rawModule; var rawState = rawModule.state; // Store the origin module's state this.state = (typeof rawState === 'function' ? rawState() : rawState) || {}; }
javascript
function Module (rawModule, runtime) { this.runtime = runtime; // Store some children item this._children = Object.create(null); // Store the origin module object which passed by programmer this._rawModule = rawModule; var rawState = rawModule.state; // Store the origin module's state this.state = (typeof rawState === 'function' ? rawState() : rawState) || {}; }
[ "function", "Module", "(", "rawModule", ",", "runtime", ")", "{", "this", ".", "runtime", "=", "runtime", ";", "this", ".", "_children", "=", "Object", ".", "create", "(", "null", ")", ";", "this", ".", "_rawModule", "=", "rawModule", ";", "var", "rawState", "=", "rawModule", ".", "state", ";", "this", ".", "state", "=", "(", "typeof", "rawState", "===", "'function'", "?", "rawState", "(", ")", ":", "rawState", ")", "||", "{", "}", ";", "}" ]
Base data struct for store's module, package with some attribute and method
[ "Base", "data", "struct", "for", "store", "s", "module", "package", "with", "some", "attribute", "and", "method" ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/dist/vuex.esm.js#L91-L101
train
vuejs/vuex
dist/vuex.esm.js
normalizeNamespace
function normalizeNamespace (fn) { return function (namespace, map) { if (typeof namespace !== 'string') { map = namespace; namespace = ''; } else if (namespace.charAt(namespace.length - 1) !== '/') { namespace += '/'; } return fn(namespace, map) } }
javascript
function normalizeNamespace (fn) { return function (namespace, map) { if (typeof namespace !== 'string') { map = namespace; namespace = ''; } else if (namespace.charAt(namespace.length - 1) !== '/') { namespace += '/'; } return fn(namespace, map) } }
[ "function", "normalizeNamespace", "(", "fn", ")", "{", "return", "function", "(", "namespace", ",", "map", ")", "{", "if", "(", "typeof", "namespace", "!==", "'string'", ")", "{", "map", "=", "namespace", ";", "namespace", "=", "''", ";", "}", "else", "if", "(", "namespace", ".", "charAt", "(", "namespace", ".", "length", "-", "1", ")", "!==", "'/'", ")", "{", "namespace", "+=", "'/'", ";", "}", "return", "fn", "(", "namespace", ",", "map", ")", "}", "}" ]
Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map. @param {Function} fn @return {Function}
[ "Return", "a", "function", "expect", "two", "param", "contains", "namespace", "and", "map", ".", "it", "will", "normalize", "the", "namespace", "and", "then", "the", "param", "s", "function", "will", "handle", "the", "new", "namespace", "and", "the", "map", "." ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/dist/vuex.esm.js#L960-L970
train
vuejs/vuex
src/helpers.js
getModuleByNamespace
function getModuleByNamespace (store, helper, namespace) { const module = store._modulesNamespaceMap[namespace] if (process.env.NODE_ENV !== 'production' && !module) { console.error(`[vuex] module namespace not found in ${helper}(): ${namespace}`) } return module }
javascript
function getModuleByNamespace (store, helper, namespace) { const module = store._modulesNamespaceMap[namespace] if (process.env.NODE_ENV !== 'production' && !module) { console.error(`[vuex] module namespace not found in ${helper}(): ${namespace}`) } return module }
[ "function", "getModuleByNamespace", "(", "store", ",", "helper", ",", "namespace", ")", "{", "const", "module", "=", "store", ".", "_modulesNamespaceMap", "[", "namespace", "]", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", "&&", "!", "module", ")", "{", "console", ".", "error", "(", "`", "${", "helper", "}", "${", "namespace", "}", "`", ")", "}", "return", "module", "}" ]
Search a special module from store by namespace. if module not exist, print error message. @param {Object} store @param {String} helper @param {String} namespace @return {Object}
[ "Search", "a", "special", "module", "from", "store", "by", "namespace", ".", "if", "module", "not", "exist", "print", "error", "message", "." ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/src/helpers.js#L161-L167
train
vuejs/vuex
src/store.js
makeLocalContext
function makeLocalContext (store, namespace, path) { const noNamespace = namespace === '' const local = { dispatch: noNamespace ? store.dispatch : (_type, _payload, _options) => { const args = unifyObjectStyle(_type, _payload, _options) const { payload, options } = args let { type } = args if (!options || !options.root) { type = namespace + type if (process.env.NODE_ENV !== 'production' && !store._actions[type]) { console.error(`[vuex] unknown local action type: ${args.type}, global type: ${type}`) return } } return store.dispatch(type, payload) }, commit: noNamespace ? store.commit : (_type, _payload, _options) => { const args = unifyObjectStyle(_type, _payload, _options) const { payload, options } = args let { type } = args if (!options || !options.root) { type = namespace + type if (process.env.NODE_ENV !== 'production' && !store._mutations[type]) { console.error(`[vuex] unknown local mutation type: ${args.type}, global type: ${type}`) return } } store.commit(type, payload, options) } } // getters and state object must be gotten lazily // because they will be changed by vm update Object.defineProperties(local, { getters: { get: noNamespace ? () => store.getters : () => makeLocalGetters(store, namespace) }, state: { get: () => getNestedState(store.state, path) } }) return local }
javascript
function makeLocalContext (store, namespace, path) { const noNamespace = namespace === '' const local = { dispatch: noNamespace ? store.dispatch : (_type, _payload, _options) => { const args = unifyObjectStyle(_type, _payload, _options) const { payload, options } = args let { type } = args if (!options || !options.root) { type = namespace + type if (process.env.NODE_ENV !== 'production' && !store._actions[type]) { console.error(`[vuex] unknown local action type: ${args.type}, global type: ${type}`) return } } return store.dispatch(type, payload) }, commit: noNamespace ? store.commit : (_type, _payload, _options) => { const args = unifyObjectStyle(_type, _payload, _options) const { payload, options } = args let { type } = args if (!options || !options.root) { type = namespace + type if (process.env.NODE_ENV !== 'production' && !store._mutations[type]) { console.error(`[vuex] unknown local mutation type: ${args.type}, global type: ${type}`) return } } store.commit(type, payload, options) } } // getters and state object must be gotten lazily // because they will be changed by vm update Object.defineProperties(local, { getters: { get: noNamespace ? () => store.getters : () => makeLocalGetters(store, namespace) }, state: { get: () => getNestedState(store.state, path) } }) return local }
[ "function", "makeLocalContext", "(", "store", ",", "namespace", ",", "path", ")", "{", "const", "noNamespace", "=", "namespace", "===", "''", "const", "local", "=", "{", "dispatch", ":", "noNamespace", "?", "store", ".", "dispatch", ":", "(", "_type", ",", "_payload", ",", "_options", ")", "=>", "{", "const", "args", "=", "unifyObjectStyle", "(", "_type", ",", "_payload", ",", "_options", ")", "const", "{", "payload", ",", "options", "}", "=", "args", "let", "{", "type", "}", "=", "args", "if", "(", "!", "options", "||", "!", "options", ".", "root", ")", "{", "type", "=", "namespace", "+", "type", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", "&&", "!", "store", ".", "_actions", "[", "type", "]", ")", "{", "console", ".", "error", "(", "`", "${", "args", ".", "type", "}", "${", "type", "}", "`", ")", "return", "}", "}", "return", "store", ".", "dispatch", "(", "type", ",", "payload", ")", "}", ",", "commit", ":", "noNamespace", "?", "store", ".", "commit", ":", "(", "_type", ",", "_payload", ",", "_options", ")", "=>", "{", "const", "args", "=", "unifyObjectStyle", "(", "_type", ",", "_payload", ",", "_options", ")", "const", "{", "payload", ",", "options", "}", "=", "args", "let", "{", "type", "}", "=", "args", "if", "(", "!", "options", "||", "!", "options", ".", "root", ")", "{", "type", "=", "namespace", "+", "type", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", "&&", "!", "store", ".", "_mutations", "[", "type", "]", ")", "{", "console", ".", "error", "(", "`", "${", "args", ".", "type", "}", "${", "type", "}", "`", ")", "return", "}", "}", "store", ".", "commit", "(", "type", ",", "payload", ",", "options", ")", "}", "}", "Object", ".", "defineProperties", "(", "local", ",", "{", "getters", ":", "{", "get", ":", "noNamespace", "?", "(", ")", "=>", "store", ".", "getters", ":", "(", ")", "=>", "makeLocalGetters", "(", "store", ",", "namespace", ")", "}", ",", "state", ":", "{", "get", ":", "(", ")", "=>", "getNestedState", "(", "store", ".", "state", ",", "path", ")", "}", "}", ")", "return", "local", "}" ]
make localized dispatch, commit, getters and state if there is no namespace, just use root ones
[ "make", "localized", "dispatch", "commit", "getters", "and", "state", "if", "there", "is", "no", "namespace", "just", "use", "root", "ones" ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/src/store.js#L343-L394
train
transloadit/uppy
packages/@uppy/golden-retriever/src/IndexedDBStore.js
migrateExpiration
function migrateExpiration (store) { const request = store.openCursor() request.onsuccess = (event) => { const cursor = event.target.result if (!cursor) { return } const entry = cursor.value entry.expires = Date.now() + DEFAULT_EXPIRY cursor.update(entry) } }
javascript
function migrateExpiration (store) { const request = store.openCursor() request.onsuccess = (event) => { const cursor = event.target.result if (!cursor) { return } const entry = cursor.value entry.expires = Date.now() + DEFAULT_EXPIRY cursor.update(entry) } }
[ "function", "migrateExpiration", "(", "store", ")", "{", "const", "request", "=", "store", ".", "openCursor", "(", ")", "request", ".", "onsuccess", "=", "(", "event", ")", "=>", "{", "const", "cursor", "=", "event", ".", "target", ".", "result", "if", "(", "!", "cursor", ")", "{", "return", "}", "const", "entry", "=", "cursor", ".", "value", "entry", ".", "expires", "=", "Date", ".", "now", "(", ")", "+", "DEFAULT_EXPIRY", "cursor", ".", "update", "(", "entry", ")", "}", "}" ]
Set default `expires` dates on existing stored blobs.
[ "Set", "default", "expires", "dates", "on", "existing", "stored", "blobs", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/golden-retriever/src/IndexedDBStore.js#L13-L24
train
transloadit/uppy
packages/@uppy/core/src/Plugin.js
debounce
function debounce (fn) { let calling = null let latestArgs = null return (...args) => { latestArgs = args if (!calling) { calling = Promise.resolve().then(() => { calling = null // At this point `args` may be different from the most // recent state, if multiple calls happened since this task // was queued. So we use the `latestArgs`, which definitely // is the most recent call. return fn(...latestArgs) }) } return calling } }
javascript
function debounce (fn) { let calling = null let latestArgs = null return (...args) => { latestArgs = args if (!calling) { calling = Promise.resolve().then(() => { calling = null // At this point `args` may be different from the most // recent state, if multiple calls happened since this task // was queued. So we use the `latestArgs`, which definitely // is the most recent call. return fn(...latestArgs) }) } return calling } }
[ "function", "debounce", "(", "fn", ")", "{", "let", "calling", "=", "null", "let", "latestArgs", "=", "null", "return", "(", "...", "args", ")", "=>", "{", "latestArgs", "=", "args", "if", "(", "!", "calling", ")", "{", "calling", "=", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "(", ")", "=>", "{", "calling", "=", "null", "return", "fn", "(", "...", "latestArgs", ")", "}", ")", "}", "return", "calling", "}", "}" ]
Defer a frequent call to the microtask queue.
[ "Defer", "a", "frequent", "call", "to", "the", "microtask", "queue", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/core/src/Plugin.js#L7-L24
train
transloadit/uppy
packages/@uppy/transloadit/src/AssemblyOptions.js
validateParams
function validateParams (params) { if (!params) { throw new Error('Transloadit: The `params` option is required.') } if (typeof params === 'string') { try { params = JSON.parse(params) } catch (err) { // Tell the user that this is not an Uppy bug! err.message = 'Transloadit: The `params` option is a malformed JSON string: ' + err.message throw err } } if (!params.auth || !params.auth.key) { throw new Error('Transloadit: The `params.auth.key` option is required. ' + 'You can find your Transloadit API key at https://transloadit.com/account/api-settings.') } }
javascript
function validateParams (params) { if (!params) { throw new Error('Transloadit: The `params` option is required.') } if (typeof params === 'string') { try { params = JSON.parse(params) } catch (err) { // Tell the user that this is not an Uppy bug! err.message = 'Transloadit: The `params` option is a malformed JSON string: ' + err.message throw err } } if (!params.auth || !params.auth.key) { throw new Error('Transloadit: The `params.auth.key` option is required. ' + 'You can find your Transloadit API key at https://transloadit.com/account/api-settings.') } }
[ "function", "validateParams", "(", "params", ")", "{", "if", "(", "!", "params", ")", "{", "throw", "new", "Error", "(", "'Transloadit: The `params` option is required.'", ")", "}", "if", "(", "typeof", "params", "===", "'string'", ")", "{", "try", "{", "params", "=", "JSON", ".", "parse", "(", "params", ")", "}", "catch", "(", "err", ")", "{", "err", ".", "message", "=", "'Transloadit: The `params` option is a malformed JSON string: '", "+", "err", ".", "message", "throw", "err", "}", "}", "if", "(", "!", "params", ".", "auth", "||", "!", "params", ".", "auth", ".", "key", ")", "{", "throw", "new", "Error", "(", "'Transloadit: The `params.auth.key` option is required. '", "+", "'You can find your Transloadit API key at https://transloadit.com/account/api-settings.'", ")", "}", "}" ]
Check that Assembly parameters are present and include all required fields.
[ "Check", "that", "Assembly", "parameters", "are", "present", "and", "include", "all", "required", "fields", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/transloadit/src/AssemblyOptions.js#L4-L24
train
transloadit/uppy
examples/react-native-expo/FileList.js
FileIcon
function FileIcon () { return <View style={styles.itemIconContainer}> <Image style={styles.itemIcon} source={require('./assets/file-icon.png')} /> </View> }
javascript
function FileIcon () { return <View style={styles.itemIconContainer}> <Image style={styles.itemIcon} source={require('./assets/file-icon.png')} /> </View> }
[ "function", "FileIcon", "(", ")", "{", "return", "<", "View", "style", "=", "{", "styles", ".", "itemIconContainer", "}", ">", " ", "<", "Image", "style", "=", "{", "styles", ".", "itemIcon", "}", "source", "=", "{", "require", "(", "'./assets/file-icon.png'", ")", "}", "/", ">", " ", "<", "/", "View", ">", "}" ]
return str }
[ "return", "str", "}" ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/examples/react-native-expo/FileList.js#L18-L25
train
transloadit/uppy
packages/@uppy/companion/src/server/controllers/authorized.js
authorized
function authorized (req, res) { const { params, uppy } = req const providerName = params.providerName if (!uppy.providerTokens || !uppy.providerTokens[providerName]) { return res.json({ authenticated: false }) } const token = uppy.providerTokens[providerName] uppy.provider.list({ token, uppy }, (err, response, body) => { const notAuthenticated = Boolean(err) if (notAuthenticated) { logger.debug(`${providerName} failed authorizarion test err:${err}`, 'provider.auth.check') } return res.json({ authenticated: !notAuthenticated }) }) }
javascript
function authorized (req, res) { const { params, uppy } = req const providerName = params.providerName if (!uppy.providerTokens || !uppy.providerTokens[providerName]) { return res.json({ authenticated: false }) } const token = uppy.providerTokens[providerName] uppy.provider.list({ token, uppy }, (err, response, body) => { const notAuthenticated = Boolean(err) if (notAuthenticated) { logger.debug(`${providerName} failed authorizarion test err:${err}`, 'provider.auth.check') } return res.json({ authenticated: !notAuthenticated }) }) }
[ "function", "authorized", "(", "req", ",", "res", ")", "{", "const", "{", "params", ",", "uppy", "}", "=", "req", "const", "providerName", "=", "params", ".", "providerName", "if", "(", "!", "uppy", ".", "providerTokens", "||", "!", "uppy", ".", "providerTokens", "[", "providerName", "]", ")", "{", "return", "res", ".", "json", "(", "{", "authenticated", ":", "false", "}", ")", "}", "const", "token", "=", "uppy", ".", "providerTokens", "[", "providerName", "]", "uppy", ".", "provider", ".", "list", "(", "{", "token", ",", "uppy", "}", ",", "(", "err", ",", "response", ",", "body", ")", "=>", "{", "const", "notAuthenticated", "=", "Boolean", "(", "err", ")", "if", "(", "notAuthenticated", ")", "{", "logger", ".", "debug", "(", "`", "${", "providerName", "}", "${", "err", "}", "`", ",", "'provider.auth.check'", ")", "}", "return", "res", ".", "json", "(", "{", "authenticated", ":", "!", "notAuthenticated", "}", ")", "}", ")", "}" ]
checks if companion is authorized to access a user's provider account. @param {object} req @param {object} res
[ "checks", "if", "companion", "is", "authorized", "to", "access", "a", "user", "s", "provider", "account", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/authorized.js#L12-L28
train