@antv/g2plot 2.3.40 → 2.4.3

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 (106) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.en-US.md +0 -1
  3. package/README.md +0 -1
  4. package/dist/g2plot.min.js +4 -4
  5. package/dist/g2plot.min.js.map +1 -1
  6. package/esm/adaptor/conversion-tag.js +3 -3
  7. package/esm/adaptor/conversion-tag.js.map +1 -1
  8. package/esm/index.d.ts +9 -1
  9. package/esm/index.js +9 -1
  10. package/esm/index.js.map +1 -1
  11. package/esm/plots/area/adaptor.js +15 -5
  12. package/esm/plots/area/adaptor.js.map +1 -1
  13. package/esm/plots/area/constants.d.ts +2 -0
  14. package/esm/plots/area/constants.js +2 -0
  15. package/esm/plots/area/constants.js.map +1 -1
  16. package/esm/plots/area/index.js +11 -4
  17. package/esm/plots/area/index.js.map +1 -1
  18. package/esm/plots/bar/adaptor.d.ts +7 -2
  19. package/esm/plots/bar/adaptor.js +67 -25
  20. package/esm/plots/bar/adaptor.js.map +1 -1
  21. package/esm/plots/bar/index.js +1 -2
  22. package/esm/plots/bar/index.js.map +1 -1
  23. package/esm/plots/line/adaptor.js +30 -15
  24. package/esm/plots/line/adaptor.js.map +1 -1
  25. package/esm/plots/line/constants.d.ts +2 -0
  26. package/esm/plots/line/constants.js +3 -0
  27. package/esm/plots/line/constants.js.map +1 -1
  28. package/esm/plots/line/index.js +8 -1
  29. package/esm/plots/line/index.js.map +1 -1
  30. package/esm/plots/line/interactions/marker-active.js +7 -6
  31. package/esm/plots/line/interactions/marker-active.js.map +1 -1
  32. package/esm/plots/sunburst/adaptor.js +1 -11
  33. package/esm/plots/sunburst/adaptor.js.map +1 -1
  34. package/esm/plots/sunburst/constant.js +1 -0
  35. package/esm/plots/sunburst/constant.js.map +1 -1
  36. package/esm/plots/sunburst/types.d.ts +1 -1
  37. package/esm/plots/sunburst/types.js.map +1 -1
  38. package/esm/plots/venn/types.d.ts +1 -1
  39. package/esm/plots/venn/types.js.map +1 -1
  40. package/esm/utils/data.js +2 -0
  41. package/esm/utils/data.js.map +1 -1
  42. package/esm/utils/geometry.js +2 -1
  43. package/esm/utils/geometry.js.map +1 -1
  44. package/lib/adaptor/conversion-tag.js +3 -3
  45. package/lib/adaptor/conversion-tag.js.map +1 -1
  46. package/lib/index.d.ts +9 -1
  47. package/lib/index.js +13 -5
  48. package/lib/index.js.map +1 -1
  49. package/lib/plots/area/adaptor.js +13 -3
  50. package/lib/plots/area/adaptor.js.map +1 -1
  51. package/lib/plots/area/constants.d.ts +2 -0
  52. package/lib/plots/area/constants.js +3 -1
  53. package/lib/plots/area/constants.js.map +1 -1
  54. package/lib/plots/area/index.js +10 -3
  55. package/lib/plots/area/index.js.map +1 -1
  56. package/lib/plots/bar/adaptor.d.ts +7 -2
  57. package/lib/plots/bar/adaptor.js +69 -26
  58. package/lib/plots/bar/adaptor.js.map +1 -1
  59. package/lib/plots/bar/index.js +1 -2
  60. package/lib/plots/bar/index.js.map +1 -1
  61. package/lib/plots/line/adaptor.js +29 -14
  62. package/lib/plots/line/adaptor.js.map +1 -1
  63. package/lib/plots/line/constants.d.ts +2 -0
  64. package/lib/plots/line/constants.js +4 -1
  65. package/lib/plots/line/constants.js.map +1 -1
  66. package/lib/plots/line/index.js +7 -0
  67. package/lib/plots/line/index.js.map +1 -1
  68. package/lib/plots/line/interactions/marker-active.js +7 -6
  69. package/lib/plots/line/interactions/marker-active.js.map +1 -1
  70. package/lib/plots/sunburst/adaptor.js +1 -11
  71. package/lib/plots/sunburst/adaptor.js.map +1 -1
  72. package/lib/plots/sunburst/constant.js +1 -0
  73. package/lib/plots/sunburst/constant.js.map +1 -1
  74. package/lib/plots/sunburst/types.d.ts +1 -1
  75. package/lib/plots/sunburst/types.js.map +1 -1
  76. package/lib/plots/venn/types.d.ts +1 -1
  77. package/lib/plots/venn/types.js.map +1 -1
  78. package/lib/utils/data.js +2 -0
  79. package/lib/utils/data.js.map +1 -1
  80. package/lib/utils/geometry.js +2 -1
  81. package/lib/utils/geometry.js.map +1 -1
  82. package/package.json +6 -5
  83. package/src/adaptor/conversion-tag.ts +3 -3
  84. package/src/index.ts +9 -1
  85. package/src/plots/area/adaptor.ts +16 -5
  86. package/src/plots/area/constants.ts +3 -0
  87. package/src/plots/area/index.ts +10 -3
  88. package/src/plots/bar/adaptor.ts +94 -47
  89. package/src/plots/bar/index.ts +1 -2
  90. package/src/plots/line/adaptor.ts +35 -14
  91. package/src/plots/line/constants.ts +4 -0
  92. package/src/plots/line/index.ts +8 -1
  93. package/src/plots/line/interactions/marker-active.ts +8 -7
  94. package/src/plots/sunburst/adaptor.ts +9 -13
  95. package/src/plots/sunburst/constant.ts +1 -0
  96. package/src/plots/sunburst/types.ts +1 -1
  97. package/src/plots/venn/types.ts +1 -1
  98. package/src/utils/data.ts +1 -0
  99. package/src/utils/geometry.ts +2 -1
  100. package/esm/plots/bar/utils.d.ts +0 -6
  101. package/esm/plots/bar/utils.js +0 -8
  102. package/esm/plots/bar/utils.js.map +0 -1
  103. package/lib/plots/bar/utils.d.ts +0 -6
  104. package/lib/plots/bar/utils.js +0 -12
  105. package/lib/plots/bar/utils.js.map +0 -1
  106. package/src/plots/bar/utils.ts +0 -9
@@ -33,8 +33,8 @@ function renderArrowTag(config, elemPrev, elemNext) {
33
33
  var view = config.view, geometry = config.geometry, group = config.group, options = config.options, horizontal = config.horizontal;
34
34
  var offset = options.offset, size = options.size, arrow = options.arrow;
35
35
  var coordinate = view.getCoordinate();
36
- var pointPrev = parsePoints(coordinate, elemPrev)[horizontal ? 3 : 0];
37
- var pointNext = parsePoints(coordinate, elemNext)[horizontal ? 0 : 3];
36
+ var pointPrev = parsePoints(coordinate, elemPrev)[3];
37
+ var pointNext = parsePoints(coordinate, elemNext)[0];
38
38
  var totalHeight = pointNext.y - pointPrev.y;
39
39
  var totalWidth = pointNext.x - pointPrev.x;
40
40
  if (typeof arrow === 'boolean') {
@@ -163,7 +163,7 @@ export function conversionTag(field, horizontal, disabled) {
163
163
  horizontal: horizontal,
164
164
  options: getConversionTagOptionsWithDefaults(conversionTag, horizontal),
165
165
  };
166
- var elements = horizontal ? interval.elements : interval.elements.slice().reverse();
166
+ var elements = interval.elements;
167
167
  each(elements, function (elem, idx) {
168
168
  if (idx > 0) {
169
169
  renderTag(config, elements[idx - 1], elem);
@@ -1 +1 @@
1
- {"version":3,"file":"conversion-tag.js","sourceRoot":"","sources":["../../src/adaptor/conversion-tag.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAA2D,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE7F,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAqD7D,SAAS,mCAAmC,CAAC,OAA6B,EAAE,UAAmB;IAC7F,OAAO,UAAU,CACf;QACE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QAC1B,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;QAC5B,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3B,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,KAAK,IAAI;YAChC,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE;gBACL,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,KAAK,IAAI;YAC9B,KAAK,EAAE;gBACL,QAAQ,EAAE,EAAE;gBACZ,IAAI,EAAE,qBAAqB;gBAC3B,SAAS,EAAE,QAAQ;gBACnB,YAAY,EAAE,QAAQ;aACvB;YACD,SAAS,EAAE,sBAAsB;SAClC;KACF,EACD,OAAO,C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Aa,EAAE,UAAU,CAAC;qBACxE,CAAC;oBACF,IAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC;oBACtF,IAAI,CAAC,QAAQ,EAAE,UAAC,IAAa,EAAE,GAAW;wBACxC,IAAI,GAAG,GAAG,CAAC,EAAE;4BACX,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;yBAC5C;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;aACF,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { map, find, each, isObject } from '@antv/util';\nimport { Coordinate, IGroup, ShapeAttrs, Element, Geometry, View, getTheme } from '@antv/g2';\nimport { Params } from '../core/adaptor';\nimport { deepAssign } from '../utils';\nimport { conversionTagFormatter } from '../utils/conversion';\nimport { Options } from '../types';\n\n/** 转化率组件配置选项 */\nexport interface ConversionTagOptions {\n /** tag 高度 */\n size?: number;\n /** tag 对柱子间距 */\n spacing?: number;\n /** tag 距离轴线距离 */\n offset?: number;\n /** 箭头形状配置 */\n arrow?:\n | {\n /** 箭头宽度 */\n headSize?: number;\n /** 箭头样式 */\n style?: ShapeAttrs;\n }\n | false;\n /** 文本配置 */\n text?:\n | {\n /** 文字大小 */\n size?: number;\n /** 文字样式 */\n style?: ShapeAttrs;\n /** 文本格式化 */\n formatter?: (prev: number, next: number) => string;\n }\n | false;\n}\n\nexport interface OptionWithConversionTag {\n conversionTag?: ConversionTagOptions | false;\n}\n\n/** 控制转化率组件绘制的选项 */\ntype TagRenderConfig = {\n /** 所在的 View */\n view: View;\n /** 所属的 geometry */\n geometry: Geometry;\n /** 转化率组件的 group */\n group: IGroup;\n /** 转化率配置 */\n options: ConversionTagOptions;\n /** 用于转化率计算的字段 */\n field: string;\n /** 水平/垂直 */\n horizontal: boolean;\n};\n\nfunction getConversionTagOptionsWithDefaults(options: ConversionTagOptions, horizontal: boolean): ConversionTagOptions {\n return deepAssign(\n {\n size: horizontal ? 32 : 80,\n spacing: horizontal ? 8 : 12,\n offset: horizontal ? 32 : 0,\n arrow: options.arrow !== false && {\n headSize: 12,\n style: {\n fill: 'rgba(0, 0, 0, 0.05)',\n },\n },\n text: options.text !== false && {\n style: {\n fontSize: 12,\n fill: 'rgba(0, 0, 0, 0.85)',\n textAlign: 'center',\n textBaseline: 'middle',\n },\n formatter: conversionTagFormatter,\n },\n },\n options\n );\n}\n\nfunction parsePoints(coordinate: Coordinate, element: Element): { x: number; y: number }[] {\n // @ts-ignore\n return map(element.getModel().points, (point) => coordinate.convertPoint(point));\n}\n\nfunction renderArrowTag(config: TagRenderConfig, elemPrev: Element, elemNext: Element): void {\n const { view, geometry, group, options, horizontal } = config;\n const { offset, size, arrow } = options;\n const coordinate = view.getCoordinate();\n const pointPrev = parsePoints(coordinate, elemPrev)[horizontal ? 3 : 0];\n const pointNext = parsePoints(coordinate, elemNext)[horizontal ? 0 : 3];\n const totalHeight = pointNext.y - pointPrev.y;\n const totalWidth = pointNext.x - pointPrev.x;\n\n if (typeof arrow === 'boolean') {\n return;\n }\n const { headSize } = arrow;\n let spacing = options.spacing;\n let points;\n\n if (horizontal) {\n if ((totalWidth - headSize) / 2 < spacing) {\n // 当柱间距不足容纳箭头尖与间隔时,画三角并挤占间隔\n spacing = Math.max(1, (totalWidth - headSize) / 2);\n points = [\n [pointPrev.x + spacing, pointPrev.y - offset],\n [pointPrev.x + spacing, pointPrev.y - offset - size],\n [pointNext.x - spacing, pointNext.y - offset - size / 2],\n ];\n } else {\n // 当柱间距足够时,画完整图形并留出间隔。\n points = [\n [pointPrev.x + spacing, pointPrev.y - offset],\n [pointPrev.x + spacing, pointPrev.y - offset - size],\n [pointNext.x - spacing - headSize, pointNext.y - offset - size],\n [pointNext.x - spacing, pointNext.y - offset - size / 2],\n [pointNext.x - spacing - headSize, pointNext.y - offset],\n ];\n }\n } else {\n if ((totalHeight - headSize) / 2 < spacing) {\n // 当柱间距不足容纳箭头尖与间隔时,画三角并挤占间隔\n spacing = Math.max(1, (totalHeight - headSize) / 2);\n points = [\n [pointPrev.x + offset, pointPrev.y + spacing],\n [pointPrev.x + offset + size, pointPrev.y + spacing],\n [pointNext.x + offset + size / 2, pointNext.y - spacing],\n ];\n } else {\n // 当柱间距足够时,画完整图形并留出间隔。\n points = [\n [pointPrev.x + offset, pointPrev.y + spacing],\n [pointPrev.x + offset + size, pointPrev.y + spacing],\n [pointNext.x + offset + size, pointNext.y - spacing - headSize],\n [pointNext.x + offset + size / 2, pointNext.y - spacing],\n [pointNext.x + offset, pointNext.y - spacing - headSize],\n ];\n }\n }\n\n group.addShape('polygon', {\n id: `${view.id}-conversion-tag-arrow-${geometry.getElementId(elemPrev.getModel().mappingData)}`,\n name: 'conversion-tag-arrow',\n origin: {\n element: elemPrev,\n nextElement: elemNext,\n },\n attrs: {\n ...(arrow.style || {}),\n points,\n },\n });\n}\n\nfunction renderTextTag(config: TagRenderConfig, elemPrev: Element, elemNext: Element): void {\n const { view, geometry, group, options, field, horizontal } = config;\n const { offset, size } = options;\n if (typeof options.text === 'boolean') {\n return;\n }\n const coordinate = view.getCoordinate();\n const text = options.text?.formatter && options.text?.formatter(elemPrev.getData()[field], elemNext.getData()[field]);\n\n const pointPrev = parsePoints(coordinate, elemPrev)[horizontal ? 3 : 0];\n const pointNext = parsePoints(coordinate, elemNext)[horizontal ? 0 : 3];\n\n const textShape = group.addShape('text', {\n id: `${view.id}-conversion-tag-text-${geometry.getElementId(elemPrev.getModel().mappingData)}`,\n name: 'conversion-tag-text',\n origin: {\n element: elemPrev,\n nextElement: elemNext,\n },\n attrs: {\n ...(options.text?.style || {}),\n text,\n x: horizontal ? (pointPrev.x + pointNext.x) / 2 : pointPrev.x + offset + size / 2,\n y: horizontal ? pointPrev.y - offset - size / 2 : (pointPrev.y + pointNext.y) / 2,\n },\n });\n\n if (horizontal) {\n const totalWidth = pointNext.x - pointPrev.x;\n const { width: textWidth } = textShape.getBBox();\n if (textWidth > totalWidth) {\n const cWidth = textWidth / text.length;\n const cEnd = Math.max(1, Math.ceil(totalWidth / cWidth) - 1);\n const textAdjusted = `${text.slice(0, cEnd)}...`;\n textShape.attr('text', textAdjusted);\n }\n }\n}\n\nfunction renderTag(options: TagRenderConfig, elemPrev: Element, elemNext: Element): void {\n renderArrowTag(options, elemPrev, elemNext);\n renderTextTag(options, elemPrev, elemNext);\n}\n\n/**\n * 返回支持转化率组件的 adaptor,适用于柱形图/条形图\n * @param field 用户转化率计算的字段\n * @param horizontal 是否水平方向的转化率\n * @param disabled 是否禁用\n */\nexport function conversionTag<O extends OptionWithConversionTag & Options>(\n field: string,\n horizontal = true,\n disabled = false\n) {\n return function (params: Params<O>): Params<O> {\n const { options, chart } = params;\n const { conversionTag, theme } = options;\n\n if (conversionTag && !disabled) {\n // 有转化率组件时,柱子宽度占比自动为 1/3\n chart.theme(\n deepAssign({}, isObject(theme) ? theme : getTheme(theme), {\n columnWidthRatio: 1 / 3,\n })\n );\n // 使用 shape annotation 绘制转化率组件\n chart.annotation().shape({\n render: (container, view) => {\n const group = container.addGroup({\n id: `${chart.id}-conversion-tag-group`,\n name: 'conversion-tag-group',\n });\n const interval = find(chart.geometries, (geom: Geometry) => geom.type === 'interval');\n const config: TagRenderConfig = {\n view,\n geometry: interval,\n group,\n field,\n horizontal,\n options: getConversionTagOptionsWithDefaults(conversionTag, horizontal),\n };\n const elements = horizontal ? interval.elements : interval.elements.slice().reverse();\n each(elements, (elem: Element, idx: number) => {\n if (idx > 0) {\n renderTag(config, elements[idx - 1], elem);\n }\n });\n },\n });\n }\n\n return params;\n };\n}\n"]}
1
+ {"version":3,"file":"conversion-tag.js","sourceRoot":"","sources":["../../src/adaptor/conversion-tag.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,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, Geometry, View, getTheme } from '@antv/g2';\nimport { Params } from '../core/adaptor';\nimport { deepAssign } from '../utils';\nimport { conversionTagFormatter } from '../utils/conversion';\nimport { Options } from '../types';\n\n/** 转化率组件配置选项 */\nexport interface ConversionTagOptions {\n /** tag 高度 */\n size?: number;\n /** tag 对柱子间距 */\n spacing?: number;\n /** tag 距离轴线距离 */\n offset?: number;\n /** 箭头形状配置 */\n arrow?:\n | {\n /** 箭头宽度 */\n headSize?: number;\n /** 箭头样式 */\n style?: ShapeAttrs;\n }\n | false;\n /** 文本配置 */\n text?:\n | {\n /** 文字大小 */\n size?: number;\n /** 文字样式 */\n style?: ShapeAttrs;\n /** 文本格式化 */\n formatter?: (prev: number, next: number) => string;\n }\n | false;\n}\n\nexport interface OptionWithConversionTag {\n conversionTag?: ConversionTagOptions | false;\n}\n\n/** 控制转化率组件绘制的选项 */\ntype TagRenderConfig = {\n /** 所在的 View */\n view: View;\n /** 所属的 geometry */\n geometry: Geometry;\n /** 转化率组件的 group */\n group: IGroup;\n /** 转化率配置 */\n options: ConversionTagOptions;\n /** 用于转化率计算的字段 */\n field: string;\n /** 水平/垂直 */\n horizontal: boolean;\n};\n\nfunction getConversionTagOptionsWithDefaults(options: ConversionTagOptions, horizontal: boolean): ConversionTagOptions {\n return deepAssign(\n {\n size: horizontal ? 32 : 80,\n spacing: horizontal ? 8 : 12,\n offset: horizontal ? 32 : 0,\n arrow: options.arrow !== false && {\n headSize: 12,\n style: {\n fill: 'rgba(0, 0, 0, 0.05)',\n },\n },\n text: options.text !== false && {\n style: {\n fontSize: 12,\n fill: 'rgba(0, 0, 0, 0.85)',\n textAlign: 'center',\n textBaseline: 'middle',\n },\n formatter: conversionTagFormatter,\n },\n },\n options\n );\n}\n\nfunction parsePoints(coordinate: Coordinate, element: Element): { x: number; y: number }[] {\n // @ts-ignore\n return map(element.getModel().points, (point) => coordinate.convertPoint(point));\n}\n\nfunction renderArrowTag(config: TagRenderConfig, elemPrev: Element, elemNext: Element): void {\n const { view, geometry, group, options, horizontal } = config;\n const { offset, size, arrow } = options;\n const coordinate = view.getCoordinate();\n const pointPrev = parsePoints(coordinate, elemPrev)[3];\n const pointNext = parsePoints(coordinate, elemNext)[0];\n const totalHeight = pointNext.y - pointPrev.y;\n const totalWidth = pointNext.x - pointPrev.x;\n\n if (typeof arrow === 'boolean') {\n return;\n }\n const { headSize } = arrow;\n let spacing = options.spacing;\n let points;\n\n if (horizontal) {\n if ((totalWidth - headSize) / 2 < spacing) {\n // 当柱间距不足容纳箭头尖与间隔时,画三角并挤占间隔\n spacing = Math.max(1, (totalWidth - headSize) / 2);\n points = [\n [pointPrev.x + spacing, pointPrev.y - offset],\n [pointPrev.x + spacing, pointPrev.y - offset - size],\n [pointNext.x - spacing, pointNext.y - offset - size / 2],\n ];\n } else {\n // 当柱间距足够时,画完整图形并留出间隔。\n points = [\n [pointPrev.x + spacing, pointPrev.y - offset],\n [pointPrev.x + spacing, pointPrev.y - offset - size],\n [pointNext.x - spacing - headSize, pointNext.y - offset - size],\n [pointNext.x - spacing, pointNext.y - offset - size / 2],\n [pointNext.x - spacing - headSize, pointNext.y - offset],\n ];\n }\n } else {\n if ((totalHeight - headSize) / 2 < spacing) {\n // 当柱间距不足容纳箭头尖与间隔时,画三角并挤占间隔\n spacing = Math.max(1, (totalHeight - headSize) / 2);\n points = [\n [pointPrev.x + offset, pointPrev.y + spacing],\n [pointPrev.x + offset + size, pointPrev.y + spacing],\n [pointNext.x + offset + size / 2, pointNext.y - spacing],\n ];\n } else {\n // 当柱间距足够时,画完整图形并留出间隔。\n points = [\n [pointPrev.x + offset, pointPrev.y + spacing],\n [pointPrev.x + offset + size, pointPrev.y + spacing],\n [pointNext.x + offset + size, pointNext.y - spacing - headSize],\n [pointNext.x + offset + size / 2, pointNext.y - spacing],\n [pointNext.x + offset, pointNext.y - spacing - headSize],\n ];\n }\n }\n\n group.addShape('polygon', {\n id: `${view.id}-conversion-tag-arrow-${geometry.getElementId(elemPrev.getModel().mappingData)}`,\n name: 'conversion-tag-arrow',\n origin: {\n element: elemPrev,\n nextElement: elemNext,\n },\n attrs: {\n ...(arrow.style || {}),\n points,\n },\n });\n}\n\nfunction renderTextTag(config: TagRenderConfig, elemPrev: Element, elemNext: Element): void {\n const { view, geometry, group, options, field, horizontal } = config;\n const { offset, size } = options;\n if (typeof options.text === 'boolean') {\n return;\n }\n const coordinate = view.getCoordinate();\n const text = options.text?.formatter && options.text?.formatter(elemPrev.getData()[field], elemNext.getData()[field]);\n\n const pointPrev = parsePoints(coordinate, elemPrev)[horizontal ? 3 : 0];\n const pointNext = parsePoints(coordinate, elemNext)[horizontal ? 0 : 3];\n\n const textShape = group.addShape('text', {\n id: `${view.id}-conversion-tag-text-${geometry.getElementId(elemPrev.getModel().mappingData)}`,\n name: 'conversion-tag-text',\n origin: {\n element: elemPrev,\n nextElement: elemNext,\n },\n attrs: {\n ...(options.text?.style || {}),\n text,\n x: horizontal ? (pointPrev.x + pointNext.x) / 2 : pointPrev.x + offset + size / 2,\n y: horizontal ? pointPrev.y - offset - size / 2 : (pointPrev.y + pointNext.y) / 2,\n },\n });\n\n if (horizontal) {\n const totalWidth = pointNext.x - pointPrev.x;\n const { width: textWidth } = textShape.getBBox();\n if (textWidth > totalWidth) {\n const cWidth = textWidth / text.length;\n const cEnd = Math.max(1, Math.ceil(totalWidth / cWidth) - 1);\n const textAdjusted = `${text.slice(0, cEnd)}...`;\n textShape.attr('text', textAdjusted);\n }\n }\n}\n\nfunction renderTag(options: TagRenderConfig, elemPrev: Element, elemNext: Element): void {\n renderArrowTag(options, elemPrev, elemNext);\n renderTextTag(options, elemPrev, elemNext);\n}\n\n/**\n * 返回支持转化率组件的 adaptor,适用于柱形图/条形图\n * @param field 用户转化率计算的字段\n * @param horizontal 是否水平方向的转化率\n * @param disabled 是否禁用\n */\nexport function conversionTag<O extends OptionWithConversionTag & Options>(\n field: string,\n horizontal = true,\n disabled = false\n) {\n return function (params: Params<O>): Params<O> {\n const { options, chart } = params;\n const { conversionTag, theme } = options;\n\n if (conversionTag && !disabled) {\n // 有转化率组件时,柱子宽度占比自动为 1/3\n chart.theme(\n deepAssign({}, isObject(theme) ? theme : getTheme(theme), {\n columnWidthRatio: 1 / 3,\n })\n );\n // 使用 shape annotation 绘制转化率组件\n chart.annotation().shape({\n render: (container, view) => {\n const group = container.addGroup({\n id: `${chart.id}-conversion-tag-group`,\n name: 'conversion-tag-group',\n });\n const interval = find(chart.geometries, (geom: Geometry) => geom.type === 'interval');\n const config: TagRenderConfig = {\n view,\n geometry: interval,\n group,\n field,\n horizontal,\n options: getConversionTagOptionsWithDefaults(conversionTag, horizontal),\n };\n const elements = interval.elements;\n each(elements, (elem: Element, idx: number) => {\n if (idx > 0) {\n renderTag(config, elements[idx - 1], elem);\n }\n });\n },\n });\n }\n\n return params;\n };\n}\n"]}
package/esm/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "2.3.40";
1
+ export declare const version = "2.4.3";
2
2
  import * as G2 from '@antv/g2';
3
3
  export { G2 };
4
4
  import { registerLocale } from './core/locale';
@@ -88,6 +88,14 @@ export { Mix as Mix } from './plots/mix';
88
88
  export type { MixOptions } from './plots/mix';
89
89
  export { Facet } from './plots/facet';
90
90
  export type { FacetOptions } from './plots/facet';
91
+ /** 提供一些工具方法 */
92
+ import { findGeometry, getAllGeometriesRecursively, findViewById } from './utils';
93
+ declare const Util: {
94
+ findGeometry: typeof findGeometry;
95
+ findViewById: typeof findViewById;
96
+ getAllGeometriesRecursively: typeof getAllGeometriesRecursively;
97
+ };
98
+ export { Util };
91
99
  /** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */
92
100
  export { flow, measureTextWidth } from './utils';
93
101
  /** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export var version = '2.3.40';
1
+ export var version = '2.4.3';
2
2
  // G2 自定义能力透出
3
3
  import * as G2 from '@antv/g2';
4
4
  export { G2 };
@@ -94,6 +94,14 @@ export { Mix as MultiView } from './plots/mix';
94
94
  export { Mix as Mix } from './plots/mix';
95
95
  // 分面图及类型定义 | author by [visiky](https://github.com/visiky)
96
96
  export { Facet } from './plots/facet';
97
+ /** 提供一些工具方法 */
98
+ import { findGeometry, getAllGeometriesRecursively, findViewById } from './utils';
99
+ var Util = {
100
+ findGeometry: findGeometry,
101
+ findViewById: findViewById,
102
+ getAllGeometriesRecursively: getAllGeometriesRecursively,
103
+ };
104
+ export { Util };
97
105
  /** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */
98
106
  export { flow, measureTextWidth } from './utils';
99
107
  /** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,CAAC;AAEd,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,8BAA8B;AAC9B,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,uBAAuB;AACvB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,WAAW;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,uBAAuB;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKnC,SAAS;AACT,cAAc,SAAS,CAAC;AAExB,2DAA2D;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,2DAA2D;AAC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,CAAC;AAGtC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjD,0CAA0C;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASpF,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrG,MAAM,CAAC,IAAM,QAAQ,GAAG,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,OAAO,SAAA,EAAE,UAAU,YAAA,EAAE,WAAW,aAAA,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export const version = '2.3.40';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\nexport { G2 };\n\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n\n// 类型定义导出\nexport * from './types';\n\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\n\n// 已经废弃,更名为 Mix\nexport { Mix as MultiView } from './plots/mix';\nexport type { MixOptions as MultiViewOptions } from './plots/mix';\n/** 开放多图层图表 (mix) */\nexport { Mix as Mix } from './plots/mix';\nexport type { MixOptions } from './plots/mix';\n\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { line, interval, area, point, polygon, schema } from './adaptor/geometries';\nexport type {\n LineGeometryOptions,\n IntervalGeometryOptions,\n AreaGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common';\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,CAAC;AAEd,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,8BAA8B;AAC9B,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,uBAAuB;AACvB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,WAAW;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,uBAAuB;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKnC,SAAS;AACT,cAAc,SAAS,CAAC;AAExB,2DAA2D;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,2DAA2D;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,uDAAuD;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,yDAAyD;AAC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AAA;IACZ,YAAY,cAAA;IACZ,2BAA2B,6BAAA;CAC5B,CAAC;AACF,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjD,0CAA0C;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASpF,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrG,MAAM,CAAC,IAAM,QAAQ,GAAG,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,OAAO,SAAA,EAAE,UAAU,YAAA,EAAE,WAAW,aAAA,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export const version = '2.4.3';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\nexport { G2 };\n\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n\n// 类型定义导出\nexport * from './types';\n\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\n\n// 已经废弃,更名为 Mix\nexport { Mix as MultiView } from './plots/mix';\nexport type { MixOptions as MultiViewOptions } from './plots/mix';\n/** 开放多图层图表 (mix) */\nexport { Mix as Mix } from './plots/mix';\nexport type { MixOptions } from './plots/mix';\n\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n\n/** 提供一些工具方法 */\nimport { findGeometry, getAllGeometriesRecursively, findViewById } from './utils';\nconst Util = {\n findGeometry,\n findViewById,\n getAllGeometriesRecursively,\n};\nexport { Util };\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { line, interval, area, point, polygon, schema } from './adaptor/geometries';\nexport type {\n LineGeometryOptions,\n IntervalGeometryOptions,\n AreaGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common';\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n"]}
@@ -1,11 +1,12 @@
1
1
  import { __assign, __rest } from "tslib";
2
- import { each } from '@antv/util';
2
+ import { each, isNil } from '@antv/util';
3
3
  import { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';
4
- import { findGeometry } from '../../utils';
4
+ import { findGeometry, getAllGeometriesRecursively } from '../../utils';
5
5
  import { area, point, line } from '../../adaptor/geometries';
6
6
  import { flow, transformLabel, deepAssign } from '../../utils';
7
7
  import { getDataWhetherPecentage } from '../../utils/transform/percent';
8
8
  import { meta, legend, axis } from '../line/adaptor';
9
+ import { POINT_VIEW_ID } from './constants';
9
10
  export { meta };
10
11
  /**
11
12
  * geometry 处理
@@ -42,11 +43,19 @@ function geometry(params) {
42
43
  var lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {
43
44
  options: { sizeField: seriesField, tooltip: false },
44
45
  });
45
- var pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
46
46
  // area geometry 处理
47
47
  area(primary);
48
48
  line(lineParams);
49
- point(pointParams);
49
+ var pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
50
+ if (pointMapping) {
51
+ var pointView = chart.createView({ id: POINT_VIEW_ID });
52
+ pointView.axis(false);
53
+ pointView.tooltip(false);
54
+ pointView.legend(false);
55
+ // [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)
56
+ pointView.data(data.filter(function (d) { return !isNil(d[yField]); }));
57
+ point(__assign(__assign({}, pointParams), { chart: pointView }));
58
+ }
50
59
  return params;
51
60
  }
52
61
  /**
@@ -84,7 +93,8 @@ function adjust(params) {
84
93
  var chart = params.chart, options = params.options;
85
94
  var isStack = options.isStack, isPercent = options.isPercent, seriesField = options.seriesField;
86
95
  if ((isPercent || isStack) && seriesField) {
87
- each(chart.geometries, function (g) {
96
+ var geometries = getAllGeometriesRecursively(chart);
97
+ each(geometries, function (g) {
88
98
  g.adjust('stack');
89
99
  });
90
100
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/area/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAA2B;IACnC,IAAA,KAAK,GAAc,MAAM,MAAp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ACR,GAAG,aACD,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,eAAe,EAAE;oBACzB,EAAE,IAAI,EAAE,sBAAsB,EAAE;oBAChC,EAAE,IAAI,EAAE,uBAAuB,EAAE;oBACjC,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;iBACnD,IACE,cAAc,CAAC,GAAG,CAAC,CACvB;SACF,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,MAAM,CAAC,MAA2B;IACjC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,OAAO,GAA6B,OAAO,QAApC,EAAE,SAAS,GAAkB,OAAO,UAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IACpD,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,WAAW,EAAE;QACzC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAC,CAAW;YACjC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,MAA2B;IACjD,0BAA0B;IAC1B,OAAO,IAAI,CACT,KAAK,EACL,OAAO,CAAC,WAAW,CAAC,EACpB,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EAAE,EACZ,WAAW,EACX,SAAS,EACT,WAAW,CACZ,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { each } from '@antv/util';\nimport { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';\nimport { findGeometry } from '../../utils';\nimport { Params } from '../../core/adaptor';\nimport { area, point, line } from '../../adaptor/geometries';\nimport { flow, transformLabel, deepAssign } from '../../utils';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { Datum } from '../../types';\nimport { meta, legend, axis } from '../line/adaptor';\nimport { AreaOptions } from './types';\n\nexport { meta };\n\n/**\n * geometry 处理\n * @param params\n */\nfunction geometry(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const {\n data,\n areaStyle,\n color,\n point: pointMapping,\n line: lineMapping,\n isPercent,\n xField,\n yField,\n tooltip,\n seriesField,\n startOnZero,\n } = options;\n const pointState = pointMapping?.state;\n\n const chartData = getDataWhetherPecentage(data, yField, xField, yField, isPercent);\n chart.data(chartData);\n // 百分比堆积图,默认会给一个 % 格式化逻辑, 用户可自定义\n const tooltipOptions = isPercent\n ? {\n formatter: (datum: Datum) => ({\n name: datum[seriesField] || datum[xField],\n value: (Number(datum[yField]) * 100).toFixed(2) + '%',\n }),\n ...tooltip,\n }\n : tooltip;\n const primary = deepAssign({}, params, {\n options: {\n area: { color, style: areaStyle },\n // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。\n // 如果存在,才设置,否则为空\n line: lineMapping && {\n color,\n ...lineMapping,\n },\n point: pointMapping && {\n color,\n ...pointMapping,\n },\n tooltip: tooltipOptions,\n // label 不传递给各个 geometry adaptor,由 label adaptor 处理\n label: undefined,\n args: {\n startOnZero,\n },\n },\n });\n // 线默认 2px\n const lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {\n options: { sizeField: seriesField, tooltip: false },\n });\n const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n\n // area geometry 处理\n area(primary);\n line(lineParams);\n point(pointParams);\n\n return params;\n}\n\n/**\n * 数据标签\n * @param params\n */\nfunction label(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { label, yField } = options;\n\n const areaGeometry = findGeometry(chart, 'area');\n\n // label 为 false, 空 则不显示 label\n if (!label) {\n areaGeometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n areaGeometry.label({\n fields: [yField],\n callback,\n cfg: {\n layout: [\n { type: 'limit-in-plot' },\n { type: 'path-adjust-position' },\n { type: 'point-adjust-position' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ],\n ...transformLabel(cfg),\n },\n });\n }\n\n return params;\n}\n\n/**\n * 处理 adjust\n * @param params\n */\nfunction adjust(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { isStack, isPercent, seriesField } = options;\n if ((isPercent || isStack) && seriesField) {\n each(chart.geometries, (g: Geometry) => {\n g.adjust('stack');\n });\n }\n\n return params;\n}\n\n/**\n * 折线图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<AreaOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n theme,\n pattern('areaStyle'),\n geometry,\n meta,\n adjust,\n axis,\n legend,\n tooltip,\n label,\n slider,\n annotation(),\n interaction,\n animation,\n limitInPlot\n )(params);\n}\n"]}
1
+ {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/area/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,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CAAC,IAAI,WAAW,EAAE;QACzC,IAAM,UAAU,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,CAAC,UAAU,EAAE,UAAC,CAAW;YAC3B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,MAA2B;IACjD,0BAA0B;IAC1B,OAAO,IAAI,CACT,KAAK,EACL,OAAO,CAAC,WAAW,CAAC,EACpB,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EAAE,EACZ,WAAW,EACX,SAAS,EACT,WAAW,CACZ,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { each, isNil } from '@antv/util';\nimport { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';\nimport { findGeometry, getAllGeometriesRecursively } from '../../utils';\nimport { Params } from '../../core/adaptor';\nimport { area, point, line } from '../../adaptor/geometries';\nimport { flow, transformLabel, deepAssign } from '../../utils';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { Datum } from '../../types';\nimport { meta, legend, axis } from '../line/adaptor';\nimport { POINT_VIEW_ID } from './constants';\nimport { AreaOptions } from './types';\n\nexport { meta };\n\n/**\n * geometry 处理\n * @param params\n */\nfunction geometry(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const {\n data,\n areaStyle,\n color,\n point: pointMapping,\n line: lineMapping,\n isPercent,\n xField,\n yField,\n tooltip,\n seriesField,\n startOnZero,\n } = options;\n const pointState = pointMapping?.state;\n\n const chartData = getDataWhetherPecentage(data, yField, xField, yField, isPercent);\n chart.data(chartData);\n // 百分比堆积图,默认会给一个 % 格式化逻辑, 用户可自定义\n const tooltipOptions = isPercent\n ? {\n formatter: (datum: Datum) => ({\n name: datum[seriesField] || datum[xField],\n value: (Number(datum[yField]) * 100).toFixed(2) + '%',\n }),\n ...tooltip,\n }\n : tooltip;\n const primary = deepAssign({}, params, {\n options: {\n area: { color, style: areaStyle },\n // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。\n // 如果存在,才设置,否则为空\n line: lineMapping && {\n color,\n ...lineMapping,\n },\n point: pointMapping && {\n color,\n ...pointMapping,\n },\n tooltip: tooltipOptions,\n // label 不传递给各个 geometry adaptor,由 label adaptor 处理\n label: undefined,\n args: {\n startOnZero,\n },\n },\n });\n // 线默认 2px\n const lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {\n options: { sizeField: seriesField, tooltip: false },\n });\n\n // area geometry 处理\n area(primary);\n line(lineParams);\n\n const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n if (pointMapping) {\n const pointView = chart.createView({ id: POINT_VIEW_ID });\n pointView.axis(false);\n pointView.tooltip(false);\n pointView.legend(false);\n // [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)\n pointView.data(data.filter((d) => !isNil(d[yField])));\n point({ ...pointParams, chart: pointView });\n }\n\n return params;\n}\n\n/**\n * 数据标签\n * @param params\n */\nfunction label(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { label, yField } = options;\n\n const areaGeometry = findGeometry(chart, 'area');\n\n // label 为 false, 空 则不显示 label\n if (!label) {\n areaGeometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n areaGeometry.label({\n fields: [yField],\n callback,\n cfg: {\n layout: [\n { type: 'limit-in-plot' },\n { type: 'path-adjust-position' },\n { type: 'point-adjust-position' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ],\n ...transformLabel(cfg),\n },\n });\n }\n\n return params;\n}\n\n/**\n * 处理 adjust\n * @param params\n */\nfunction adjust(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { isStack, isPercent, seriesField } = options;\n if ((isPercent || isStack) && seriesField) {\n const geometries = getAllGeometriesRecursively(chart);\n each(geometries, (g: Geometry) => {\n g.adjust('stack');\n });\n }\n\n return params;\n}\n\n/**\n * 折线图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<AreaOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n theme,\n pattern('areaStyle'),\n geometry,\n meta,\n adjust,\n axis,\n legend,\n tooltip,\n label,\n slider,\n annotation(),\n interaction,\n animation,\n limitInPlot\n )(params);\n}\n"]}
@@ -1,3 +1,5 @@
1
+ /** point 标注点视图 */
2
+ export declare const POINT_VIEW_ID = "point-view";
1
3
  /**
2
4
  * 面积图默认配置项
3
5
  */
@@ -1,5 +1,7 @@
1
1
  import { Plot } from '../../core/plot';
2
2
  import { deepAssign } from '../../utils';
3
+ /** point 标注点视图 */
4
+ export var POINT_VIEW_ID = 'point-view';
3
5
  /**
4
6
  * 面积图默认配置项
5
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/plots/area/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,EAAE;IACtE,OAAO,EAAE;QACP,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE;YACV,IAAI,EAAE,GAAG;SACV;KACF;IACD,OAAO,EAAE,IAAI;IACb,OAAO;IACP,IAAI,EAAE,EAAE;IACR,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { Plot } from '../../core/plot';\nimport { deepAssign } from '../../utils';\n\n/**\n * 面积图默认配置项\n */\nexport const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {\n tooltip: {\n shared: true,\n showMarkers: true,\n showCrosshairs: true,\n crosshairs: {\n type: 'x',\n },\n },\n isStack: true,\n // 默认开启\n line: {},\n legend: {\n position: 'top-left',\n },\n});\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/plots/area/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,kBAAkB;AAClB,MAAM,CAAC,IAAM,aAAa,GAAG,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,EAAE;IACtE,OAAO,EAAE;QACP,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE;YACV,IAAI,EAAE,GAAG;SACV;KACF;IACD,OAAO,EAAE,IAAI;IACb,OAAO;IACP,IAAI,EAAE,EAAE;IACR,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { Plot } from '../../core/plot';\nimport { deepAssign } from '../../utils';\n\n/** point 标注点视图 */\nexport const POINT_VIEW_ID = 'point-view';\n\n/**\n * 面积图默认配置项\n */\nexport const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {\n tooltip: {\n shared: true,\n showMarkers: true,\n showCrosshairs: true,\n crosshairs: {\n type: 'x',\n },\n },\n isStack: true,\n // 默认开启\n line: {},\n legend: {\n position: 'top-left',\n },\n});\n"]}
@@ -1,8 +1,10 @@
1
1
  import { __extends } from "tslib";
2
+ import { isNil } from '@antv/util';
2
3
  import { Plot } from '../../core/plot';
3
4
  import { getDataWhetherPecentage } from '../../utils/transform/percent';
5
+ import { findViewById } from '../../utils';
4
6
  import { adaptor, meta } from './adaptor';
5
- import { DEFAULT_OPTIONS } from './constants';
7
+ import { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';
6
8
  var Area = /** @class */ (function (_super) {
7
9
  __extends(Area, _super);
8
10
  function Area() {
@@ -30,10 +32,15 @@ var Area = /** @class */ (function (_super) {
30
32
  */
31
33
  Area.prototype.changeData = function (data) {
32
34
  this.updateOption({ data: data });
33
- var _a = this.options, isPercent = _a.isPercent, xField = _a.xField, yField = _a.yField;
34
- var _b = this, chart = _b.chart, options = _b.options;
35
+ var _a = this, chart = _a.chart, options = _a.options;
36
+ var isPercent = options.isPercent, xField = options.xField, yField = options.yField;
35
37
  meta({ chart: chart, options: options });
36
- this.chart.changeData(getDataWhetherPecentage(data, yField, xField, yField, isPercent));
38
+ var chartdata = getDataWhetherPecentage(data, yField, xField, yField, isPercent);
39
+ this.chart.changeData(chartdata);
40
+ var pointView = findViewById(this.chart, POINT_VIEW_ID);
41
+ if (pointView) {
42
+ pointView.changeData(data.filter(function (d) { return !isNil(d[yField]); }));
43
+ }
37
44
  };
38
45
  /**
39
46
  * 获取 面积图 的适配器
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/area/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C;IAA0B,wBAAiB;IAA3C;QAAA,qEAqCC;QA5BC,WAAW;QACJ,UAAI,GAAW,MAAM,CAAC;;IA2B/B,CAAC;IApCC;;;OAGG;IACI,sBAAiB,GAAxB;QACE,OAAO,eAAe,CAAC;IACzB,CAAC;IAKD;;OAEG;IACO,gCAAiB,GAA3B;QACE,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,yBAAU,GAAjB,UAAkB,IAAyB;QACzC,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;QACtB,IAAA,KAAgC,IAAI,CAAC,OAAO,EAA1C,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,MAAM,YAAiB,CAAC;QAC7C,IAAA,KAAqB,IAAI,EAAvB,KAAK,WAAA,EAAE,OAAO,aAAS,CAAC;QAChC,IAAI,CAAC,EAAE,KAAK,OAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED;;OAEG;IACO,+BAAgB,GAA1B;QACE,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,WAAC;AAAD,CAAC,AArCD,CAA0B,IAAI,GAqC7B","sourcesContent":["import { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { AreaOptions } from './types';\nimport { adaptor, meta } from './adaptor';\nimport { DEFAULT_OPTIONS } from './constants';\n\nexport type { AreaOptions };\n\nexport class Area extends Plot<AreaOptions> {\n /**\n * 获取 面积图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<AreaOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public type: string = 'area';\n\n /**\n * 获取 面积图 默认配置\n */\n protected getDefaultOptions() {\n return Area.getDefaultOptions();\n }\n\n /**\n * @override\n * @param data\n */\n public changeData(data: AreaOptions['data']) {\n this.updateOption({ data });\n const { isPercent, xField, yField } = this.options;\n const { chart, options } = this;\n meta({ chart, options });\n this.chart.changeData(getDataWhetherPecentage(data, yField, xField, yField, isPercent));\n }\n\n /**\n * 获取 面积图 的适配器\n */\n protected getSchemaAdaptor(): Adaptor<AreaOptions> {\n return adaptor;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/area/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI7D;IAA0B,wBAAiB;IAA3C;QAAA,qEA0CC;QAjCC,WAAW;QACJ,UAAI,GAAW,MAAM,CAAC;;IAgC/B,CAAC;IAzCC;;;OAGG;IACI,sBAAiB,GAAxB;QACE,OAAO,eAAe,CAAC;IACzB,CAAC;IAKD;;OAEG;IACO,gCAAiB,GAA3B;QACE,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,yBAAU,GAAjB,UAAkB,IAAyB;QACzC,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;QACtB,IAAA,KAAqB,IAAI,EAAvB,KAAK,WAAA,EAAE,OAAO,aAAS,CAAC;QACxB,IAAA,SAAS,GAAqB,OAAO,UAA5B,EAAE,MAAM,GAAa,OAAO,OAApB,EAAE,MAAM,GAAK,OAAO,OAAZ,CAAa;QAC9C,IAAI,CAAC,EAAE,KAAK,OAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;QACzB,IAAM,SAAS,GAAG,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACnF,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACjC,IAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QAC1D,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAjB,CAAiB,CAAC,CAAC,CAAC;SAC7D;IACH,CAAC;IAED;;OAEG;IACO,+BAAgB,GAA1B;QACE,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,WAAC;AAAD,CAAC,AA1CD,CAA0B,IAAI,GA0C7B","sourcesContent":["import { isNil } from '@antv/util';\nimport { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { findViewById } from '../../utils';\nimport { AreaOptions } from './types';\nimport { adaptor, meta } from './adaptor';\nimport { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';\n\nexport type { AreaOptions };\n\nexport class Area extends Plot<AreaOptions> {\n /**\n * 获取 面积图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<AreaOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public type: string = 'area';\n\n /**\n * 获取 面积图 默认配置\n */\n protected getDefaultOptions() {\n return Area.getDefaultOptions();\n }\n\n /**\n * @override\n * @param data\n */\n public changeData(data: AreaOptions['data']) {\n this.updateOption({ data });\n const { chart, options } = this;\n const { isPercent, xField, yField } = options;\n meta({ chart, options });\n const chartdata = getDataWhetherPecentage(data, yField, xField, yField, isPercent);\n this.chart.changeData(chartdata);\n const pointView = findViewById(this.chart, POINT_VIEW_ID);\n if (pointView) {\n pointView.changeData(data.filter((d) => !isNil(d[yField])));\n }\n }\n\n /**\n * 获取 面积图 的适配器\n */\n protected getSchemaAdaptor(): Adaptor<AreaOptions> {\n return adaptor;\n }\n}\n"]}
@@ -1,8 +1,13 @@
1
1
  import { Params } from '../../core/adaptor';
2
- import { BarOptions } from './types';
3
2
  export { meta } from '../column/adaptor';
3
+ import { BarOptions } from './types';
4
4
  /**
5
5
  * 柱形图适配器
6
6
  * @param params
7
7
  */
8
- export declare function adaptor(params: Params<BarOptions>): Params<import("../..").Options>;
8
+ export declare function geometry(params: Params<BarOptions>): Params<BarOptions>;
9
+ /**
10
+ * @param chart
11
+ * @param options
12
+ */
13
+ export declare function adaptor(params: Params<BarOptions>): Params<BarOptions>;
@@ -1,14 +1,37 @@
1
1
  import { __assign } from "tslib";
2
+ import { tooltip } from '../../adaptor/common';
3
+ import { deepAssign, flow } from '../../utils';
2
4
  import { adaptor as columnAdaptor } from '../column/adaptor';
3
- import { transformBarData } from './utils';
4
5
  export { meta } from '../column/adaptor';
5
6
  /**
6
- * 柱形图适配器
7
+ * 处理默认配置项
8
+ * 1. switch xField、 yField
9
+ * 2. switch xAxis、 yAxis and adjust axis.position configuration
10
+ */
11
+ function defaultOptions(params) {
12
+ var options = params.options;
13
+ var xField = options.xField, yField = options.yField, xAxis = options.xAxis, yAxis = options.yAxis;
14
+ var position = {
15
+ left: 'bottom',
16
+ right: 'top',
17
+ top: 'left',
18
+ bottom: 'right',
19
+ };
20
+ var verticalAxis = yAxis !== false
21
+ ? __assign({ position: position[(yAxis === null || yAxis === void 0 ? void 0 : yAxis.position) || 'left'] }, yAxis) : false;
22
+ var horizontalAxis = xAxis !== false
23
+ ? __assign({ position: position[(xAxis === null || xAxis === void 0 ? void 0 : xAxis.position) || 'bottom'] }, xAxis) : false;
24
+ return __assign(__assign({}, params), { options: __assign(__assign({}, options), { xField: yField, yField: xField,
25
+ // 条形图 xAxis,yAxis 不可以做 deepAssign
26
+ xAxis: verticalAxis, yAxis: horizontalAxis }) });
27
+ }
28
+ /**
29
+ * label 适配器
7
30
  * @param params
8
31
  */
9
- export function adaptor(params) {
10
- var chart = params.chart, options = params.options;
11
- var xField = options.xField, yField = options.yField, xAxis = options.xAxis, yAxis = options.yAxis, barStyle = options.barStyle, barWidthRatio = options.barWidthRatio, label = options.label, data = options.data, seriesField = options.seriesField, isStack = options.isStack, minBarWidth = options.minBarWidth, maxBarWidth = options.maxBarWidth;
32
+ function label(params) {
33
+ var options = params.options;
34
+ var label = options.label;
12
35
  // label of bar charts default position is left, if plot has label
13
36
  if (label && !label.position) {
14
37
  label.position = 'left';
@@ -22,38 +45,57 @@ export function adaptor(params) {
22
45
  ];
23
46
  }
24
47
  }
48
+ return deepAssign({}, params, { options: { label: label } });
49
+ }
50
+ /**
51
+ * legend 适配器
52
+ * @param params
53
+ */
54
+ function legend(params) {
55
+ var options = params.options;
25
56
  // 默认 legend 位置
57
+ var seriesField = options.seriesField, isStack = options.isStack;
26
58
  var legend = options.legend;
27
59
  if (seriesField) {
28
60
  if (legend !== false) {
29
- legend = __assign({ position: isStack ? 'top-left' : 'right-top', reversed: isStack ? false : true }, (legend || {}));
61
+ legend = __assign({ position: isStack ? 'top-left' : 'right-top' }, (legend || {}));
30
62
  }
31
63
  }
32
64
  else {
33
65
  legend = false;
34
66
  }
35
- // @ts-ignore 直接改值
36
- params.options.legend = legend;
37
- // 默认 tooltip 配置
38
- var tooltip = options.tooltip;
39
- if (seriesField) {
40
- if (tooltip !== false) {
41
- tooltip = __assign({ reversed: isStack ? false : true }, (tooltip || {}));
42
- }
43
- }
44
- // @ts-ignore 直接改值
45
- params.options.tooltip = tooltip;
46
- // transpose column to bar
47
- chart.coordinate().transpose();
67
+ return deepAssign({}, params, { options: { legend: legend } });
68
+ }
69
+ /**
70
+ * coordinate 适配器
71
+ * @param params
72
+ */
73
+ function coordinate(params) {
74
+ var chart = params.chart;
75
+ // transpose column to bar 对角变换 & y 方向镜像变换
76
+ chart.coordinate({ actions: [['transpose'], ['reflect', 'y']] });
77
+ return params;
78
+ }
79
+ /**
80
+ * 柱形图适配器
81
+ * @param params
82
+ */
83
+ export function geometry(params) {
84
+ var chart = params.chart, options = params.options;
85
+ var barStyle = options.barStyle, barWidthRatio = options.barWidthRatio, minBarWidth = options.minBarWidth, maxBarWidth = options.maxBarWidth, barBackground = options.barBackground;
48
86
  return columnAdaptor({
49
87
  chart: chart,
50
- options: __assign(__assign({}, options), { label: label,
51
- // switch xField and yField
52
- xField: yField, yField: xField, xAxis: yAxis, yAxis: xAxis,
88
+ options: __assign(__assign({}, options), {
53
89
  // rename attrs as column
54
- columnStyle: barStyle, columnWidthRatio: barWidthRatio, minColumnWidth: minBarWidth, maxColumnWidth: maxBarWidth, columnBackground: options.barBackground,
55
- // bar 调整数据顺序
56
- data: transformBarData(data) }),
90
+ columnStyle: barStyle, columnWidthRatio: barWidthRatio, minColumnWidth: minBarWidth, maxColumnWidth: maxBarWidth, columnBackground: barBackground }),
57
91
  }, true);
58
92
  }
93
+ /**
94
+ * @param chart
95
+ * @param options
96
+ */
97
+ export function adaptor(params) {
98
+ // flow 的方式处理所有的配置到 G2 API
99
+ return flow(defaultOptions, label, legend, tooltip, coordinate, geometry)(params);
100
+ }
59
101
  //# sourceMappingURL=adaptor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/bar/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,MAA0B;IACxC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAEhC,IAAA,MAAM,GAYJ,OAAO,OAZH,EACN,MAAM,GAWJ,OAAO,OAXH,EACN,KAAK,GAUH,OAAO,MAVJ,EACL,KAAK,GASH,OAAO,MATJ,EACL,QAAQ,GAQN,OAAO,SARD,EACR,aAAa,GAOX,OAAO,cAPI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AAC,IAAI,IAC7B,CAAC,OAAO,IAAI,EAAE,CAAC,CACnB,CAAC;SACH;KACF;IACD,kBAAkB;IAClB,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAEjC,0BAA0B;IAC1B,KAAK,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,CAAC;IAE/B,OAAO,aAAa,CAClB;QACE,KAAK,OAAA;QACL,OAAO,wBACF,OAAO,KACV,KAAK,OAAA;YACL,2BAA2B;YAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK;YACZ,yBAAyB;YACzB,WAAW,EAAE,QAAQ,EACrB,gBAAgB,EAAE,aAAa,EAC/B,cAAc,EAAE,WAAW,EAC3B,cAAc,EAAE,WAAW,EAC3B,gBAAgB,EAAE,OAAO,CAAC,aAAa;YACvC,aAAa;YACb,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAC7B;KACF,EACD,IAAI,CACL,CAAC;AACJ,CAAC","sourcesContent":["import { Params } from '../../core/adaptor';\nimport { adaptor as columnAdaptor } from '../column/adaptor';\nimport { BarOptions } from './types';\nimport { transformBarData } from './utils';\n\nexport { meta } from '../column/adaptor';\n\n/**\n * 柱形图适配器\n * @param params\n */\nexport function adaptor(params: Params<BarOptions>) {\n const { chart, options } = params;\n const {\n xField,\n yField,\n xAxis,\n yAxis,\n barStyle,\n barWidthRatio,\n label,\n data,\n seriesField,\n isStack,\n minBarWidth,\n maxBarWidth,\n } = options;\n\n // label of bar charts default position is left, if plot has label\n if (label && !label.position) {\n label.position = 'left';\n // 配置默认的 label layout: 如果用户没有指定 layout 和 position, 则自动配置 layout\n if (!label.layout) {\n label.layout = [\n { type: 'interval-adjust-position' },\n { type: 'interval-hide-overlap' },\n { type: 'adjust-color' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ];\n }\n }\n\n // 默认 legend 位置\n let { legend } = options;\n if (seriesField) {\n if (legend !== false) {\n legend = {\n position: isStack ? 'top-left' : 'right-top',\n reversed: isStack ? false : true,\n ...(legend || {}),\n };\n }\n } else {\n legend = false;\n }\n // @ts-ignore 直接改值\n params.options.legend = legend;\n\n // 默认 tooltip 配置\n let { tooltip } = options;\n if (seriesField) {\n if (tooltip !== false) {\n tooltip = {\n reversed: isStack ? false : true,\n ...(tooltip || {}),\n };\n }\n }\n // @ts-ignore 直接改值\n params.options.tooltip = tooltip;\n\n // transpose column to bar\n chart.coordinate().transpose();\n\n return columnAdaptor(\n {\n chart,\n options: {\n ...options,\n label,\n // switch xField and yField\n xField: yField,\n yField: xField,\n xAxis: yAxis,\n yAxis: xAxis,\n // rename attrs as column\n columnStyle: barStyle,\n columnWidthRatio: barWidthRatio,\n minColumnWidth: minBarWidth,\n maxColumnWidth: maxBarWidth,\n columnBackground: options.barBackground,\n // bar 调整数据顺序\n data: transformBarData(data),\n },\n },\n true\n );\n}\n"]}
1
+ {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/bar/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC;;;;GAIG;AACH,SAAS,cAAc,CAAC,MAA0B;IACxC,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,MAAM,GAA2B,OAAO,OAAlC,EAAE,MAAM,GAAmB,OAAO,OAA1B,EAAE,KAAK,GAAY,OAAO,MAAnB,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;IAEjD,IAAM,QAAQ,GAAG;QACf,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK;QACZ,GAAG,EAAE,MAAM;QACX,MAAM,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F,OAAO;YACV,yBAAyB;YACzB,WAAW,EAAE,QAAQ,EACrB,gBAAgB,EAAE,aAAa,EAC/B,cAAc,EAAE,WAAW,EAC3B,cAAc,EAAE,WAAW,EAC3B,gBAAgB,EAAE,aAAa,GAChC;KACF,EACD,IAAI,CACiB,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,MAA0B;IAChD,0BAA0B;IAC1B,OAAO,IAAI,CAAqB,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AACxG,CAAC","sourcesContent":["import { Params } from '../../core/adaptor';\nimport { tooltip } from '../../adaptor/common';\nimport { deepAssign, flow } from '../../utils';\nimport { Axis } from '../../types';\nimport { adaptor as columnAdaptor } from '../column/adaptor';\nexport { meta } from '../column/adaptor';\nimport { BarOptions } from './types';\n\n/**\n * 处理默认配置项\n * 1. switch xField、 yField\n * 2. switch xAxis、 yAxis and adjust axis.position configuration\n */\nfunction defaultOptions(params: Params<BarOptions>): Params<BarOptions> {\n const { options } = params;\n const { xField, yField, xAxis, yAxis } = options;\n\n const position = {\n left: 'bottom',\n right: 'top',\n top: 'left',\n bottom: 'right',\n };\n\n const verticalAxis =\n yAxis !== false\n ? {\n position: position[yAxis?.position || 'left'],\n ...yAxis,\n }\n : false;\n const horizontalAxis =\n xAxis !== false\n ? {\n position: position[xAxis?.position || 'bottom'],\n ...xAxis,\n }\n : false;\n\n return {\n ...params,\n options: {\n ...options,\n xField: yField,\n yField: xField,\n // 条形图 xAxis,yAxis 不可以做 deepAssign\n xAxis: verticalAxis as Axis,\n yAxis: horizontalAxis as Axis,\n },\n };\n}\n\n/**\n * label 适配器\n * @param params\n */\nfunction label(params: Params<BarOptions>): Params<BarOptions> {\n const { options } = params;\n const { label } = options;\n // label of bar charts default position is left, if plot has label\n if (label && !label.position) {\n label.position = 'left';\n // 配置默认的 label layout: 如果用户没有指定 layout 和 position, 则自动配置 layout\n if (!label.layout) {\n label.layout = [\n { type: 'interval-adjust-position' },\n { type: 'interval-hide-overlap' },\n { type: 'adjust-color' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ];\n }\n }\n\n return deepAssign({}, params, { options: { label } });\n}\n\n/**\n * legend 适配器\n * @param params\n */\nfunction legend(params: Params<BarOptions>): Params<BarOptions> {\n const { options } = params;\n\n // 默认 legend 位置\n const { seriesField, isStack } = options;\n let { legend } = options;\n if (seriesField) {\n if (legend !== false) {\n legend = {\n position: isStack ? 'top-left' : 'right-top',\n ...(legend || {}),\n };\n }\n } else {\n legend = false;\n }\n\n return deepAssign({}, params, { options: { legend } });\n}\n\n/**\n * coordinate 适配器\n * @param params\n */\nfunction coordinate(params: Params<BarOptions>): Params<BarOptions> {\n const { chart } = params;\n // transpose column to bar 对角变换 & y 方向镜像变换\n chart.coordinate({ actions: [['transpose'], ['reflect', 'y']] });\n return params;\n}\n\n/**\n * 柱形图适配器\n * @param params\n */\nexport function geometry(params: Params<BarOptions>) {\n const { chart, options } = params;\n\n const { barStyle, barWidthRatio, minBarWidth, maxBarWidth, barBackground } = options;\n\n return columnAdaptor(\n {\n chart,\n options: {\n ...options,\n // rename attrs as column\n columnStyle: barStyle,\n columnWidthRatio: barWidthRatio,\n minColumnWidth: minBarWidth,\n maxColumnWidth: maxBarWidth,\n columnBackground: barBackground,\n },\n },\n true\n ) as Params<BarOptions>;\n}\n\n/**\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<BarOptions>): Params<BarOptions> {\n // flow 的方式处理所有的配置到 G2 API\n return flow<Params<BarOptions>>(defaultOptions, label, legend, tooltip, coordinate, geometry)(params);\n}\n"]}
@@ -3,7 +3,6 @@ import { Plot } from '../../core/plot';
3
3
  import { getDataWhetherPecentage } from '../../utils/transform/percent';
4
4
  import { adaptor, meta } from './adaptor';
5
5
  import { DEFAULT_OPTIONS } from './constants';
6
- import { transformBarData } from './utils';
7
6
  /**
8
7
  * 条形图
9
8
  */
@@ -31,7 +30,7 @@ var Bar = /** @class */ (function (_super) {
31
30
  var xField = options.xField, yField = options.yField, isPercent = options.isPercent;
32
31
  var switchedFieldOptions = __assign(__assign({}, options), { xField: yField, yField: xField });
33
32
  meta({ chart: chart, options: switchedFieldOptions });
34
- chart.changeData(getDataWhetherPecentage(transformBarData(data), xField, yField, xField, isPercent));
33
+ chart.changeData(getDataWhetherPecentage(data, xField, yField, xField, isPercent));
35
34
  };
36
35
  /**
37
36
  * 获取 条形图 默认配置
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/bar/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAI3C;;GAEG;AACH;IAAyB,uBAAgB;IAAzC;QAAA,qEAqCC;QA5BC,WAAW;QACK,UAAI,GAAW,KAAK,CAAC;;IA2BvC,CAAC;IApCC;;;OAGG;IACI,qBAAiB,GAAxB;QACE,OAAO,eAAe,CAAC;IACzB,CAAC;IAKD;;OAEG;IACI,wBAAU,GAAjB,UAAkB,IAAwB;QACxC,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;QACtB,IAAA,KAAqB,IAAI,EAAvB,KAAK,WAAA,EAAE,OAAO,aAAS,CAAC;QACxB,IAAA,MAAM,GAAwB,OAAO,OAA/B,EAAE,MAAM,GAAgB,OAAO,OAAvB,EAAE,SAAS,GAAK,OAAO,UAAZ,CAAa;QAC9C,IAAM,oBAAoB,yBAAQ,OAAO,KAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,CAAC;QAC5E,IAAI,CAAC,EAAE,KAAK,OAAA,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAC;QAC/C,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACvG,CAAC;IAED;;OAEG;IACO,+BAAiB,GAA3B;QACE,OAAO,GAAG,CAAC,iBAAiB,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACO,8BAAgB,GAA1B;QACE,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,UAAC;AAAD,CAAC,AArCD,CAAyB,IAAI,GAqC5B","sourcesContent":["import { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { BarOptions } from './types';\nimport { adaptor, meta } from './adaptor';\nimport { DEFAULT_OPTIONS } from './constants';\nimport { transformBarData } from './utils';\n\nexport type { BarOptions };\n\n/**\n * 条形图\n */\nexport class Bar extends Plot<BarOptions> {\n /**\n * 获取 条形图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<BarOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public readonly type: string = 'bar';\n\n /**\n * @override\n */\n public changeData(data: BarOptions['data']) {\n this.updateOption({ data });\n const { chart, options } = this;\n const { xField, yField, isPercent } = options;\n const switchedFieldOptions = { ...options, xField: yField, yField: xField };\n meta({ chart, options: switchedFieldOptions });\n chart.changeData(getDataWhetherPecentage(transformBarData(data), xField, yField, xField, isPercent));\n }\n\n /**\n * 获取 条形图 默认配置\n */\n protected getDefaultOptions() {\n return Bar.getDefaultOptions();\n }\n\n /**\n * 获取 条形图 的适配器\n */\n protected getSchemaAdaptor(): Adaptor<BarOptions> {\n return adaptor;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/bar/index.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plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { BarOptions } from './types';\nimport { adaptor, meta } from './adaptor';\nimport { DEFAULT_OPTIONS } from './constants';\n\nexport type { BarOptions };\n\n/**\n * 条形图\n */\nexport class Bar extends Plot<BarOptions> {\n /**\n * 获取 条形图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<BarOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public readonly type: string = 'bar';\n\n /**\n * @override\n */\n public changeData(data: BarOptions['data']) {\n this.updateOption({ data });\n const { chart, options } = this;\n const { xField, yField, isPercent } = options;\n const switchedFieldOptions = { ...options, xField: yField, yField: xField };\n meta({ chart, options: switchedFieldOptions });\n chart.changeData(getDataWhetherPecentage(data, xField, yField, xField, isPercent));\n }\n\n /**\n * 获取 条形图 默认配置\n */\n protected getDefaultOptions() {\n return Bar.getDefaultOptions();\n }\n\n /**\n * 获取 条形图 的适配器\n */\n protected getSchemaAdaptor(): Adaptor<BarOptions> {\n return adaptor;\n }\n}\n"]}