chart.d.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { IRenderer, RendererPlugin, Canvas as GCanvas } from '@antv/g';
  2. import { G2Context } from '../runtime';
  3. import { ViewComposition } from '../spec';
  4. import { G2ViewTree } from '../runtime/types/options';
  5. import { NodePropertyDescriptor } from './props';
  6. import { ValueAttribute, Concrete, ArrayAttribute, ObjectAttribute } from './types';
  7. import { Mark } from './mark';
  8. import { Composition, View } from './composition';
  9. export declare const G2_CHART_KEY = "G2_CHART_KEY";
  10. export type ChartOptions = ViewComposition & {
  11. container?: string | HTMLElement;
  12. canvas?: GCanvas;
  13. width?: number;
  14. height?: number;
  15. autoFit?: boolean;
  16. renderer?: IRenderer;
  17. plugins?: RendererPlugin[];
  18. theme?: string;
  19. };
  20. type ChartProps = Concrete<ViewComposition>;
  21. export interface Chart extends Composition, Mark {
  22. data: ValueAttribute<ChartProps['data'], Chart>;
  23. width: ValueAttribute<ChartProps['width'], Chart>;
  24. height: ValueAttribute<ChartProps['height'], Chart>;
  25. coordinate: ValueAttribute<ChartProps['coordinate'], Chart>;
  26. interaction: ObjectAttribute<ChartProps['interaction'], Chart>;
  27. key: ValueAttribute<ChartProps['key'], Chart>;
  28. transform: ArrayAttribute<ChartProps['transform'], Chart>;
  29. theme: ObjectAttribute<ChartProps['theme'], Chart>;
  30. title: ValueAttribute<ChartProps['title'], Chart>;
  31. scale: ObjectAttribute<ChartOptions['scale'], Chart>;
  32. axis: ObjectAttribute<ChartOptions['axis'], Chart>;
  33. legend: ObjectAttribute<ChartOptions['legend'], Chart>;
  34. style: ObjectAttribute<ChartOptions['style'], Chart>;
  35. labelTransform: ArrayAttribute<ChartOptions['labelTransform'], Chart>;
  36. }
  37. export declare const props: NodePropertyDescriptor[];
  38. export declare class Chart extends View<ChartOptions> {
  39. private _container;
  40. private _context;
  41. private _emitter;
  42. private _width;
  43. private _height;
  44. private _renderer;
  45. private _plugins;
  46. private _hasBindAutoFit;
  47. private _rendering;
  48. private _trailing;
  49. private _trailingResolve;
  50. private _trailingReject;
  51. private _previousDefinedType;
  52. constructor(options: ChartOptions);
  53. render(): Promise<Chart>;
  54. /**
  55. * @overload
  56. * @returns {G2ViewTree}
  57. */
  58. options(): G2ViewTree;
  59. /**
  60. * @overload
  61. * @param {G2ViewTree} options
  62. * @returns {Chart}
  63. */
  64. options(options: G2ViewTree): Chart;
  65. getContainer(): HTMLElement;
  66. getContext(): G2Context;
  67. on(event: string, callback: (...args: any[]) => any, once?: boolean): this;
  68. once(event: string, callback: (...args: any[]) => any): this;
  69. emit(event: string, ...args: any[]): this;
  70. off(event?: string, callback?: (...args: any[]) => any): this;
  71. clear(): void;
  72. destroy(): void;
  73. forceFit(): Promise<Chart>;
  74. changeSize(width: number, height: number): Promise<Chart>;
  75. private _reset;
  76. private _renderTrailing;
  77. private _createResolve;
  78. private _createReject;
  79. private _computedOptions;
  80. private _createCanvas;
  81. private _addToTrailing;
  82. private _onResize;
  83. private _bindAutoFit;
  84. private _unbindAutoFit;
  85. }
  86. export {};