4fa34b5133978a35d036d7535423f7875381c71c49afa1703b4ca22d13be15d2f3960a97428bf33baa0d5e655257f19dedeb1fb592aca728572246561f1eea 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import VisualMapModel, { VisualMapOption, VisualMeta } from './VisualMapModel.js';
  2. import { VisualMappingOption } from '../../visual/VisualMapping.js';
  3. import { VisualOptionPiecewise } from '../../util/types.js';
  4. import { Dictionary } from 'zrender/lib/core/types.js';
  5. interface VisualPiece extends VisualOptionPiecewise {
  6. min?: number;
  7. max?: number;
  8. lt?: number;
  9. gt?: number;
  10. lte?: number;
  11. gte?: number;
  12. value?: number;
  13. label?: string;
  14. }
  15. declare type VisualState = VisualMapModel['stateList'][number];
  16. declare type InnerVisualPiece = VisualMappingOption['pieceList'][number];
  17. /**
  18. * Order Rule:
  19. *
  20. * option.categories / option.pieces / option.text / option.selected:
  21. * If !option.inverse,
  22. * Order when vertical: ['top', ..., 'bottom'].
  23. * Order when horizontal: ['left', ..., 'right'].
  24. * If option.inverse, the meaning of
  25. * the order should be reversed.
  26. *
  27. * this._pieceList:
  28. * The order is always [low, ..., high].
  29. *
  30. * Mapping from location to low-high:
  31. * If !option.inverse
  32. * When vertical, top is high.
  33. * When horizontal, right is high.
  34. * If option.inverse, reverse.
  35. */
  36. export interface PiecewiseVisualMapOption extends VisualMapOption {
  37. align?: 'auto' | 'left' | 'right';
  38. minOpen?: boolean;
  39. maxOpen?: boolean;
  40. /**
  41. * When put the controller vertically, it is the length of
  42. * horizontal side of each item. Otherwise, vertical side.
  43. * When put the controller vertically, it is the length of
  44. * vertical side of each item. Otherwise, horizontal side.
  45. */
  46. itemWidth?: number;
  47. itemHeight?: number;
  48. itemSymbol?: string;
  49. pieces?: VisualPiece[];
  50. /**
  51. * category names, like: ['some1', 'some2', 'some3'].
  52. * Attr min/max are ignored when categories set. See "Order Rule"
  53. */
  54. categories?: string[];
  55. /**
  56. * If set to 5, auto split five pieces equally.
  57. * If set to 0 and component type not set, component type will be
  58. * determined as "continuous". (It is less reasonable but for ec2
  59. * compatibility, see echarts/component/visualMap/typeDefaulter)
  60. */
  61. splitNumber?: number;
  62. /**
  63. * Object. If not specified, means selected. When pieces and splitNumber: {'0': true, '5': true}
  64. * When categories: {'cate1': false, 'cate3': true} When selected === false, means all unselected.
  65. */
  66. selected?: Dictionary<boolean>;
  67. selectedMode?: 'multiple' | 'single' | boolean;
  68. /**
  69. * By default, when text is used, label will hide (the logic
  70. * is remained for compatibility reason)
  71. */
  72. showLabel?: boolean;
  73. itemGap?: number;
  74. hoverLink?: boolean;
  75. }
  76. declare class PiecewiseModel extends VisualMapModel<PiecewiseVisualMapOption> {
  77. static type: "visualMap.piecewise";
  78. type: "visualMap.piecewise";
  79. /**
  80. * The order is always [low, ..., high].
  81. * [{text: string, interval: Array.<number>}, ...]
  82. */
  83. private _pieceList;
  84. private _mode;
  85. optionUpdated(newOption: PiecewiseVisualMapOption, isInit?: boolean): void;
  86. /**
  87. * @protected
  88. * @override
  89. */
  90. completeVisualOption(): void;
  91. private _resetSelected;
  92. /**
  93. * @public
  94. */
  95. getItemSymbol(): string;
  96. /**
  97. * @public
  98. */
  99. getSelectedMapKey(piece: InnerVisualPiece): string;
  100. /**
  101. * @public
  102. */
  103. getPieceList(): InnerVisualPiece[];
  104. /**
  105. * @return {string}
  106. */
  107. private _determineMode;
  108. /**
  109. * @override
  110. */
  111. setSelected(selected: this['option']['selected']): void;
  112. /**
  113. * @override
  114. */
  115. getValueState(value: number): VisualState;
  116. /**
  117. * @public
  118. * @param pieceIndex piece index in visualMapModel.getPieceList()
  119. */
  120. findTargetDataIndices(pieceIndex: number): {
  121. seriesId: string;
  122. dataIndex: number[];
  123. }[];
  124. /**
  125. * @private
  126. * @param piece piece.value or piece.interval is required.
  127. * @return Can be Infinity or -Infinity
  128. */
  129. getRepresentValue(piece: InnerVisualPiece): string | number;
  130. getVisualMeta(getColorVisual: (value: number, valueState: VisualState) => string): VisualMeta;
  131. static defaultOption: PiecewiseVisualMapOption;
  132. }
  133. export default PiecewiseModel;