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

Function pieces

src/component/visualMap/PiecewiseModel.ts:509–587  ·  view source on GitHub ↗
(outPieceList)

Source from the content-addressed store, hash-verified

507 },
508
509 pieces(outPieceList) {
510 const thisOption = this.option;
511
512 zrUtil.each(thisOption.pieces, function (pieceListItem, index) {
513
514 if (!zrUtil.isObject(pieceListItem)) {
515 pieceListItem = {value: pieceListItem};
516 }
517
518 const item: InnerVisualPiece = {text: '', index: index};
519
520 if (pieceListItem.label != null) {
521 item.text = pieceListItem.label;
522 }
523
524 if (pieceListItem.hasOwnProperty('value')) {
525 const value = item.value = pieceListItem.value;
526 item.interval = [value, value];
527 item.close = [1, 1];
528 }
529 else {
530 // `min` `max` is legacy option.
531 // `lt` `gt` `lte` `gte` is recommended.
532 const interval = item.interval = [] as unknown as [number, number];
533 const close: typeof item.close = item.close = [0, 0];
534
535 const closeList = [1, 0, 1] as const;
536 const infinityList = [-Infinity, Infinity];
537
538 const useMinMax = [];
539 for (let lg = 0; lg < 2; lg++) {
540 const names = ([['gte', 'gt', 'min'], ['lte', 'lt', 'max']] as const)[lg];
541 for (let i = 0; i < 3 && interval[lg] == null; i++) {
542 interval[lg] = pieceListItem[names[i]];
543 close[lg] = closeList[i];
544 useMinMax[lg] = i === 2;
545 }
546 interval[lg] == null && (interval[lg] = infinityList[lg]);
547 }
548 useMinMax[0] && interval[1] === Infinity && (close[0] = 0);
549 useMinMax[1] && interval[0] === -Infinity && (close[1] = 0);
550
551 if (__DEV__) {
552 if (interval[0] > interval[1]) {
553 console.warn(
554 'Piece ' + index + 'is illegal: ' + interval
555 + ' lower bound should not greater then uppper bound.'
556 );
557 }
558 }
559
560 if (interval[0] === interval[1] && close[0] && close[1]) {
561 // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}],
562 // we use value to lift the priority when min === max
563 item.value = interval[0];
564 }
565 }
566

Callers

nothing calls this directly

Calls 5

reformIntervalsFunction · 0.90
normalizeReverseFunction · 0.85
retrieveVisualsMethod · 0.80
formatValueTextMethod · 0.80
eachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…