@antv/g2plot 2.4.13 → 2.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/g2plot.min.js +3 -17
  2. package/dist/g2plot.min.js.map +1 -1
  3. package/esm/adaptor/common.d.ts +10 -0
  4. package/esm/adaptor/common.js +25 -0
  5. package/esm/adaptor/common.js.map +1 -1
  6. package/esm/adaptor/geometries/area.js +2 -1
  7. package/esm/adaptor/geometries/area.js.map +1 -1
  8. package/esm/adaptor/geometries/edge.js +2 -1
  9. package/esm/adaptor/geometries/edge.js.map +1 -1
  10. package/esm/adaptor/geometries/interval.js +9 -2
  11. package/esm/adaptor/geometries/interval.js.map +1 -1
  12. package/esm/adaptor/geometries/line.js +2 -2
  13. package/esm/adaptor/geometries/line.js.map +1 -1
  14. package/esm/adaptor/geometries/point.js +2 -1
  15. package/esm/adaptor/geometries/point.js.map +1 -1
  16. package/esm/adaptor/geometries/polygon.js +2 -1
  17. package/esm/adaptor/geometries/polygon.js.map +1 -1
  18. package/esm/adaptor/geometries/schema.js +2 -1
  19. package/esm/adaptor/geometries/schema.js.map +1 -1
  20. package/esm/adaptor/pattern.d.ts +1 -1
  21. package/esm/index.d.ts +1 -1
  22. package/esm/index.js +1 -1
  23. package/esm/index.js.map +1 -1
  24. package/esm/plots/area/adaptor.js +4 -4
  25. package/esm/plots/area/adaptor.js.map +1 -1
  26. package/esm/plots/area/index.js +2 -2
  27. package/esm/plots/area/index.js.map +1 -1
  28. package/esm/plots/area/types.d.ts +6 -0
  29. package/esm/plots/area/types.js.map +1 -1
  30. package/esm/plots/bar/adaptor.js +3 -3
  31. package/esm/plots/bar/adaptor.js.map +1 -1
  32. package/esm/plots/bar/index.js +2 -2
  33. package/esm/plots/bar/index.js.map +1 -1
  34. package/esm/plots/column/adaptor.js +4 -4
  35. package/esm/plots/column/adaptor.js.map +1 -1
  36. package/esm/plots/column/index.js +2 -2
  37. package/esm/plots/column/index.js.map +1 -1
  38. package/esm/plots/column/types.d.ts +6 -0
  39. package/esm/plots/column/types.js.map +1 -1
  40. package/esm/plots/mix/adaptor.d.ts +5 -0
  41. package/esm/plots/mix/adaptor.js +18 -5
  42. package/esm/plots/mix/adaptor.js.map +1 -1
  43. package/esm/plots/mix/types.d.ts +24 -2
  44. package/esm/plots/mix/types.js.map +1 -1
  45. package/esm/plots/mix/utils.d.ts +18 -17
  46. package/esm/plots/mix/utils.js.map +1 -1
  47. package/esm/plots/pie/adaptor.js +1 -1
  48. package/esm/plots/pie/adaptor.js.map +1 -1
  49. package/esm/types/common.d.ts +6 -0
  50. package/esm/types/common.js.map +1 -1
  51. package/esm/types/coordinate.d.ts +13 -0
  52. package/esm/types/coordinate.js +1 -0
  53. package/esm/types/coordinate.js.map +1 -0
  54. package/esm/utils/transform/percent.d.ts +1 -1
  55. package/esm/utils/transform/percent.js +1 -1
  56. package/esm/utils/transform/percent.js.map +1 -1
  57. package/lib/adaptor/common.d.ts +10 -0
  58. package/lib/adaptor/common.js +27 -1
  59. package/lib/adaptor/common.js.map +1 -1
  60. package/lib/adaptor/geometries/area.js +2 -1
  61. package/lib/adaptor/geometries/area.js.map +1 -1
  62. package/lib/adaptor/geometries/edge.js +2 -1
  63. package/lib/adaptor/geometries/edge.js.map +1 -1
  64. package/lib/adaptor/geometries/interval.js +9 -2
  65. package/lib/adaptor/geometries/interval.js.map +1 -1
  66. package/lib/adaptor/geometries/line.js +2 -2
  67. package/lib/adaptor/geometries/line.js.map +1 -1
  68. package/lib/adaptor/geometries/point.js +2 -1
  69. package/lib/adaptor/geometries/point.js.map +1 -1
  70. package/lib/adaptor/geometries/polygon.js +2 -1
  71. package/lib/adaptor/geometries/polygon.js.map +1 -1
  72. package/lib/adaptor/geometries/schema.js +2 -1
  73. package/lib/adaptor/geometries/schema.js.map +1 -1
  74. package/lib/adaptor/pattern.d.ts +1 -1
  75. package/lib/index.d.ts +1 -1
  76. package/lib/index.js +1 -1
  77. package/lib/index.js.map +1 -1
  78. package/lib/plots/area/adaptor.js +2 -2
  79. package/lib/plots/area/adaptor.js.map +1 -1
  80. package/lib/plots/area/index.js +1 -1
  81. package/lib/plots/area/index.js.map +1 -1
  82. package/lib/plots/area/types.d.ts +6 -0
  83. package/lib/plots/area/types.js.map +1 -1
  84. package/lib/plots/bar/adaptor.js +3 -3
  85. package/lib/plots/bar/adaptor.js.map +1 -1
  86. package/lib/plots/bar/index.js +1 -1
  87. package/lib/plots/bar/index.js.map +1 -1
  88. package/lib/plots/column/adaptor.js +2 -2
  89. package/lib/plots/column/adaptor.js.map +1 -1
  90. package/lib/plots/column/index.js +1 -1
  91. package/lib/plots/column/index.js.map +1 -1
  92. package/lib/plots/column/types.d.ts +6 -0
  93. package/lib/plots/column/types.js.map +1 -1
  94. package/lib/plots/mix/adaptor.d.ts +5 -0
  95. package/lib/plots/mix/adaptor.js +19 -5
  96. package/lib/plots/mix/adaptor.js.map +1 -1
  97. package/lib/plots/mix/types.d.ts +24 -2
  98. package/lib/plots/mix/types.js.map +1 -1
  99. package/lib/plots/mix/utils.d.ts +18 -17
  100. package/lib/plots/mix/utils.js.map +1 -1
  101. package/lib/plots/pie/adaptor.js +1 -1
  102. package/lib/plots/pie/adaptor.js.map +1 -1
  103. package/lib/types/common.d.ts +6 -0
  104. package/lib/types/common.js.map +1 -1
  105. package/lib/types/coordinate.d.ts +13 -0
  106. package/lib/types/coordinate.js +3 -0
  107. package/lib/types/coordinate.js.map +1 -0
  108. package/lib/utils/transform/percent.d.ts +1 -1
  109. package/lib/utils/transform/percent.js +3 -3
  110. package/lib/utils/transform/percent.js.map +1 -1
  111. package/package.json +2 -1
  112. package/src/adaptor/common.ts +28 -1
  113. package/src/adaptor/geometries/area.ts +2 -1
  114. package/src/adaptor/geometries/edge.ts +2 -1
  115. package/src/adaptor/geometries/interval.ts +9 -1
  116. package/src/adaptor/geometries/line.ts +2 -2
  117. package/src/adaptor/geometries/point.ts +2 -1
  118. package/src/adaptor/geometries/polygon.ts +2 -1
  119. package/src/adaptor/geometries/schema.ts +2 -1
  120. package/src/index.ts +1 -1
  121. package/src/plots/area/adaptor.ts +14 -3
  122. package/src/plots/area/index.ts +2 -2
  123. package/src/plots/area/types.ts +7 -0
  124. package/src/plots/bar/adaptor.ts +3 -3
  125. package/src/plots/bar/index.ts +2 -2
  126. package/src/plots/column/adaptor.ts +4 -2
  127. package/src/plots/column/index.ts +2 -2
  128. package/src/plots/column/types.ts +7 -0
  129. package/src/plots/mix/adaptor.ts +24 -5
  130. package/src/plots/mix/types.ts +24 -2
  131. package/src/plots/mix/utils.ts +18 -17
  132. package/src/plots/pie/adaptor.ts +1 -1
  133. package/src/types/common.ts +6 -0
  134. package/src/types/coordinate.ts +17 -0
  135. package/src/utils/transform/percent.ts +1 -1
  136. package/CHANGELOG.md +0 -1499
