@antv/g2plot 2.4.15 → 2.4.18

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 (63) hide show
  1. package/dist/g2plot.min.js +3 -17
  2. package/dist/g2plot.min.js.map +1 -1
  3. package/esm/adaptor/geometries/area.js +2 -1
  4. package/esm/adaptor/geometries/area.js.map +1 -1
  5. package/esm/adaptor/geometries/edge.js +2 -1
  6. package/esm/adaptor/geometries/edge.js.map +1 -1
  7. package/esm/adaptor/geometries/interval.js +9 -2
  8. package/esm/adaptor/geometries/interval.js.map +1 -1
  9. package/esm/adaptor/geometries/line.js +2 -2
  10. package/esm/adaptor/geometries/line.js.map +1 -1
  11. package/esm/adaptor/geometries/point.js +2 -1
  12. package/esm/adaptor/geometries/point.js.map +1 -1
  13. package/esm/adaptor/geometries/polygon.js +2 -1
  14. package/esm/adaptor/geometries/polygon.js.map +1 -1
  15. package/esm/adaptor/geometries/schema.js +2 -1
  16. package/esm/adaptor/geometries/schema.js.map +1 -1
  17. package/esm/adaptor/pattern.d.ts +1 -1
  18. package/esm/index.d.ts +1 -1
  19. package/esm/index.js +1 -1
  20. package/esm/index.js.map +1 -1
  21. package/esm/plots/pie/adaptor.js +8 -5
  22. package/esm/plots/pie/adaptor.js.map +1 -1
  23. package/esm/plots/sankey/layout.js +14 -3
  24. package/esm/plots/sankey/layout.js.map +1 -1
  25. package/esm/types/common.d.ts +6 -0
  26. package/esm/types/common.js.map +1 -1
  27. package/lib/adaptor/geometries/area.js +2 -1
  28. package/lib/adaptor/geometries/area.js.map +1 -1
  29. package/lib/adaptor/geometries/edge.js +2 -1
  30. package/lib/adaptor/geometries/edge.js.map +1 -1
  31. package/lib/adaptor/geometries/interval.js +9 -2
  32. package/lib/adaptor/geometries/interval.js.map +1 -1
  33. package/lib/adaptor/geometries/line.js +2 -2
  34. package/lib/adaptor/geometries/line.js.map +1 -1
  35. package/lib/adaptor/geometries/point.js +2 -1
  36. package/lib/adaptor/geometries/point.js.map +1 -1
  37. package/lib/adaptor/geometries/polygon.js +2 -1
  38. package/lib/adaptor/geometries/polygon.js.map +1 -1
  39. package/lib/adaptor/geometries/schema.js +2 -1
  40. package/lib/adaptor/geometries/schema.js.map +1 -1
  41. package/lib/adaptor/pattern.d.ts +1 -1
  42. package/lib/index.d.ts +1 -1
  43. package/lib/index.js +1 -1
  44. package/lib/index.js.map +1 -1
  45. package/lib/plots/pie/adaptor.js +8 -5
  46. package/lib/plots/pie/adaptor.js.map +1 -1
  47. package/lib/plots/sankey/layout.js +14 -3
  48. package/lib/plots/sankey/layout.js.map +1 -1
  49. package/lib/types/common.d.ts +6 -0
  50. package/lib/types/common.js.map +1 -1
  51. package/package.json +2 -1
  52. package/src/adaptor/geometries/area.ts +2 -1
  53. package/src/adaptor/geometries/edge.ts +2 -1
  54. package/src/adaptor/geometries/interval.ts +9 -1
  55. package/src/adaptor/geometries/line.ts +2 -2
  56. package/src/adaptor/geometries/point.ts +2 -1
  57. package/src/adaptor/geometries/polygon.ts +2 -1
  58. package/src/adaptor/geometries/schema.ts +2 -1
  59. package/src/index.ts +1 -1
  60. package/src/plots/pie/adaptor.ts +8 -5
  61. package/src/plots/sankey/layout.ts +34 -21
  62. package/src/types/common.ts +6 -0
  63. package/CHANGELOG.md +0 -1521
@@ -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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2plot",
3
- "version": "2.4.15",
3
+ "version": "2.4.18",
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",
@@ -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
  )
@@ -24,7 +24,7 @@ export interface PointGeometryOptions extends GeometryOptions {
24
24
  */
25
25
  export function point<O extends PointGeometryOptions>(params: Params<O>): Params<O> {
26
26
  const { options } = params;
27
- const { point, xField, yField, seriesField, sizeField, shapeField, tooltip } = options;
27
+ const { point, xField, yField, seriesField, sizeField, shapeField, tooltip, useDeferredLabel } = options;
28
28
 
29
29
  const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField, sizeField, shapeField]);
30
30
 
@@ -40,6 +40,7 @@ export function point<O extends PointGeometryOptions>(params: Params<O>): Params
40
40
  tooltip: formatter,
41
41
  ...point,
42
42
  },
43
+ args: { useDeferredLabel },
43
44
  },
44
45
  })
45
46
  )
@@ -20,7 +20,7 @@ export interface PolygonGeometryOptions extends GeometryOptions {
20
20
  */
21
21
  export function polygon<O extends PolygonGeometryOptions>(params: Params<O>): Params<O> {
22
22
  const { options } = params;
23
- const { polygon, xField, yField, seriesField, tooltip } = options;
23
+ const { polygon, 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 polygon<O extends PolygonGeometryOptions>(params: Params<O>): Pa
35
35
  tooltip: formatter,
36
36
  ...polygon,
37
37
  },
38
+ args: { useDeferredLabel },
38
39
  },
39
40
  })
40
41
  )
@@ -20,7 +20,7 @@ export interface SchemaGeometryOptions extends GeometryOptions {
20
20
  */
21
21
  export function schema<O extends SchemaGeometryOptions>(params: Params<O>): Params<O> {
22
22
  const { options } = params;
23
- const { schema, xField, yField, seriesField, tooltip } = options;
23
+ const { schema, 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 schema<O extends SchemaGeometryOptions>(params: Params<O>): Para
35
35
  tooltip: formatter,
36
36
  ...schema,
37
37
  },
38
+ args: { useDeferredLabel },
38
39
  },
39
40
  })
40
41
  )
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '2.4.15';
1
+ export const version = '2.4.18';
2
2
 
3
3
  // G2 自定义能力透出
4
4
  import * as G2 from '@antv/g2';
@@ -191,11 +191,14 @@ export function transformStatisticOptions(options: PieOptions): PieOptions {
191
191
  {},
192
192
  {
193
193
  formatter: (datum: Datum) => {
194
- // 交互中
195
- if (datum) {
196
- return datum[colorField];
197
- }
198
- return !isNil(titleOpt.content) ? titleOpt.content : i18n.get(['statistic', 'total']);
194
+ // 交互中, datum existed.
195
+ const text = datum
196
+ ? datum[colorField]
197
+ : !isNil(titleOpt.content)
198
+ ? titleOpt.content
199
+ : i18n.get(['statistic', 'total']);
200
+ const metaFormatter = get(meta, [colorField, 'formatter']) || ((v) => v);
201
+ return metaFormatter(text);
199
202
  },
200
203
  },
201
204
  titleOpt
@@ -150,25 +150,38 @@ export function sankeyLayout(
150
150
  const layoutData: SankeyLayoutOutputData = sankeyProcessor(data);
151
151
 
152
152
  // post process (x, y), etc.
153
- layoutData.nodes.forEach((node) => {
154
- const { x0, x1, y0, y1 } = node;
155
- /* points
156
- * 3---2
157
- * | |
158
- * 0---1
159
- */
160
- node.x = [x0, x1, x1, x0];
161
- node.y = [y0, y0, y1, y1];
162
- });
163
-
164
- layoutData.links.forEach((edge) => {
165
- const { source, target } = edge;
166
- const sx = source.x1;
167
- const tx = target.x0;
168
- edge.x = [sx, sx, tx, tx];
169
- const offset = edge.width / 2;
170
- edge.y = [edge.y0 + offset, edge.y0 - offset, edge.y1 + offset, edge.y1 - offset];
171
- });
172
-
173
- return layoutData;
153
+ const nodes = layoutData.nodes
154
+ .map((node) => {
155
+ const { x0, x1, y0, y1 } = node;
156
+ /* points
157
+ * 3---2
158
+ * | |
159
+ * 0---1
160
+ */
161
+ node.x = [x0, x1, x1, x0];
162
+ node.y = [y0, y0, y1, y1];
163
+
164
+ return node;
165
+ })
166
+ .filter((node) => {
167
+ return node.name !== null;
168
+ });
169
+
170
+ const links = layoutData.links
171
+ .map((edge) => {
172
+ const { source, target } = edge;
173
+ const sx = source.x1;
174
+ const tx = target.x0;
175
+ edge.x = [sx, sx, tx, tx];
176
+ const offset = edge.width / 2;
177
+ edge.y = [edge.y0 + offset, edge.y0 - offset, edge.y1 + offset, edge.y1 - offset];
178
+
179
+ return edge;
180
+ })
181
+ .filter((edge) => {
182
+ const { source, target } = edge;
183
+ return source.name !== null && target.name !== null;
184
+ });
185
+
186
+ return { nodes, links };
174
187
  }
@@ -147,6 +147,12 @@ export type Options = {
147
147
  * @default false
148
148
  */
149
149
  readonly supportCSSTransform?: boolean;
150
+ /**
151
+ * @title 是否开启 label 延迟渲染
152
+ * @description 开启后 label 渲染会在浏览器空闲时机执行。可制定具体 number 数值,来限定 timeout 时间 (建议开启时,指定 timeout 时间)
153
+ * @default false
154
+ */
155
+ readonly useDeferredLabel?: boolean | number;
150
156
 
151
157
  /**
152
158
  * @title 数据