51bfd3567ec8564fc1ee0e1dd79be72700efa2aefc553e1405b75eecdd22f38f058985633e2331ae6d6120c874358c23a5d05a9f102504c51cd5c0b6603b05 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. import { TextCommonOption, LineStyleOption, OrdinalRawValue, ZRColor, AreaStyleOption, ComponentOption, ColorString, AnimationOptionMixin, Dictionary, ScaleDataValue, CommonAxisPointerOption } from '../util/types.js';
  2. export declare const AXIS_TYPES: {
  3. readonly value: 1;
  4. readonly category: 1;
  5. readonly time: 1;
  6. readonly log: 1;
  7. };
  8. export declare type OptionAxisType = keyof typeof AXIS_TYPES;
  9. export interface AxisBaseOptionCommon extends ComponentOption, AnimationOptionMixin {
  10. type?: OptionAxisType;
  11. show?: boolean;
  12. inverse?: boolean;
  13. name?: string;
  14. nameLocation?: 'start' | 'middle' | 'end';
  15. nameRotate?: number;
  16. nameTruncate?: {
  17. maxWidth?: number;
  18. ellipsis?: string;
  19. placeholder?: string;
  20. };
  21. nameTextStyle?: AxisNameTextStyleOption;
  22. nameGap?: number;
  23. silent?: boolean;
  24. triggerEvent?: boolean;
  25. tooltip?: {
  26. show?: boolean;
  27. };
  28. axisLabel?: AxisLabelBaseOption;
  29. axisPointer?: CommonAxisPointerOption;
  30. axisLine?: AxisLineOption;
  31. axisTick?: AxisTickOption;
  32. minorTick?: MinorTickOption;
  33. splitLine?: SplitLineOption;
  34. minorSplitLine?: MinorSplitLineOption;
  35. splitArea?: SplitAreaOption;
  36. /**
  37. * Min value of the axis. can be:
  38. * + ScaleDataValue
  39. * + 'dataMin': use the min value in data.
  40. * + null/undefined: auto decide min value (consider pretty look and boundaryGap).
  41. */
  42. min?: ScaleDataValue | 'dataMin' | ((extent: {
  43. min: number;
  44. max: number;
  45. }) => ScaleDataValue);
  46. /**
  47. * Max value of the axis. can be:
  48. * + ScaleDataValue
  49. * + 'dataMax': use the max value in data.
  50. * + null/undefined: auto decide max value (consider pretty look and boundaryGap).
  51. */
  52. max?: ScaleDataValue | 'dataMax' | ((extent: {
  53. min: number;
  54. max: number;
  55. }) => ScaleDataValue);
  56. }
  57. export interface NumericAxisBaseOptionCommon extends AxisBaseOptionCommon {
  58. boundaryGap?: [number | string, number | string];
  59. /**
  60. * AxisTick and axisLabel and splitLine are caculated based on splitNumber.
  61. */
  62. splitNumber?: number;
  63. /**
  64. * Interval specifies the span of the ticks is mandatorily.
  65. */
  66. interval?: number;
  67. /**
  68. * Specify min interval when auto calculate tick interval.
  69. */
  70. minInterval?: number;
  71. /**
  72. * Specify max interval when auto calculate tick interval.
  73. */
  74. maxInterval?: number;
  75. /**
  76. * If align ticks to the first axis that is not use alignTicks
  77. * If all axes has alignTicks: true. The first one will be applied.
  78. *
  79. * Will be ignored if interval is set.
  80. */
  81. alignTicks?: boolean;
  82. }
  83. export interface CategoryAxisBaseOption extends AxisBaseOptionCommon {
  84. type?: 'category';
  85. boundaryGap?: boolean;
  86. axisLabel?: AxisLabelOption<'category'> & {
  87. interval?: 'auto' | number | ((index: number, value: string) => boolean);
  88. };
  89. data?: (OrdinalRawValue | {
  90. value: OrdinalRawValue;
  91. textStyle?: TextCommonOption;
  92. })[];
  93. deduplication?: boolean;
  94. axisTick?: AxisBaseOptionCommon['axisTick'] & {
  95. alignWithLabel?: boolean;
  96. interval?: 'auto' | number | ((index: number, value: string) => boolean);
  97. };
  98. }
  99. export interface ValueAxisBaseOption extends NumericAxisBaseOptionCommon {
  100. type?: 'value';
  101. axisLabel?: AxisLabelOption<'value'>;
  102. /**
  103. * Optional value can be:
  104. * + `false`: always include value 0.
  105. * + `false`: always include value 0.
  106. */
  107. scale?: boolean;
  108. }
  109. export interface LogAxisBaseOption extends NumericAxisBaseOptionCommon {
  110. type?: 'log';
  111. axisLabel?: AxisLabelOption<'log'>;
  112. logBase?: number;
  113. }
  114. export interface TimeAxisBaseOption extends NumericAxisBaseOptionCommon {
  115. type?: 'time';
  116. axisLabel?: AxisLabelOption<'time'>;
  117. }
  118. interface AxisNameTextStyleOption extends TextCommonOption {
  119. rich?: Dictionary<TextCommonOption>;
  120. }
  121. interface AxisLineOption {
  122. show?: boolean | 'auto';
  123. onZero?: boolean;
  124. onZeroAxisIndex?: number;
  125. symbol?: string | [string, string];
  126. symbolSize?: number[];
  127. symbolOffset?: string | number | (string | number)[];
  128. lineStyle?: LineStyleOption;
  129. }
  130. interface AxisTickOption {
  131. show?: boolean | 'auto';
  132. inside?: boolean;
  133. length?: number;
  134. lineStyle?: LineStyleOption;
  135. }
  136. declare type AxisLabelValueFormatter = (value: number, index: number) => string;
  137. declare type AxisLabelCategoryFormatter = (value: string, index: number) => string;
  138. declare type TimeAxisLabelUnitFormatter = AxisLabelValueFormatter | string[] | string;
  139. export declare type TimeAxisLabelFormatterOption = string | ((value: number, index: number, extra: {
  140. level: number;
  141. }) => string) | {
  142. year?: TimeAxisLabelUnitFormatter;
  143. month?: TimeAxisLabelUnitFormatter;
  144. week?: TimeAxisLabelUnitFormatter;
  145. day?: TimeAxisLabelUnitFormatter;
  146. hour?: TimeAxisLabelUnitFormatter;
  147. minute?: TimeAxisLabelUnitFormatter;
  148. second?: TimeAxisLabelUnitFormatter;
  149. millisecond?: TimeAxisLabelUnitFormatter;
  150. inherit?: boolean;
  151. };
  152. declare type LabelFormatters = {
  153. value: AxisLabelValueFormatter | string;
  154. log: AxisLabelValueFormatter | string;
  155. category: AxisLabelCategoryFormatter | string;
  156. time: TimeAxisLabelFormatterOption;
  157. };
  158. interface AxisLabelBaseOption extends Omit<TextCommonOption, 'color'> {
  159. show?: boolean;
  160. inside?: boolean;
  161. rotate?: number;
  162. showMinLabel?: boolean;
  163. showMaxLabel?: boolean;
  164. margin?: number;
  165. rich?: Dictionary<TextCommonOption>;
  166. /**
  167. * If hide overlapping labels.
  168. */
  169. hideOverlap?: boolean;
  170. color?: ColorString | ((value?: string | number, index?: number) => ColorString);
  171. }
  172. interface AxisLabelOption<TType extends OptionAxisType> extends AxisLabelBaseOption {
  173. formatter?: LabelFormatters[TType];
  174. }
  175. interface MinorTickOption {
  176. show?: boolean;
  177. splitNumber?: number;
  178. length?: number;
  179. lineStyle?: LineStyleOption;
  180. }
  181. interface SplitLineOption {
  182. show?: boolean;
  183. interval?: 'auto' | number | ((index: number, value: string) => boolean);
  184. lineStyle?: LineStyleOption<ZRColor | ZRColor[]>;
  185. }
  186. interface MinorSplitLineOption {
  187. show?: boolean;
  188. lineStyle?: LineStyleOption;
  189. }
  190. interface SplitAreaOption {
  191. show?: boolean;
  192. interval?: 'auto' | number | ((index: number, value: string) => boolean);
  193. areaStyle?: AreaStyleOption<ZRColor[]>;
  194. }
  195. export declare type AxisBaseOption = ValueAxisBaseOption | LogAxisBaseOption | CategoryAxisBaseOption | TimeAxisBaseOption | AxisBaseOptionCommon;
  196. export {};