@@ -1 +1 @@
1
- {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/mix/adaptor.ts"],"names":[],"mappings":";;;;AAAA,mCAAkC;AAElC,sDAA4E;AAC5E,+CAA8E;AAE9E,wCAAyD;AACzD,2CAAuD;AACvD,qCAAqD;AAKrD,iCAA0C;AAE1C;;;GAGG;AACH,SAAS,SAAS,CAAC,MAA0B;IACnC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,KAAK,GAAa,OAAO,MAApB,EAAE,MAAM,GAAK,OAAO,OAAZ,CAAa;IAElC,WAAI,CAAC,KAAK,EAAE,UAAC,CAAQ;QACX,IAAA,MAAM,GAAmF,CAAC,OAApF,EAAE,IAAI,GAA6E,CAAC,KAA9E,EAAE,IAAI,GAAuE,CAAC,KAAxE,EAAE,IAAI,GAAiE,CAAC,KAAlE,EAAE,UAAU,GAAqD,CAAC,WAAtD,EAAE,YAAY,GAAuC,CAAC,aAAxC,EAAE,WAAW,GAA0B,CAAC,YAA3B,EAAE,OAAO,GAAiB,CAAC,QAAlB,EAAE,UAAU,GAAK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AAC;IAC/B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,SAAS,CAAC,MAA0B;IACnC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,KAAK,GAAK,OAAO,MAAZ,CAAa;IAE1B,WAAI,CAAC,KAAK,EAAE,UAAC,IAAI;QACP,IAAA,IAAI,GAA2B,IAAI,KAA/B,EAAE,MAAM,GAAmB,IAAI,OAAvB,EAAE,KAAiB,IAAI,QAAT,EAAZ,OAAO,mBAAG,EAAE,KAAA,CAAU;QACpC,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;QAE5B,IAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,oBAAG,MAAM,QAAA,IAAK,YAAI,CAAC,OAAO,EAAE,6BAAsB,CAAC,EAAG,CAAC;QACxF,IAAI,OAAO,EAAE;YACX,gBAAgB;YAChB,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;SACjC;QAED,uBAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAgB,OAAO,CAAC,MAA0B;IAChD,OAAO,YAAI,CACT,kBAAS,EAAE,sBAAsB;IACjC,SAAS,EACT,SAAS,EACT,oBAAW,EACX,kBAAS,EACT,cAAK,EACL,gBAAO;IACP,uBAAuB;KACxB,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAXD,0BAWC","sourcesContent":["import { each } from '@antv/util';\nimport { Geometry } from '@antv/g2';\nimport { geometry as geometryAdaptor } from '../../adaptor/geometries/base';\nimport { interaction, animation, theme, tooltip } from '../../adaptor/common';\nimport { Params } from '../../core/adaptor';\nimport { PLOT_CONTAINER_OPTIONS } from '../../core/plot';\nimport { AXIS_META_CONFIG_KEYS } from '../../constant';\nimport { deepAssign, flow, pick } from '../../utils';\nimport { Axis } from '../../types/axis';\nimport { Legend } from '../../types/legend';\nimport { Interaction } from '../../types/interaction';\nimport { MixOptions, IView, IGeometry } from './types';\nimport { execPlotAdaptor } from './utils';\n\n/**\n * geometry 处理\n * @param params\n */\nfunction multiView(params: Params<MixOptions>): Params<MixOptions> {\n const { chart, options } = params;\n const { views, legend } = options;\n\n each(views, (v: IView) => {\n const { region, data, meta, axes, coordinate, interactions, annotations, tooltip, geometries } = v;\n\n // 1. 创建 view\n const viewOfG2 = chart.createView({\n region,\n });\n\n // 2. data\n viewOfG2.data(data);\n\n // 3. meta\n let scales: Record<string, any> = {};\n if (axes) {\n each(axes, (axis: Axis, field: string) => {\n scales[field] = pick(axis, AXIS_META_CONFIG_KEYS);\n });\n }\n\n scales = deepAssign({}, meta, scales);\n viewOfG2.scale(scales);\n\n // 4. x y axis\n if (!axes) {\n viewOfG2.axis(false);\n } else {\n each(axes, (axis: Axis, field: string) => {\n viewOfG2.axis(field, axis);\n });\n }\n\n // 5. coordinate\n viewOfG2.coordinate(coordinate);\n\n // 6. geometry\n each(geometries, (geometry: IGeometry) => {\n const { ext } = geometryAdaptor({\n chart: viewOfG2,\n options: geometry,\n });\n\n // adjust\n const { adjust } = geometry;\n if (adjust) {\n ext.geometry.adjust(adjust);\n }\n });\n\n // 7. interactions\n each(interactions, (interaction: Interaction) => {\n if (interaction.enable === false) {\n viewOfG2.removeInteraction(interaction.type);\n } else {\n viewOfG2.interaction(interaction.type, interaction.cfg);\n }\n });\n\n // 8. annotations\n each(annotations, (annotation) => {\n viewOfG2.annotation()[annotation.type]({\n ...annotation,\n });\n });\n\n // 9. animation (先做动画)\n if (typeof v.animation === 'boolean') {\n viewOfG2.animate(false);\n } else {\n viewOfG2.animate(true);\n // 9.1 所有的 Geometry 都使用同一动画(各个图形如有区别,todo 自行覆盖)\n each(viewOfG2.geometries, (g: Geometry) => {\n g.animate(v.animation);\n });\n }\n\n if (tooltip) {\n // 10. tooltip\n viewOfG2.interaction('tooltip');\n viewOfG2.tooltip(tooltip);\n }\n });\n\n // legend\n if (!legend) {\n chart.legend(false);\n } else {\n each(legend, (l: Legend, field: string) => {\n chart.legend(field, l);\n });\n }\n\n // tooltip\n chart.tooltip(options.tooltip);\n return params;\n}\n\n/**\n * 支持嵌套使用 g2plot 内置图表\n * @param params\n */\nfunction multiPlot(params: Params<MixOptions>): Params<MixOptions> {\n const { chart, options } = params;\n const { plots } = options;\n\n each(plots, (plot) => {\n const { type, region, options = {} } = plot;\n const { tooltip } = options;\n\n const viewOfG2 = chart.createView({ region, ...pick(options, PLOT_CONTAINER_OPTIONS) });\n if (tooltip) {\n // 配置 tooltip 交互\n viewOfG2.interaction('tooltip');\n }\n\n execPlotAdaptor(type, viewOfG2, options);\n });\n\n return params;\n}\n\n/**\n * 图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<MixOptions>) {\n return flow(\n animation, // 多 view 的图,动画配置放到最前面\n multiView,\n multiPlot,\n interaction,\n animation,\n theme,\n tooltip\n // ... 其他的 adaptor flow\n )(params);\n}\n"]}
1
+ {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/mix/adaptor.ts"],"names":[],"mappings":";;;;AAAA,mCAAkC;AAElC,sDAA4E;AAC5E,+CAA0F;AAE1F,wCAAyD;AACzD,2CAAuD;AACvD,qCAAqD;AAKrD,iCAA0C;AAE1C;;;GAGG;AACH,SAAS,SAAS,CAAC,MAA0B;IACnC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,KAAK,GAAa,OAAO,MAApB,EAAE,MAAM,GAAK,OAAO,OAAZ,CAAa;IAElC,WAAI,CAAC,KAAK,EAAE,UAAC,CAAQ;QACX,IAAA,MAAM,GAAmF,CAAC,OAApF,EAAE,IAAI,GAA6E,CAAC,KAA9E,EAAE,IAAI,GAAuE,CAAC,KAAxE,EAAE,IAAI,GAAiE,CAAC,KAAlE,EAAE,UAAU,GAA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C,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvC,OAAO,MAAM,CAAC;AAChB,CAAC;AAND,wBAMC;AAED;;;;GAIG;AACH,SAAgB,OAAO,CAAC,MAA0B;IAChD,OAAO,YAAI,CACT,kBAAS,EAAE,sBAAsB;IACjC,SAAS,EACT,SAAS,EACT,oBAAW,EACX,kBAAS,EACT,cAAK,EACL,gBAAO,EACP,MAAM,EACN,mBAAU,EAAE;IACZ,uBAAuB;KACxB,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAbD,0BAaC","sourcesContent":["import { each } from '@antv/util';\nimport { Geometry } from '@antv/g2';\nimport { geometry as geometryAdaptor } from '../../adaptor/geometries/base';\nimport { interaction, animation, theme, tooltip, annotation } from '../../adaptor/common';\nimport { Params } from '../../core/adaptor';\nimport { PLOT_CONTAINER_OPTIONS } from '../../core/plot';\nimport { AXIS_META_CONFIG_KEYS } from '../../constant';\nimport { deepAssign, flow, pick } from '../../utils';\nimport { Axis } from '../../types/axis';\nimport { Legend } from '../../types/legend';\nimport { Interaction } from '../../types/interaction';\nimport { MixOptions, IView, IGeometry } from './types';\nimport { execPlotAdaptor } from './utils';\n\n/**\n * geometry 处理\n * @param params\n */\nfunction multiView(params: Params<MixOptions>): Params<MixOptions> {\n const { chart, options } = params;\n const { views, legend } = options;\n\n each(views, (v: IView) => {\n const { region, data, meta, axes, coordinate, interactions, annotations, tooltip, geometries } = v;\n\n // 1. 创建 view\n const viewOfG2 = chart.createView({\n region,\n });\n\n // 2. data\n viewOfG2.data(data);\n\n // 3. meta\n let scales: Record<string, any> = {};\n if (axes) {\n each(axes, (axis: Axis, field: string) => {\n scales[field] = pick(axis, AXIS_META_CONFIG_KEYS);\n });\n }\n\n scales = deepAssign({}, meta, scales);\n viewOfG2.scale(scales);\n\n // 4. x y axis\n if (!axes) {\n viewOfG2.axis(false);\n } else {\n each(axes, (axis: Axis, field: string) => {\n viewOfG2.axis(field, axis);\n });\n }\n\n // 5. coordinate\n viewOfG2.coordinate(coordinate);\n\n // 6. geometry\n each(geometries, (geometry: IGeometry) => {\n const { ext } = geometryAdaptor({\n chart: viewOfG2,\n options: geometry,\n });\n\n // adjust\n const { adjust } = geometry;\n if (adjust) {\n ext.geometry.adjust(adjust);\n }\n });\n\n // 7. interactions\n each(interactions, (interaction: Interaction) => {\n if (interaction.enable === false) {\n viewOfG2.removeInteraction(interaction.type);\n } else {\n viewOfG2.interaction(interaction.type, interaction.cfg);\n }\n });\n\n // 8. annotations\n each(annotations, (annotation) => {\n viewOfG2.annotation()[annotation.type]({\n ...annotation,\n });\n });\n\n // 9. animation (先做动画)\n if (typeof v.animation === 'boolean') {\n viewOfG2.animate(false);\n } else {\n viewOfG2.animate(true);\n // 9.1 所有的 Geometry 都使用同一动画(各个图形如有区别,todo 自行覆盖)\n each(viewOfG2.geometries, (g: Geometry) => {\n g.animate(v.animation);\n });\n }\n\n if (tooltip) {\n // 10. tooltip\n viewOfG2.interaction('tooltip');\n viewOfG2.tooltip(tooltip);\n }\n });\n\n // legend\n if (!legend) {\n chart.legend(false);\n } else {\n each(legend, (l: Legend, field: string) => {\n chart.legend(field, l);\n });\n }\n\n // tooltip\n chart.tooltip(options.tooltip);\n return params;\n}\n\n/**\n * 支持嵌套使用 g2plot 内置图表\n * @param params\n */\nfunction multiPlot(params: Params<MixOptions>): Params<MixOptions> {\n const { chart, options } = params;\n const { plots, data = [] } = options;\n\n each(plots, (plot) => {\n const { type, region, options = {}, top } = plot;\n const { tooltip } = options;\n\n if (top) {\n execPlotAdaptor(type, chart, { ...options, data });\n return;\n }\n\n const viewOfG2 = chart.createView({ region, ...pick(options, PLOT_CONTAINER_OPTIONS) });\n if (tooltip) {\n // 配置 tooltip 交互\n viewOfG2.interaction('tooltip');\n }\n\n execPlotAdaptor(type, viewOfG2, { data, ...options });\n });\n\n return params;\n}\n\n/**\n * 处理缩略轴的 adaptor (mix)\n * @param params\n */\nexport function slider(params: Params<MixOptions>): Params<MixOptions> {\n const { chart, options } = params;\n\n chart.option('slider', options.slider);\n\n return params;\n}\n\n/**\n * 图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<MixOptions>) {\n return flow(\n animation, // 多 view 的图,动画配置放到最前面\n multiView,\n multiPlot,\n interaction,\n animation,\n theme,\n tooltip,\n slider,\n annotation()\n // ... 其他的 adaptor flow\n )(params);\n}\n"]}
@@ -6,6 +6,7 @@ import { Geometry } from '../../adaptor/geometries/base';
6
6
  import { Animation } from '../../types/animation';
7
7
  import { Annotation } from '../../types/annotation';
8
8
  import { Interaction } from '../../types/interaction';
9
+ import { Slider } from '../../types/slider';
9
10
  import { IPlotTypes } from './utils';
10
11
  /**
11
12
  * @title geometry 映射信息
@@ -65,16 +66,31 @@ export declare type IView = {
65
66
  * @title 子 plot 的配置
66
67
  */
67
68
  export declare type IPlot = IPlotTypes & {
69
+ /**
70
+ * @title 数据
71
+ * @description 设置画布具体的数据. 默认基础顶层 data
72
+ */
73
+ readonly data?: Record<string, any>[];
68
74
  /**
69
75
  * @title plot view 的布局范围
70
76
  * @default "占满全部"
71
77
  */
72
78
  readonly region?: Region;
79
+ /**
80
+ * @title 是否为顶层
81
+ * @description 设置为 true 时,几何图形挂在顶层 chart 对象上,而不是子 view 下。此时 region 设置无效,data 继承顶层 data 配置。
82
+ * @default false
83
+ */
84
+ readonly top?: boolean;
73
85
  };
74
86
  /**
75
87
  * @title 类型定义
76
88
  */
77
89
  export interface MixOptions extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'legend' | 'tooltip' | 'slider' | 'scrollbar'> {
90
+ /**
91
+ * @title 顶层数据配置
92
+ */
93
+ readonly data?: Options['data'];
78
94
  /**
79
95
  * @title 是否同步子 view 的配置
80
96
  * @description 目前仅仅支持 true / false,后续需要增加 function 的方式进行自定义 view 之前的布局同步
@@ -92,12 +108,18 @@ export interface MixOptions extends Omit<Options, 'data' | 'legend' | 'xAxis' |
92
108
  readonly plots?: IPlot[];
93
109
  /**
94
110
  * @title tooltip 配置
95
- * @description tooltip 配置在 chart 层配置
111
+ * @description Mix tooltip 组件配置,统一顶层配置
112
+ * TODO 字段映射
96
113
  */
97
114
  readonly tooltip?: Tooltip;
98
115
  /**
99
116
  * @title legend 配置
100
- * @description 统一顶层配置
117
+ * @description Mix 图例配置,统一顶层配置
101
118
  */
102
119
  readonly legend?: false | Record<string, Legend>;
120
+ /**
121
+ * @title slider 配置
122
+ * @description Mix 缩略轴配置,统一顶层配置
123
+ */
124
+ readonly slider?: Slider;
103
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/mix/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Data, Meta, Options, Region, Tooltip } from '../../types';\nimport { Axis } from '../../types/axis';\nimport { Legend } from '../../types/legend';\nimport { Geometry } from '../../adaptor/geometries/base';\nimport { Animation } from '../../types/animation';\nimport { Annotation } from '../../types/annotation';\nimport { Interaction } from '../../types/interaction';\nimport { IPlotTypes } from './utils';\n\n/**\n * @title geometry 映射信息\n */\nexport type IGeometry = Geometry & {\n adjust?: Types.AdjustOption;\n};\n/**\n * @title 子 view 的配置\n * @description 暂时不开嵌套 view 的情况\n */\nexport type IView = {\n /**\n * @title view 的布局范围\n * @default \"占满全部\"\n */\n readonly region?: Region;\n /**\n * @title view 中的数据\n */\n readonly data: Data;\n /**\n * @title view 中对应的 meta 字段配置\n */\n readonly meta?: Record<string, Meta>;\n /**\n * @title 坐标系的配置\n * @description 每一个 view 具有相同的坐标系\n */\n readonly coordinate?: Types.CoordinateOption;\n /**\n * @title 图形 geometry 及映射配置\n */\n readonly geometries: IGeometry[];\n /**\n * @title x,y 轴\n */\n readonly axes?: false | Record<string, Axis>;\n /**\n * @title interactions\n */\n readonly interactions?: Interaction[];\n /**\n * @title annotation\n */\n readonly annotations?: Annotation[];\n /**\n * @title annotation\n */\n readonly animation?: Animation;\n /**\n * @title tooltip\n */\n readonly tooltip?: Tooltip;\n};\n\n/**\n * @title 子 plot 的配置\n */\nexport type IPlot = IPlotTypes & {\n /**\n * @title plot view 的布局范围\n * @default \"占满全部\"\n */\n readonly region?: Region;\n};\n\n/**\n * @title 类型定义\n */\nexport interface MixOptions\n extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'legend' | 'tooltip' | 'slider' | 'scrollbar'> {\n /**\n * @title 是否同步子 view 的配置\n * @description 目前仅仅支持 true / false,后续需要增加 function 的方式进行自定义 view 之前的布局同步\n */\n readonly syncViewPadding?: boolean;\n /**\n * @title 每一个图层的配置\n * @description 每个图层包括有自己的:数据、图形、图形映射\n */\n readonly views?: IView[];\n /**\n * @title 限定与指定 plot 类型\n * @description 支持使用已有的 plot,限定与指定 plot 类型\n */\n readonly plots?: IPlot[];\n /**\n * @title tooltip 配置\n * @description tooltip 配置在 chart 层配置\n */\n readonly tooltip?: Tooltip;\n /**\n * @title legend 配置\n * @description 统一顶层配置\n */\n readonly legend?: false | Record<string, Legend>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/mix/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Data, Meta, Options, Region, Tooltip } from '../../types';\nimport { Axis } from '../../types/axis';\nimport { Legend } from '../../types/legend';\nimport { Geometry } from '../../adaptor/geometries/base';\nimport { Animation } from '../../types/animation';\nimport { Annotation } from '../../types/annotation';\nimport { Interaction } from '../../types/interaction';\nimport { Slider } from '../../types/slider';\nimport { IPlotTypes } from './utils';\n\n/**\n * @title geometry 映射信息\n */\nexport type IGeometry = Geometry & {\n adjust?: Types.AdjustOption;\n};\n/**\n * @title 子 view 的配置\n * @description 暂时不开嵌套 view 的情况\n */\nexport type IView = {\n /**\n * @title view 的布局范围\n * @default \"占满全部\"\n */\n readonly region?: Region;\n /**\n * @title view 中的数据\n */\n readonly data: Data;\n /**\n * @title view 中对应的 meta 字段配置\n */\n readonly meta?: Record<string, Meta>;\n /**\n * @title 坐标系的配置\n * @description 每一个 view 具有相同的坐标系\n */\n readonly coordinate?: Types.CoordinateOption;\n /**\n * @title 图形 geometry 及映射配置\n */\n readonly geometries: IGeometry[];\n /**\n * @title x,y 轴\n */\n readonly axes?: false | Record<string, Axis>;\n /**\n * @title interactions\n */\n readonly interactions?: Interaction[];\n /**\n * @title annotation\n */\n readonly annotations?: Annotation[];\n /**\n * @title annotation\n */\n readonly animation?: Animation;\n /**\n * @title tooltip\n */\n readonly tooltip?: Tooltip;\n};\n\n/**\n * @title 子 plot 的配置\n */\nexport type IPlot = IPlotTypes & {\n /**\n * @title 数据\n * @description 设置画布具体的数据. 默认基础顶层 data\n */\n readonly data?: Record<string, any>[];\n /**\n * @title plot view 的布局范围\n * @default \"占满全部\"\n */\n readonly region?: Region;\n /**\n * @title 是否为顶层\n * @description 设置为 true 时,几何图形挂在顶层 chart 对象上,而不是子 view 下。此时 region 设置无效,data 继承顶层 data 配置。\n * @default false\n */\n readonly top?: boolean;\n};\n\n/**\n * @title 类型定义\n */\nexport interface MixOptions\n extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'legend' | 'tooltip' | 'slider' | 'scrollbar'> {\n /**\n * @title 顶层数据配置\n */\n readonly data?: Options['data'];\n /**\n * @title 是否同步子 view 的配置\n * @description 目前仅仅支持 true / false,后续需要增加 function 的方式进行自定义 view 之前的布局同步\n */\n readonly syncViewPadding?: boolean;\n /**\n * @title 每一个图层的配置\n * @description 每个图层包括有自己的:数据、图形、图形映射\n */\n readonly views?: IView[];\n /**\n * @title 限定与指定 plot 类型\n * @description 支持使用已有的 plot,限定与指定 plot 类型\n */\n readonly plots?: IPlot[];\n /**\n * @title tooltip 配置\n * @description Mix tooltip 组件配置,统一顶层配置\n * TODO 字段映射\n */\n readonly tooltip?: Tooltip;\n /**\n * @title legend 配置\n * @description Mix 图例配置,统一顶层配置\n */\n readonly legend?: false | Record<string, Legend>;\n /**\n * @title slider 配置\n * @description Mix 缩略轴配置,统一顶层配置\n */\n readonly slider?: Slider;\n}\n"]}
@@ -14,10 +14,11 @@ import { ScatterOptions } from '../scatter';
14
14
  import { HistogramOptions } from '../histogram';
15
15
  import { FunnelOptions } from '../funnel';
16
16
  import { StockOptions } from '../stock';
17
+ import { Options } from '../../types';
17
18
  /**
18
- * 移除 options 中的 width、height 设置
19
+ * 移除 options 中的 width、height 设置, 将 options 的 data 设置为可选
19
20
  */
20
- declare type OmitSize<T> = Omit<T, 'width' | 'height'>;
21
+ declare type PlotOptions<T> = Omit<T, 'width' | 'height' | 'data'> & Partial<Pick<T extends Options ? T : never, 'data'>>;
21
22
  /**
22
23
  * multi-view 中的支持的 plots 类型(带 options 定义)
23
24
  */
@@ -29,49 +30,49 @@ export declare type IPlotTypes = {
29
30
  /**
30
31
  * plot 配置
31
32
  */
32
- readonly options: OmitSize<LineOptions>;
33
+ readonly options: PlotOptions<LineOptions>;
33
34
  } | {
34
35
  readonly type: 'pie';
35
- readonly options: OmitSize<PieOptions>;
36
+ readonly options: PlotOptions<PieOptions>;
36
37
  } | {
37
38
  readonly type: 'bar';
38
- readonly options: OmitSize<BarOptions>;
39
+ readonly options: PlotOptions<BarOptions>;
39
40
  } | {
40
41
  readonly type: 'column';
41
- readonly options: OmitSize<ColumnOptions>;
42
+ readonly options: PlotOptions<ColumnOptions>;
42
43
  } | {
43
44
  readonly type: 'area';
44
- readonly options: OmitSize<AreaOptions>;
45
+ readonly options: PlotOptions<AreaOptions>;
45
46
  } | {
46
47
  readonly type: 'gauge';
47
- readonly options: OmitSize<GaugeOptions>;
48
+ readonly options: PlotOptions<GaugeOptions>;
48
49
  } | {
49
50
  readonly type: 'tiny-line';
50
- readonly options: OmitSize<TinyLineOptions>;
51
+ readonly options: PlotOptions<TinyLineOptions>;
51
52
  } | {
52
53
  readonly type: 'tiny-area';
53
- readonly options: OmitSize<TinyAreaOptions>;
54
+ readonly options: PlotOptions<TinyAreaOptions>;
54
55
  } | {
55
56
  readonly type: 'tiny-column';
56
- readonly options: OmitSize<TinyColumnOptions>;
57
+ readonly options: PlotOptions<TinyColumnOptions>;
57
58
  } | {
58
59
  readonly type: 'ring-progress';
59
- readonly options: OmitSize<RingProgressOptions>;
60
+ readonly options: PlotOptions<RingProgressOptions>;
60
61
  } | {
61
62
  readonly type: 'progress';
62
- readonly options: OmitSize<ProgressOptions>;
63
+ readonly options: PlotOptions<ProgressOptions>;
63
64
  } | {
64
65
  readonly type: 'histogram';
65
- readonly options: OmitSize<HistogramOptions>;
66
+ readonly options: PlotOptions<HistogramOptions>;
66
67
  } | {
67
68
  readonly type: 'scatter';
68
- readonly options: OmitSize<ScatterOptions>;
69
+ readonly options: PlotOptions<ScatterOptions>;
69
70
  } | {
70
71
  readonly type: 'funnel';
71
- readonly options: OmitSize<FunnelOptions>;
72
+ readonly options: PlotOptions<FunnelOptions>;
72
73
  } | {
73
74
  readonly type: 'stock';
74
- readonly options: OmitSize<StockOptions>;
75
+ readonly options: PlotOptions<StockOptions>;
75
76
  };
76
77
  /**
77
78
  * 执行 plot 的 adaptor, 默认都带上 defaultOptions
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/plots/mix/utils.ts"],"names":[],"mappings":";;;AACA,mCAAiC;AACjC,qCAAyC;AACzC,2CAAyD;AACzD,0CAAuD;AACvD,6CAA6D;AAC7D,0CAAuD;AACvD,2CAAyD;AACzD,4CAA2D;AAC3D,gDAAkE;AAClE,kDAAsE;AACtE,gDAAkE;AAClE,qDAA0E;AAC1E,gDAAiE;AACjE,+CAA+D;AAC/D,iDAAmE;AACnE,8CAA6D;AAC7D,6CAA2D;AAC3D,gCAA4C;AAC5C,8BAAyC;AACzC,8BAAyC;AACzC,oCAAkD;AAClD,gCAA4C;AAC5C,kCAA+C;AAC/C,0CAAyD;AACzD,0CAAyD;AACzD,8CAA+D;AAC/D,kDAAqE;AACrE,wCAAwD;AACxD,sCAAqD;AACrD,0CAA2D;AAC3D,oCAAkD;AACl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AAC;IACnC,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,oBAAkB,IAAI,UAAO,CAAC,CAAC;QAC7C,OAAO;KACR;IACD,IAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC;QACL,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,kBAAU,CAAC,EAAE,EAAE,GAAG,CAAC,iBAAiB,EAAE,EAAE,UAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC;KAC9F,CAAC,CAAC;AACL,CAAC;AAfD,0CAeC","sourcesContent":["import { View } from '@antv/g2';\nimport { get } from '@antv/util';\nimport { deepAssign } from '../../utils';\nimport { adaptor as lineAdaptor } from '../line/adaptor';\nimport { adaptor as pieAdaptor } from '../pie/adaptor';\nimport { adaptor as columnAdaptor } from '../column/adaptor';\nimport { adaptor as barAdaptor } from '../bar/adaptor';\nimport { adaptor as areaAdaptor } from '../area/adaptor';\nimport { adaptor as gaugeAdaptor } from '../gauge/adaptor';\nimport { adaptor as tinyLineAdaptor } from '../tiny-line/adaptor';\nimport { adaptor as tinyColumnAdaptor } from '../tiny-column/adaptor';\nimport { adaptor as tinyAreaAdaptor } from '../tiny-area/adaptor';\nimport { adaptor as ringProgressAdaptor } from '../ring-progress/adaptor';\nimport { adaptor as progressAdaptor } from '../progress/adaptor';\nimport { adaptor as scatterAdaptor } from '../scatter/adaptor';\nimport { adaptor as histogramAdaptor } from '../histogram/adaptor';\nimport { adaptor as funnelAdaptor } from '../funnel/adaptor';\nimport { adaptor as stockAdaptor } from '../stock/adaptor';\nimport { Line, LineOptions } from '../line';\nimport { Pie, PieOptions } from '../pie';\nimport { Bar, BarOptions } from '../bar';\nimport { Column, ColumnOptions } from '../column';\nimport { Area, AreaOptions } from '../area';\nimport { Gauge, GaugeOptions } from '../gauge';\nimport { TinyLine, TinyLineOptions } from '../tiny-line';\nimport { TinyArea, TinyAreaOptions } from '../tiny-area';\nimport { TinyColumn, TinyColumnOptions } from '../tiny-column';\nimport { RingProgress, RingProgressOptions } from '../ring-progress';\nimport { Progress, ProgressOptions } from '../progress';\nimport { Scatter, ScatterOptions } from '../scatter';\nimport { Histogram, HistogramOptions } from '../histogram';\nimport { Funnel, FunnelOptions } from '../funnel';\nimport { Stock, StockOptions } from '../stock';\n\n/**\n * 移除 options 中的 width、height 设置\n */\ntype OmitSize<T> = Omit<T, 'width' | 'height'>;\n\n/**\n * multi-view 中的支持的 plots 类型(带 options 定义)\n */\nexport type IPlotTypes =\n | {\n /**\n * plot 类型\n */\n readonly type: 'line';\n /**\n * plot 配置\n */\n readonly options: OmitSize<LineOptions>;\n }\n | {\n readonly type: 'pie';\n readonly options: OmitSize<PieOptions>;\n }\n | {\n readonly type: 'bar';\n readonly options: OmitSize<BarOptions>;\n }\n | {\n readonly type: 'column';\n readonly options: OmitSize<ColumnOptions>;\n }\n | {\n readonly type: 'area';\n readonly options: OmitSize<AreaOptions>;\n }\n | {\n readonly type: 'gauge';\n readonly options: OmitSize<GaugeOptions>;\n }\n | {\n readonly type: 'tiny-line';\n readonly options: OmitSize<TinyLineOptions>;\n }\n | {\n readonly type: 'tiny-area';\n readonly options: OmitSize<TinyAreaOptions>;\n }\n | {\n readonly type: 'tiny-column';\n readonly options: OmitSize<TinyColumnOptions>;\n }\n | {\n readonly type: 'ring-progress';\n readonly options: OmitSize<RingProgressOptions>;\n }\n | {\n readonly type: 'progress';\n readonly options: OmitSize<ProgressOptions>;\n }\n | {\n readonly type: 'histogram';\n readonly options: OmitSize<HistogramOptions>;\n }\n | {\n readonly type: 'scatter';\n readonly options: OmitSize<ScatterOptions>;\n }\n | {\n readonly type: 'funnel';\n readonly options: OmitSize<FunnelOptions>;\n }\n | {\n readonly type: 'stock';\n readonly options: OmitSize<StockOptions>;\n };\n\n/**\n * 可在 multi-view 中使用的 plots\n */\nconst PLOT_ADAPTORS = {\n line: lineAdaptor,\n pie: pieAdaptor,\n column: columnAdaptor,\n bar: barAdaptor,\n area: areaAdaptor,\n gauge: gaugeAdaptor,\n 'tiny-line': tinyLineAdaptor,\n 'tiny-column': tinyColumnAdaptor,\n 'tiny-area': tinyAreaAdaptor,\n 'ring-progress': ringProgressAdaptor,\n progress: progressAdaptor,\n scatter: scatterAdaptor,\n histogram: histogramAdaptor,\n funnel: funnelAdaptor,\n stock: stockAdaptor,\n};\n\n/**\n * 获取指定 plot 的 class contructor\n * @param {string} plot\n */\nconst PLOT_CONSTRUCTOR = {\n line: Line,\n pie: Pie,\n column: Column,\n bar: Bar,\n area: Area,\n gauge: Gauge,\n 'tiny-line': TinyLine,\n 'tiny-column': TinyColumn,\n 'tiny-area': TinyArea,\n 'ring-progress': RingProgress,\n progress: Progress,\n scatter: Scatter,\n histogram: Histogram,\n funnel: Funnel,\n stock: Stock,\n};\n\n/**\n * 在 mix 图表以及 facet 图表中,defaultOptions 进行复写简化\n */\nconst DEFAULT_OPTIONS_MAP = {\n pie: { label: false },\n column: { tooltip: { showMarkers: false } },\n bar: { tooltip: { showMarkers: false } },\n};\n\n/**\n * 执行 plot 的 adaptor, 默认都带上 defaultOptions\n * @param {string} plot\n */\nexport function execPlotAdaptor<T extends IPlotTypes['type']>(\n plot: T,\n view: View,\n options: IPlotTypes['options']\n): void {\n const cls = PLOT_CONSTRUCTOR[plot];\n if (!cls) {\n console.error(`could not find ${plot} plot`);\n return;\n }\n const module = PLOT_ADAPTORS[plot];\n module({\n chart: view,\n options: deepAssign({}, cls.getDefaultOptions(), get(DEFAULT_OPTIONS_MAP, plot, {}), options),\n });\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/plots/mix/utils.ts"],"names":[],"mappings":";;;AACA,mCAAiC;AACjC,qCAAyC;AACzC,2CAAyD;AACzD,0CAAuD;AACvD,6CAA6D;AAC7D,0CAAuD;AACvD,2CAAyD;AACzD,4CAA2D;AAC3D,gDAAkE;AAClE,kDAAsE;AACtE,gDAAkE;AAClE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,EAAE,KAAK,EAAE;IACrB,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE;IAC3C,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE;CACzC,CAAC;AAEF;;;GAGG;AACH,SAAgB,eAAe,CAC7B,IAAO,EACP,IAAU,EACV,OAA8B;IAE9B,IAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,oBAAkB,IAAI,UAAO,CAAC,CAAC;QAC7C,OAAO;KACR;IACD,IAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC;QACL,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,kBAAU,CAAC,EAAE,EAAE,GAAG,CAAC,iBAAiB,EAAE,EAAE,UAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC;KAC9F,CAAC,CAAC;AACL,CAAC;AAfD,0CAeC","sourcesContent":["import { View } from '@antv/g2';\nimport { get } from '@antv/util';\nimport { deepAssign } from '../../utils';\nimport { adaptor as lineAdaptor } from '../line/adaptor';\nimport { adaptor as pieAdaptor } from '../pie/adaptor';\nimport { adaptor as columnAdaptor } from '../column/adaptor';\nimport { adaptor as barAdaptor } from '../bar/adaptor';\nimport { adaptor as areaAdaptor } from '../area/adaptor';\nimport { adaptor as gaugeAdaptor } from '../gauge/adaptor';\nimport { adaptor as tinyLineAdaptor } from '../tiny-line/adaptor';\nimport { adaptor as tinyColumnAdaptor } from '../tiny-column/adaptor';\nimport { adaptor as tinyAreaAdaptor } from '../tiny-area/adaptor';\nimport { adaptor as ringProgressAdaptor } from '../ring-progress/adaptor';\nimport { adaptor as progressAdaptor } from '../progress/adaptor';\nimport { adaptor as scatterAdaptor } from '../scatter/adaptor';\nimport { adaptor as histogramAdaptor } from '../histogram/adaptor';\nimport { adaptor as funnelAdaptor } from '../funnel/adaptor';\nimport { adaptor as stockAdaptor } from '../stock/adaptor';\nimport { Line, LineOptions } from '../line';\nimport { Pie, PieOptions } from '../pie';\nimport { Bar, BarOptions } from '../bar';\nimport { Column, ColumnOptions } from '../column';\nimport { Area, AreaOptions } from '../area';\nimport { Gauge, GaugeOptions } from '../gauge';\nimport { TinyLine, TinyLineOptions } from '../tiny-line';\nimport { TinyArea, TinyAreaOptions } from '../tiny-area';\nimport { TinyColumn, TinyColumnOptions } from '../tiny-column';\nimport { RingProgress, RingProgressOptions } from '../ring-progress';\nimport { Progress, ProgressOptions } from '../progress';\nimport { Scatter, ScatterOptions } from '../scatter';\nimport { Histogram, HistogramOptions } from '../histogram';\nimport { Funnel, FunnelOptions } from '../funnel';\nimport { Stock, StockOptions } from '../stock';\nimport { Options } from '../../types';\n\n/**\n * 移除 options 中的 width、height 设置, 将 options 的 data 设置为可选\n */\ntype PlotOptions<T> = Omit<T, 'width' | 'height' | 'data'> & Partial<Pick<T extends Options ? T : never, 'data'>>;\n\n/**\n * multi-view 中的支持的 plots 类型(带 options 定义)\n */\nexport type IPlotTypes =\n | {\n /**\n * plot 类型\n */\n readonly type: 'line';\n /**\n * plot 配置\n */\n readonly options: PlotOptions<LineOptions>;\n }\n | {\n readonly type: 'pie';\n readonly options: PlotOptions<PieOptions>;\n }\n | {\n readonly type: 'bar';\n readonly options: PlotOptions<BarOptions>;\n }\n | {\n readonly type: 'column';\n readonly options: PlotOptions<ColumnOptions>;\n }\n | {\n readonly type: 'area';\n readonly options: PlotOptions<AreaOptions>;\n }\n | {\n readonly type: 'gauge';\n readonly options: PlotOptions<GaugeOptions>;\n }\n | {\n readonly type: 'tiny-line';\n readonly options: PlotOptions<TinyLineOptions>;\n }\n | {\n readonly type: 'tiny-area';\n readonly options: PlotOptions<TinyAreaOptions>;\n }\n | {\n readonly type: 'tiny-column';\n readonly options: PlotOptions<TinyColumnOptions>;\n }\n | {\n readonly type: 'ring-progress';\n readonly options: PlotOptions<RingProgressOptions>;\n }\n | {\n readonly type: 'progress';\n readonly options: PlotOptions<ProgressOptions>;\n }\n | {\n readonly type: 'histogram';\n readonly options: PlotOptions<HistogramOptions>;\n }\n | {\n readonly type: 'scatter';\n readonly options: PlotOptions<ScatterOptions>;\n }\n | {\n readonly type: 'funnel';\n readonly options: PlotOptions<FunnelOptions>;\n }\n | {\n readonly type: 'stock';\n readonly options: PlotOptions<StockOptions>;\n };\n\n/**\n * 可在 multi-view 中使用的 plots\n */\nconst PLOT_ADAPTORS = {\n line: lineAdaptor,\n pie: pieAdaptor,\n column: columnAdaptor,\n bar: barAdaptor,\n area: areaAdaptor,\n gauge: gaugeAdaptor,\n 'tiny-line': tinyLineAdaptor,\n 'tiny-column': tinyColumnAdaptor,\n 'tiny-area': tinyAreaAdaptor,\n 'ring-progress': ringProgressAdaptor,\n progress: progressAdaptor,\n scatter: scatterAdaptor,\n histogram: histogramAdaptor,\n funnel: funnelAdaptor,\n stock: stockAdaptor,\n};\n\n/**\n * 获取指定 plot 的 class contructor\n * @param {string} plot\n */\nconst PLOT_CONSTRUCTOR = {\n line: Line,\n pie: Pie,\n column: Column,\n bar: Bar,\n area: Area,\n gauge: Gauge,\n 'tiny-line': TinyLine,\n 'tiny-column': TinyColumn,\n 'tiny-area': TinyArea,\n 'ring-progress': RingProgress,\n progress: Progress,\n scatter: Scatter,\n histogram: Histogram,\n funnel: Funnel,\n stock: Stock,\n};\n\n/**\n * 在 mix 图表以及 facet 图表中,defaultOptions 进行复写简化\n */\nconst DEFAULT_OPTIONS_MAP = {\n pie: { label: false },\n column: { tooltip: { showMarkers: false } },\n bar: { tooltip: { showMarkers: false } },\n};\n\n/**\n * 执行 plot 的 adaptor, 默认都带上 defaultOptions\n * @param {string} plot\n */\nexport function execPlotAdaptor<T extends IPlotTypes['type']>(\n plot: T,\n view: View,\n options: IPlotTypes['options']\n): void {\n const cls = PLOT_CONSTRUCTOR[plot];\n if (!cls) {\n console.error(`could not find ${plot} plot`);\n return;\n }\n const module = PLOT_ADAPTORS[plot];\n module({\n chart: view,\n options: deepAssign({}, cls.getDefaultOptions(), get(DEFAULT_OPTIONS_MAP, plot, {}), options),\n });\n}\n"]}
@@ -127,7 +127,7 @@ function label(params) {
127
127
  var angleScale = chart.getScaleByField(angleField);
128
128
  var percent = angleScale === null || angleScale === void 0 ? void 0 : angleScale.scale(value);
129
129
  return util_1.isFunction(content_1)
130
- ? // append pecent (number) to data, users can get origin data from `dataum._origin`
130
+ ? // append percent (number) to data, users can get origin data from `dataum._origin`
131
131
  content_1(tslib_1.__assign(tslib_1.__assign({}, data), { percent: percent }), dataum, index)
132
132
  : util_1.isString(content_1)
133
133
  ? utils_1.template(content_1, {
@@ -1 +1 @@
1
- {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/pie/adaptor.ts"],"names":[],"mappings":";;;;AAAA,mCAA0G;AAE1G,+CAAmF;AACnF,sDAAmE;AACnE,uDAAoD;AACpD,iDAAgD;AAChD,4CAA8C;AAE9C,qCAA8G;AAE9G,uCAA6C;AAC7C,iCAAgE;AAChE,+CAA+C;AAG/C;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAA0B;IAClC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,IAAI,GAA8C,OAAO,KAArD,EAAE,UAAU,GAAkC,OAAO,WAAzC,EAAE,UAAU,GAAsB,OAAO,WAA7B,EAAE,KAAK,GAAe,OAAO,MAAtB,EAAE,QAAQ,GAAK,OAAO,SAAZ,CAAa;IAElE,WAAW;IACX,IAAI,WAAW,GAAG,0BAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAEvD,IAAI,iBAAS,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE;QACtC,0BAA0B;QAC1B,IAAM,iBAAe,GAAG,gBAAgB,CAAC;QACzC,WAAW,GAAG,WAAW,CAAC,GAAG,CAA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oBAAoB;wBAC7B,MAAM,EAAK,4BAAa,YAAS;wBACjC,GAAG,EAAE,EAAE,SAAS,WAAA,EAAE,WAAW,aAAA,EAAE;qBAChC;iBACF,CAAC;aACH;YACD,WAAI,OAAC,CAAC,CAAC,GAAG,0CAAE,KAAK,EAAE,UAAC,KAAK;gBACvB,aAAW,CAAC,IAAI,uCAAM,KAAK,KAAE,GAAG,EAAE,EAAE,SAAS,WAAA,EAAE,WAAW,aAAA,EAAE,IAAG,CAAC;YAClE,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,kBAAU,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,aAAW,EAAE,CAAC,CAAC,CAAC;SAC1E;aAAM;YACL,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;SACxC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AA7BD,kCA6BC;AAED;;;;GAIG;AACH,SAAgB,OAAO,CAAC,MAA0B;IAChD,0BAA0B;IAC1B,OAAO,YAAI,CACT,iBAAO,CAAC,UAAU,CAAC,EACnB,QAAQ,EACR,IAAI,EACJ,cAAK,EACL,UAAU,EACV,eAAM,EACN,OAAO,EACP,KAAK,EACL,cAAK;IACL,mBAAmB;IACnB,aAAa,EACb,WAAW,EACX,kBAAS,CACV,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAjBD,0BAiBC","sourcesContent":["import { isFunction, isString, isNil, get, isArray, isNumber, each, toString, isEmpty } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { legend, animation, theme, state, annotation } from '../../adaptor/common';\nimport { getMappingFunction } from '../../adaptor/geometries/base';\nimport { interval } from '../../adaptor/geometries';\nimport { pattern } from '../../adaptor/pattern';\nimport { getLocale } from '../../core/locale';\nimport { Interaction } from '../../types/interaction';\nimport { flow, template, transformLabel, deepAssign, renderStatistic, processIllegalData } from '../../utils';\nimport { Data, Datum } from '../../types';\nimport { DEFAULT_OPTIONS } from './contants';\nimport { adaptOffset, getTotalValue, isAllZero } from './utils';\nimport { PIE_STATISTIC } from './interactions';\nimport { PieOptions } from './types';\n\n/**\n * 字段\n * @param params\n */\nfunction geometry(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { data, angleField, colorField, color, pieStyle } = options;\n\n // 处理不合法的数据\n let processData = processIllegalData(data, angleField);\n\n if (isAllZero(processData, angleField)) {\n // 数据全 0 处理,调整 position 映射\n const percentageField = '$$percentage$$';\n processData = processData.map((d) => ({ ...d, [percentageField]: 1 / processData.length }));\n chart.data(processData);\n\n const p = deepAssign({}, params, {\n options: {\n xField: '1',\n yField: percentageField,\n seriesField: colorField,\n isStack: true,\n interval: {\n color,\n style: pieStyle,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n },\n });\n\n interval(p);\n } else {\n chart.data(processData);\n\n const p = deepAssign({}, params, {\n options: {\n xField: '1',\n yField: angleField,\n seriesField: colorField,\n isStack: true,\n interval: {\n color,\n style: pieStyle,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n },\n });\n\n interval(p);\n }\n\n return params;\n}\n\n/**\n * meta 配置\n * @param params\n */\nfunction meta(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { meta, colorField } = options;\n\n // meta 直接是 scale 的信息\n const scales = deepAssign({}, meta);\n chart.scale(scales, {\n [colorField]: { type: 'cat' },\n });\n\n return params;\n}\n\n/**\n * coord 配置\n * @param params\n */\nfunction coordinate(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { radius, innerRadius, startAngle, endAngle } = options;\n\n chart.coordinate({\n type: 'theta',\n cfg: {\n radius,\n innerRadius,\n startAngle,\n endAngle,\n },\n });\n\n return params;\n}\n\n/**\n * label 配置\n * @param params\n */\nfunction label(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { label, colorField, angleField } = options;\n\n const geometry = chart.geometries[0];\n // label 为 false, 空 则不显示 label\n if (!label) {\n geometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n const labelCfg = transformLabel(cfg);\n\n // ① 提供模板字符串的 label content 配置\n if (labelCfg.content) {\n const { content } = labelCfg;\n labelCfg.content = (data: object, dataum: any, index: number) => {\n const name = data[colorField];\n const value = data[angleField];\n // dymatic get scale, scale is ready this time\n const angleScale = chart.getScaleByField(angleField);\n const percent = angleScale?.scale(value);\n return isFunction(content)\n ? // append pecent (number) to data, users can get origin data from `dataum._origin`\n content({ ...data, percent }, dataum, index)\n : isString(content)\n ? template(content as string, {\n value,\n name,\n // percentage (string), default keep 2\n percentage: isNumber(percent) && !isNil(value) ? `${(percent * 100).toFixed(2)}%` : null,\n })\n : content;\n };\n }\n\n const LABEL_LAYOUT_TYPE_MAP = {\n inner: '',\n outer: 'pie-outer',\n spider: 'pie-spider',\n };\n const labelLayoutType = labelCfg.type ? LABEL_LAYOUT_TYPE_MAP[labelCfg.type] : 'pie-outer';\n const labelLayoutCfg = labelCfg.layout ? (!isArray(labelCfg.layout) ? [labelCfg.layout] : labelCfg.layout) : [];\n labelCfg.layout = (labelLayoutType ? [{ type: labelLayoutType }] : []).concat(labelLayoutCfg);\n\n geometry.label({\n // fix: could not create scale, when field is undefined(attributes 中的 fields 定义都会被用来创建 scale)\n fields: colorField ? [angleField, colorField] : [angleField],\n callback,\n cfg: {\n ...labelCfg,\n offset: adaptOffset(labelCfg.type, labelCfg.offset),\n type: 'pie',\n },\n });\n }\n return params;\n}\n\n/**\n * statistic options 处理\n * 1. 默认继承 default options 的样式\n * 2. 默认使用 meta 的 formatter\n */\nexport function transformStatisticOptions(options: PieOptions): PieOptions {\n const { innerRadius, statistic, angleField, colorField, meta, locale } = options;\n\n const i18n = getLocale(locale);\n\n if (innerRadius && statistic) {\n let { title: titleOpt, content: contentOpt } = deepAssign({}, DEFAULT_OPTIONS.statistic, statistic);\n if (titleOpt !== false) {\n titleOpt = deepAssign(\n {},\n {\n formatter: (datum: Datum) => {\n // 交互中\n if (datum) {\n return datum[colorField];\n }\n return !isNil(titleOpt.content) ? titleOpt.content : i18n.get(['statistic', 'total']);\n },\n },\n titleOpt\n );\n }\n if (contentOpt !== false) {\n contentOpt = deepAssign(\n {},\n {\n formatter: (datum: Datum, data: Data) => {\n const dataValue = datum ? datum[angleField] : getTotalValue(data, angleField);\n const metaFormatter = get(meta, [angleField, 'formatter']) || ((v) => v);\n // 交互中\n if (datum) {\n return metaFormatter(dataValue);\n }\n return !isNil(contentOpt.content) ? contentOpt.content : metaFormatter(dataValue);\n },\n },\n contentOpt\n );\n }\n\n return deepAssign({}, { statistic: { title: titleOpt, content: contentOpt } }, options);\n }\n return options;\n}\n\n/**\n * statistic 中心文本配置\n * @param params\n */\nexport function pieAnnotation(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { innerRadius, statistic } = transformStatisticOptions(options);\n // 先清空标注,再重新渲染\n chart.getController('annotation').clear(true);\n\n // 先进行其他 annotations,再去渲染统计文本\n flow(annotation())(params);\n\n /** 中心文本 指标卡 */\n if (innerRadius && statistic) {\n renderStatistic(chart, { statistic, plotType: 'pie' });\n }\n\n return params;\n}\n\n/**\n * 饼图 tooltip 配置\n * 1. 强制 tooltip.shared 为 false\n * @param params\n */\nfunction tooltip(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { tooltip, colorField, angleField, data } = options;\n\n if (tooltip === false) {\n chart.tooltip(tooltip);\n } else {\n chart.tooltip(deepAssign({}, tooltip, { shared: false }));\n\n // 主要解决 all zero, 对于非 all zero 不再适用\n if (isAllZero(data, angleField)) {\n let fields = get(tooltip, 'fields');\n let formatter = get(tooltip, 'formatter');\n\n if (isEmpty(get(tooltip, 'fields'))) {\n fields = [colorField, angleField];\n formatter = formatter || ((datum) => ({ name: datum[colorField], value: toString(datum[angleField]) }));\n }\n chart.geometries[0].tooltip(fields.join('*'), getMappingFunction(fields, formatter));\n }\n }\n\n return params;\n}\n\n/**\n * Interaction 配置 (饼图特殊的 interaction, 中心文本变更的时候,需要将一些配置参数传进去)\n * @param params\n */\nexport function interaction(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { interactions, statistic, annotations } = transformStatisticOptions(options);\n\n each(interactions, (i: Interaction) => {\n if (i.enable === false) {\n chart.removeInteraction(i.type);\n } else if (i.type === 'pie-statistic-active') {\n // 只针对 start 阶段的配置,进行添加参数信息\n let startStages = [];\n if (!i.cfg?.start) {\n startStages = [\n {\n trigger: 'element:mouseenter',\n action: `${PIE_STATISTIC}:change`,\n arg: { statistic, annotations },\n },\n ];\n }\n each(i.cfg?.start, (stage) => {\n startStages.push({ ...stage, arg: { statistic, annotations } });\n });\n chart.interaction(i.type, deepAssign({}, i.cfg, { start: startStages }));\n } else {\n chart.interaction(i.type, i.cfg || {});\n }\n });\n\n return params;\n}\n\n/**\n * 饼图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<PieOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow<Params<PieOptions>>(\n pattern('pieStyle'),\n geometry,\n meta,\n theme,\n coordinate,\n legend,\n tooltip,\n label,\n state,\n /** 指标卡中心文本 放在下层 */\n pieAnnotation,\n interaction,\n animation\n )(params);\n}\n"]}
1
+ {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/pie/adaptor.ts"],"names":[],"mappings":";;;;AAAA,mCAA0G;AAE1G,+CAAmF;AACnF,sDAAmE;AACnE,uDAAoD;AACpD,iDAAgD;AAChD,4CAA8C;AAE9C,qCAA8G;AAE9G,uCAA6C;AAC7C,iCAAgE;AAChE,+CAA+C;AAG/C;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAA0B;IAClC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,IAAI,GAA8C,OAAO,KAArD,EA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ACL,mBAAmB;IACnB,aAAa,EACb,WAAW,EACX,kBAAS,CACV,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAjBD,0BAiBC","sourcesContent":["import { isFunction, isString, isNil, get, isArray, isNumber, each, toString, isEmpty } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { legend, animation, theme, state, annotation } from '../../adaptor/common';\nimport { getMappingFunction } from '../../adaptor/geometries/base';\nimport { interval } from '../../adaptor/geometries';\nimport { pattern } from '../../adaptor/pattern';\nimport { getLocale } from '../../core/locale';\nimport { Interaction } from '../../types/interaction';\nimport { flow, template, transformLabel, deepAssign, renderStatistic, processIllegalData } from '../../utils';\nimport { Data, Datum } from '../../types';\nimport { DEFAULT_OPTIONS } from './contants';\nimport { adaptOffset, getTotalValue, isAllZero } from './utils';\nimport { PIE_STATISTIC } from './interactions';\nimport { PieOptions } from './types';\n\n/**\n * 字段\n * @param params\n */\nfunction geometry(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { data, angleField, colorField, color, pieStyle } = options;\n\n // 处理不合法的数据\n let processData = processIllegalData(data, angleField);\n\n if (isAllZero(processData, angleField)) {\n // 数据全 0 处理,调整 position 映射\n const percentageField = '$$percentage$$';\n processData = processData.map((d) => ({ ...d, [percentageField]: 1 / processData.length }));\n chart.data(processData);\n\n const p = deepAssign({}, params, {\n options: {\n xField: '1',\n yField: percentageField,\n seriesField: colorField,\n isStack: true,\n interval: {\n color,\n style: pieStyle,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n },\n });\n\n interval(p);\n } else {\n chart.data(processData);\n\n const p = deepAssign({}, params, {\n options: {\n xField: '1',\n yField: angleField,\n seriesField: colorField,\n isStack: true,\n interval: {\n color,\n style: pieStyle,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n },\n });\n\n interval(p);\n }\n\n return params;\n}\n\n/**\n * meta 配置\n * @param params\n */\nfunction meta(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { meta, colorField } = options;\n\n // meta 直接是 scale 的信息\n const scales = deepAssign({}, meta);\n chart.scale(scales, {\n [colorField]: { type: 'cat' },\n });\n\n return params;\n}\n\n/**\n * coord 配置\n * @param params\n */\nfunction coordinate(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { radius, innerRadius, startAngle, endAngle } = options;\n\n chart.coordinate({\n type: 'theta',\n cfg: {\n radius,\n innerRadius,\n startAngle,\n endAngle,\n },\n });\n\n return params;\n}\n\n/**\n * label 配置\n * @param params\n */\nfunction label(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { label, colorField, angleField } = options;\n\n const geometry = chart.geometries[0];\n // label 为 false, 空 则不显示 label\n if (!label) {\n geometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n const labelCfg = transformLabel(cfg);\n\n // ① 提供模板字符串的 label content 配置\n if (labelCfg.content) {\n const { content } = labelCfg;\n labelCfg.content = (data: object, dataum: any, index: number) => {\n const name = data[colorField];\n const value = data[angleField];\n // dymatic get scale, scale is ready this time\n const angleScale = chart.getScaleByField(angleField);\n const percent = angleScale?.scale(value);\n return isFunction(content)\n ? // append percent (number) to data, users can get origin data from `dataum._origin`\n content({ ...data, percent }, dataum, index)\n : isString(content)\n ? template(content as string, {\n value,\n name,\n // percentage (string), default keep 2\n percentage: isNumber(percent) && !isNil(value) ? `${(percent * 100).toFixed(2)}%` : null,\n })\n : content;\n };\n }\n\n const LABEL_LAYOUT_TYPE_MAP = {\n inner: '',\n outer: 'pie-outer',\n spider: 'pie-spider',\n };\n const labelLayoutType = labelCfg.type ? LABEL_LAYOUT_TYPE_MAP[labelCfg.type] : 'pie-outer';\n const labelLayoutCfg = labelCfg.layout ? (!isArray(labelCfg.layout) ? [labelCfg.layout] : labelCfg.layout) : [];\n labelCfg.layout = (labelLayoutType ? [{ type: labelLayoutType }] : []).concat(labelLayoutCfg);\n\n geometry.label({\n // fix: could not create scale, when field is undefined(attributes 中的 fields 定义都会被用来创建 scale)\n fields: colorField ? [angleField, colorField] : [angleField],\n callback,\n cfg: {\n ...labelCfg,\n offset: adaptOffset(labelCfg.type, labelCfg.offset),\n type: 'pie',\n },\n });\n }\n return params;\n}\n\n/**\n * statistic options 处理\n * 1. 默认继承 default options 的样式\n * 2. 默认使用 meta 的 formatter\n */\nexport function transformStatisticOptions(options: PieOptions): PieOptions {\n const { innerRadius, statistic, angleField, colorField, meta, locale } = options;\n\n const i18n = getLocale(locale);\n\n if (innerRadius && statistic) {\n let { title: titleOpt, content: contentOpt } = deepAssign({}, DEFAULT_OPTIONS.statistic, statistic);\n if (titleOpt !== false) {\n titleOpt = deepAssign(\n {},\n {\n formatter: (datum: Datum) => {\n // 交互中\n if (datum) {\n return datum[colorField];\n }\n return !isNil(titleOpt.content) ? titleOpt.content : i18n.get(['statistic', 'total']);\n },\n },\n titleOpt\n );\n }\n if (contentOpt !== false) {\n contentOpt = deepAssign(\n {},\n {\n formatter: (datum: Datum, data: Data) => {\n const dataValue = datum ? datum[angleField] : getTotalValue(data, angleField);\n const metaFormatter = get(meta, [angleField, 'formatter']) || ((v) => v);\n // 交互中\n if (datum) {\n return metaFormatter(dataValue);\n }\n return !isNil(contentOpt.content) ? contentOpt.content : metaFormatter(dataValue);\n },\n },\n contentOpt\n );\n }\n\n return deepAssign({}, { statistic: { title: titleOpt, content: contentOpt } }, options);\n }\n return options;\n}\n\n/**\n * statistic 中心文本配置\n * @param params\n */\nexport function pieAnnotation(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { innerRadius, statistic } = transformStatisticOptions(options);\n // 先清空标注,再重新渲染\n chart.getController('annotation').clear(true);\n\n // 先进行其他 annotations,再去渲染统计文本\n flow(annotation())(params);\n\n /** 中心文本 指标卡 */\n if (innerRadius && statistic) {\n renderStatistic(chart, { statistic, plotType: 'pie' });\n }\n\n return params;\n}\n\n/**\n * 饼图 tooltip 配置\n * 1. 强制 tooltip.shared 为 false\n * @param params\n */\nfunction tooltip(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { tooltip, colorField, angleField, data } = options;\n\n if (tooltip === false) {\n chart.tooltip(tooltip);\n } else {\n chart.tooltip(deepAssign({}, tooltip, { shared: false }));\n\n // 主要解决 all zero, 对于非 all zero 不再适用\n if (isAllZero(data, angleField)) {\n let fields = get(tooltip, 'fields');\n let formatter = get(tooltip, 'formatter');\n\n if (isEmpty(get(tooltip, 'fields'))) {\n fields = [colorField, angleField];\n formatter = formatter || ((datum) => ({ name: datum[colorField], value: toString(datum[angleField]) }));\n }\n chart.geometries[0].tooltip(fields.join('*'), getMappingFunction(fields, formatter));\n }\n }\n\n return params;\n}\n\n/**\n * Interaction 配置 (饼图特殊的 interaction, 中心文本变更的时候,需要将一些配置参数传进去)\n * @param params\n */\nexport function interaction(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { interactions, statistic, annotations } = transformStatisticOptions(options);\n\n each(interactions, (i: Interaction) => {\n if (i.enable === false) {\n chart.removeInteraction(i.type);\n } else if (i.type === 'pie-statistic-active') {\n // 只针对 start 阶段的配置,进行添加参数信息\n let startStages = [];\n if (!i.cfg?.start) {\n startStages = [\n {\n trigger: 'element:mouseenter',\n action: `${PIE_STATISTIC}:change`,\n arg: { statistic, annotations },\n },\n ];\n }\n each(i.cfg?.start, (stage) => {\n startStages.push({ ...stage, arg: { statistic, annotations } });\n });\n chart.interaction(i.type, deepAssign({}, i.cfg, { start: startStages }));\n } else {\n chart.interaction(i.type, i.cfg || {});\n }\n });\n\n return params;\n}\n\n/**\n * 饼图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<PieOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow<Params<PieOptions>>(\n pattern('pieStyle'),\n geometry,\n meta,\n theme,\n coordinate,\n legend,\n tooltip,\n label,\n state,\n /** 指标卡中心文本 放在下层 */\n pieAnnotation,\n interaction,\n animation\n )(params);\n}\n"]}
@@ -135,6 +135,12 @@ export declare type Options = {
135
135
  * @default false
136
136
  */
137
137
  readonly supportCSSTransform?: boolean;
138
+ /**
139
+ * @title 是否开启 label 延迟渲染
140
+ * @description 开启后 label 渲染会在浏览器空闲时机执行。可制定具体 number 数值,来限定 timeout 时间 (建议开启时,指定 timeout 时间)
141
+ * @default false
142
+ */
143
+ readonly useDeferredLabel?: boolean | number;
138
144
  /**
139
145
  * @title 数据
140
146
  * @description 设置画布具体的数据
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Axis } from './axis';\nimport { Label } from './label';\nimport { Tooltip } from './tooltip';\nimport { Legend } from './legend';\nimport { Interaction } from './interaction';\nimport { Animation } from './animation';\nimport { Annotation } from './annotation';\nimport { State } from './state';\nimport { Slider } from './slider';\nimport { Scrollbar } from './scrollbar';\nimport { ColorAttr, PatternAttr } from './attr';\nimport { Meta } from './meta';\n\n/** annotation position */\nexport type AnnotationPosition = Types.AnnotationPosition;\nexport type RegionPositionBaseOption = Types.RegionPositionBaseOption;\nexport type TextOption = Types.TextOption;\n\n/** 一条数据记录 */\nexport type Datum = Record<string, any>;\n\n/** 一个数据序列 */\nexport type Data = Datum[];\n\n/** 点位置信息 */\nexport type Point = {\n readonly x: number;\n readonly y: number;\n};\n\n/** 描述一个点 x y 位置 */\nexport type Position = [number, number];\n\n/** 一个区域描述 */\nexport type Region = {\n /**\n * @title 开始位置\n * @description the top-left corner of layer-range, range from 0 to 1, relative to parent layer's range\n */\n readonly start: Point;\n /**\n * @title 结束位置\n * @description the bottom-right corner of layer-range, range from 0 to 1, relative to parent layer's range\n */\n readonly end: Point;\n};\n\n/** 位置 */\nexport type BBox = {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n};\n\n/** 文字 */\nexport type TextStyle = {\n /**\n * @title 文本大小\n */\n readonly fontSize?: number;\n /**\n * @title 字体系列\n */\n readonly fontFamily?: string;\n /**\n * @title 文本粗细\n */\n readonly fontWeight?: number;\n /**\n * @title 文本行高\n */\n readonly lineHeight?: number;\n /**\n * @title 文本对齐方式\n */\n readonly textAlign?: 'center' | 'left' | 'right';\n /**\n * @title 文本基线\n */\n readonly textBaseline?: 'middle' | 'top' | 'bottom';\n};\n\nexport type Size = {\n readonly width: number;\n readonly height: number;\n};\n\n/** 基础的 Options 配置 */\nexport type Options = {\n /**\n * @title 画布宽度\n */\n readonly width?: number;\n /**\n * @title 画布高度\n */\n readonly height?: number;\n /**\n * @title 自适应\n * @description 画布是否自动适配容器大小,默认为 true\n */\n readonly autoFit?: boolean;\n /**\n * @title 内填充\n * @description 画布的 padding 值,或者开启 'auto'\n */\n readonly padding?: number[] | number | 'auto';\n /**\n * @title 画布宽度\n * @description 额外怎加的 padding 值\n */\n readonly appendPadding?: number[] | number;\n /**\n * @title 额外填充\n * @description 是否同步子 view 的 padding\n */\n readonly syncViewPadding?: boolean | Types.SyncViewPaddingFn;\n\n /**\n * @title 国际化\n * @description 语言配置\n */\n readonly locale?: string;\n\n /**\n * @title 渲染引擎\n * @description 设置渲染引擎,'svg' | 'canvas'\n * @default \"canvas\"\n */\n readonly renderer?: 'svg' | 'canvas';\n /**\n * @title 屏幕像素比\n * @description 默认为 window.devicePixelRatio\n */\n readonly pixelRatio?: number;\n /**\n * @title 是否启局部渲染\n * @description 是否开启局部渲染,默认为 true\n * @default true\n */\n readonly localRefresh?: boolean;\n /**\n * @title 是否支持 CSS transform\n * @description 开启后图表的交互以及事件将在页面设置了 css transform 属性时生效,默认关闭。\n * @default false\n */\n readonly supportCSSTransform?: boolean;\n\n /**\n * @title 数据\n * @description 设置画布具体的数据\n */\n readonly data: Record<string, any>[];\n /**\n * @title 数据字段元信息\n * @description 设置数据字段元信息\n */\n readonly meta?: Record<string, Meta>;\n\n // G2 相关\n /**\n * @title 主题\n * @description G2 主题,字符串或者 theme object\n * @default \"light\"\n */\n readonly theme?: string | object;\n /**\n * @title 颜色色板\n * @description 设置颜色色板\n */\n readonly color?: ColorAttr;\n /**\n * @title pattern 配置\n * @description 设置图表 pattern\n */\n readonly pattern?: PatternAttr;\n /**\n * @title 横坐标\n * @description 设置画布横坐标的配置项\n */\n readonly xAxis?: Axis;\n /**\n * @title 纵坐标\n * @description 设置画布纵坐标的配置项\n */\n readonly yAxis?: Axis;\n /**\n * @title 数据标签\n * @description 设置数据标签\n */\n readonly label?: Label;\n /**\n * @title tooltip 提示\n * @description 设置画布 tooltip 的配置项\n */\n readonly tooltip?: Tooltip;\n /**\n * @title 图例\n * @description 设置画布图例 legend 的配置项\n */\n readonly legend?: Legend;\n /**\n * @title 缩略轴\n * @description 设置缩略轴 slider 的配置项\n */\n readonly slider?: Slider;\n /**\n * @title 滚动条\n * @description 设置画布缩略轴 scrollbar 的配置项\n */\n readonly scrollbar?: Scrollbar;\n /**\n * @title 动画\n * @description 设置图表动画\n */\n readonly animation?: Animation;\n /**\n * @title 交互\n * @description 设置画布交互行为\n */\n readonly interactions?: Interaction[];\n /**\n * @title 注解\n * @description 设置画布注解\n */\n readonly annotations?: Annotation[];\n /**\n * @title 图表状态\n * @description 设置画布配置 active,inactive,selected 三种状态的样式,也可在 Theme 主题中配置\n */\n readonly state?: State;\n /**\n * @title 是否裁剪\n * @description 是否对超出坐标系范围的 Geometry 进行剪切\n */\n readonly limitInPlot?: boolean;\n /**\n * @title 内置交互\n * @description 内置注册的交互\n * @deprecated false\n */\n readonly defaultInteractions?: string[];\n};\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Axis } from './axis';\nimport { Label } from './label';\nimport { Tooltip } from './tooltip';\nimport { Legend } from './legend';\nimport { Interaction } from './interaction';\nimport { Animation } from './animation';\nimport { Annotation } from './annotation';\nimport { State } from './state';\nimport { Slider } from './slider';\nimport { Scrollbar } from './scrollbar';\nimport { ColorAttr, PatternAttr } from './attr';\nimport { Meta } from './meta';\n\n/** annotation position */\nexport type AnnotationPosition = Types.AnnotationPosition;\nexport type RegionPositionBaseOption = Types.RegionPositionBaseOption;\nexport type TextOption = Types.TextOption;\n\n/** 一条数据记录 */\nexport type Datum = Record<string, any>;\n\n/** 一个数据序列 */\nexport type Data = Datum[];\n\n/** 点位置信息 */\nexport type Point = {\n readonly x: number;\n readonly y: number;\n};\n\n/** 描述一个点 x y 位置 */\nexport type Position = [number, number];\n\n/** 一个区域描述 */\nexport type Region = {\n /**\n * @title 开始位置\n * @description the top-left corner of layer-range, range from 0 to 1, relative to parent layer's range\n */\n readonly start: Point;\n /**\n * @title 结束位置\n * @description the bottom-right corner of layer-range, range from 0 to 1, relative to parent layer's range\n */\n readonly end: Point;\n};\n\n/** 位置 */\nexport type BBox = {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n};\n\n/** 文字 */\nexport type TextStyle = {\n /**\n * @title 文本大小\n */\n readonly fontSize?: number;\n /**\n * @title 字体系列\n */\n readonly fontFamily?: string;\n /**\n * @title 文本粗细\n */\n readonly fontWeight?: number;\n /**\n * @title 文本行高\n */\n readonly lineHeight?: number;\n /**\n * @title 文本对齐方式\n */\n readonly textAlign?: 'center' | 'left' | 'right';\n /**\n * @title 文本基线\n */\n readonly textBaseline?: 'middle' | 'top' | 'bottom';\n};\n\nexport type Size = {\n readonly width: number;\n readonly height: number;\n};\n\n/** 基础的 Options 配置 */\nexport type Options = {\n /**\n * @title 画布宽度\n */\n readonly width?: number;\n /**\n * @title 画布高度\n */\n readonly height?: number;\n /**\n * @title 自适应\n * @description 画布是否自动适配容器大小,默认为 true\n */\n readonly autoFit?: boolean;\n /**\n * @title 内填充\n * @description 画布的 padding 值,或者开启 'auto'\n */\n readonly padding?: number[] | number | 'auto';\n /**\n * @title 画布宽度\n * @description 额外怎加的 padding 值\n */\n readonly appendPadding?: number[] | number;\n /**\n * @title 额外填充\n * @description 是否同步子 view 的 padding\n */\n readonly syncViewPadding?: boolean | Types.SyncViewPaddingFn;\n\n /**\n * @title 国际化\n * @description 语言配置\n */\n readonly locale?: string;\n\n /**\n * @title 渲染引擎\n * @description 设置渲染引擎,'svg' | 'canvas'\n * @default \"canvas\"\n */\n readonly renderer?: 'svg' | 'canvas';\n /**\n * @title 屏幕像素比\n * @description 默认为 window.devicePixelRatio\n */\n readonly pixelRatio?: number;\n /**\n * @title 是否启局部渲染\n * @description 是否开启局部渲染,默认为 true\n * @default true\n */\n readonly localRefresh?: boolean;\n /**\n * @title 是否支持 CSS transform\n * @description 开启后图表的交互以及事件将在页面设置了 css transform 属性时生效,默认关闭。\n * @default false\n */\n readonly supportCSSTransform?: boolean;\n /**\n * @title 是否开启 label 延迟渲染\n * @description 开启后 label 渲染会在浏览器空闲时机执行。可制定具体 number 数值,来限定 timeout 时间 (建议开启时,指定 timeout 时间)\n * @default false\n */\n readonly useDeferredLabel?: boolean | number;\n\n /**\n * @title 数据\n * @description 设置画布具体的数据\n */\n readonly data: Record<string, any>[];\n /**\n * @title 数据字段元信息\n * @description 设置数据字段元信息\n */\n readonly meta?: Record<string, Meta>;\n\n // G2 相关\n /**\n * @title 主题\n * @description G2 主题,字符串或者 theme object\n * @default \"light\"\n */\n readonly theme?: string | object;\n /**\n * @title 颜色色板\n * @description 设置颜色色板\n */\n readonly color?: ColorAttr;\n /**\n * @title pattern 配置\n * @description 设置图表 pattern\n */\n readonly pattern?: PatternAttr;\n /**\n * @title 横坐标\n * @description 设置画布横坐标的配置项\n */\n readonly xAxis?: Axis;\n /**\n * @title 纵坐标\n * @description 设置画布纵坐标的配置项\n */\n readonly yAxis?: Axis;\n /**\n * @title 数据标签\n * @description 设置数据标签\n */\n readonly label?: Label;\n /**\n * @title tooltip 提示\n * @description 设置画布 tooltip 的配置项\n */\n readonly tooltip?: Tooltip;\n /**\n * @title 图例\n * @description 设置画布图例 legend 的配置项\n */\n readonly legend?: Legend;\n /**\n * @title 缩略轴\n * @description 设置缩略轴 slider 的配置项\n */\n readonly slider?: Slider;\n /**\n * @title 滚动条\n * @description 设置画布缩略轴 scrollbar 的配置项\n */\n readonly scrollbar?: Scrollbar;\n /**\n * @title 动画\n * @description 设置图表动画\n */\n readonly animation?: Animation;\n /**\n * @title 交互\n * @description 设置画布交互行为\n */\n readonly interactions?: Interaction[];\n /**\n * @title 注解\n * @description 设置画布注解\n */\n readonly annotations?: Annotation[];\n /**\n * @title 图表状态\n * @description 设置画布配置 active,inactive,selected 三种状态的样式,也可在 Theme 主题中配置\n */\n readonly state?: State;\n /**\n * @title 是否裁剪\n * @description 是否对超出坐标系范围的 Geometry 进行剪切\n */\n readonly limitInPlot?: boolean;\n /**\n * @title 内置交互\n * @description 内置注册的交互\n * @deprecated false\n */\n readonly defaultInteractions?: string[];\n};\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Transformations of coordinate
3
+ */
4
+ export declare type Transformations = Array<{
5
+ /** send (x, y) to (-x, y) */
6
+ type: 'reflectX';
7
+ } | {
8
+ /** send (x, y) to (x, -y) */
9
+ type: 'reflectY';
10
+ } | {
11
+ /** send (x, y) to (y, x) */
12
+ type: 'transpose';
13
+ }>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=coordinate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinate.js","sourceRoot":"","sources":["../../src/types/coordinate.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Transformations of coordinate\n */\nexport type Transformations = Array<\n | {\n /** send (x, y) to (-x, y) */\n type: 'reflectX';\n }\n | {\n /** send (x, y) to (x, -y) */\n type: 'reflectY';\n }\n | {\n /** send (x, y) to (y, x) */\n type: 'transpose';\n }\n>;\n"]}
@@ -23,4 +23,4 @@ export declare function getDeepPercent(data: Record<string, any>[], measure: str
23
23
  * 获取数据,如果是百分比,进行数据转换 (适用于面积图、柱状图、条形图)
24
24
  * @param isPercent 是否百分比
25
25
  */
26
- export declare function getDataWhetherPecentage(data: Record<string, any>[], yField: string, groupField: string, asField: string, isPercent?: boolean): Record<string, any>[];
26
+ export declare function getDataWhetherPercentage(data: Record<string, any>[], yField: string, groupField: string, asField: string, isPercent?: boolean): Record<string, any>[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDataWhetherPecentage = exports.getDeepPercent = exports.percent = void 0;
3
+ exports.getDataWhetherPercentage = exports.getDeepPercent = exports.percent = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var util_1 = require("@antv/util");
6
6
  var number_1 = require("../number");
@@ -63,8 +63,8 @@ exports.getDeepPercent = getDeepPercent;
63
63
  * 获取数据,如果是百分比,进行数据转换 (适用于面积图、柱状图、条形图)
64
64
  * @param isPercent 是否百分比
65
65
  */
66
- function getDataWhetherPecentage(data, yField, groupField, asField, isPercent) {
66
+ function getDataWhetherPercentage(data, yField, groupField, asField, isPercent) {
67
67
  return !isPercent ? data : percent(data, yField, groupField, asField);
68
68
  }
69
- exports.getDataWhetherPecentage = getDataWhetherPecentage;
69
+ exports.getDataWhetherPercentage = getDataWhetherPercentage;
70
70
  //# sourceMappingURL=percent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../src/utils/transform/percent.ts"],"names":[],"mappings":";;;;AAAA,mCAAyC;AAEzC,oCAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,IAAU,EAAE,OAAe,EAAE,UAAkB,EAAE,EAAU;IACjF,qBAAqB;IACrB,IAAM,MAAM,GAAG,aAAM,CACnB,IAAI,EACJ,UAAC,GAAG,EAAE,KAAY;QAChB,IAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAM,CAAC,GAAG,KA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AAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAEzB,GAAG,GAAG,qBAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACtC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAEzB,OAAO,GAAG,CAAC;IACb,CAAC,EACD,IAAI,GAAG,EAAkB,CAC1B,CAAC;IAEF,eAAe;IACf,OAAO,UAAG,CAAC,IAAI,EAAE,UAAC,KAAY;;QAC5B,IAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACzB,gBAAgB;QAChB,IAAM,UAAU,GAAG,aAAM,CAAC,MAAM,EAAE,UAAC,KAAK,EAAE,KAAK,IAAK,OAAA,KAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAG,EAAzB,CAAyB,EAAE,EAAE,CAAC,CAAC;QAEnF,IAAM,UAAU,GAAG,qBAAY,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpG,6CACK,KAAK,gBACP,OAAO,IAAG,UAAU,OACrB;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAhCD,wCAgCC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,IAA2B,EAC3B,MAAc,EACd,UAAkB,EAClB,OAAe,EACf,SAAmB;IAEnB,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AARD,0DAQC","sourcesContent":["import { map, reduce } from '@antv/util';\nimport { Data, Datum } from '../../types';\nimport { isRealNumber } from '../number';\n\n/**\n * 对数据进行百分比化\n * @param data\n * @param measure\n * @param groupField\n * @param as\n */\nexport function percent(data: Data, measure: string, groupField: string, as: string) {\n // 1. 先计算每一个分组的 max 值\n const sumMap = reduce(\n data,\n (map, datum: Datum) => {\n const groupValue = datum[groupField];\n let sum = map.has(groupValue) ? map.get(groupValue) : 0;\n\n const v = datum[measure];\n\n sum = isRealNumber(v) ? sum + v : sum;\n map.set(groupValue, sum);\n\n return map;\n },\n new Map<string, number>()\n );\n\n // 2. 循环数组,计算占比\n return map(data, (datum: Datum) => {\n const v = datum[measure];\n const groupValue = datum[groupField];\n const percentage = isRealNumber(v) && sumMap.get(groupValue) !== 0 ? v / sumMap.get(groupValue) : 0;\n\n return {\n ...datum,\n [as]: percentage,\n };\n });\n}\n\n/**\n * 对数据进行深层百分比化\n * @param data\n * @param measure // 数值\n * @param fields // 需要分组的 field值\n * @param as // 存储percent 百分比的值\n */\nexport function getDeepPercent(data: Record<string, any>[], measure: string, fields: string[], percent: string) {\n const sumMap = reduce(\n data,\n (map, datum: Datum) => {\n // 获取分组得到的枚举key值\n const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');\n\n let sum = map.has(groupValue) ? map.get(groupValue) : 0;\n\n const v = datum[measure];\n\n sum = isRealNumber(v) ? sum + v : sum;\n map.set(groupValue, sum);\n\n return map;\n },\n new Map<string, number>()\n );\n\n // 2. 循环数组,计算占比\n return map(data, (datum: Datum) => {\n const v = datum[measure];\n // 获取分组得到的枚举key值\n const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');\n\n const percentage = isRealNumber(v) && sumMap.get(groupValue) !== 0 ? v / sumMap.get(groupValue) : 0;\n\n return {\n ...datum,\n [percent]: percentage,\n };\n });\n}\n\n/**\n * 获取数据,如果是百分比,进行数据转换 (适用于面积图、柱状图、条形图)\n * @param isPercent 是否百分比\n */\nexport function getDataWhetherPecentage(\n data: Record<string, any>[],\n yField: string,\n groupField: string,\n asField: string,\n isPercent?: boolean\n) {\n return !isPercent ? data : percent(data, yField, groupField, asField);\n}\n"]}
1
+ {"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../src/utils/transform/percent.ts"],"names":[],"mappings":";;;;AAAA,mCAAyC;AAEzC,oCAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,IAAU,EAAE,OAAe,EAAE,UAAkB,EAAE,EAAU;IACjF,qBAAqB;IACrB,IAAM,MAAM,GAAG,aAAM,CACnB,IAAI,EACJ,UAAC,GAAG,EAAE,KAAY;QAChB,IAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAEzB,GAAG,GAAG,qBAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACtC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAEzB,OAAO,GAAG,CAAC;IACb,CAAC,EACD,IAAI,GAAG,EAAkB,CAC1B,CAAC;IAEF,eAAe;IACf,OAAO,UAAG,CAAC,IAAI,EAAE,UAAC,KAAY;;QAC5B,IAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACzB,IAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QACrC,IAAM,UAAU,GAAG,qBAAY,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpG,6CACK,KAAK,gBACP,EAAE,IAAG,UAAU,OAChB;IACJ,CAAC,CA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AC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpG,6CACK,KAAK,gBACP,OAAO,IAAG,UAAU,OACrB;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAhCD,wCAgCC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CACtC,IAA2B,EAC3B,MAAc,EACd,UAAkB,EAClB,OAAe,EACf,SAAmB;IAEnB,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AARD,4DAQC","sourcesContent":["import { map, reduce } from '@antv/util';\nimport { Data, Datum } from '../../types';\nimport { isRealNumber } from '../number';\n\n/**\n * 对数据进行百分比化\n * @param data\n * @param measure\n * @param groupField\n * @param as\n */\nexport function percent(data: Data, measure: string, groupField: string, as: string) {\n // 1. 先计算每一个分组的 max 值\n const sumMap = reduce(\n data,\n (map, datum: Datum) => {\n const groupValue = datum[groupField];\n let sum = map.has(groupValue) ? map.get(groupValue) : 0;\n\n const v = datum[measure];\n\n sum = isRealNumber(v) ? sum + v : sum;\n map.set(groupValue, sum);\n\n return map;\n },\n new Map<string, number>()\n );\n\n // 2. 循环数组,计算占比\n return map(data, (datum: Datum) => {\n const v = datum[measure];\n const groupValue = datum[groupField];\n const percentage = isRealNumber(v) && sumMap.get(groupValue) !== 0 ? v / sumMap.get(groupValue) : 0;\n\n return {\n ...datum,\n [as]: percentage,\n };\n });\n}\n\n/**\n * 对数据进行深层百分比化\n * @param data\n * @param measure // 数值\n * @param fields // 需要分组的 field值\n * @param as // 存储percent 百分比的值\n */\nexport function getDeepPercent(data: Record<string, any>[], measure: string, fields: string[], percent: string) {\n const sumMap = reduce(\n data,\n (map, datum: Datum) => {\n // 获取分组得到的枚举key值\n const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');\n\n let sum = map.has(groupValue) ? map.get(groupValue) : 0;\n\n const v = datum[measure];\n\n sum = isRealNumber(v) ? sum + v : sum;\n map.set(groupValue, sum);\n\n return map;\n },\n new Map<string, number>()\n );\n\n // 2. 循环数组,计算占比\n return map(data, (datum: Datum) => {\n const v = datum[measure];\n // 获取分组得到的枚举key值\n const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');\n\n const percentage = isRealNumber(v) && sumMap.get(groupValue) !== 0 ? v / sumMap.get(groupValue) : 0;\n\n return {\n ...datum,\n [percent]: percentage,\n };\n });\n}\n\n/**\n * 获取数据,如果是百分比,进行数据转换 (适用于面积图、柱状图、条形图)\n * @param isPercent 是否百分比\n */\nexport function getDataWhetherPercentage(\n data: Record<string, any>[],\n yField: string,\n groupField: string,\n asField: string,\n isPercent?: boolean\n) {\n return !isPercent ? data : percent(data, yField, groupField, asField);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2plot",
3
- "version": "2.4.13",
3
+ "version": "2.4.16",
4
4
  "description": "An interactive and responsive charting library",
5
5
  "keywords": [
6
6
  "chart",
@@ -87,6 +87,7 @@
87
87
  "eslint-plugin-import": "^2.22.0",
88
88
  "eslint-plugin-prettier": "^3.1.0",
89
89
  "gatsby": "^2.24.63",
90
+ "gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.27",
90
91
  "generate-changelog": "^1.8.0",
91
92
  "gh-pages": "^3.1.0",
92
93
  "husky": "^4.2.3",
@@ -1,8 +1,9 @@
1
- import { Geometry } from '@antv/g2';
1
+ import { Geometry, Types } from '@antv/g2';
2
2
  import { each, isNil, isObject } from '@antv/util';
3
3
  import { Params } from '../core/adaptor';
4
4
  import { Options } from '../types';
5
5
  import { Interaction } from '../types/interaction';
6
+ import { Transformations } from '../types/coordinate';
6
7
  import { Axis } from '../types/axis';
7
8
  import { AXIS_META_CONFIG_KEYS } from '../constant';
8
9
  import { pick, deepAssign } from '../utils';
@@ -207,4 +208,30 @@ export function limitInPlot(params: Params<Options>): Params<Options> {
207
208
  return params;
208
209
  }
209
210
 
211
+ /**
212
+ * 坐标系转换
213
+ */
214
+ export function transformations(coordinateType: Types.CoordinateOption['type'] = 'rect') {
215
+ return (params: Params<Options & { coordinate: Transformations }>) => {
216
+ const { chart, options } = params;
217
+ const { coordinate } = options;
218
+
219
+ const actions: Types.CoordinateActions[] = Array.from(coordinate || [])
220
+ .map((cfg) => {
221
+ if (cfg.type === 'reflectX') return ['reflect', 'x'] as Types.CoordinateActions;
222
+ if (cfg.type === 'reflectY') return ['reflect', 'y'] as Types.CoordinateActions;
223
+ if (cfg.type === 'transpose') return ['transpose'] as Types.CoordinateActions;
224
+
225
+ return null;
226
+ })
227
+ .filter((d) => !!d);
228
+
229
+ if (actions.length !== 0) {
230
+ chart.coordinate({ type: coordinateType, actions });
231
+ }
232
+
233
+ return params;
234
+ };
235
+ }
236
+
210
237
  export { pattern } from './pattern';
@@ -22,7 +22,7 @@ export interface AreaGeometryOptions extends GeometryOptions {
22
22
  */
23
23
  export function area<O extends AreaGeometryOptions>(params: Params<O>): Params<O> {
24
24
  const { options } = params;
25
- const { area, xField, yField, seriesField, smooth, tooltip } = options;
25
+ const { area, xField, yField, seriesField, smooth, tooltip, useDeferredLabel } = options;
26
26
 
27
27
  const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);
28
28
 
@@ -39,6 +39,7 @@ export function area<O extends AreaGeometryOptions>(params: Params<O>): Params<O
39
39
  tooltip: formatter,
40
40
  ...area,
41
41
  },
42
+ args: { useDeferredLabel },
42
43
  },
43
44
  })
44
45
  )
@@ -20,7 +20,7 @@ export interface EdgeGeometryOptions extends GeometryOptions {
20
20
  */
21
21
  export function edge<O extends EdgeGeometryOptions>(params: Params<O>): Params<O> {
22
22
  const { options } = params;
23
- const { edge, xField, yField, seriesField, tooltip } = options;
23
+ const { edge, xField, yField, seriesField, tooltip, useDeferredLabel } = options;
24
24
 
25
25
  const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);
26
26
 
@@ -35,6 +35,7 @@ export function edge<O extends EdgeGeometryOptions>(params: Params<O>): Params<O
35
35
  tooltip: formatter,
36
36
  ...edge,
37
37
  },
38
+ args: { useDeferredLabel },
38
39
  },
39
40
  })
40
41
  )
@@ -97,6 +97,7 @@ export function interval<O extends IntervalGeometryOptions>(params: Params<O>):
97
97
  columnBackground,
98
98
  dodgePadding,
99
99
  intervalPadding,
100
+ useDeferredLabel,
100
101
  } = options;
101
102
 
102
103
  const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);
@@ -113,7 +114,14 @@ export function interval<O extends IntervalGeometryOptions>(params: Params<O>):
113
114
  tooltip: formatter,
114
115
  ...interval,
115
116
  },
116
- args: { dodgePadding, intervalPadding, minColumnWidth, maxColumnWidth, background: columnBackground },
117
+ args: {
118
+ dodgePadding,
119
+ intervalPadding,
120
+ minColumnWidth,
121
+ maxColumnWidth,
122
+ background: columnBackground,
123
+ useDeferredLabel,
124
+ },
117
125
  },
118
126
  })
119
127
  )
@@ -27,7 +27,7 @@ export interface LineGeometryOptions extends GeometryOptions {
27
27
  */
28
28
  export function line<O extends LineGeometryOptions>(params: Params<O>): Params<O> {
29
29
  const { options } = params;
30
- const { line, stepType, xField, yField, seriesField, smooth, connectNulls, tooltip } = options;
30
+ const { line, stepType, xField, yField, seriesField, smooth, connectNulls, tooltip, useDeferredLabel } = options;
31
31
 
32
32
  const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);
33
33
 
@@ -46,7 +46,7 @@ export function line<O extends LineGeometryOptions>(params: Params<O>): Params<O
46
46
  },
47
47
  line
48
48
  ),
49
- args: { connectNulls },
49
+ args: { connectNulls, useDeferredLabel },
50
50
  },
51
51
  })
52
52
  )