MCPcopy Index your code
hub / github.com/apache/echarts / getVisualMeta

Method getVisualMeta

src/component/visualMap/PiecewiseModel.ts:353–411  ·  view source on GitHub ↗
(
        getColorVisual: (value: number, valueState: VisualState) => string
    )

Source from the content-addressed store, hash-verified

351 }
352
353 getVisualMeta(
354 getColorVisual: (value: number, valueState: VisualState) => string
355 ): VisualMeta {
356 // Do not support category. (category axis is ordinal, numerical)
357 if (this.isCategory()) {
358 return;
359 }
360
361 const stops: VisualMeta['stops'] = [];
362 const outerColors: VisualMeta['outerColors'] = ['', ''];
363 const visualMapModel = this;
364
365 function setStop(interval: [number, number], valueState?: VisualState) {
366 const representValue = visualMapModel.getRepresentValue({
367 interval: interval
368 }) as number;// Not category
369 if (!valueState) {
370 valueState = visualMapModel.getValueState(representValue);
371 }
372 const color = getColorVisual(representValue, valueState);
373 if (interval[0] === -Infinity) {
374 outerColors[0] = color;
375 }
376 else if (interval[1] === Infinity) {
377 outerColors[1] = color;
378 }
379 else {
380 stops.push(
381 {value: interval[0], color: color},
382 {value: interval[1], color: color}
383 );
384 }
385 }
386
387 // Suplement
388 const pieceList = this._pieceList.slice();
389 if (!pieceList.length) {
390 pieceList.push({interval: [-Infinity, Infinity]});
391 }
392 else {
393 let edge = pieceList[0].interval[0];
394 edge !== -Infinity && pieceList.unshift({interval: [-Infinity, edge]});
395 edge = pieceList[pieceList.length - 1].interval[1];
396 edge !== Infinity && pieceList.push({interval: [edge, Infinity]});
397 }
398
399 let curr = -Infinity;
400 zrUtil.each(pieceList, function (piece) {
401 const interval = piece.interval;
402 if (interval) {
403 // Fulfill gap.
404 interval[0] > curr && setStop([curr, interval[0]], 'outOfRange');
405 setStop(interval.slice() as [number, number]);
406 curr = interval[1];
407 }
408 }, this);
409
410 return {stops: stops, outerColors: outerColors};

Callers

nothing calls this directly

Calls 2

isCategoryMethod · 0.80
eachMethod · 0.45

Tested by

no test coverage detected