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

Method _renderDataShadow

src/component/dataZoom/SliderZoomView.ts:360–489  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

358 }
359
360 private _renderDataShadow() {
361 const info = this._dataShadowInfo = this._prepareDataShadowInfo();
362
363 this._displayables.dataShadowSegs = [];
364
365 if (!info) {
366 return;
367 }
368
369 const size = this._size;
370 const oldSize = this._shadowSize || [];
371 const seriesModel = info.series;
372 const data = seriesModel.getRawData();
373 const candlestickDim = seriesModel.getShadowDim && seriesModel.getShadowDim();
374 const otherDim: string = candlestickDim && data.getDimensionInfo(candlestickDim)
375 ? seriesModel.getShadowDim() // @see candlestick
376 : info.otherDim;
377
378 if (otherDim == null) {
379 return;
380 }
381
382 let polygonPts = this._shadowPolygonPts;
383 let polylinePts = this._shadowPolylinePts;
384 // Not re-render if data doesn't change.
385 if (
386 data !== this._shadowData || otherDim !== this._shadowDim
387 || size[0] !== oldSize[0] || size[1] !== oldSize[1]
388 ) {
389 const thisDataExtent = data.getDataExtent(info.thisDim);
390 let otherDataExtent = data.getDataExtent(otherDim);
391 // Nice extent.
392 const otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
393 otherDataExtent = [
394 otherDataExtent[0] - otherOffset,
395 otherDataExtent[1] + otherOffset
396 ];
397 const otherShadowExtent = [0, size[1]];
398 const thisShadowExtent = [0, size[0]];
399
400 const areaPoints = [[size[0], 0], [0, 0]];
401 const linePoints: number[][] = [];
402 const step = thisShadowExtent[1] / (Math.max(1, data.count() - 1));
403 const normalizationConstant = size[0] / (thisDataExtent[1] - thisDataExtent[0]);
404 const isTimeAxis = info.thisAxis.type === 'time';
405 let thisCoord = -step;
406
407 // Optimize for large data shadow
408 const stride = Math.round(data.count() / size[0]);
409 let lastIsEmpty: boolean;
410
411 data.each([info.thisDim, otherDim], function (thisValue: ParsedValue, otherValue: ParsedValue, index) {
412 if (stride > 0 && (index % stride)) {
413 if (!isTimeAxis) {
414 thisCoord += step;
415 }
416 return;
417 }

Callers 1

_buildViewMethod · 0.95

Calls 9

linearMapFunction · 0.90
getShadowDimMethod · 0.65
countMethod · 0.65
getRawDataMethod · 0.45
getDimensionInfoMethod · 0.45
getDataExtentMethod · 0.45
eachMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected