MCPcopy
hub / github.com/apache/echarts / _updateSymbolPosition

Method _updateSymbolPosition

src/chart/helper/EffectLine.ts:207–249  ·  view source on GitHub ↗
(symbol: ECSymbolOnEffectLine)

Source from the content-addressed store, hash-verified

205 }
206
207 protected _updateSymbolPosition(symbol: ECSymbolOnEffectLine) {
208 const p1 = symbol.__p1;
209 const p2 = symbol.__p2;
210 const cp1 = symbol.__cp1;
211 const t = symbol.__t <= 1 ? symbol.__t : 2 - symbol.__t;
212 const pos = [symbol.x, symbol.y];
213 const lastPos = pos.slice();
214 const quadraticAt = curveUtil.quadraticAt;
215 const quadraticDerivativeAt = curveUtil.quadraticDerivativeAt;
216 pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t);
217 pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t);
218
219 // Tangent
220 const tx = symbol.__t <= 1 ? quadraticDerivativeAt(p1[0], cp1[0], p2[0], t)
221 : quadraticDerivativeAt(p2[0], cp1[0], p1[0], 1 - t);
222 const ty = symbol.__t <= 1 ? quadraticDerivativeAt(p1[1], cp1[1], p2[1], t)
223 : quadraticDerivativeAt(p2[1], cp1[1], p1[1], 1 - t);
224
225
226 symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
227 // enable continuity trail for 'line', 'rect', 'roundRect' symbolType
228 if (this._symbolType === 'line' || this._symbolType === 'rect' || this._symbolType === 'roundRect') {
229 if (symbol.__lastT !== undefined && symbol.__lastT < symbol.__t) {
230 symbol.scaleY = vec2.dist(lastPos, pos) * 1.05;
231 // make sure the last segment render within endPoint
232 if (t === 1) {
233 pos[0] = lastPos[0] + (pos[0] - lastPos[0]) / 2;
234 pos[1] = lastPos[1] + (pos[1] - lastPos[1]) / 2;
235 }
236 }
237 else if (symbol.__lastT === 1) {
238 // After first loop, symbol.__t does NOT start with 0, so connect p1 to pos directly.
239 symbol.scaleY = 2 * vec2.dist(p1, pos);
240 }
241 else {
242 symbol.scaleY = this._symbolScale[1];
243 }
244 }
245 symbol.__lastT = symbol.__t;
246 symbol.ignore = false;
247 symbol.x = pos[0];
248 symbol.y = pos[1];
249 }
250
251
252 updateLayout(lineData: SeriesData, idx: number) {

Callers 1

_animateSymbolMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected