utils.d.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { View } from '@antv/g2';
  2. import { Options } from '../../types';
  3. import { AreaOptions } from '../area';
  4. import { BarOptions } from '../bar';
  5. import { ColumnOptions } from '../column';
  6. import { FunnelOptions } from '../funnel';
  7. import { GaugeOptions } from '../gauge';
  8. import { HistogramOptions } from '../histogram';
  9. import { LineOptions } from '../line';
  10. import { PieOptions } from '../pie';
  11. import { ProgressOptions } from '../progress';
  12. import { RingProgressOptions } from '../ring-progress';
  13. import { ScatterOptions } from '../scatter';
  14. import { StockOptions } from '../stock';
  15. import { TinyAreaOptions } from '../tiny-area';
  16. import { TinyColumnOptions } from '../tiny-column';
  17. import { TinyLineOptions } from '../tiny-line';
  18. /**
  19. * 移除 options 中的 width、height 设置, 将 options 的 data 设置为可选
  20. */
  21. type PlotOptions<T> = Omit<T, 'width' | 'height' | 'data'> & Partial<Pick<T extends Options ? T : never, 'data'>>;
  22. /**
  23. * multi-view 中的支持的 plots 类型(带 options 定义)
  24. */
  25. export type IPlotTypes = {
  26. /**
  27. * plot 类型
  28. */
  29. readonly type: 'line';
  30. /**
  31. * plot 配置
  32. */
  33. readonly options: PlotOptions<LineOptions>;
  34. } | {
  35. readonly type: 'pie';
  36. readonly options: PlotOptions<PieOptions>;
  37. } | {
  38. readonly type: 'bar';
  39. readonly options: PlotOptions<BarOptions>;
  40. } | {
  41. readonly type: 'column';
  42. readonly options: PlotOptions<ColumnOptions>;
  43. } | {
  44. readonly type: 'area';
  45. readonly options: PlotOptions<AreaOptions>;
  46. } | {
  47. readonly type: 'gauge';
  48. readonly options: PlotOptions<GaugeOptions>;
  49. } | {
  50. readonly type: 'tiny-line';
  51. readonly options: PlotOptions<TinyLineOptions>;
  52. } | {
  53. readonly type: 'tiny-area';
  54. readonly options: PlotOptions<TinyAreaOptions>;
  55. } | {
  56. readonly type: 'tiny-column';
  57. readonly options: PlotOptions<TinyColumnOptions>;
  58. } | {
  59. readonly type: 'ring-progress';
  60. readonly options: PlotOptions<RingProgressOptions>;
  61. } | {
  62. readonly type: 'progress';
  63. readonly options: PlotOptions<ProgressOptions>;
  64. } | {
  65. readonly type: 'histogram';
  66. readonly options: PlotOptions<HistogramOptions>;
  67. } | {
  68. readonly type: 'scatter';
  69. readonly options: PlotOptions<ScatterOptions>;
  70. } | {
  71. readonly type: 'funnel';
  72. readonly options: PlotOptions<FunnelOptions>;
  73. } | {
  74. readonly type: 'stock';
  75. readonly options: PlotOptions<StockOptions>;
  76. };
  77. /**
  78. * 执行 plot 的 adaptor, 默认都带上 defaultOptions
  79. * @param {string} plot
  80. */
  81. export declare function execPlotAdaptor<T extends IPlotTypes['type']>(plot: T, view: View, options: IPlotTypes['options']): void;
  82. export {};