base.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import Layout from '../base/layout';
  2. import { Range, Point, Option } from './types';
  3. interface RectPoint {
  4. x: number | [number, number];
  5. y: number | [number, number];
  6. y0?: number;
  7. size?: number;
  8. }
  9. interface Rect {
  10. xMin: number;
  11. xMax: number;
  12. yMin: number;
  13. yMax: number;
  14. }
  15. /**
  16. * 直角坐标系
  17. * convert相关的方法,涉及将标准坐标系映射到实际坐标系内
  18. * transform相关的方法,是仅将某一种关键点转换成另一种关键点 (比如将x/y/size/y0转换成yMin/yMax/..)
  19. */
  20. declare class Base extends Layout {
  21. type: string;
  22. isPolar: boolean;
  23. transposed: boolean;
  24. center: Point;
  25. x: Range;
  26. y: Range;
  27. constructor(option: Option);
  28. update(option: Option): this;
  29. isCyclic(): boolean;
  30. _zoomVal(val: any, func: any): any;
  31. /**
  32. * 把归一后的值映射到对应的定义域
  33. * @param point
  34. */
  35. convert(point: any): {
  36. x: any;
  37. y: any;
  38. };
  39. /**
  40. * convert 的反处理,把定义域的值,反处理到归一的值
  41. */
  42. invert(point: any): {
  43. [x: string]: any;
  44. };
  45. /**
  46. * 把归一化的值映射到 canvas 的坐标点
  47. * @param point
  48. * @returns
  49. */
  50. convertPoint(point: any): {
  51. x: any;
  52. y: any;
  53. };
  54. /**
  55. * 把canvas坐标的点位映射回归一的值
  56. */
  57. invertPoint(point: any): {
  58. [x: string]: any;
  59. };
  60. convertRect(rectPoint: RectPoint): Rect;
  61. transformToRect(rectPoint: RectPoint): Rect;
  62. }
  63. export default Base;