first commit

This commit is contained in:
jefferyzhao
2025-07-31 17:44:12 +08:00
commit b9bdc8598b
42390 changed files with 4467935 additions and 0 deletions

236
node_modules/echarts/lib/chart/helper/EffectLine.js generated vendored Normal file
View File

@ -0,0 +1,236 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var Line = require("./Line");
var zrUtil = require("zrender/lib/core/util");
var _symbol = require("../../util/symbol");
var createSymbol = _symbol.createSymbol;
var vec2 = require("zrender/lib/core/vector");
var curveUtil = require("zrender/lib/core/curve");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Provide effect for line
* @module echarts/chart/helper/EffectLine
*/
/**
* @constructor
* @extends {module:zrender/graphic/Group}
* @alias {module:echarts/chart/helper/Line}
*/
function EffectLine(lineData, idx, seriesScope) {
graphic.Group.call(this);
this.add(this.createLine(lineData, idx, seriesScope));
this._updateEffectSymbol(lineData, idx);
}
var effectLineProto = EffectLine.prototype;
effectLineProto.createLine = function (lineData, idx, seriesScope) {
return new Line(lineData, idx, seriesScope);
};
effectLineProto._updateEffectSymbol = function (lineData, idx) {
var itemModel = lineData.getItemModel(idx);
var effectModel = itemModel.getModel('effect');
var size = effectModel.get('symbolSize');
var symbolType = effectModel.get('symbol');
if (!zrUtil.isArray(size)) {
size = [size, size];
}
var color = effectModel.get('color') || lineData.getItemVisual(idx, 'color');
var symbol = this.childAt(1);
if (this._symbolType !== symbolType) {
// Remove previous
this.remove(symbol);
symbol = createSymbol(symbolType, -0.5, -0.5, 1, 1, color);
symbol.z2 = 100;
symbol.culling = true;
this.add(symbol);
} // Symbol may be removed if loop is false
if (!symbol) {
return;
} // Shadow color is same with color in default
symbol.setStyle('shadowColor', color);
symbol.setStyle(effectModel.getItemStyle(['color']));
symbol.attr('scale', size);
symbol.setColor(color);
symbol.attr('scale', size);
this._symbolType = symbolType;
this._symbolScale = size;
this._updateEffectAnimation(lineData, effectModel, idx);
};
effectLineProto._updateEffectAnimation = function (lineData, effectModel, idx) {
var symbol = this.childAt(1);
if (!symbol) {
return;
}
var self = this;
var points = lineData.getItemLayout(idx);
var period = effectModel.get('period') * 1000;
var loop = effectModel.get('loop');
var constantSpeed = effectModel.get('constantSpeed');
var delayExpr = zrUtil.retrieve(effectModel.get('delay'), function (idx) {
return idx / lineData.count() * period / 3;
});
var isDelayFunc = typeof delayExpr === 'function'; // Ignore when updating
symbol.ignore = true;
this.updateAnimationPoints(symbol, points);
if (constantSpeed > 0) {
period = this.getLineLength(symbol) / constantSpeed * 1000;
}
if (period !== this._period || loop !== this._loop) {
symbol.stopAnimation();
var delay = delayExpr;
if (isDelayFunc) {
delay = delayExpr(idx);
}
if (symbol.__t > 0) {
delay = -period * symbol.__t;
}
symbol.__t = 0;
var animator = symbol.animate('', loop).when(period, {
__t: 1
}).delay(delay).during(function () {
self.updateSymbolPosition(symbol);
});
if (!loop) {
animator.done(function () {
self.remove(symbol);
});
}
animator.start();
}
this._period = period;
this._loop = loop;
};
effectLineProto.getLineLength = function (symbol) {
// Not so accurate
return vec2.dist(symbol.__p1, symbol.__cp1) + vec2.dist(symbol.__cp1, symbol.__p2);
};
effectLineProto.updateAnimationPoints = function (symbol, points) {
symbol.__p1 = points[0];
symbol.__p2 = points[1];
symbol.__cp1 = points[2] || [(points[0][0] + points[1][0]) / 2, (points[0][1] + points[1][1]) / 2];
};
effectLineProto.updateData = function (lineData, idx, seriesScope) {
this.childAt(0).updateData(lineData, idx, seriesScope);
this._updateEffectSymbol(lineData, idx);
};
effectLineProto.updateSymbolPosition = function (symbol) {
var p1 = symbol.__p1;
var p2 = symbol.__p2;
var cp1 = symbol.__cp1;
var t = symbol.__t;
var pos = symbol.position;
var lastPos = [pos[0], pos[1]];
var quadraticAt = curveUtil.quadraticAt;
var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt;
pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t);
pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t); // Tangent
var tx = quadraticDerivativeAt(p1[0], cp1[0], p2[0], t);
var ty = quadraticDerivativeAt(p1[1], cp1[1], p2[1], t);
symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2; // enable continuity trail for 'line', 'rect', 'roundRect' symbolType
if (this._symbolType === 'line' || this._symbolType === 'rect' || this._symbolType === 'roundRect') {
if (symbol.__lastT !== undefined && symbol.__lastT < symbol.__t) {
var scaleY = vec2.dist(lastPos, pos) * 1.05;
symbol.attr('scale', [symbol.scale[0], scaleY]); // make sure the last segment render within endPoint
if (t === 1) {
pos[0] = lastPos[0] + (pos[0] - lastPos[0]) / 2;
pos[1] = lastPos[1] + (pos[1] - lastPos[1]) / 2;
}
} else if (symbol.__lastT === 1) {
// After first loop, symbol.__t does NOT start with 0, so connect p1 to pos directly.
var scaleY = 2 * vec2.dist(p1, pos);
symbol.attr('scale', [symbol.scale[0], scaleY]);
} else {
symbol.attr('scale', this._symbolScale);
}
}
symbol.__lastT = symbol.__t;
symbol.ignore = false;
};
effectLineProto.updateLayout = function (lineData, idx) {
this.childAt(0).updateLayout(lineData, idx);
var effectModel = lineData.getItemModel(idx).getModel('effect');
this._updateEffectAnimation(lineData, effectModel, idx);
};
zrUtil.inherits(EffectLine, graphic.Group);
var _default = EffectLine;
module.exports = _default;

149
node_modules/echarts/lib/chart/helper/EffectPolyline.js generated vendored Normal file
View File

@ -0,0 +1,149 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var Polyline = require("./Polyline");
var zrUtil = require("zrender/lib/core/util");
var EffectLine = require("./EffectLine");
var vec2 = require("zrender/lib/core/vector");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Provide effect for line
* @module echarts/chart/helper/EffectLine
*/
/**
* @constructor
* @extends {module:echarts/chart/helper/EffectLine}
* @alias {module:echarts/chart/helper/Polyline}
*/
function EffectPolyline(lineData, idx, seriesScope) {
EffectLine.call(this, lineData, idx, seriesScope);
this._lastFrame = 0;
this._lastFramePercent = 0;
}
var effectPolylineProto = EffectPolyline.prototype; // Overwrite
effectPolylineProto.createLine = function (lineData, idx, seriesScope) {
return new Polyline(lineData, idx, seriesScope);
}; // Overwrite
effectPolylineProto.updateAnimationPoints = function (symbol, points) {
this._points = points;
var accLenArr = [0];
var len = 0;
for (var i = 1; i < points.length; i++) {
var p1 = points[i - 1];
var p2 = points[i];
len += vec2.dist(p1, p2);
accLenArr.push(len);
}
if (len === 0) {
return;
}
for (var i = 0; i < accLenArr.length; i++) {
accLenArr[i] /= len;
}
this._offsets = accLenArr;
this._length = len;
}; // Overwrite
effectPolylineProto.getLineLength = function (symbol) {
return this._length;
}; // Overwrite
effectPolylineProto.updateSymbolPosition = function (symbol) {
var t = symbol.__t;
var points = this._points;
var offsets = this._offsets;
var len = points.length;
if (!offsets) {
// Has length 0
return;
}
var lastFrame = this._lastFrame;
var frame;
if (t < this._lastFramePercent) {
// Start from the next frame
// PENDING start from lastFrame ?
var start = Math.min(lastFrame + 1, len - 1);
for (frame = start; frame >= 0; frame--) {
if (offsets[frame] <= t) {
break;
}
} // PENDING really need to do this ?
frame = Math.min(frame, len - 2);
} else {
for (var frame = lastFrame; frame < len; frame++) {
if (offsets[frame] > t) {
break;
}
}
frame = Math.min(frame - 1, len - 2);
}
vec2.lerp(symbol.position, points[frame], points[frame + 1], (t - offsets[frame]) / (offsets[frame + 1] - offsets[frame]));
var tx = points[frame + 1][0] - points[frame][0];
var ty = points[frame + 1][1] - points[frame][1];
symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
this._lastFrame = frame;
this._lastFramePercent = t;
symbol.ignore = false;
};
zrUtil.inherits(EffectPolyline, EffectLine);
var _default = EffectPolyline;
module.exports = _default;

263
node_modules/echarts/lib/chart/helper/EffectSymbol.js generated vendored Normal file
View File

@ -0,0 +1,263 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var zrUtil = require("zrender/lib/core/util");
var _symbol = require("../../util/symbol");
var createSymbol = _symbol.createSymbol;
var _graphic = require("../../util/graphic");
var Group = _graphic.Group;
var _number = require("../../util/number");
var parsePercent = _number.parsePercent;
var SymbolClz = require("./Symbol");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Symbol with ripple effect
* @module echarts/chart/helper/EffectSymbol
*/
var EFFECT_RIPPLE_NUMBER = 3;
function normalizeSymbolSize(symbolSize) {
if (!zrUtil.isArray(symbolSize)) {
symbolSize = [+symbolSize, +symbolSize];
}
return symbolSize;
}
function updateRipplePath(rippleGroup, effectCfg) {
var color = effectCfg.rippleEffectColor || effectCfg.color;
rippleGroup.eachChild(function (ripplePath) {
ripplePath.attr({
z: effectCfg.z,
zlevel: effectCfg.zlevel,
style: {
stroke: effectCfg.brushType === 'stroke' ? color : null,
fill: effectCfg.brushType === 'fill' ? color : null
}
});
});
}
/**
* @constructor
* @param {module:echarts/data/List} data
* @param {number} idx
* @extends {module:zrender/graphic/Group}
*/
function EffectSymbol(data, idx) {
Group.call(this);
var symbol = new SymbolClz(data, idx);
var rippleGroup = new Group();
this.add(symbol);
this.add(rippleGroup);
rippleGroup.beforeUpdate = function () {
this.attr(symbol.getScale());
};
this.updateData(data, idx);
}
var effectSymbolProto = EffectSymbol.prototype;
effectSymbolProto.stopEffectAnimation = function () {
this.childAt(1).removeAll();
};
effectSymbolProto.startEffectAnimation = function (effectCfg) {
var symbolType = effectCfg.symbolType;
var color = effectCfg.color;
var rippleGroup = this.childAt(1);
for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) {
// If width/height are set too small (e.g., set to 1) on ios10
// and macOS Sierra, a circle stroke become a rect, no matter what
// the scale is set. So we set width/height as 2. See #4136.
var ripplePath = createSymbol(symbolType, -1, -1, 2, 2, color);
ripplePath.attr({
style: {
strokeNoScale: true
},
z2: 99,
silent: true,
scale: [0.5, 0.5]
});
var delay = -i / EFFECT_RIPPLE_NUMBER * effectCfg.period + effectCfg.effectOffset; // TODO Configurable effectCfg.period
ripplePath.animate('', true).when(effectCfg.period, {
scale: [effectCfg.rippleScale / 2, effectCfg.rippleScale / 2]
}).delay(delay).start();
ripplePath.animateStyle(true).when(effectCfg.period, {
opacity: 0
}).delay(delay).start();
rippleGroup.add(ripplePath);
}
updateRipplePath(rippleGroup, effectCfg);
};
/**
* Update effect symbol
*/
effectSymbolProto.updateEffectAnimation = function (effectCfg) {
var oldEffectCfg = this._effectCfg;
var rippleGroup = this.childAt(1); // Must reinitialize effect if following configuration changed
var DIFFICULT_PROPS = ['symbolType', 'period', 'rippleScale'];
for (var i = 0; i < DIFFICULT_PROPS.length; i++) {
var propName = DIFFICULT_PROPS[i];
if (oldEffectCfg[propName] !== effectCfg[propName]) {
this.stopEffectAnimation();
this.startEffectAnimation(effectCfg);
return;
}
}
updateRipplePath(rippleGroup, effectCfg);
};
/**
* Highlight symbol
*/
effectSymbolProto.highlight = function () {
this.trigger('emphasis');
};
/**
* Downplay symbol
*/
effectSymbolProto.downplay = function () {
this.trigger('normal');
};
/**
* Update symbol properties
* @param {module:echarts/data/List} data
* @param {number} idx
*/
effectSymbolProto.updateData = function (data, idx) {
var seriesModel = data.hostModel;
this.childAt(0).updateData(data, idx);
var rippleGroup = this.childAt(1);
var itemModel = data.getItemModel(idx);
var symbolType = data.getItemVisual(idx, 'symbol');
var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
var color = data.getItemVisual(idx, 'color');
rippleGroup.attr('scale', symbolSize);
rippleGroup.traverse(function (ripplePath) {
ripplePath.attr({
fill: color
});
});
var symbolOffset = itemModel.getShallow('symbolOffset');
if (symbolOffset) {
var pos = rippleGroup.position;
pos[0] = parsePercent(symbolOffset[0], symbolSize[0]);
pos[1] = parsePercent(symbolOffset[1], symbolSize[1]);
}
var symbolRotate = data.getItemVisual(idx, 'symbolRotate');
rippleGroup.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
var effectCfg = {};
effectCfg.showEffectOn = seriesModel.get('showEffectOn');
effectCfg.rippleScale = itemModel.get('rippleEffect.scale');
effectCfg.brushType = itemModel.get('rippleEffect.brushType');
effectCfg.period = itemModel.get('rippleEffect.period') * 1000;
effectCfg.effectOffset = idx / data.count();
effectCfg.z = itemModel.getShallow('z') || 0;
effectCfg.zlevel = itemModel.getShallow('zlevel') || 0;
effectCfg.symbolType = symbolType;
effectCfg.color = color;
effectCfg.rippleEffectColor = itemModel.get('rippleEffect.color');
this.off('mouseover').off('mouseout').off('emphasis').off('normal');
if (effectCfg.showEffectOn === 'render') {
this._effectCfg ? this.updateEffectAnimation(effectCfg) : this.startEffectAnimation(effectCfg);
this._effectCfg = effectCfg;
} else {
// Not keep old effect config
this._effectCfg = null;
this.stopEffectAnimation();
var symbol = this.childAt(0);
var onEmphasis = function () {
symbol.highlight();
if (effectCfg.showEffectOn !== 'render') {
this.startEffectAnimation(effectCfg);
}
};
var onNormal = function () {
symbol.downplay();
if (effectCfg.showEffectOn !== 'render') {
this.stopEffectAnimation();
}
};
this.on('mouseover', onEmphasis, this).on('mouseout', onNormal, this).on('emphasis', onEmphasis, this).on('normal', onNormal, this);
}
this._effectCfg = effectCfg;
};
effectSymbolProto.fadeOut = function (cb) {
this.off('mouseover').off('mouseout').off('emphasis').off('normal');
cb && cb();
};
zrUtil.inherits(EffectSymbol, Group);
var _default = EffectSymbol;
module.exports = _default;

273
node_modules/echarts/lib/chart/helper/LargeLineDraw.js generated vendored Normal file
View File

@ -0,0 +1,273 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var IncrementalDisplayable = require("zrender/lib/graphic/IncrementalDisplayable");
var lineContain = require("zrender/lib/contain/line");
var quadraticContain = require("zrender/lib/contain/quadratic");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// TODO Batch by color
var LargeLineShape = graphic.extendShape({
shape: {
polyline: false,
curveness: 0,
segs: []
},
buildPath: function (path, shape) {
var segs = shape.segs;
var curveness = shape.curveness;
if (shape.polyline) {
for (var i = 0; i < segs.length;) {
var count = segs[i++];
if (count > 0) {
path.moveTo(segs[i++], segs[i++]);
for (var k = 1; k < count; k++) {
path.lineTo(segs[i++], segs[i++]);
}
}
}
} else {
for (var i = 0; i < segs.length;) {
var x0 = segs[i++];
var y0 = segs[i++];
var x1 = segs[i++];
var y1 = segs[i++];
path.moveTo(x0, y0);
if (curveness > 0) {
var x2 = (x0 + x1) / 2 - (y0 - y1) * curveness;
var y2 = (y0 + y1) / 2 - (x1 - x0) * curveness;
path.quadraticCurveTo(x2, y2, x1, y1);
} else {
path.lineTo(x1, y1);
}
}
}
},
findDataIndex: function (x, y) {
var shape = this.shape;
var segs = shape.segs;
var curveness = shape.curveness;
if (shape.polyline) {
var dataIndex = 0;
for (var i = 0; i < segs.length;) {
var count = segs[i++];
if (count > 0) {
var x0 = segs[i++];
var y0 = segs[i++];
for (var k = 1; k < count; k++) {
var x1 = segs[i++];
var y1 = segs[i++];
if (lineContain.containStroke(x0, y0, x1, y1)) {
return dataIndex;
}
}
}
dataIndex++;
}
} else {
var dataIndex = 0;
for (var i = 0; i < segs.length;) {
var x0 = segs[i++];
var y0 = segs[i++];
var x1 = segs[i++];
var y1 = segs[i++];
if (curveness > 0) {
var x2 = (x0 + x1) / 2 - (y0 - y1) * curveness;
var y2 = (y0 + y1) / 2 - (x1 - x0) * curveness;
if (quadraticContain.containStroke(x0, y0, x2, y2, x1, y1)) {
return dataIndex;
}
} else {
if (lineContain.containStroke(x0, y0, x1, y1)) {
return dataIndex;
}
}
dataIndex++;
}
}
return -1;
}
});
function LargeLineDraw() {
this.group = new graphic.Group();
}
var largeLineProto = LargeLineDraw.prototype;
largeLineProto.isPersistent = function () {
return !this._incremental;
};
/**
* Update symbols draw by new data
* @param {module:echarts/data/List} data
*/
largeLineProto.updateData = function (data) {
this.group.removeAll();
var lineEl = new LargeLineShape({
rectHover: true,
cursor: 'default'
});
lineEl.setShape({
segs: data.getLayout('linesPoints')
});
this._setCommon(lineEl, data); // Add back
this.group.add(lineEl);
this._incremental = null;
};
/**
* @override
*/
largeLineProto.incrementalPrepareUpdate = function (data) {
this.group.removeAll();
this._clearIncremental();
if (data.count() > 5e5) {
if (!this._incremental) {
this._incremental = new IncrementalDisplayable({
silent: true
});
}
this.group.add(this._incremental);
} else {
this._incremental = null;
}
};
/**
* @override
*/
largeLineProto.incrementalUpdate = function (taskParams, data) {
var lineEl = new LargeLineShape();
lineEl.setShape({
segs: data.getLayout('linesPoints')
});
this._setCommon(lineEl, data, !!this._incremental);
if (!this._incremental) {
lineEl.rectHover = true;
lineEl.cursor = 'default';
lineEl.__startIndex = taskParams.start;
this.group.add(lineEl);
} else {
this._incremental.addDisplayable(lineEl, true);
}
};
/**
* @override
*/
largeLineProto.remove = function () {
this._clearIncremental();
this._incremental = null;
this.group.removeAll();
};
largeLineProto._setCommon = function (lineEl, data, isIncremental) {
var hostModel = data.hostModel;
lineEl.setShape({
polyline: hostModel.get('polyline'),
curveness: hostModel.get('lineStyle.curveness')
});
lineEl.useStyle(hostModel.getModel('lineStyle').getLineStyle());
lineEl.style.strokeNoScale = true;
var visualColor = data.getVisual('color');
if (visualColor) {
lineEl.setStyle('stroke', visualColor);
}
lineEl.setStyle('fill');
if (!isIncremental) {
// Enable tooltip
// PENDING May have performance issue when path is extremely large
lineEl.seriesIndex = hostModel.seriesIndex;
lineEl.on('mousemove', function (e) {
lineEl.dataIndex = null;
var dataIndex = lineEl.findDataIndex(e.offsetX, e.offsetY);
if (dataIndex > 0) {
// Provide dataIndex for tooltip
lineEl.dataIndex = dataIndex + lineEl.__startIndex;
}
});
}
};
largeLineProto._clearIncremental = function () {
var incremental = this._incremental;
if (incremental) {
incremental.clearDisplaybles();
}
};
var _default = LargeLineDraw;
module.exports = _default;

View File

@ -0,0 +1,302 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var _symbol = require("../../util/symbol");
var createSymbol = _symbol.createSymbol;
var IncrementalDisplayable = require("zrender/lib/graphic/IncrementalDisplayable");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/* global Float32Array */
// TODO Batch by color
var BOOST_SIZE_THRESHOLD = 4;
var LargeSymbolPath = graphic.extendShape({
shape: {
points: null
},
symbolProxy: null,
softClipShape: null,
buildPath: function (path, shape) {
var points = shape.points;
var size = shape.size;
var symbolProxy = this.symbolProxy;
var symbolProxyShape = symbolProxy.shape;
var ctx = path.getContext ? path.getContext() : path;
var canBoost = ctx && size[0] < BOOST_SIZE_THRESHOLD; // Do draw in afterBrush.
if (canBoost) {
return;
}
for (var i = 0; i < points.length;) {
var x = points[i++];
var y = points[i++];
if (isNaN(x) || isNaN(y)) {
continue;
}
if (this.softClipShape && !this.softClipShape.contain(x, y)) {
continue;
}
symbolProxyShape.x = x - size[0] / 2;
symbolProxyShape.y = y - size[1] / 2;
symbolProxyShape.width = size[0];
symbolProxyShape.height = size[1];
symbolProxy.buildPath(path, symbolProxyShape, true);
}
},
afterBrush: function (ctx) {
var shape = this.shape;
var points = shape.points;
var size = shape.size;
var canBoost = size[0] < BOOST_SIZE_THRESHOLD;
if (!canBoost) {
return;
}
this.setTransform(ctx); // PENDING If style or other canvas status changed?
for (var i = 0; i < points.length;) {
var x = points[i++];
var y = points[i++];
if (isNaN(x) || isNaN(y)) {
continue;
}
if (this.softClipShape && !this.softClipShape.contain(x, y)) {
continue;
} // fillRect is faster than building a rect path and draw.
// And it support light globalCompositeOperation.
ctx.fillRect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]);
}
this.restoreTransform(ctx);
},
findDataIndex: function (x, y) {
// TODO ???
// Consider transform
var shape = this.shape;
var points = shape.points;
var size = shape.size;
var w = Math.max(size[0], 4);
var h = Math.max(size[1], 4); // Not consider transform
// Treat each element as a rect
// top down traverse
for (var idx = points.length / 2 - 1; idx >= 0; idx--) {
var i = idx * 2;
var x0 = points[i] - w / 2;
var y0 = points[i + 1] - h / 2;
if (x >= x0 && y >= y0 && x <= x0 + w && y <= y0 + h) {
return idx;
}
}
return -1;
}
});
function LargeSymbolDraw() {
this.group = new graphic.Group();
}
var largeSymbolProto = LargeSymbolDraw.prototype;
largeSymbolProto.isPersistent = function () {
return !this._incremental;
};
/**
* Update symbols draw by new data
* @param {module:echarts/data/List} data
* @param {Object} opt
* @param {Object} [opt.clipShape]
*/
largeSymbolProto.updateData = function (data, opt) {
this.group.removeAll();
var symbolEl = new LargeSymbolPath({
rectHover: true,
cursor: 'default'
});
symbolEl.setShape({
points: data.getLayout('symbolPoints')
});
this._setCommon(symbolEl, data, false, opt);
this.group.add(symbolEl);
this._incremental = null;
};
largeSymbolProto.updateLayout = function (data) {
if (this._incremental) {
return;
}
var points = data.getLayout('symbolPoints');
this.group.eachChild(function (child) {
if (child.startIndex != null) {
var len = (child.endIndex - child.startIndex) * 2;
var byteOffset = child.startIndex * 4 * 2;
points = new Float32Array(points.buffer, byteOffset, len);
}
child.setShape('points', points);
});
};
largeSymbolProto.incrementalPrepareUpdate = function (data) {
this.group.removeAll();
this._clearIncremental(); // Only use incremental displayables when data amount is larger than 2 million.
// PENDING Incremental data?
if (data.count() > 2e6) {
if (!this._incremental) {
this._incremental = new IncrementalDisplayable({
silent: true
});
}
this.group.add(this._incremental);
} else {
this._incremental = null;
}
};
largeSymbolProto.incrementalUpdate = function (taskParams, data, opt) {
var symbolEl;
if (this._incremental) {
symbolEl = new LargeSymbolPath();
this._incremental.addDisplayable(symbolEl, true);
} else {
symbolEl = new LargeSymbolPath({
rectHover: true,
cursor: 'default',
startIndex: taskParams.start,
endIndex: taskParams.end
});
symbolEl.incremental = true;
this.group.add(symbolEl);
}
symbolEl.setShape({
points: data.getLayout('symbolPoints')
});
this._setCommon(symbolEl, data, !!this._incremental, opt);
};
largeSymbolProto._setCommon = function (symbolEl, data, isIncremental, opt) {
var hostModel = data.hostModel;
opt = opt || {}; // TODO
// if (data.hasItemVisual.symbolSize) {
// // TODO typed array?
// symbolEl.setShape('sizes', data.mapArray(
// function (idx) {
// var size = data.getItemVisual(idx, 'symbolSize');
// return (size instanceof Array) ? size : [size, size];
// }
// ));
// }
// else {
var size = data.getVisual('symbolSize');
symbolEl.setShape('size', size instanceof Array ? size : [size, size]); // }
symbolEl.softClipShape = opt.clipShape || null; // Create symbolProxy to build path for each data
symbolEl.symbolProxy = createSymbol(data.getVisual('symbol'), 0, 0, 0, 0); // Use symbolProxy setColor method
symbolEl.setColor = symbolEl.symbolProxy.setColor;
var extrudeShadow = symbolEl.shape.size[0] < BOOST_SIZE_THRESHOLD;
symbolEl.useStyle( // Draw shadow when doing fillRect is extremely slow.
hostModel.getModel('itemStyle').getItemStyle(extrudeShadow ? ['color', 'shadowBlur', 'shadowColor'] : ['color']));
var visualColor = data.getVisual('color');
if (visualColor) {
symbolEl.setColor(visualColor);
}
if (!isIncremental) {
// Enable tooltip
// PENDING May have performance issue when path is extremely large
symbolEl.seriesIndex = hostModel.seriesIndex;
symbolEl.on('mousemove', function (e) {
symbolEl.dataIndex = null;
var dataIndex = symbolEl.findDataIndex(e.offsetX, e.offsetY);
if (dataIndex >= 0) {
// Provide dataIndex for tooltip
symbolEl.dataIndex = dataIndex + (symbolEl.startIndex || 0);
}
});
}
};
largeSymbolProto.remove = function () {
this._clearIncremental();
this._incremental = null;
this.group.removeAll();
};
largeSymbolProto._clearIncremental = function () {
var incremental = this._incremental;
if (incremental) {
incremental.clearDisplaybles();
}
};
var _default = LargeSymbolDraw;
module.exports = _default;

481
node_modules/echarts/lib/chart/helper/Line.js generated vendored Normal file
View File

@ -0,0 +1,481 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var zrUtil = require("zrender/lib/core/util");
var vector = require("zrender/lib/core/vector");
var symbolUtil = require("../../util/symbol");
var LinePath = require("./LinePath");
var graphic = require("../../util/graphic");
var _number = require("../../util/number");
var round = _number.round;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @module echarts/chart/helper/Line
*/
var SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'];
function makeSymbolTypeKey(symbolCategory) {
return '_' + symbolCategory + 'Type';
}
/**
* @inner
*/
function createSymbol(name, lineData, idx) {
var symbolType = lineData.getItemVisual(idx, name);
if (!symbolType || symbolType === 'none') {
return;
}
var color = lineData.getItemVisual(idx, 'color');
var symbolSize = lineData.getItemVisual(idx, name + 'Size');
var symbolRotate = lineData.getItemVisual(idx, name + 'Rotate');
if (!zrUtil.isArray(symbolSize)) {
symbolSize = [symbolSize, symbolSize];
}
var symbolPath = symbolUtil.createSymbol(symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2, symbolSize[0], symbolSize[1], color); // rotate by default if symbolRotate is not specified or NaN
symbolPath.__specifiedRotation = symbolRotate == null || isNaN(symbolRotate) ? void 0 : +symbolRotate * Math.PI / 180 || 0;
symbolPath.name = name;
return symbolPath;
}
function createLine(points) {
var line = new LinePath({
name: 'line',
subPixelOptimize: true
});
setLinePoints(line.shape, points);
return line;
}
function setLinePoints(targetShape, points) {
targetShape.x1 = points[0][0];
targetShape.y1 = points[0][1];
targetShape.x2 = points[1][0];
targetShape.y2 = points[1][1];
targetShape.percent = 1;
var cp1 = points[2];
if (cp1) {
targetShape.cpx1 = cp1[0];
targetShape.cpy1 = cp1[1];
} else {
targetShape.cpx1 = NaN;
targetShape.cpy1 = NaN;
}
}
function updateSymbolAndLabelBeforeLineUpdate() {
var lineGroup = this;
var symbolFrom = lineGroup.childOfName('fromSymbol');
var symbolTo = lineGroup.childOfName('toSymbol');
var label = lineGroup.childOfName('label'); // Quick reject
if (!symbolFrom && !symbolTo && label.ignore) {
return;
}
var invScale = 1;
var parentNode = this.parent;
while (parentNode) {
if (parentNode.scale) {
invScale /= parentNode.scale[0];
}
parentNode = parentNode.parent;
}
var line = lineGroup.childOfName('line'); // If line not changed
// FIXME Parent scale changed
if (!this.__dirty && !line.__dirty) {
return;
}
var percent = line.shape.percent;
var fromPos = line.pointAt(0);
var toPos = line.pointAt(percent);
var d = vector.sub([], toPos, fromPos);
vector.normalize(d, d);
if (symbolFrom) {
symbolFrom.attr('position', fromPos); // Fix #12388
// when symbol is set to be 'arrow' in markLine,
// symbolRotate value will be ignored, and compulsively use tangent angle.
// rotate by default if symbol rotation is not specified
var specifiedRotation = symbolFrom.__specifiedRotation;
if (specifiedRotation == null) {
var tangent = line.tangentAt(0);
symbolFrom.attr('rotation', Math.PI / 2 - Math.atan2(tangent[1], tangent[0]));
} else {
symbolFrom.attr('rotation', specifiedRotation);
}
symbolFrom.attr('scale', [invScale * percent, invScale * percent]);
}
if (symbolTo) {
symbolTo.attr('position', toPos); // Fix #12388
// when symbol is set to be 'arrow' in markLine,
// symbolRotate value will be ignored, and compulsively use tangent angle.
// rotate by default if symbol rotation is not specified
var specifiedRotation = symbolTo.__specifiedRotation;
if (specifiedRotation == null) {
var tangent = line.tangentAt(1);
symbolTo.attr('rotation', -Math.PI / 2 - Math.atan2(tangent[1], tangent[0]));
} else {
symbolTo.attr('rotation', specifiedRotation);
}
symbolTo.attr('scale', [invScale * percent, invScale * percent]);
}
if (!label.ignore) {
label.attr('position', toPos);
var textPosition;
var textAlign;
var textVerticalAlign;
var textOrigin;
var distance = label.__labelDistance;
var distanceX = distance[0] * invScale;
var distanceY = distance[1] * invScale;
var halfPercent = percent / 2;
var tangent = line.tangentAt(halfPercent);
var n = [tangent[1], -tangent[0]];
var cp = line.pointAt(halfPercent);
if (n[1] > 0) {
n[0] = -n[0];
n[1] = -n[1];
}
var dir = tangent[0] < 0 ? -1 : 1;
if (label.__position !== 'start' && label.__position !== 'end') {
var rotation = -Math.atan2(tangent[1], tangent[0]);
if (toPos[0] < fromPos[0]) {
rotation = Math.PI + rotation;
}
label.attr('rotation', rotation);
}
var dy;
switch (label.__position) {
case 'insideStartTop':
case 'insideMiddleTop':
case 'insideEndTop':
case 'middle':
dy = -distanceY;
textVerticalAlign = 'bottom';
break;
case 'insideStartBottom':
case 'insideMiddleBottom':
case 'insideEndBottom':
dy = distanceY;
textVerticalAlign = 'top';
break;
default:
dy = 0;
textVerticalAlign = 'middle';
}
switch (label.__position) {
case 'end':
textPosition = [d[0] * distanceX + toPos[0], d[1] * distanceY + toPos[1]];
textAlign = d[0] > 0.8 ? 'left' : d[0] < -0.8 ? 'right' : 'center';
textVerticalAlign = d[1] > 0.8 ? 'top' : d[1] < -0.8 ? 'bottom' : 'middle';
break;
case 'start':
textPosition = [-d[0] * distanceX + fromPos[0], -d[1] * distanceY + fromPos[1]];
textAlign = d[0] > 0.8 ? 'right' : d[0] < -0.8 ? 'left' : 'center';
textVerticalAlign = d[1] > 0.8 ? 'bottom' : d[1] < -0.8 ? 'top' : 'middle';
break;
case 'insideStartTop':
case 'insideStart':
case 'insideStartBottom':
textPosition = [distanceX * dir + fromPos[0], fromPos[1] + dy];
textAlign = tangent[0] < 0 ? 'right' : 'left';
textOrigin = [-distanceX * dir, -dy];
break;
case 'insideMiddleTop':
case 'insideMiddle':
case 'insideMiddleBottom':
case 'middle':
textPosition = [cp[0], cp[1] + dy];
textAlign = 'center';
textOrigin = [0, -dy];
break;
case 'insideEndTop':
case 'insideEnd':
case 'insideEndBottom':
textPosition = [-distanceX * dir + toPos[0], toPos[1] + dy];
textAlign = tangent[0] >= 0 ? 'right' : 'left';
textOrigin = [distanceX * dir, -dy];
break;
}
label.attr({
style: {
// Use the user specified text align and baseline first
textVerticalAlign: label.__verticalAlign || textVerticalAlign,
textAlign: label.__textAlign || textAlign
},
position: textPosition,
scale: [invScale, invScale],
origin: textOrigin
});
}
}
/**
* @constructor
* @extends {module:zrender/graphic/Group}
* @alias {module:echarts/chart/helper/Line}
*/
function Line(lineData, idx, seriesScope) {
graphic.Group.call(this);
this._createLine(lineData, idx, seriesScope);
}
var lineProto = Line.prototype; // Update symbol position and rotation
lineProto.beforeUpdate = updateSymbolAndLabelBeforeLineUpdate;
lineProto._createLine = function (lineData, idx, seriesScope) {
var seriesModel = lineData.hostModel;
var linePoints = lineData.getItemLayout(idx);
var line = createLine(linePoints);
line.shape.percent = 0;
graphic.initProps(line, {
shape: {
percent: 1
}
}, seriesModel, idx);
this.add(line);
var label = new graphic.Text({
name: 'label',
// FIXME
// Temporary solution for `focusNodeAdjacency`.
// line label do not use the opacity of lineStyle.
lineLabelOriginalOpacity: 1
});
this.add(label);
zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
var symbol = createSymbol(symbolCategory, lineData, idx); // symbols must added after line to make sure
// it will be updated after line#update.
// Or symbol position and rotation update in line#beforeUpdate will be one frame slow
this.add(symbol);
this[makeSymbolTypeKey(symbolCategory)] = lineData.getItemVisual(idx, symbolCategory);
}, this);
this._updateCommonStl(lineData, idx, seriesScope);
};
lineProto.updateData = function (lineData, idx, seriesScope) {
var seriesModel = lineData.hostModel;
var line = this.childOfName('line');
var linePoints = lineData.getItemLayout(idx);
var target = {
shape: {}
};
setLinePoints(target.shape, linePoints);
graphic.updateProps(line, target, seriesModel, idx);
zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
var symbolType = lineData.getItemVisual(idx, symbolCategory);
var key = makeSymbolTypeKey(symbolCategory); // Symbol changed
if (this[key] !== symbolType) {
this.remove(this.childOfName(symbolCategory));
var symbol = createSymbol(symbolCategory, lineData, idx);
this.add(symbol);
}
this[key] = symbolType;
}, this);
this._updateCommonStl(lineData, idx, seriesScope);
};
lineProto._updateCommonStl = function (lineData, idx, seriesScope) {
var seriesModel = lineData.hostModel;
var line = this.childOfName('line');
var lineStyle = seriesScope && seriesScope.lineStyle;
var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
var labelModel = seriesScope && seriesScope.labelModel;
var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel; // Optimization for large dataset
if (!seriesScope || lineData.hasItemOption) {
var itemModel = lineData.getItemModel(idx);
lineStyle = itemModel.getModel('lineStyle').getLineStyle();
hoverLineStyle = itemModel.getModel('emphasis.lineStyle').getLineStyle();
labelModel = itemModel.getModel('label');
hoverLabelModel = itemModel.getModel('emphasis.label');
}
var visualColor = lineData.getItemVisual(idx, 'color');
var visualOpacity = zrUtil.retrieve3(lineData.getItemVisual(idx, 'opacity'), lineStyle.opacity, 1);
line.useStyle(zrUtil.defaults({
strokeNoScale: true,
fill: 'none',
stroke: visualColor,
opacity: visualOpacity
}, lineStyle));
line.hoverStyle = hoverLineStyle; // Update symbol
zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
var symbol = this.childOfName(symbolCategory);
if (symbol) {
symbol.setColor(visualColor);
symbol.setStyle({
opacity: visualOpacity
});
}
}, this);
var showLabel = labelModel.getShallow('show');
var hoverShowLabel = hoverLabelModel.getShallow('show');
var label = this.childOfName('label');
var defaultLabelColor;
var baseText; // FIXME: the logic below probably should be merged to `graphic.setLabelStyle`.
if (showLabel || hoverShowLabel) {
defaultLabelColor = visualColor || '#000';
baseText = seriesModel.getFormattedLabel(idx, 'normal', lineData.dataType);
if (baseText == null) {
var rawVal = seriesModel.getRawValue(idx);
baseText = rawVal == null ? lineData.getName(idx) : isFinite(rawVal) ? round(rawVal) : rawVal;
}
}
var normalText = showLabel ? baseText : null;
var emphasisText = hoverShowLabel ? zrUtil.retrieve2(seriesModel.getFormattedLabel(idx, 'emphasis', lineData.dataType), baseText) : null;
var labelStyle = label.style; // Always set `textStyle` even if `normalStyle.text` is null, because default
// values have to be set on `normalStyle`.
if (normalText != null || emphasisText != null) {
graphic.setTextStyle(label.style, labelModel, {
text: normalText
}, {
autoColor: defaultLabelColor
});
label.__textAlign = labelStyle.textAlign;
label.__verticalAlign = labelStyle.textVerticalAlign; // 'start', 'middle', 'end'
label.__position = labelModel.get('position') || 'middle';
var distance = labelModel.get('distance');
if (!zrUtil.isArray(distance)) {
distance = [distance, distance];
}
label.__labelDistance = distance;
}
if (emphasisText != null) {
// Only these properties supported in this emphasis style here.
label.hoverStyle = {
text: emphasisText,
textFill: hoverLabelModel.getTextColor(true),
// For merging hover style to normal style, do not use
// `hoverLabelModel.getFont()` here.
fontStyle: hoverLabelModel.getShallow('fontStyle'),
fontWeight: hoverLabelModel.getShallow('fontWeight'),
fontSize: hoverLabelModel.getShallow('fontSize'),
fontFamily: hoverLabelModel.getShallow('fontFamily')
};
} else {
label.hoverStyle = {
text: null
};
}
label.ignore = !showLabel && !hoverShowLabel;
graphic.setHoverStyle(this);
};
lineProto.highlight = function () {
this.trigger('emphasis');
};
lineProto.downplay = function () {
this.trigger('normal');
};
lineProto.updateLayout = function (lineData, idx) {
this.setLinePoints(lineData.getItemLayout(idx));
};
lineProto.setLinePoints = function (points) {
var linePath = this.childOfName('line');
setLinePoints(linePath.shape, points);
linePath.dirty();
};
zrUtil.inherits(Line, graphic.Group);
var _default = Line;
module.exports = _default;

194
node_modules/echarts/lib/chart/helper/LineDraw.js generated vendored Normal file
View File

@ -0,0 +1,194 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var LineGroup = require("./Line");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @module echarts/chart/helper/LineDraw
*/
// import IncrementalDisplayable from 'zrender/src/graphic/IncrementalDisplayable';
/**
* @alias module:echarts/component/marker/LineDraw
* @constructor
*/
function LineDraw(ctor) {
this._ctor = ctor || LineGroup;
this.group = new graphic.Group();
}
var lineDrawProto = LineDraw.prototype;
lineDrawProto.isPersistent = function () {
return true;
};
/**
* @param {module:echarts/data/List} lineData
*/
lineDrawProto.updateData = function (lineData) {
var lineDraw = this;
var group = lineDraw.group;
var oldLineData = lineDraw._lineData;
lineDraw._lineData = lineData; // There is no oldLineData only when first rendering or switching from
// stream mode to normal mode, where previous elements should be removed.
if (!oldLineData) {
group.removeAll();
}
var seriesScope = makeSeriesScope(lineData);
lineData.diff(oldLineData).add(function (idx) {
doAdd(lineDraw, lineData, idx, seriesScope);
}).update(function (newIdx, oldIdx) {
doUpdate(lineDraw, oldLineData, lineData, oldIdx, newIdx, seriesScope);
}).remove(function (idx) {
group.remove(oldLineData.getItemGraphicEl(idx));
}).execute();
};
function doAdd(lineDraw, lineData, idx, seriesScope) {
var itemLayout = lineData.getItemLayout(idx);
if (!lineNeedsDraw(itemLayout)) {
return;
}
var el = new lineDraw._ctor(lineData, idx, seriesScope);
lineData.setItemGraphicEl(idx, el);
lineDraw.group.add(el);
}
function doUpdate(lineDraw, oldLineData, newLineData, oldIdx, newIdx, seriesScope) {
var itemEl = oldLineData.getItemGraphicEl(oldIdx);
if (!lineNeedsDraw(newLineData.getItemLayout(newIdx))) {
lineDraw.group.remove(itemEl);
return;
}
if (!itemEl) {
itemEl = new lineDraw._ctor(newLineData, newIdx, seriesScope);
} else {
itemEl.updateData(newLineData, newIdx, seriesScope);
}
newLineData.setItemGraphicEl(newIdx, itemEl);
lineDraw.group.add(itemEl);
}
lineDrawProto.updateLayout = function () {
var lineData = this._lineData; // Do not support update layout in incremental mode.
if (!lineData) {
return;
}
lineData.eachItemGraphicEl(function (el, idx) {
el.updateLayout(lineData, idx);
}, this);
};
lineDrawProto.incrementalPrepareUpdate = function (lineData) {
this._seriesScope = makeSeriesScope(lineData);
this._lineData = null;
this.group.removeAll();
};
function isEffectObject(el) {
return el.animators && el.animators.length > 0;
}
lineDrawProto.incrementalUpdate = function (taskParams, lineData) {
function updateIncrementalAndHover(el) {
if (!el.isGroup && !isEffectObject(el)) {
el.incremental = el.useHoverLayer = true;
}
}
for (var idx = taskParams.start; idx < taskParams.end; idx++) {
var itemLayout = lineData.getItemLayout(idx);
if (lineNeedsDraw(itemLayout)) {
var el = new this._ctor(lineData, idx, this._seriesScope);
el.traverse(updateIncrementalAndHover);
this.group.add(el);
lineData.setItemGraphicEl(idx, el);
}
}
};
function makeSeriesScope(lineData) {
var hostModel = lineData.hostModel;
return {
lineStyle: hostModel.getModel('lineStyle').getLineStyle(),
hoverLineStyle: hostModel.getModel('emphasis.lineStyle').getLineStyle(),
labelModel: hostModel.getModel('label'),
hoverLabelModel: hostModel.getModel('emphasis.label')
};
}
lineDrawProto.remove = function () {
this._clearIncremental();
this._incremental = null;
this.group.removeAll();
};
lineDrawProto._clearIncremental = function () {
var incremental = this._incremental;
if (incremental) {
incremental.clearDisplaybles();
}
};
function isPointNaN(pt) {
return isNaN(pt[0]) || isNaN(pt[1]);
}
function lineNeedsDraw(pts) {
return !isPointNaN(pts[0]) && !isPointNaN(pts[1]);
}
var _default = LineDraw;
module.exports = _default;

87
node_modules/echarts/lib/chart/helper/LinePath.js generated vendored Normal file
View File

@ -0,0 +1,87 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var vec2 = require("zrender/lib/core/vector");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Line path for bezier and straight line draw
*/
var straightLineProto = graphic.Line.prototype;
var bezierCurveProto = graphic.BezierCurve.prototype;
function isLine(shape) {
return isNaN(+shape.cpx1) || isNaN(+shape.cpy1);
}
var _default = graphic.extendShape({
type: 'ec-line',
style: {
stroke: '#000',
fill: null
},
shape: {
x1: 0,
y1: 0,
x2: 0,
y2: 0,
percent: 1,
cpx1: null,
cpy1: null
},
buildPath: function (ctx, shape) {
this[isLine(shape) ? '_buildPathLine' : '_buildPathCurve'](ctx, shape);
},
_buildPathLine: straightLineProto.buildPath,
_buildPathCurve: bezierCurveProto.buildPath,
pointAt: function (t) {
return this[isLine(this.shape) ? '_pointAtLine' : '_pointAtCurve'](t);
},
_pointAtLine: straightLineProto.pointAt,
_pointAtCurve: bezierCurveProto.pointAt,
tangentAt: function (t) {
var shape = this.shape;
var p = isLine(shape) ? [shape.x2 - shape.x1, shape.y2 - shape.y1] : this._tangentAtCurve(t);
return vec2.normalize(p, p);
},
_tangentAtCurve: bezierCurveProto.tangentAt
});
module.exports = _default;

115
node_modules/echarts/lib/chart/helper/Polyline.js generated vendored Normal file
View File

@ -0,0 +1,115 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var zrUtil = require("zrender/lib/core/util");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @module echarts/chart/helper/Line
*/
/**
* @constructor
* @extends {module:zrender/graphic/Group}
* @alias {module:echarts/chart/helper/Polyline}
*/
function Polyline(lineData, idx, seriesScope) {
graphic.Group.call(this);
this._createPolyline(lineData, idx, seriesScope);
}
var polylineProto = Polyline.prototype;
polylineProto._createPolyline = function (lineData, idx, seriesScope) {
// var seriesModel = lineData.hostModel;
var points = lineData.getItemLayout(idx);
var line = new graphic.Polyline({
shape: {
points: points
}
});
this.add(line);
this._updateCommonStl(lineData, idx, seriesScope);
};
polylineProto.updateData = function (lineData, idx, seriesScope) {
var seriesModel = lineData.hostModel;
var line = this.childAt(0);
var target = {
shape: {
points: lineData.getItemLayout(idx)
}
};
graphic.updateProps(line, target, seriesModel, idx);
this._updateCommonStl(lineData, idx, seriesScope);
};
polylineProto._updateCommonStl = function (lineData, idx, seriesScope) {
var line = this.childAt(0);
var itemModel = lineData.getItemModel(idx);
var visualColor = lineData.getItemVisual(idx, 'color');
var lineStyle = seriesScope && seriesScope.lineStyle;
var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
if (!seriesScope || lineData.hasItemOption) {
lineStyle = itemModel.getModel('lineStyle').getLineStyle();
hoverLineStyle = itemModel.getModel('emphasis.lineStyle').getLineStyle();
}
line.useStyle(zrUtil.defaults({
strokeNoScale: true,
fill: 'none',
stroke: visualColor
}, lineStyle));
line.hoverStyle = hoverLineStyle;
graphic.setHoverStyle(this);
};
polylineProto.updateLayout = function (lineData, idx) {
var polyline = this.childAt(0);
polyline.setShape('points', lineData.getItemLayout(idx));
};
zrUtil.inherits(Polyline, graphic.Group);
var _default = Polyline;
module.exports = _default;

388
node_modules/echarts/lib/chart/helper/Symbol.js generated vendored Normal file
View File

@ -0,0 +1,388 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var zrUtil = require("zrender/lib/core/util");
var _symbol = require("../../util/symbol");
var createSymbol = _symbol.createSymbol;
var graphic = require("../../util/graphic");
var _number = require("../../util/number");
var parsePercent = _number.parsePercent;
var _labelHelper = require("./labelHelper");
var getDefaultLabel = _labelHelper.getDefaultLabel;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @module echarts/chart/helper/Symbol
*/
/**
* @constructor
* @alias {module:echarts/chart/helper/Symbol}
* @param {module:echarts/data/List} data
* @param {number} idx
* @extends {module:zrender/graphic/Group}
*/
function SymbolClz(data, idx, seriesScope) {
graphic.Group.call(this);
this.updateData(data, idx, seriesScope);
}
var symbolProto = SymbolClz.prototype;
/**
* @public
* @static
* @param {module:echarts/data/List} data
* @param {number} dataIndex
* @return {Array.<number>} [width, height]
*/
var getSymbolSize = SymbolClz.getSymbolSize = function (data, idx) {
var symbolSize = data.getItemVisual(idx, 'symbolSize');
return symbolSize instanceof Array ? symbolSize.slice() : [+symbolSize, +symbolSize];
};
function getScale(symbolSize) {
return [symbolSize[0] / 2, symbolSize[1] / 2];
}
function driftSymbol(dx, dy) {
this.parent.drift(dx, dy);
}
symbolProto._createSymbol = function (symbolType, data, idx, symbolSize, keepAspect) {
// Remove paths created before
this.removeAll();
var color = data.getItemVisual(idx, 'color'); // var symbolPath = createSymbol(
// symbolType, -0.5, -0.5, 1, 1, color
// );
// If width/height are set too small (e.g., set to 1) on ios10
// and macOS Sierra, a circle stroke become a rect, no matter what
// the scale is set. So we set width/height as 2. See #4150.
var symbolPath = createSymbol(symbolType, -1, -1, 2, 2, color, keepAspect);
symbolPath.attr({
z2: 100,
culling: true,
scale: getScale(symbolSize)
}); // Rewrite drift method
symbolPath.drift = driftSymbol;
this._symbolType = symbolType;
this.add(symbolPath);
};
/**
* Stop animation
* @param {boolean} toLastFrame
*/
symbolProto.stopSymbolAnimation = function (toLastFrame) {
this.childAt(0).stopAnimation(toLastFrame);
};
/**
* FIXME:
* Caution: This method breaks the encapsulation of this module,
* but it indeed brings convenience. So do not use the method
* unless you detailedly know all the implements of `Symbol`,
* especially animation.
*
* Get symbol path element.
*/
symbolProto.getSymbolPath = function () {
return this.childAt(0);
};
/**
* Get scale(aka, current symbol size).
* Including the change caused by animation
*/
symbolProto.getScale = function () {
return this.childAt(0).scale;
};
/**
* Highlight symbol
*/
symbolProto.highlight = function () {
this.childAt(0).trigger('emphasis');
};
/**
* Downplay symbol
*/
symbolProto.downplay = function () {
this.childAt(0).trigger('normal');
};
/**
* @param {number} zlevel
* @param {number} z
*/
symbolProto.setZ = function (zlevel, z) {
var symbolPath = this.childAt(0);
symbolPath.zlevel = zlevel;
symbolPath.z = z;
};
symbolProto.setDraggable = function (draggable) {
var symbolPath = this.childAt(0);
symbolPath.draggable = draggable;
symbolPath.cursor = draggable ? 'move' : symbolPath.cursor;
};
/**
* Update symbol properties
* @param {module:echarts/data/List} data
* @param {number} idx
* @param {Object} [seriesScope]
* @param {Object} [seriesScope.itemStyle]
* @param {Object} [seriesScope.hoverItemStyle]
* @param {Object} [seriesScope.symbolRotate]
* @param {Object} [seriesScope.symbolOffset]
* @param {module:echarts/model/Model} [seriesScope.labelModel]
* @param {module:echarts/model/Model} [seriesScope.hoverLabelModel]
* @param {boolean} [seriesScope.hoverAnimation]
* @param {Object} [seriesScope.cursorStyle]
* @param {module:echarts/model/Model} [seriesScope.itemModel]
* @param {string} [seriesScope.symbolInnerColor]
* @param {Object} [seriesScope.fadeIn=false]
*/
symbolProto.updateData = function (data, idx, seriesScope) {
this.silent = false;
var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
var seriesModel = data.hostModel;
var symbolSize = getSymbolSize(data, idx);
var isInit = symbolType !== this._symbolType;
if (isInit) {
var keepAspect = data.getItemVisual(idx, 'symbolKeepAspect');
this._createSymbol(symbolType, data, idx, symbolSize, keepAspect);
} else {
var symbolPath = this.childAt(0);
symbolPath.silent = false;
graphic.updateProps(symbolPath, {
scale: getScale(symbolSize)
}, seriesModel, idx);
}
this._updateCommon(data, idx, symbolSize, seriesScope);
if (isInit) {
var symbolPath = this.childAt(0);
var fadeIn = seriesScope && seriesScope.fadeIn;
var target = {
scale: symbolPath.scale.slice()
};
fadeIn && (target.style = {
opacity: symbolPath.style.opacity
});
symbolPath.scale = [0, 0];
fadeIn && (symbolPath.style.opacity = 0);
graphic.initProps(symbolPath, target, seriesModel, idx);
}
this._seriesModel = seriesModel;
}; // Update common properties
var normalStyleAccessPath = ['itemStyle'];
var emphasisStyleAccessPath = ['emphasis', 'itemStyle'];
var normalLabelAccessPath = ['label'];
var emphasisLabelAccessPath = ['emphasis', 'label'];
/**
* @param {module:echarts/data/List} data
* @param {number} idx
* @param {Array.<number>} symbolSize
* @param {Object} [seriesScope]
*/
symbolProto._updateCommon = function (data, idx, symbolSize, seriesScope) {
var symbolPath = this.childAt(0);
var seriesModel = data.hostModel;
var color = data.getItemVisual(idx, 'color'); // Reset style
if (symbolPath.type !== 'image') {
symbolPath.useStyle({
strokeNoScale: true
});
} else {
symbolPath.setStyle({
opacity: 1,
shadowBlur: null,
shadowOffsetX: null,
shadowOffsetY: null,
shadowColor: null
});
}
var itemStyle = seriesScope && seriesScope.itemStyle;
var hoverItemStyle = seriesScope && seriesScope.hoverItemStyle;
var symbolOffset = seriesScope && seriesScope.symbolOffset;
var labelModel = seriesScope && seriesScope.labelModel;
var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
var hoverAnimation = seriesScope && seriesScope.hoverAnimation;
var cursorStyle = seriesScope && seriesScope.cursorStyle;
if (!seriesScope || data.hasItemOption) {
var itemModel = seriesScope && seriesScope.itemModel ? seriesScope.itemModel : data.getItemModel(idx); // Color must be excluded.
// Because symbol provide setColor individually to set fill and stroke
itemStyle = itemModel.getModel(normalStyleAccessPath).getItemStyle(['color']);
hoverItemStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
symbolOffset = itemModel.getShallow('symbolOffset');
labelModel = itemModel.getModel(normalLabelAccessPath);
hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath);
hoverAnimation = itemModel.getShallow('hoverAnimation');
cursorStyle = itemModel.getShallow('cursor');
} else {
hoverItemStyle = zrUtil.extend({}, hoverItemStyle);
}
var elStyle = symbolPath.style;
var symbolRotate = data.getItemVisual(idx, 'symbolRotate');
symbolPath.attr('rotation', (symbolRotate || 0) * Math.PI / 180 || 0);
if (symbolOffset) {
symbolPath.attr('position', [parsePercent(symbolOffset[0], symbolSize[0]), parsePercent(symbolOffset[1], symbolSize[1])]);
}
cursorStyle && symbolPath.attr('cursor', cursorStyle); // PENDING setColor before setStyle!!!
symbolPath.setColor(color, seriesScope && seriesScope.symbolInnerColor);
symbolPath.setStyle(itemStyle);
var opacity = data.getItemVisual(idx, 'opacity');
if (opacity != null) {
elStyle.opacity = opacity;
}
var liftZ = data.getItemVisual(idx, 'liftZ');
var z2Origin = symbolPath.__z2Origin;
if (liftZ != null) {
if (z2Origin == null) {
symbolPath.__z2Origin = symbolPath.z2;
symbolPath.z2 += liftZ;
}
} else if (z2Origin != null) {
symbolPath.z2 = z2Origin;
symbolPath.__z2Origin = null;
}
var useNameLabel = seriesScope && seriesScope.useNameLabel;
graphic.setLabelStyle(elStyle, hoverItemStyle, labelModel, hoverLabelModel, {
labelFetcher: seriesModel,
labelDataIndex: idx,
defaultText: getLabelDefaultText,
isRectText: true,
autoColor: color
}); // Do not execute util needed.
function getLabelDefaultText(idx, opt) {
return useNameLabel ? data.getName(idx) : getDefaultLabel(data, idx);
}
symbolPath.__symbolOriginalScale = getScale(symbolSize);
symbolPath.hoverStyle = hoverItemStyle;
symbolPath.highDownOnUpdate = hoverAnimation && seriesModel.isAnimationEnabled() ? highDownOnUpdate : null;
graphic.setHoverStyle(symbolPath);
};
function highDownOnUpdate(fromState, toState) {
// Do not support this hover animation util some scenario required.
// Animation can only be supported in hover layer when using `el.incremetal`.
if (this.incremental || this.useHoverLayer) {
return;
}
if (toState === 'emphasis') {
var scale = this.__symbolOriginalScale;
var ratio = scale[1] / scale[0];
var emphasisOpt = {
scale: [Math.max(scale[0] * 1.1, scale[0] + 3), Math.max(scale[1] * 1.1, scale[1] + 3 * ratio)]
}; // FIXME
// modify it after support stop specified animation.
// toState === fromState
// ? (this.stopAnimation(), this.attr(emphasisOpt))
this.animateTo(emphasisOpt, 400, 'elasticOut');
} else if (toState === 'normal') {
this.animateTo({
scale: this.__symbolOriginalScale
}, 400, 'elasticOut');
}
}
/**
* @param {Function} cb
* @param {Object} [opt]
* @param {Object} [opt.keepLabel=true]
*/
symbolProto.fadeOut = function (cb, opt) {
var symbolPath = this.childAt(0); // Avoid mistaken hover when fading out
this.silent = symbolPath.silent = true; // Not show text when animating
!(opt && opt.keepLabel) && (symbolPath.style.text = null);
graphic.updateProps(symbolPath, {
style: {
opacity: 0
},
scale: [0, 0]
}, this._seriesModel, this.dataIndex, cb);
};
zrUtil.inherits(SymbolClz, graphic.Group);
var _default = SymbolClz;
module.exports = _default;

224
node_modules/echarts/lib/chart/helper/SymbolDraw.js generated vendored Normal file
View File

@ -0,0 +1,224 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var SymbolClz = require("./Symbol");
var _util = require("zrender/lib/core/util");
var isObject = _util.isObject;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @module echarts/chart/helper/SymbolDraw
*/
/**
* @constructor
* @alias module:echarts/chart/helper/SymbolDraw
* @param {module:zrender/graphic/Group} [symbolCtor]
*/
function SymbolDraw(symbolCtor) {
this.group = new graphic.Group();
this._symbolCtor = symbolCtor || SymbolClz;
}
var symbolDrawProto = SymbolDraw.prototype;
function symbolNeedsDraw(data, point, idx, opt) {
return point && !isNaN(point[0]) && !isNaN(point[1]) && !(opt.isIgnore && opt.isIgnore(idx)) // We do not set clipShape on group, because it will cut part of
// the symbol element shape. We use the same clip shape here as
// the line clip.
&& !(opt.clipShape && !opt.clipShape.contain(point[0], point[1])) && data.getItemVisual(idx, 'symbol') !== 'none';
}
/**
* Update symbols draw by new data
* @param {module:echarts/data/List} data
* @param {Object} [opt] Or isIgnore
* @param {Function} [opt.isIgnore]
* @param {Object} [opt.clipShape]
*/
symbolDrawProto.updateData = function (data, opt) {
opt = normalizeUpdateOpt(opt);
var group = this.group;
var seriesModel = data.hostModel;
var oldData = this._data;
var SymbolCtor = this._symbolCtor;
var seriesScope = makeSeriesScope(data); // There is no oldLineData only when first rendering or switching from
// stream mode to normal mode, where previous elements should be removed.
if (!oldData) {
group.removeAll();
}
data.diff(oldData).add(function (newIdx) {
var point = data.getItemLayout(newIdx);
if (symbolNeedsDraw(data, point, newIdx, opt)) {
var symbolEl = new SymbolCtor(data, newIdx, seriesScope);
symbolEl.attr('position', point);
data.setItemGraphicEl(newIdx, symbolEl);
group.add(symbolEl);
}
}).update(function (newIdx, oldIdx) {
var symbolEl = oldData.getItemGraphicEl(oldIdx);
var point = data.getItemLayout(newIdx);
if (!symbolNeedsDraw(data, point, newIdx, opt)) {
group.remove(symbolEl);
return;
}
if (!symbolEl) {
symbolEl = new SymbolCtor(data, newIdx);
symbolEl.attr('position', point);
} else {
symbolEl.updateData(data, newIdx, seriesScope);
graphic.updateProps(symbolEl, {
position: point
}, seriesModel);
} // Add back
group.add(symbolEl);
data.setItemGraphicEl(newIdx, symbolEl);
}).remove(function (oldIdx) {
var el = oldData.getItemGraphicEl(oldIdx);
el && el.fadeOut(function () {
group.remove(el);
});
}).execute();
this._data = data;
};
symbolDrawProto.isPersistent = function () {
return true;
};
symbolDrawProto.updateLayout = function () {
var data = this._data;
if (data) {
// Not use animation
data.eachItemGraphicEl(function (el, idx) {
var point = data.getItemLayout(idx);
el.attr('position', point);
});
}
};
symbolDrawProto.incrementalPrepareUpdate = function (data) {
this._seriesScope = makeSeriesScope(data);
this._data = null;
this.group.removeAll();
};
/**
* Update symbols draw by new data
* @param {module:echarts/data/List} data
* @param {Object} [opt] Or isIgnore
* @param {Function} [opt.isIgnore]
* @param {Object} [opt.clipShape]
*/
symbolDrawProto.incrementalUpdate = function (taskParams, data, opt) {
opt = normalizeUpdateOpt(opt);
function updateIncrementalAndHover(el) {
if (!el.isGroup) {
el.incremental = el.useHoverLayer = true;
}
}
for (var idx = taskParams.start; idx < taskParams.end; idx++) {
var point = data.getItemLayout(idx);
if (symbolNeedsDraw(data, point, idx, opt)) {
var el = new this._symbolCtor(data, idx, this._seriesScope);
el.traverse(updateIncrementalAndHover);
el.attr('position', point);
this.group.add(el);
data.setItemGraphicEl(idx, el);
}
}
};
function normalizeUpdateOpt(opt) {
if (opt != null && !isObject(opt)) {
opt = {
isIgnore: opt
};
}
return opt || {};
}
symbolDrawProto.remove = function (enableAnimation) {
var group = this.group;
var data = this._data; // Incremental model do not have this._data.
if (data && enableAnimation) {
data.eachItemGraphicEl(function (el) {
el.fadeOut(function () {
group.remove(el);
});
});
} else {
group.removeAll();
}
};
function makeSeriesScope(data) {
var seriesModel = data.hostModel;
return {
itemStyle: seriesModel.getModel('itemStyle').getItemStyle(['color']),
hoverItemStyle: seriesModel.getModel('emphasis.itemStyle').getItemStyle(),
symbolRotate: seriesModel.get('symbolRotate'),
symbolOffset: seriesModel.get('symbolOffset'),
hoverAnimation: seriesModel.get('hoverAnimation'),
labelModel: seriesModel.getModel('label'),
hoverLabelModel: seriesModel.getModel('emphasis.label'),
cursorStyle: seriesModel.get('cursor')
};
}
var _default = SymbolDraw;
module.exports = _default;

View File

@ -0,0 +1,124 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var _number = require("../../util/number");
var round = _number.round;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function createGridClipPath(cartesian, hasAnimation, seriesModel) {
var rect = cartesian.getArea();
var isHorizontal = cartesian.getBaseAxis().isHorizontal();
var x = rect.x;
var y = rect.y;
var width = rect.width;
var height = rect.height;
var lineWidth = seriesModel.get('lineStyle.width') || 2; // Expand the clip path a bit to avoid the border is clipped and looks thinner
x -= lineWidth / 2;
y -= lineWidth / 2;
width += lineWidth;
height += lineWidth; // fix: https://github.com/apache/incubator-echarts/issues/11369
x = Math.floor(x);
width = Math.round(width);
var clipPath = new graphic.Rect({
shape: {
x: x,
y: y,
width: width,
height: height
}
});
if (hasAnimation) {
clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
graphic.initProps(clipPath, {
shape: {
width: width,
height: height
}
}, seriesModel);
}
return clipPath;
}
function createPolarClipPath(polar, hasAnimation, seriesModel) {
var sectorArea = polar.getArea(); // Avoid float number rounding error for symbol on the edge of axis extent.
var clipPath = new graphic.Sector({
shape: {
cx: round(polar.cx, 1),
cy: round(polar.cy, 1),
r0: round(sectorArea.r0, 1),
r: round(sectorArea.r, 1),
startAngle: sectorArea.startAngle,
endAngle: sectorArea.endAngle,
clockwise: sectorArea.clockwise
}
});
if (hasAnimation) {
clipPath.shape.endAngle = sectorArea.startAngle;
graphic.initProps(clipPath, {
shape: {
endAngle: sectorArea.endAngle
}
}, seriesModel);
}
return clipPath;
}
function createClipPath(coordSys, hasAnimation, seriesModel) {
if (!coordSys) {
return null;
} else if (coordSys.type === 'polar') {
return createPolarClipPath(coordSys, hasAnimation, seriesModel);
} else if (coordSys.type === 'cartesian2d') {
return createGridClipPath(coordSys, hasAnimation, seriesModel);
}
return null;
}
exports.createGridClipPath = createGridClipPath;
exports.createPolarClipPath = createPolarClipPath;
exports.createClipPath = createClipPath;

View File

@ -0,0 +1,122 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var zrUtil = require("zrender/lib/core/util");
var List = require("../../data/List");
var Graph = require("../../data/Graph");
var linkList = require("../../data/helper/linkList");
var createDimensions = require("../../data/helper/createDimensions");
var CoordinateSystem = require("../../CoordinateSystem");
var createListFromArray = require("./createListFromArray");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function _default(nodes, edges, seriesModel, directed, beforeLink) {
// ??? TODO
// support dataset?
var graph = new Graph(directed);
for (var i = 0; i < nodes.length; i++) {
graph.addNode(zrUtil.retrieve( // Id, name, dataIndex
nodes[i].id, nodes[i].name, i), i);
}
var linkNameList = [];
var validEdges = [];
var linkCount = 0;
for (var i = 0; i < edges.length; i++) {
var link = edges[i];
var source = link.source;
var target = link.target; // addEdge may fail when source or target not exists
if (graph.addEdge(source, target, linkCount)) {
validEdges.push(link);
linkNameList.push(zrUtil.retrieve(link.id, source + ' > ' + target));
linkCount++;
}
}
var coordSys = seriesModel.get('coordinateSystem');
var nodeData;
if (coordSys === 'cartesian2d' || coordSys === 'polar') {
nodeData = createListFromArray(nodes, seriesModel);
} else {
var coordSysCtor = CoordinateSystem.get(coordSys);
var coordDimensions = coordSysCtor && coordSysCtor.type !== 'view' ? coordSysCtor.dimensions || [] : []; // FIXME: Some geo do not need `value` dimenson, whereas `calendar` needs
// `value` dimension, but graph need `value` dimension. It's better to
// uniform this behavior.
if (zrUtil.indexOf(coordDimensions, 'value') < 0) {
coordDimensions.concat(['value']);
}
var dimensionNames = createDimensions(nodes, {
coordDimensions: coordDimensions
});
nodeData = new List(dimensionNames, seriesModel);
nodeData.initData(nodes);
}
var edgeData = new List(['value'], seriesModel);
edgeData.initData(validEdges, linkNameList);
beforeLink && beforeLink(nodeData, edgeData);
linkList({
mainData: nodeData,
struct: graph,
structAttr: 'graph',
datas: {
node: nodeData,
edge: edgeData
},
datasAttr: {
node: 'data',
edge: 'edgeData'
}
}); // Update dataIndex of nodes and edges because invalid edge may be removed
graph.update();
return graph;
}
module.exports = _default;

View File

@ -0,0 +1,143 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var zrUtil = require("zrender/lib/core/util");
var List = require("../../data/List");
var Graph = require("../../data/Graph");
var linkList = require("../../data/helper/linkList");
var createDimensions = require("../../data/helper/createDimensions");
var CoordinateSystem = require("../../CoordinateSystem");
var createListFromArray = require("./createListFromArray");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* 从邻接矩阵生成
* ```
* TARGET
* -1--2--3--4--5-
* 1| x x x x x
* 2| x x x x x
* 3| x x x x x SOURCE
* 4| x x x x x
* 5| x x x x x
* ```
*
* @param {Array.<Object>} nodes 节点信息
* @param {Array} matrix 邻接矩阵
* @param {module:echarts/model/Series}
* @param {boolean} directed 是否是有向图
* @return {module:echarts/data/Graph}
*/
function _default(nodes, matrix, hostModel, directed) {
var graph = new Graph(directed);
for (var i = 0; i < nodes.length; i++) {
graph.addNode(zrUtil.retrieve( // Id, name, dataIndex
nodes[i].id, nodes[i].name, i), i);
}
var size = matrix.length;
var links = [];
var linkCount = 0;
for (var i = 0; i < size; i++) {
for (var j = 0; j < size; j++) {
var val = matrix[i][j];
if (val === 0) {
continue;
}
var n1 = graph.nodes[i];
var n2 = graph.nodes[j];
var edge = graph.addEdge(n1, n2, linkCount);
if (edge) {
linkCount++;
links.push({
value: val
});
}
}
}
var coordSys = hostModel.get('coordinateSystem');
var nodeData;
if (coordSys === 'cartesian2d' || coordSys === 'polar') {
nodeData = createListFromArray({
data: nodes
}, hostModel);
} else {
// FIXME
var coordSysCtor = CoordinateSystem.get(coordSys); // FIXME
var dimensionNames = createDimensions(nodes, {
coordDimensions: (coordSysCtor && coordSysCtor.type !== 'view' ? coordSysCtor.dimensions || [] : []).concat(['value'])
});
nodeData = new List(dimensionNames, hostModel);
nodeData.initData(nodes);
}
var edgeData = new List(['value'], hostModel);
edgeData.initData(links);
linkList({
mainData: nodeData,
struct: graph,
structAttr: 'graph',
datas: {
node: nodeData,
edge: edgeData
},
datasAttr: {
node: 'data',
edge: 'edgeData'
}
}); // Update dataIndex of nodes and edges because invalid edge may be removed
graph.update();
return graph;
}
module.exports = _default;

View File

@ -0,0 +1,172 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var zrUtil = require("zrender/lib/core/util");
var List = require("../../data/List");
var createDimensions = require("../../data/helper/createDimensions");
var _sourceType = require("../../data/helper/sourceType");
var SOURCE_FORMAT_ORIGINAL = _sourceType.SOURCE_FORMAT_ORIGINAL;
var _dimensionHelper = require("../../data/helper/dimensionHelper");
var getDimensionTypeByAxis = _dimensionHelper.getDimensionTypeByAxis;
var _model = require("../../util/model");
var getDataItemValue = _model.getDataItemValue;
var CoordinateSystem = require("../../CoordinateSystem");
var _referHelper = require("../../model/referHelper");
var getCoordSysInfoBySeries = _referHelper.getCoordSysInfoBySeries;
var Source = require("../../data/Source");
var _dataStackHelper = require("../../data/helper/dataStackHelper");
var enableDataStack = _dataStackHelper.enableDataStack;
var _sourceHelper = require("../../data/helper/sourceHelper");
var makeSeriesEncodeForAxisCoordSys = _sourceHelper.makeSeriesEncodeForAxisCoordSys;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @param {module:echarts/data/Source|Array} source Or raw data.
* @param {module:echarts/model/Series} seriesModel
* @param {Object} [opt]
* @param {string} [opt.generateCoord]
* @param {boolean} [opt.useEncodeDefaulter]
*/
function createListFromArray(source, seriesModel, opt) {
opt = opt || {};
if (!Source.isInstance(source)) {
source = Source.seriesDataToSource(source);
}
var coordSysName = seriesModel.get('coordinateSystem');
var registeredCoordSys = CoordinateSystem.get(coordSysName);
var coordSysInfo = getCoordSysInfoBySeries(seriesModel);
var coordSysDimDefs;
if (coordSysInfo) {
coordSysDimDefs = zrUtil.map(coordSysInfo.coordSysDims, function (dim) {
var dimInfo = {
name: dim
};
var axisModel = coordSysInfo.axisMap.get(dim);
if (axisModel) {
var axisType = axisModel.get('type');
dimInfo.type = getDimensionTypeByAxis(axisType); // dimInfo.stackable = isStackable(axisType);
}
return dimInfo;
});
}
if (!coordSysDimDefs) {
// Get dimensions from registered coordinate system
coordSysDimDefs = registeredCoordSys && (registeredCoordSys.getDimensionsInfo ? registeredCoordSys.getDimensionsInfo() : registeredCoordSys.dimensions.slice()) || ['x', 'y'];
}
var dimInfoList = createDimensions(source, {
coordDimensions: coordSysDimDefs,
generateCoord: opt.generateCoord,
encodeDefaulter: opt.useEncodeDefaulter ? zrUtil.curry(makeSeriesEncodeForAxisCoordSys, coordSysDimDefs, seriesModel) : null
});
var firstCategoryDimIndex;
var hasNameEncode;
coordSysInfo && zrUtil.each(dimInfoList, function (dimInfo, dimIndex) {
var coordDim = dimInfo.coordDim;
var categoryAxisModel = coordSysInfo.categoryAxisMap.get(coordDim);
if (categoryAxisModel) {
if (firstCategoryDimIndex == null) {
firstCategoryDimIndex = dimIndex;
}
dimInfo.ordinalMeta = categoryAxisModel.getOrdinalMeta();
}
if (dimInfo.otherDims.itemName != null) {
hasNameEncode = true;
}
});
if (!hasNameEncode && firstCategoryDimIndex != null) {
dimInfoList[firstCategoryDimIndex].otherDims.itemName = 0;
}
var stackCalculationInfo = enableDataStack(seriesModel, dimInfoList);
var list = new List(dimInfoList, seriesModel);
list.setCalculationInfo(stackCalculationInfo);
var dimValueGetter = firstCategoryDimIndex != null && isNeedCompleteOrdinalData(source) ? function (itemOpt, dimName, dataIndex, dimIndex) {
// Use dataIndex as ordinal value in categoryAxis
return dimIndex === firstCategoryDimIndex ? dataIndex : this.defaultDimValueGetter(itemOpt, dimName, dataIndex, dimIndex);
} : null;
list.hasItemOption = false;
list.initData(source, null, dimValueGetter);
return list;
}
function isNeedCompleteOrdinalData(source) {
if (source.sourceFormat === SOURCE_FORMAT_ORIGINAL) {
var sampleItem = firstDataNotNull(source.data || []);
return sampleItem != null && !zrUtil.isArray(getDataItemValue(sampleItem));
}
}
function firstDataNotNull(data) {
var i = 0;
while (i < data.length && data[i] == null) {
i++;
}
return data[i];
}
var _default = createListFromArray;
module.exports = _default;

View File

@ -0,0 +1,76 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var createDimensions = require("../../data/helper/createDimensions");
var List = require("../../data/List");
var _util = require("zrender/lib/core/util");
var extend = _util.extend;
var isArray = _util.isArray;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* [Usage]:
* (1)
* createListSimply(seriesModel, ['value']);
* (2)
* createListSimply(seriesModel, {
* coordDimensions: ['value'],
* dimensionsCount: 5
* });
*
* @param {module:echarts/model/Series} seriesModel
* @param {Object|Array.<string|Object>} opt opt or coordDimensions
* The options in opt, see `echarts/data/helper/createDimensions`
* @param {Array.<string>} [nameList]
* @return {module:echarts/data/List}
*/
function _default(seriesModel, opt, nameList) {
opt = isArray(opt) && {
coordDimensions: opt
} || extend({}, opt);
var source = seriesModel.getSource();
var dimensionsInfo = createDimensions(source, opt);
var list = new List(dimensionsInfo, seriesModel);
list.initData(source, nameList);
return list;
}
module.exports = _default;

View File

@ -0,0 +1,63 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var _model = require("../../util/model");
var makeInner = _model.makeInner;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @return {string} If large mode changed, return string 'reset';
*/
function _default() {
var inner = makeInner();
return function (seriesModel) {
var fields = inner(seriesModel);
var pipelineContext = seriesModel.pipelineContext;
var originalLarge = fields.large;
var originalProgressive = fields.progressiveRender; // FIXME: if the planner works on a filtered series, `pipelineContext` does not
// exists. See #11611 . Probably we need to modify this structure, see the comment
// on `performRawSeries` in `Schedular.js`.
var large = fields.large = pipelineContext && pipelineContext.large;
var progressive = fields.progressiveRender = pipelineContext && pipelineContext.progressiveRender;
return !!(originalLarge ^ large || originalProgressive ^ progressive) && 'reset';
};
}
module.exports = _default;

View File

@ -0,0 +1,65 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var echarts = require("../../echarts");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @payload
* @property {number} [seriesIndex]
* @property {string} [seriesId]
* @property {string} [seriesName]
* @property {number} [dataIndex]
*/
echarts.registerAction({
type: 'focusNodeAdjacency',
event: 'focusNodeAdjacency',
update: 'series:focusNodeAdjacency'
}, function () {});
/**
* @payload
* @property {number} [seriesIndex]
* @property {string} [seriesId]
* @property {string} [seriesName]
*/
echarts.registerAction({
type: 'unfocusNodeAdjacency',
event: 'unfocusNodeAdjacency',
update: 'series:unfocusNodeAdjacency'
}, function () {});

67
node_modules/echarts/lib/chart/helper/labelHelper.js generated vendored Normal file
View File

@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var _dataProvider = require("../../data/helper/dataProvider");
var retrieveRawValue = _dataProvider.retrieveRawValue;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @param {module:echarts/data/List} data
* @param {number} dataIndex
* @return {string} label string. Not null/undefined
*/
function getDefaultLabel(data, dataIndex) {
var labelDims = data.mapDimension('defaultedLabel', true);
var len = labelDims.length; // Simple optimization (in lots of cases, label dims length is 1)
if (len === 1) {
return retrieveRawValue(data, dataIndex, labelDims[0]);
} else if (len) {
var vals = [];
for (var i = 0; i < labelDims.length; i++) {
var val = retrieveRawValue(data, dataIndex, labelDims[i]);
vals.push(val);
}
return vals.join(' ');
}
}
exports.getDefaultLabel = getDefaultLabel;

View File

@ -0,0 +1,258 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var zrUtil = require("zrender/lib/core/util");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var KEY_DELIMITER = '-->';
/**
* params handler
* @param {module:echarts/model/SeriesModel} seriesModel
* @returns {*}
*/
var getAutoCurvenessParams = function (seriesModel) {
return seriesModel.get('autoCurveness') || null;
};
/**
* Generate a list of edge curvatures, 20 is the default
* @param {module:echarts/model/SeriesModel} seriesModel
* @param {number} appendLength
* @return 20 => [0, -0.2, 0.2, -0.4, 0.4, -0.6, 0.6, -0.8, 0.8, -1, 1, -1.2, 1.2, -1.4, 1.4, -1.6, 1.6, -1.8, 1.8, -2]
*/
var createCurveness = function (seriesModel, appendLength) {
var autoCurvenessParmas = getAutoCurvenessParams(seriesModel);
var length = 20;
var curvenessList = []; // handler the function set
if (typeof autoCurvenessParmas === 'number') {
length = autoCurvenessParmas;
} else if (zrUtil.isArray(autoCurvenessParmas)) {
seriesModel.__curvenessList = autoCurvenessParmas;
return;
} // append length
if (appendLength > length) {
length = appendLength;
} // make sure the length is even
var len = length % 2 ? length + 2 : length + 3;
curvenessList = [];
for (var i = 0; i < len; i++) {
curvenessList.push((i % 2 ? i + 1 : i) / 10 * (i % 2 ? -1 : 1));
}
seriesModel.__curvenessList = curvenessList;
};
/**
* Create different cache key data in the positive and negative directions, in order to set the curvature later
* @param {number|string|module:echarts/data/Graph.Node} n1
* @param {number|string|module:echarts/data/Graph.Node} n2
* @param {module:echarts/model/SeriesModel} seriesModel
* @returns {string} key
*/
var getKeyOfEdges = function (n1, n2, seriesModel) {
var source = [n1.id, n1.dataIndex].join('.');
var target = [n2.id, n2.dataIndex].join('.');
return [seriesModel.uid, source, target].join(KEY_DELIMITER);
};
/**
* get opposite key
* @param {string} key
* @returns {string}
*/
var getOppositeKey = function (key) {
var keys = key.split(KEY_DELIMITER);
return [keys[0], keys[2], keys[1]].join(KEY_DELIMITER);
};
/**
* get edgeMap with key
* @param edge
* @param {module:echarts/model/SeriesModel} seriesModel
*/
var getEdgeFromMap = function (edge, seriesModel) {
var key = getKeyOfEdges(edge.node1, edge.node2, seriesModel);
return seriesModel.__edgeMap[key];
};
/**
* calculate all cases total length
* @param edge
* @param seriesModel
* @returns {number}
*/
var getTotalLengthBetweenNodes = function (edge, seriesModel) {
var len = getEdgeMapLengthWithKey(getKeyOfEdges(edge.node1, edge.node2, seriesModel), seriesModel);
var lenV = getEdgeMapLengthWithKey(getKeyOfEdges(edge.node2, edge.node1, seriesModel), seriesModel);
return len + lenV;
};
/**
*
* @param key
*/
var getEdgeMapLengthWithKey = function (key, seriesModel) {
var edgeMap = seriesModel.__edgeMap;
return edgeMap[key] ? edgeMap[key].length : 0;
};
/**
* Count the number of edges between the same two points, used to obtain the curvature table and the parity of the edge
* @see /graph/GraphSeries.js@getInitialData
* @param {module:echarts/model/SeriesModel} seriesModel
*/
function initCurvenessList(seriesModel) {
if (!getAutoCurvenessParams(seriesModel)) {
return;
}
seriesModel.__curvenessList = [];
seriesModel.__edgeMap = {}; // calc the array of curveness List
createCurveness(seriesModel);
}
/**
* set edgeMap with key
* @param {number|string|module:echarts/data/Graph.Node} n1
* @param {number|string|module:echarts/data/Graph.Node} n2
* @param {module:echarts/model/SeriesModel} seriesModel
* @param {number} index
*/
function createEdgeMapForCurveness(n1, n2, seriesModel, index) {
if (!getAutoCurvenessParams(seriesModel)) {
return;
}
var key = getKeyOfEdges(n1, n2, seriesModel);
var edgeMap = seriesModel.__edgeMap;
var oppositeEdges = edgeMap[getOppositeKey(key)]; // set direction
if (edgeMap[key] && !oppositeEdges) {
edgeMap[key].isForward = true;
} else if (oppositeEdges && edgeMap[key]) {
oppositeEdges.isForward = true;
edgeMap[key].isForward = false;
}
edgeMap[key] = edgeMap[key] || [];
edgeMap[key].push(index);
}
/**
* get curvature for edge
* @param edge
* @param {module:echarts/model/SeriesModel} seriesModel
* @param index
*/
function getCurvenessForEdge(edge, seriesModel, index, needReverse) {
var autoCurvenessParams = getAutoCurvenessParams(seriesModel);
var isArrayParam = zrUtil.isArray(autoCurvenessParams);
if (!autoCurvenessParams) {
return null;
}
var edgeArray = getEdgeFromMap(edge, seriesModel);
if (!edgeArray) {
return null;
}
var edgeIndex = -1;
for (var i = 0; i < edgeArray.length; i++) {
if (edgeArray[i] === index) {
edgeIndex = i;
break;
}
} // if totalLen is Longer createCurveness
var totalLen = getTotalLengthBetweenNodes(edge, seriesModel);
createCurveness(seriesModel, totalLen);
edge.lineStyle = edge.lineStyle || {}; // if is opposite edge, must set curvenss to opposite number
var curKey = getKeyOfEdges(edge.node1, edge.node2, seriesModel);
var curvenessList = seriesModel.__curvenessList; // if pass array no need parity
var parityCorrection = isArrayParam ? 0 : totalLen % 2 ? 0 : 1;
if (!edgeArray.isForward) {
// the opposite edge show outside
var oppositeKey = getOppositeKey(curKey);
var len = getEdgeMapLengthWithKey(oppositeKey, seriesModel);
var resValue = curvenessList[edgeIndex + len + parityCorrection]; // isNeedReverse, simple, force type need reverse the curveness in the junction of the forword and the opposite
if (needReverse) {
// set as array may make the parity handle with the len of opposite
if (isArrayParam) {
if (autoCurvenessParams && autoCurvenessParams[0] === 0) {
return (len + parityCorrection) % 2 ? resValue : -resValue;
} else {
return ((len % 2 ? 0 : 1) + parityCorrection) % 2 ? resValue : -resValue;
}
} else {
return (len + parityCorrection) % 2 ? resValue : -resValue;
}
} else {
return curvenessList[edgeIndex + len + parityCorrection];
}
} else {
return curvenessList[parityCorrection + edgeIndex];
}
}
exports.initCurvenessList = initCurvenessList;
exports.createEdgeMapForCurveness = createEdgeMapForCurveness;
exports.getCurvenessForEdge = getCurvenessForEdge;

104
node_modules/echarts/lib/chart/helper/treeHelper.js generated vendored Normal file
View File

@ -0,0 +1,104 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var zrUtil = require("zrender/lib/core/util");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function retrieveTargetInfo(payload, validPayloadTypes, seriesModel) {
if (payload && zrUtil.indexOf(validPayloadTypes, payload.type) >= 0) {
var root = seriesModel.getData().tree.root;
var targetNode = payload.targetNode;
if (typeof targetNode === 'string') {
targetNode = root.getNodeById(targetNode);
}
if (targetNode && root.contains(targetNode)) {
return {
node: targetNode
};
}
var targetNodeId = payload.targetNodeId;
if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) {
return {
node: targetNode
};
}
}
} // Not includes the given node at the last item.
function getPathToRoot(node) {
var path = [];
while (node) {
node = node.parentNode;
node && path.push(node);
}
return path.reverse();
}
function aboveViewRoot(viewRoot, node) {
var viewPath = getPathToRoot(viewRoot);
return zrUtil.indexOf(viewPath, node) >= 0;
} // From root to the input node (the input node will be included).
function wrapTreePathInfo(node, seriesModel) {
var treePathInfo = [];
while (node) {
var nodeDataIndex = node.dataIndex;
treePathInfo.push({
name: node.name,
dataIndex: nodeDataIndex,
value: seriesModel.getRawValue(nodeDataIndex)
});
node = node.parentNode;
}
treePathInfo.reverse();
return treePathInfo;
}
exports.retrieveTargetInfo = retrieveTargetInfo;
exports.getPathToRoot = getPathToRoot;
exports.aboveViewRoot = aboveViewRoot;
exports.wrapTreePathInfo = wrapTreePathInfo;

View File

@ -0,0 +1,146 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var createListSimply = require("../helper/createListSimply");
var zrUtil = require("zrender/lib/core/util");
var _dimensionHelper = require("../../data/helper/dimensionHelper");
var getDimensionTypeByAxis = _dimensionHelper.getDimensionTypeByAxis;
var _sourceHelper = require("../../data/helper/sourceHelper");
var makeSeriesEncodeForAxisCoordSys = _sourceHelper.makeSeriesEncodeForAxisCoordSys;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var seriesModelMixin = {
/**
* @private
* @type {string}
*/
_baseAxisDim: null,
/**
* @override
*/
getInitialData: function (option, ecModel) {
// When both types of xAxis and yAxis are 'value', layout is
// needed to be specified by user. Otherwise, layout can be
// judged by which axis is category.
var ordinalMeta;
var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
var xAxisType = xAxisModel.get('type');
var yAxisType = yAxisModel.get('type');
var addOrdinal; // FIXME
// Consider time axis.
if (xAxisType === 'category') {
option.layout = 'horizontal';
ordinalMeta = xAxisModel.getOrdinalMeta();
addOrdinal = true;
} else if (yAxisType === 'category') {
option.layout = 'vertical';
ordinalMeta = yAxisModel.getOrdinalMeta();
addOrdinal = true;
} else {
option.layout = option.layout || 'horizontal';
}
var coordDims = ['x', 'y'];
var baseAxisDimIndex = option.layout === 'horizontal' ? 0 : 1;
var baseAxisDim = this._baseAxisDim = coordDims[baseAxisDimIndex];
var otherAxisDim = coordDims[1 - baseAxisDimIndex];
var axisModels = [xAxisModel, yAxisModel];
var baseAxisType = axisModels[baseAxisDimIndex].get('type');
var otherAxisType = axisModels[1 - baseAxisDimIndex].get('type');
var data = option.data; // ??? FIXME make a stage to perform data transfrom.
// MUST create a new data, consider setOption({}) again.
if (data && addOrdinal) {
var newOptionData = [];
zrUtil.each(data, function (item, index) {
var newItem;
if (item.value && zrUtil.isArray(item.value)) {
newItem = item.value.slice();
item.value.unshift(index);
} else if (zrUtil.isArray(item)) {
newItem = item.slice();
item.unshift(index);
} else {
newItem = item;
}
newOptionData.push(newItem);
});
option.data = newOptionData;
}
var defaultValueDimensions = this.defaultValueDimensions;
var coordDimensions = [{
name: baseAxisDim,
type: getDimensionTypeByAxis(baseAxisType),
ordinalMeta: ordinalMeta,
otherDims: {
tooltip: false,
itemName: 0
},
dimsDef: ['base']
}, {
name: otherAxisDim,
type: getDimensionTypeByAxis(otherAxisType),
dimsDef: defaultValueDimensions.slice()
}];
return createListSimply(this, {
coordDimensions: coordDimensions,
dimensionsCount: defaultValueDimensions.length + 1,
encodeDefaulter: zrUtil.curry(makeSeriesEncodeForAxisCoordSys, coordDimensions, this)
});
},
/**
* If horizontal, base axis is x, otherwise y.
* @override
*/
getBaseAxis: function () {
var dim = this._baseAxisDim;
return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
}
};
exports.seriesModelMixin = seriesModelMixin;