85a120a03a813a7360bdddf42a496759d56438249ed76d8d8d0045df929802eb01129fdec7af122c246dd8cf87e60a66a058380425f961e702e723bcfbc490 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import { HashMap } from 'zrender/lib/core/util.js';
  2. import AxisProxy from './AxisProxy.js';
  3. import ComponentModel from '../../model/Component.js';
  4. import { LayoutOrient, ComponentOption, LabelOption } from '../../util/types.js';
  5. import Model from '../../model/Model.js';
  6. import GlobalModel from '../../model/Global.js';
  7. import { AxisBaseModel } from '../../coord/AxisBaseModel.js';
  8. import { DataZoomAxisDimension } from './helper.js';
  9. export interface DataZoomOption extends ComponentOption {
  10. mainType?: 'dataZoom';
  11. /**
  12. * Default auto by axisIndex
  13. */
  14. orient?: LayoutOrient;
  15. /**
  16. * Default the first horizontal category axis.
  17. */
  18. xAxisIndex?: number | number[];
  19. xAxisId?: string | string[];
  20. /**
  21. * Default the first vertical category axis.
  22. */
  23. yAxisIndex?: number | number[];
  24. yAxisId?: string | string[];
  25. radiusAxisIndex?: number | number[];
  26. radiusAxisId?: string | string[];
  27. angleAxisIndex?: number | number[];
  28. angleAxisId?: string | string[];
  29. singleAxisIndex?: number | number[];
  30. singleAxisId?: string | string[];
  31. /**
  32. * Possible values: 'filter' or 'empty' or 'weakFilter'.
  33. * 'filter': data items which are out of window will be removed. This option is
  34. * applicable when filtering outliers. For each data item, it will be
  35. * filtered if one of the relevant dimensions is out of the window.
  36. * 'weakFilter': data items which are out of window will be removed. This option
  37. * is applicable when filtering outliers. For each data item, it will be
  38. * filtered only if all of the relevant dimensions are out of the same
  39. * side of the window.
  40. * 'empty': data items which are out of window will be set to empty.
  41. * This option is applicable when user should not neglect
  42. * that there are some data items out of window.
  43. * 'none': Do not filter.
  44. * Taking line chart as an example, line will be broken in
  45. * the filtered points when filterModel is set to 'empty', but
  46. * be connected when set to 'filter'.
  47. */
  48. filterMode?: 'filter' | 'weakFilter' | 'empty' | 'none';
  49. /**
  50. * Dispatch action by the fixed rate, avoid frequency.
  51. * default 100. Do not throttle when use null/undefined.
  52. * If animation === true and animationDurationUpdate > 0,
  53. * default value is 100, otherwise 20.
  54. */
  55. throttle?: number | null | undefined;
  56. /**
  57. * Start percent. 0 ~ 100
  58. */
  59. start?: number;
  60. /**
  61. * End percent. 0 ~ 100
  62. */
  63. end?: number;
  64. /**
  65. * Start value. If startValue specified, start is ignored
  66. */
  67. startValue?: number | string | Date;
  68. /**
  69. * End value. If endValue specified, end is ignored.
  70. */
  71. endValue?: number | string | Date;
  72. /**
  73. * Min span percent, 0 - 100
  74. * The range of dataZoom can not be smaller than that.
  75. */
  76. minSpan?: number;
  77. /**
  78. * Max span percent, 0 - 100
  79. * The range of dataZoom can not be larger than that.
  80. */
  81. maxSpan?: number;
  82. minValueSpan?: number;
  83. maxValueSpan?: number;
  84. rangeMode?: ['value' | 'percent', 'value' | 'percent'];
  85. realtime?: boolean;
  86. textStyle?: LabelOption;
  87. }
  88. declare type RangeOption = Pick<DataZoomOption, 'start' | 'end' | 'startValue' | 'endValue'>;
  89. export declare type DataZoomExtendedAxisBaseModel = AxisBaseModel & {
  90. __dzAxisProxy: AxisProxy;
  91. };
  92. declare class DataZoomAxisInfo {
  93. indexList: number[];
  94. indexMap: boolean[];
  95. add(axisCmptIdx: number): void;
  96. }
  97. export declare type DataZoomTargetAxisInfoMap = HashMap<DataZoomAxisInfo, DataZoomAxisDimension>;
  98. declare class DataZoomModel<Opts extends DataZoomOption = DataZoomOption> extends ComponentModel<Opts> {
  99. static type: string;
  100. type: string;
  101. static dependencies: string[];
  102. static defaultOption: DataZoomOption;
  103. private _autoThrottle;
  104. private _orient;
  105. private _targetAxisInfoMap;
  106. private _noTarget;
  107. /**
  108. * It is `[rangeModeForMin, rangeModeForMax]`.
  109. * The optional values for `rangeMode`:
  110. * + `'value'` mode: the axis extent will always be determined by
  111. * `dataZoom.startValue` and `dataZoom.endValue`, despite
  112. * how data like and how `axis.min` and `axis.max` are.
  113. * + `'percent'` mode: `100` represents 100% of the `[dMin, dMax]`,
  114. * where `dMin` is `axis.min` if `axis.min` specified, otherwise `data.extent[0]`,
  115. * and `dMax` is `axis.max` if `axis.max` specified, otherwise `data.extent[1]`.
  116. * Axis extent will be determined by the result of the percent of `[dMin, dMax]`.
  117. *
  118. * For example, when users are using dynamic data (update data periodically via `setOption`),
  119. * if in `'value`' mode, the window will be kept in a fixed value range despite how
  120. * data are appended, while if in `'percent'` mode, whe window range will be changed alone with
  121. * the appended data (suppose `axis.min` and `axis.max` are not specified).
  122. */
  123. private _rangePropMode;
  124. /**
  125. * @readonly
  126. */
  127. settledOption: Opts;
  128. init(option: Opts, parentModel: Model, ecModel: GlobalModel): void;
  129. mergeOption(newOption: Opts): void;
  130. private _doInit;
  131. private _resetTarget;
  132. private _fillSpecifiedTargetAxis;
  133. private _fillAutoTargetAxisByOrient;
  134. private _makeAutoOrientByTargetAxis;
  135. private _setDefaultThrottle;
  136. private _updateRangeUse;
  137. noTarget(): boolean;
  138. getFirstTargetAxisModel(): AxisBaseModel;
  139. /**
  140. * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel
  141. */
  142. eachTargetAxis<Ctx>(callback: (this: Ctx, axisDim: DataZoomAxisDimension, axisIndex: number) => void, context?: Ctx): void;
  143. /**
  144. * @return If not found, return null/undefined.
  145. */
  146. getAxisProxy(axisDim: DataZoomAxisDimension, axisIndex: number): AxisProxy;
  147. /**
  148. * @return If not found, return null/undefined.
  149. */
  150. getAxisModel(axisDim: DataZoomAxisDimension, axisIndex: number): AxisBaseModel;
  151. /**
  152. * If not specified, set to undefined.
  153. */
  154. setRawRange(opt: RangeOption): void;
  155. setCalculatedRange(opt: RangeOption): void;
  156. getPercentRange(): number[];
  157. /**
  158. * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0);
  159. *
  160. * @return [startValue, endValue] value can only be '-' or finite number.
  161. */
  162. getValueRange(axisDim: DataZoomAxisDimension, axisIndex: number): number[];
  163. /**
  164. * @param axisModel If axisModel given, find axisProxy
  165. * corresponding to the axisModel
  166. */
  167. findRepresentativeAxisProxy(axisModel?: AxisBaseModel): AxisProxy;
  168. getRangePropMode(): DataZoomModel['_rangePropMode'];
  169. getOrient(): LayoutOrient;
  170. }
  171. export default DataZoomModel;