base.d.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { Params } from '../../core/adaptor';
  2. import { ColorAttr, Datum, Options, RawFields, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr } from '../../types';
  3. import { Label } from '../../types/label';
  4. import { State } from '../../types/state';
  5. /**
  6. * 图形映射属性,按照优先级来的
  7. */
  8. export type MappingOptions = {
  9. /** color 映射 */
  10. readonly color?: ColorAttr;
  11. /** shape 映射 */
  12. readonly shape?: ShapeAttr;
  13. /** 大小映射, 提供回调的方式 */
  14. readonly size?: SizeAttr;
  15. /** 样式映射 */
  16. readonly style?: StyleAttr;
  17. /** tooltip 映射 */
  18. readonly tooltip?: TooltipAttr;
  19. };
  20. /**
  21. * 一个图形映射的逻辑,纯粹的图形语法
  22. * // TODO 后续需要处理 adjust 的配置,然后通过 field 信息。比如 styleField,labelField 等一定是一个数组形式
  23. */
  24. export type Geometry = {
  25. /** geometry 类型, 'line' | 'interval' | 'point' | 'area' | 'polygon' */
  26. readonly type?: string;
  27. /** x 轴字段 */
  28. readonly xField?: string;
  29. /** y 轴字段 */
  30. readonly yField?: string;
  31. /** 分组字段 */
  32. readonly colorField?: string;
  33. /** shape 的映射字段 */
  34. readonly shapeField?: string;
  35. /** size 映射字段 */
  36. readonly sizeField?: string;
  37. /** style 的映射字段 */
  38. readonly styleField?: string;
  39. /** tooltip 的映射字段 */
  40. readonly tooltipFields?: string[] | false;
  41. /** 其他原始字段, 用于 mapping 回调参数 */
  42. readonly rawFields?: RawFields;
  43. /** 图形映射规则 */
  44. readonly mapping?: MappingOptions;
  45. /** label 映射通道,因为历史原因导致实现略有区别 */
  46. readonly label?: Label;
  47. /** 不同状态的样式 */
  48. readonly state?: State;
  49. /** 自定义信息,一般在 registerShape 中使用 */
  50. readonly customInfo?: any;
  51. /** geometry params */
  52. readonly args?: any;
  53. };
  54. /**
  55. * geometry options
  56. */
  57. export type GeometryOptions = Geometry & Partial<Options>;
  58. /**
  59. * 获得映射的字段列表
  60. * @param options
  61. * @param field
  62. */
  63. export declare function getMappingField(o: GeometryOptions, field: 'color' | 'shape' | 'size' | 'style'): {
  64. mappingFields: string[];
  65. tileMappingField: string;
  66. };
  67. /**
  68. * 获得映射函数
  69. * @param mappingFields
  70. * @param func
  71. */
  72. export declare function getMappingFunction(mappingFields: string[], func: (datum: Datum) => any): (...args: any[]) => any;
  73. /**
  74. * 通用 geometry 的配置处理的 adaptor
  75. * @param params
  76. */
  77. export declare function geometry<O extends GeometryOptions>(params: Params<O>): Params<O>;