scale.time.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. export default class TimeScale extends Scale {
  2. static id: string;
  3. /**
  4. * @type {any}
  5. */
  6. static defaults: any;
  7. /**
  8. * @param {object} props
  9. */
  10. constructor(props: object);
  11. /** @type {{data: number[], labels: number[], all: number[]}} */
  12. _cache: {
  13. data: number[];
  14. labels: number[];
  15. all: number[];
  16. };
  17. /** @type {Unit} */
  18. _unit: Unit;
  19. /** @type {Unit=} */
  20. _majorUnit: Unit | undefined;
  21. _offsets: {};
  22. _normalized: boolean;
  23. _parseOpts: {
  24. parser: any;
  25. round: any;
  26. isoWeekday: any;
  27. };
  28. init(scaleOpts: any, opts?: {}): void;
  29. _adapter: DateAdapter;
  30. /**
  31. * @param {*} raw
  32. * @param {number?} [index]
  33. * @return {number}
  34. */
  35. parse(raw: any, index?: number | null): number;
  36. /**
  37. * @private
  38. */
  39. private _getLabelBounds;
  40. /**
  41. * Returns the start and end offsets from edges in the form of {start, end}
  42. * where each value is a relative width to the scale and ranges between 0 and 1.
  43. * They add extra margins on the both sides by scaling down the original scale.
  44. * Offsets are added when the `offset` option is true.
  45. * @param {number[]} timestamps
  46. * @protected
  47. */
  48. protected initOffsets(timestamps?: number[]): void;
  49. /**
  50. * Generates a maximum of `capacity` timestamps between min and max, rounded to the
  51. * `minor` unit using the given scale time `options`.
  52. * Important: this method can return ticks outside the min and max range, it's the
  53. * responsibility of the calling code to clamp values if needed.
  54. * @protected
  55. */
  56. protected _generate(): number[];
  57. /**
  58. * @param {number} value
  59. * @return {string}
  60. */
  61. getLabelForValue(value: number): string;
  62. /**
  63. * @param {number} value
  64. * @param {string|undefined} format
  65. * @return {string}
  66. */
  67. format(value: number, format: string | undefined): string;
  68. /**
  69. * Function to format an individual tick mark
  70. * @param {number} time
  71. * @param {number} index
  72. * @param {object[]} ticks
  73. * @param {string|undefined} [format]
  74. * @return {string}
  75. * @private
  76. */
  77. private _tickFormatFunction;
  78. /**
  79. * @param {object[]} ticks
  80. */
  81. generateTickLabels(ticks: object[]): void;
  82. /**
  83. * @param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC)
  84. * @return {number}
  85. */
  86. getDecimalForValue(value: number): number;
  87. /**
  88. * @param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC)
  89. * @return {number}
  90. */
  91. getPixelForValue(value: number): number;
  92. /**
  93. * @param {number} pixel
  94. * @return {number}
  95. */
  96. getValueForPixel(pixel: number): number;
  97. /**
  98. * @param {string} label
  99. * @return {{w:number, h:number}}
  100. * @private
  101. */
  102. private _getLabelSize;
  103. /**
  104. * @param {number} exampleTime
  105. * @return {number}
  106. * @private
  107. */
  108. private _getLabelCapacity;
  109. /**
  110. * @protected
  111. */
  112. protected getDataTimestamps(): any;
  113. /**
  114. * @protected
  115. */
  116. protected getLabelTimestamps(): number[];
  117. /**
  118. * @param {number[]} values
  119. * @protected
  120. */
  121. protected normalize(values: number[]): number[];
  122. }
  123. export type Unit = import('../core/core.adapters.js').TimeUnit;
  124. export type Interval = {
  125. common: boolean;
  126. size: number;
  127. steps?: number;
  128. };
  129. export type DateAdapter = import('../core/core.adapters.js').DateAdapter;
  130. import Scale from "../core/core.scale.js";