@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.
- package/dist/g2plot.min.js +3 -17
- package/dist/g2plot.min.js.map +1 -1
- package/esm/adaptor/geometries/area.js +2 -1
- package/esm/adaptor/geometries/area.js.map +1 -1
- package/esm/adaptor/geometries/edge.js +2 -1
- package/esm/adaptor/geometries/edge.js.map +1 -1
- package/esm/adaptor/geometries/interval.js +9 -2
- package/esm/adaptor/geometries/interval.js.map +1 -1
- package/esm/adaptor/geometries/line.js +2 -2
- package/esm/adaptor/geometries/line.js.map +1 -1
- package/esm/adaptor/geometries/point.js +2 -1
- package/esm/adaptor/geometries/point.js.map +1 -1
- package/esm/adaptor/geometries/polygon.js +2 -1
- package/esm/adaptor/geometries/polygon.js.map +1 -1
- package/esm/adaptor/geometries/schema.js +2 -1
- package/esm/adaptor/geometries/schema.js.map +1 -1
- package/esm/adaptor/pattern.d.ts +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/plots/pie/adaptor.js +8 -5
- package/esm/plots/pie/adaptor.js.map +1 -1
- package/esm/plots/sankey/layout.js +14 -3
- package/esm/plots/sankey/layout.js.map +1 -1
- package/esm/types/common.d.ts +6 -0
- package/esm/types/common.js.map +1 -1
- package/lib/adaptor/geometries/area.js +2 -1
- package/lib/adaptor/geometries/area.js.map +1 -1
- package/lib/adaptor/geometries/edge.js +2 -1
- package/lib/adaptor/geometries/edge.js.map +1 -1
- package/lib/adaptor/geometries/interval.js +9 -2
- package/lib/adaptor/geometries/interval.js.map +1 -1
- package/lib/adaptor/geometries/line.js +2 -2
- package/lib/adaptor/geometries/line.js.map +1 -1
- package/lib/adaptor/geometries/point.js +2 -1
- package/lib/adaptor/geometries/point.js.map +1 -1
- package/lib/adaptor/geometries/polygon.js +2 -1
- package/lib/adaptor/geometries/polygon.js.map +1 -1
- package/lib/adaptor/geometries/schema.js +2 -1
- package/lib/adaptor/geometries/schema.js.map +1 -1
- package/lib/adaptor/pattern.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/plots/pie/adaptor.js +8 -5
- package/lib/plots/pie/adaptor.js.map +1 -1
- package/lib/plots/sankey/layout.js +14 -3
- package/lib/plots/sankey/layout.js.map +1 -1
- package/lib/types/common.d.ts +6 -0
- package/lib/types/common.js.map +1 -1
- package/package.json +2 -1
- package/src/adaptor/geometries/area.ts +2 -1
- package/src/adaptor/geometries/edge.ts +2 -1
- package/src/adaptor/geometries/interval.ts +9 -1
- package/src/adaptor/geometries/line.ts +2 -2
- package/src/adaptor/geometries/point.ts +2 -1
- package/src/adaptor/geometries/polygon.ts +2 -1
- package/src/adaptor/geometries/schema.ts +2 -1
- package/src/index.ts +1 -1
- package/src/plots/pie/adaptor.ts +8 -5
- package/src/plots/sankey/layout.ts +34 -21
- package/src/types/common.ts +6 -0
- package/CHANGELOG.md +0 -1521
package/esm/types/common.js.map
CHANGED
|
@@ -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"]}
|
|
@@ -11,7 +11,7 @@ var base_1 = require("./base");
|
|
|
11
11
|
*/
|
|
12
12
|
function area(params) {
|
|
13
13
|
var options = params.options;
|
|
14
|
-
var area = options.area, xField = options.xField, yField = options.yField, seriesField = options.seriesField, smooth = options.smooth, tooltip = options.tooltip;
|
|
14
|
+
var area = options.area, xField = options.xField, yField = options.yField, seriesField = options.seriesField, smooth = options.smooth, tooltip = options.tooltip, useDeferredLabel = options.useDeferredLabel;
|
|
15
15
|
var _a = tooltip_1.getTooltipMapping(tooltip, [xField, yField, seriesField]), fields = _a.fields, formatter = _a.formatter;
|
|
16
16
|
// 如果存在才处理
|
|
17
17
|
return area
|
|
@@ -21,6 +21,7 @@ function area(params) {
|
|
|
21
21
|
colorField: seriesField,
|
|
22
22
|
tooltipFields: fields,
|
|
23
23
|
mapping: tslib_1.__assign({ shape: smooth ? 'smooth' : 'area', tooltip: formatter }, area),
|
|
24
|
+
args: { useDeferredLabel: useDeferredLabel },
|
|
24
25
|
},
|
|
25
26
|
}))
|
|
26
27
|
: params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"area.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/area.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAenE;;;GAGG;AACH,SAAgB,IAAI,CAAgC,MAAiB;IAC3D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,IAAI,
|
|
1
|
+
{"version":3,"file":"area.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/area.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAenE;;;GAGG;AACH,SAAgB,IAAI,CAAgC,MAAiB;IAC3D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,IAAI,GAAqE,OAAO,KAA5E,EAAE,MAAM,GAA6D,OAAO,OAApE,EAAE,MAAM,GAAqD,OAAO,OAA5D,EAAE,WAAW,GAAwC,OAAO,YAA/C,EAAE,MAAM,GAAgC,OAAO,OAAvC,EAAE,OAAO,GAAuB,OAAO,QAA9B,EAAE,gBAAgB,GAAK,OAAO,iBAAZ,CAAa;IAEnF,IAAA,KAAwB,2BAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAA/E,MAAM,YAAA,EAAE,SAAS,eAA8D,CAAC;IAExF,UAAU;IACV,OAAO,IAAI;QACT,CAAC,CAAC,eAAQ,CACN,kBAAU,CAAC,EAAE,EAAE,MAAM,EAAE;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;gBACZ,UAAU,EAAE,WAAW;gBACvB,aAAa,EAAE,MAAM;gBACrB,OAAO,qBACL,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EACjC,OAAO,EAAE,SAAS,IACf,IAAI,CACR;gBACD,IAAI,EAAE,EAAE,gBAAgB,kBAAA,EAAE;aAC3B;SACF,CAAC,CACH;QACH,CAAC,CAAC,MAAM,CAAC;AACb,CAAC;AAxBD,oBAwBC","sourcesContent":["import { Params } from '../../core/adaptor';\nimport { getTooltipMapping } from '../../utils/tooltip';\nimport { deepAssign } from '../../utils';\nimport { GeometryOptions, geometry, MappingOptions } from './base';\n\nexport interface AreaGeometryOptions extends GeometryOptions {\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly seriesField?: string;\n /** 是否平滑 */\n readonly smooth?: boolean;\n /** area 图形的样式设置 */\n readonly area?: MappingOptions;\n}\n\n/**\n * area geometry 的配置处理\n * @param params\n */\nexport function area<O extends AreaGeometryOptions>(params: Params<O>): Params<O> {\n const { options } = params;\n const { area, xField, yField, seriesField, smooth, tooltip, useDeferredLabel } = options;\n\n const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);\n\n // 如果存在才处理\n return area\n ? geometry(\n deepAssign({}, params, {\n options: {\n type: 'area',\n colorField: seriesField,\n tooltipFields: fields,\n mapping: {\n shape: smooth ? 'smooth' : 'area',\n tooltip: formatter,\n ...area,\n },\n args: { useDeferredLabel },\n },\n })\n )\n : params;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ var base_1 = require("./base");
|
|
|
11
11
|
*/
|
|
12
12
|
function edge(params) {
|
|
13
13
|
var options = params.options;
|
|
14
|
-
var edge = options.edge, xField = options.xField, yField = options.yField, seriesField = options.seriesField, tooltip = options.tooltip;
|
|
14
|
+
var edge = options.edge, xField = options.xField, yField = options.yField, seriesField = options.seriesField, tooltip = options.tooltip, useDeferredLabel = options.useDeferredLabel;
|
|
15
15
|
var _a = tooltip_1.getTooltipMapping(tooltip, [xField, yField, seriesField]), fields = _a.fields, formatter = _a.formatter;
|
|
16
16
|
return edge
|
|
17
17
|
? base_1.geometry(utils_1.deepAssign({}, params, {
|
|
@@ -20,6 +20,7 @@ function edge(params) {
|
|
|
20
20
|
colorField: seriesField,
|
|
21
21
|
tooltipFields: fields,
|
|
22
22
|
mapping: tslib_1.__assign({ tooltip: formatter }, edge),
|
|
23
|
+
args: { useDeferredLabel: useDeferredLabel },
|
|
23
24
|
},
|
|
24
25
|
}))
|
|
25
26
|
: params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/edge.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAanE;;;GAGG;AACH,SAAgB,IAAI,CAAgC,MAAiB;IAC3D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,IAAI,
|
|
1
|
+
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/edge.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAanE;;;GAGG;AACH,SAAgB,IAAI,CAAgC,MAAiB;IAC3D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,IAAI,GAA6D,OAAO,KAApE,EAAE,MAAM,GAAqD,OAAO,OAA5D,EAAE,MAAM,GAA6C,OAAO,OAApD,EAAE,WAAW,GAAgC,OAAO,YAAvC,EAAE,OAAO,GAAuB,OAAO,QAA9B,EAAE,gBAAgB,GAAK,OAAO,iBAAZ,CAAa;IAE3E,IAAA,KAAwB,2BAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAA/E,MAAM,YAAA,EAAE,SAAS,eAA8D,CAAC;IAExF,OAAO,IAAI;QACT,CAAC,CAAC,eAAQ,CACN,kBAAU,CAAC,EAAE,EAAE,MAAM,EAAE;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;gBACZ,UAAU,EAAE,WAAW;gBACvB,aAAa,EAAE,MAAM;gBACrB,OAAO,qBACL,OAAO,EAAE,SAAS,IACf,IAAI,CACR;gBACD,IAAI,EAAE,EAAE,gBAAgB,kBAAA,EAAE;aAC3B;SACF,CAAC,CACH;QACH,CAAC,CAAC,MAAM,CAAC;AACb,CAAC;AAtBD,oBAsBC","sourcesContent":["import { Params } from '../../core/adaptor';\nimport { getTooltipMapping } from '../../utils/tooltip';\nimport { deepAssign } from '../../utils';\nimport { geometry, MappingOptions, GeometryOptions } from './base';\n\nexport interface EdgeGeometryOptions extends GeometryOptions {\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组颜色字段 */\n readonly seriesField?: string;\n /** edge 图形映射规则 */\n readonly edge?: MappingOptions;\n}\n\n/**\n * edge 的配置处理\n * @param params\n */\nexport function edge<O extends EdgeGeometryOptions>(params: Params<O>): Params<O> {\n const { options } = params;\n const { edge, xField, yField, seriesField, tooltip, useDeferredLabel } = options;\n\n const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);\n\n return edge\n ? geometry(\n deepAssign({}, params, {\n options: {\n type: 'edge',\n colorField: seriesField,\n tooltipFields: fields,\n mapping: {\n tooltip: formatter,\n ...edge,\n },\n args: { useDeferredLabel },\n },\n })\n )\n : params;\n}\n"]}
|
|
@@ -50,7 +50,7 @@ function otherAdaptor(params) {
|
|
|
50
50
|
}
|
|
51
51
|
function interval(params) {
|
|
52
52
|
var options = params.options;
|
|
53
|
-
var xField = options.xField, yField = options.yField, interval = options.interval, seriesField = options.seriesField, tooltip = options.tooltip, minColumnWidth = options.minColumnWidth, maxColumnWidth = options.maxColumnWidth, columnBackground = options.columnBackground, dodgePadding = options.dodgePadding, intervalPadding = options.intervalPadding;
|
|
53
|
+
var xField = options.xField, yField = options.yField, interval = options.interval, seriesField = options.seriesField, tooltip = options.tooltip, minColumnWidth = options.minColumnWidth, maxColumnWidth = options.maxColumnWidth, columnBackground = options.columnBackground, dodgePadding = options.dodgePadding, intervalPadding = options.intervalPadding, useDeferredLabel = options.useDeferredLabel;
|
|
54
54
|
var _a = tooltip_1.getTooltipMapping(tooltip, [xField, yField, seriesField]), fields = _a.fields, formatter = _a.formatter;
|
|
55
55
|
// 保障一定要存在 interval 映射
|
|
56
56
|
var ext = (interval
|
|
@@ -60,7 +60,14 @@ function interval(params) {
|
|
|
60
60
|
colorField: seriesField,
|
|
61
61
|
tooltipFields: fields,
|
|
62
62
|
mapping: tslib_1.__assign({ tooltip: formatter }, interval),
|
|
63
|
-
args: {
|
|
63
|
+
args: {
|
|
64
|
+
dodgePadding: dodgePadding,
|
|
65
|
+
intervalPadding: intervalPadding,
|
|
66
|
+
minColumnWidth: minColumnWidth,
|
|
67
|
+
maxColumnWidth: maxColumnWidth,
|
|
68
|
+
background: columnBackground,
|
|
69
|
+
useDeferredLabel: useDeferredLabel,
|
|
70
|
+
},
|
|
64
71
|
},
|
|
65
72
|
}))
|
|
66
73
|
: params).ext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interval.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/interval.ts"],"names":[],"mappings":";;;;AAAA,+BAA0D;AAC1D,mCAA6C;AAE7C,qCAAyC;AACzC,+CAAwD;AACxD,+BAAmE;AAiCnE;;;GAGG;AACH,SAAS,YAAY,CAAoC,MAAiB;IAChE,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,OAAO,GAAU,MAAM,QAAhB,EAAE,GAAG,GAAK,MAAM,IAAX,CAAY;IAC/B,IAAA,WAAW,GAAmE,OAAO,YAA1E,EAAE,OAAO,GAA0D,OAAO,QAAjE,EAAE,OAAO,GAAiD,OAAO,QAAxD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AAC;AACL,CAAC;AA/CD,4BA+CC","sourcesContent":["import { Geometry, getTheme, ShapeAttrs } from '@antv/g2';\nimport { isNil, isObject } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { deepAssign } from '../../utils';\nimport { getTooltipMapping } from '../../utils/tooltip';\nimport { GeometryOptions, MappingOptions, geometry } from './base';\n\nexport interface IntervalGeometryOptions extends GeometryOptions {\n /** x 轴字段 */\n readonly xField: string;\n /** y 轴字段 */\n readonly yField: string;\n /** 拆分字段,在分组柱状图下同 groupField、colorField,在堆积柱状图下同 stackField、colorField */\n readonly seriesField?: string;\n /** 是否分组柱形图 */\n readonly isGroup?: boolean;\n /** 是否堆积柱状图 */\n readonly isStack?: boolean;\n /** 柱状图宽度占比 [0-1] */\n readonly widthRatio?: number;\n /** 分组间柱子之间的组间间距(像素级),仅对分组柱状图适用 */\n readonly intervalPadding?: number;\n /** 分组中柱子之间的间距 [0-1],仅对分组柱状图适用 */\n readonly marginRatio?: number;\n /** 分组中柱子之间的组内间距(像素级),仅对分组柱状图适用 */\n readonly dodgePadding?: number;\n /** 柱状图最小宽度(像素) */\n readonly minColumnWidth?: number;\n /** 柱状图最大宽度(像素) */\n readonly maxColumnWidth?: number;\n /** 柱子的背景样式设置 */\n readonly columnBackground?: { style: ShapeAttrs };\n /** 柱子视觉通道配置(含 color、shape、size、style、tooltip) */\n readonly interval?: MappingOptions;\n /** 分组字段,优先级高于 seriesField , isGroup: true 时会根据 groupField 进行分组。*/\n readonly groupField?: string;\n}\n\n/**\n * 柱形图其他的 adaptor\n * @param params\n */\nfunction otherAdaptor<O extends IntervalGeometryOptions>(params: Params<O>): Params<O> {\n const { chart, options, ext } = params;\n const { seriesField, isGroup, isStack, marginRatio, widthRatio, groupField, theme } = options;\n\n /**\n * adjust\n */\n const adjust = [];\n if (seriesField) {\n // group\n if (isGroup) {\n adjust.push({\n type: 'dodge',\n dodgeBy: groupField || seriesField,\n marginRatio,\n });\n }\n // stack\n if (isStack) {\n adjust.push({\n type: 'stack',\n marginRatio,\n });\n }\n }\n\n if (adjust.length && ext?.geometry) {\n const g = ext?.geometry as Geometry;\n g.adjust(adjust);\n }\n\n // widthRatio\n if (!isNil(widthRatio)) {\n chart.theme(\n deepAssign({}, isObject(theme) ? theme : getTheme(theme), {\n // columWidthRatio 配置覆盖 theme 中的配置\n columnWidthRatio: widthRatio,\n })\n );\n }\n\n return params;\n}\n\nexport function interval<O extends IntervalGeometryOptions>(params: Params<O>): Params<O> {\n const { options } = params;\n const {\n xField,\n yField,\n interval,\n seriesField,\n tooltip,\n minColumnWidth,\n maxColumnWidth,\n columnBackground,\n dodgePadding,\n intervalPadding,\n useDeferredLabel,\n } = options;\n\n const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);\n\n // 保障一定要存在 interval 映射\n const { ext } = interval\n ? geometry(\n deepAssign({}, params, {\n options: {\n type: 'interval',\n colorField: seriesField,\n tooltipFields: fields,\n mapping: {\n tooltip: formatter,\n ...interval,\n },\n args: {\n dodgePadding,\n intervalPadding,\n minColumnWidth,\n maxColumnWidth,\n background: columnBackground,\n useDeferredLabel,\n },\n },\n })\n )\n : params;\n\n return otherAdaptor({\n ...params,\n ext,\n });\n}\n"]}
|
|
@@ -11,7 +11,7 @@ var base_1 = require("./base");
|
|
|
11
11
|
*/
|
|
12
12
|
function line(params) {
|
|
13
13
|
var options = params.options;
|
|
14
|
-
var line = options.line, stepType = options.stepType, xField = options.xField, yField = options.yField, seriesField = options.seriesField, smooth = options.smooth, connectNulls = options.connectNulls, tooltip = options.tooltip;
|
|
14
|
+
var line = options.line, stepType = options.stepType, xField = options.xField, yField = options.yField, seriesField = options.seriesField, smooth = options.smooth, connectNulls = options.connectNulls, tooltip = options.tooltip, useDeferredLabel = options.useDeferredLabel;
|
|
15
15
|
var _a = tooltip_1.getTooltipMapping(tooltip, [xField, yField, seriesField]), fields = _a.fields, formatter = _a.formatter;
|
|
16
16
|
// 如果存在才处理
|
|
17
17
|
return line
|
|
@@ -24,7 +24,7 @@ function line(params) {
|
|
|
24
24
|
shape: stepType || (smooth ? 'smooth' : 'line'),
|
|
25
25
|
tooltip: formatter,
|
|
26
26
|
}, line),
|
|
27
|
-
args: { connectNulls: connectNulls },
|
|
27
|
+
args: { connectNulls: connectNulls, useDeferredLabel: useDeferredLabel },
|
|
28
28
|
},
|
|
29
29
|
}))
|
|
30
30
|
: params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/line.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAmBnE;;;GAGG;AACH,SAAgB,IAAI,CAAgC,MAAiB;IAC3D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,IAAI,
|
|
1
|
+
{"version":3,"file":"line.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/line.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAmBnE;;;GAGG;AACH,SAAgB,IAAI,CAAgC,MAAiB;IAC3D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,IAAI,GAA6F,OAAO,KAApG,EAAE,QAAQ,GAAmF,OAAO,SAA1F,EAAE,MAAM,GAA2E,OAAO,OAAlF,EAAE,MAAM,GAAmE,OAAO,OAA1E,EAAE,WAAW,GAAsD,OAAO,YAA7D,EAAE,MAAM,GAA8C,OAAO,OAArD,EAAE,YAAY,GAAgC,OAAO,aAAvC,EAAE,OAAO,GAAuB,OAAO,QAA9B,EAAE,gBAAgB,GAAK,OAAO,iBAAZ,CAAa;IAE3G,IAAA,KAAwB,2BAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAA/E,MAAM,YAAA,EAAE,SAAS,eAA8D,CAAC;IAExF,UAAU;IACV,OAAO,IAAI;QACT,CAAC,CAAC,eAAQ,CACN,kBAAU,CAAC,EAAE,EAAE,MAAM,EAAE;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;gBACZ,UAAU,EAAE,WAAW;gBACvB,aAAa,EAAE,MAAM;gBACrB,OAAO,EAAE,cAAO,CACd;oBACE,KAAK,EAAE,QAAQ,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;oBAC/C,OAAO,EAAE,SAAS;iBACnB,EACD,IAAI,CACL;gBACD,IAAI,EAAE,EAAE,YAAY,cAAA,EAAE,gBAAgB,kBAAA,EAAE;aACzC;SACF,CAAC,CACH;QACH,CAAC,CAAC,MAAM,CAAC;AACb,CAAC;AA1BD,oBA0BC","sourcesContent":["import { deepMix } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { getTooltipMapping } from '../../utils/tooltip';\nimport { deepAssign } from '../../utils';\nimport { GeometryOptions, geometry, MappingOptions } from './base';\n\nexport interface LineGeometryOptions extends GeometryOptions {\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly seriesField?: string;\n /** 是否平滑 */\n readonly smooth?: boolean;\n /** 是否连接空数据 */\n readonly connectNulls?: boolean;\n /** line 映射配置 */\n readonly line?: MappingOptions;\n /** 阶梯折线图类型 */\n readonly stepType?: string;\n}\n\n/**\n * line 辅助点的配置处理\n * @param params\n */\nexport function line<O extends LineGeometryOptions>(params: Params<O>): Params<O> {\n const { options } = params;\n const { line, stepType, xField, yField, seriesField, smooth, connectNulls, tooltip, useDeferredLabel } = options;\n\n const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);\n\n // 如果存在才处理\n return line\n ? geometry(\n deepAssign({}, params, {\n options: {\n type: 'line',\n colorField: seriesField,\n tooltipFields: fields,\n mapping: deepMix(\n {\n shape: stepType || (smooth ? 'smooth' : 'line'),\n tooltip: formatter,\n },\n line\n ),\n args: { connectNulls, useDeferredLabel },\n },\n })\n )\n : params;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ var base_1 = require("./base");
|
|
|
11
11
|
*/
|
|
12
12
|
function point(params) {
|
|
13
13
|
var options = params.options;
|
|
14
|
-
var point = options.point, xField = options.xField, yField = options.yField, seriesField = options.seriesField, sizeField = options.sizeField, shapeField = options.shapeField, tooltip = options.tooltip;
|
|
14
|
+
var point = options.point, xField = options.xField, yField = options.yField, seriesField = options.seriesField, sizeField = options.sizeField, shapeField = options.shapeField, tooltip = options.tooltip, useDeferredLabel = options.useDeferredLabel;
|
|
15
15
|
var _a = tooltip_1.getTooltipMapping(tooltip, [xField, yField, seriesField, sizeField, shapeField]), fields = _a.fields, formatter = _a.formatter;
|
|
16
16
|
return point
|
|
17
17
|
? base_1.geometry(utils_1.deepAssign({}, params, {
|
|
@@ -21,6 +21,7 @@ function point(params) {
|
|
|
21
21
|
shapeField: shapeField,
|
|
22
22
|
tooltipFields: fields,
|
|
23
23
|
mapping: tslib_1.__assign({ tooltip: formatter }, point),
|
|
24
|
+
args: { useDeferredLabel: useDeferredLabel },
|
|
24
25
|
},
|
|
25
26
|
}))
|
|
26
27
|
: params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/point.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAiBnE;;;GAGG;AACH,SAAgB,KAAK,CAAiC,MAAiB;IAC7D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,KAAK,
|
|
1
|
+
{"version":3,"file":"point.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/point.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAiBnE;;;GAGG;AACH,SAAgB,KAAK,CAAiC,MAAiB;IAC7D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,KAAK,GAAoF,OAAO,MAA3F,EAAE,MAAM,GAA4E,OAAO,OAAnF,EAAE,MAAM,GAAoE,OAAO,OAA3E,EAAE,WAAW,GAAuD,OAAO,YAA9D,EAAE,SAAS,GAA4C,OAAO,UAAnD,EAAE,UAAU,GAAgC,OAAO,WAAvC,EAAE,OAAO,GAAuB,OAAO,QAA9B,EAAE,gBAAgB,GAAK,OAAO,iBAAZ,CAAa;IAEnG,IAAA,KAAwB,2BAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,EAAtG,MAAM,YAAA,EAAE,SAAS,eAAqF,CAAC;IAE/G,OAAO,KAAK;QACV,CAAC,CAAC,eAAQ,CACN,kBAAU,CAAC,EAAE,EAAE,MAAM,EAAE;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,OAAO;gBACb,UAAU,EAAE,WAAW;gBACvB,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,MAAM;gBACrB,OAAO,qBACL,OAAO,EAAE,SAAS,IACf,KAAK,CACT;gBACD,IAAI,EAAE,EAAE,gBAAgB,kBAAA,EAAE;aAC3B;SACF,CAAC,CACH;QACH,CAAC,CAAC,MAAM,CAAC;AACb,CAAC;AAvBD,sBAuBC","sourcesContent":["import { Params } from '../../core/adaptor';\nimport { getTooltipMapping } from '../../utils/tooltip';\nimport { deepAssign } from '../../utils';\nimport { geometry, MappingOptions, GeometryOptions } from './base';\n\nexport interface PointGeometryOptions extends GeometryOptions {\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly seriesField?: string;\n /** size 映射字段 */\n readonly sizeField?: string;\n /** shape 的映射字段 */\n readonly shapeField?: string;\n /** point 图形映射规则 */\n readonly point?: MappingOptions;\n}\n\n/**\n * point 辅助点的配置处理\n * @param params\n */\nexport function point<O extends PointGeometryOptions>(params: Params<O>): Params<O> {\n const { options } = params;\n const { point, xField, yField, seriesField, sizeField, shapeField, tooltip, useDeferredLabel } = options;\n\n const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField, sizeField, shapeField]);\n\n return point\n ? geometry(\n deepAssign({}, params, {\n options: {\n type: 'point',\n colorField: seriesField,\n shapeField: shapeField,\n tooltipFields: fields,\n mapping: {\n tooltip: formatter,\n ...point,\n },\n args: { useDeferredLabel },\n },\n })\n )\n : params;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ var base_1 = require("./base");
|
|
|
11
11
|
*/
|
|
12
12
|
function polygon(params) {
|
|
13
13
|
var options = params.options;
|
|
14
|
-
var polygon = options.polygon, xField = options.xField, yField = options.yField, seriesField = options.seriesField, tooltip = options.tooltip;
|
|
14
|
+
var polygon = options.polygon, xField = options.xField, yField = options.yField, seriesField = options.seriesField, tooltip = options.tooltip, useDeferredLabel = options.useDeferredLabel;
|
|
15
15
|
var _a = tooltip_1.getTooltipMapping(tooltip, [xField, yField, seriesField]), fields = _a.fields, formatter = _a.formatter;
|
|
16
16
|
return polygon
|
|
17
17
|
? base_1.geometry(utils_1.deepAssign({}, params, {
|
|
@@ -20,6 +20,7 @@ function polygon(params) {
|
|
|
20
20
|
colorField: seriesField,
|
|
21
21
|
tooltipFields: fields,
|
|
22
22
|
mapping: tslib_1.__assign({ tooltip: formatter }, polygon),
|
|
23
|
+
args: { useDeferredLabel: useDeferredLabel },
|
|
23
24
|
},
|
|
24
25
|
}))
|
|
25
26
|
: params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/polygon.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAanE;;;GAGG;AACH,SAAgB,OAAO,CAAmC,MAAiB;IACjE,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/polygon.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAanE;;;GAGG;AACH,SAAgB,OAAO,CAAmC,MAAiB;IACjE,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,OAAO,GAA6D,OAAO,QAApE,EAAE,MAAM,GAAqD,OAAO,OAA5D,EAAE,MAAM,GAA6C,OAAO,OAApD,EAAE,WAAW,GAAgC,OAAO,YAAvC,EAAE,OAAO,GAAuB,OAAO,QAA9B,EAAE,gBAAgB,GAAK,OAAO,iBAAZ,CAAa;IAE9E,IAAA,KAAwB,2BAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAA/E,MAAM,YAAA,EAAE,SAAS,eAA8D,CAAC;IAExF,OAAO,OAAO;QACZ,CAAC,CAAC,eAAQ,CACN,kBAAU,CAAC,EAAE,EAAE,MAAM,EAAE;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE,WAAW;gBACvB,aAAa,EAAE,MAAM;gBACrB,OAAO,qBACL,OAAO,EAAE,SAAS,IACf,OAAO,CACX;gBACD,IAAI,EAAE,EAAE,gBAAgB,kBAAA,EAAE;aAC3B;SACF,CAAC,CACH;QACH,CAAC,CAAC,MAAM,CAAC;AACb,CAAC;AAtBD,0BAsBC","sourcesContent":["import { Params } from '../../core/adaptor';\nimport { getTooltipMapping } from '../../utils/tooltip';\nimport { deepAssign } from '../../utils';\nimport { geometry, MappingOptions, GeometryOptions } from './base';\n\nexport interface PolygonGeometryOptions extends GeometryOptions {\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly seriesField?: string;\n /** point 图形映射规则 */\n readonly polygon?: MappingOptions;\n}\n\n/**\n * polygon 的配置处理\n * @param params\n */\nexport function polygon<O extends PolygonGeometryOptions>(params: Params<O>): Params<O> {\n const { options } = params;\n const { polygon, xField, yField, seriesField, tooltip, useDeferredLabel } = options;\n\n const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);\n\n return polygon\n ? geometry(\n deepAssign({}, params, {\n options: {\n type: 'polygon',\n colorField: seriesField,\n tooltipFields: fields,\n mapping: {\n tooltip: formatter,\n ...polygon,\n },\n args: { useDeferredLabel },\n },\n })\n )\n : params;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ var base_1 = require("./base");
|
|
|
11
11
|
*/
|
|
12
12
|
function schema(params) {
|
|
13
13
|
var options = params.options;
|
|
14
|
-
var schema = options.schema, xField = options.xField, yField = options.yField, seriesField = options.seriesField, tooltip = options.tooltip;
|
|
14
|
+
var schema = options.schema, xField = options.xField, yField = options.yField, seriesField = options.seriesField, tooltip = options.tooltip, useDeferredLabel = options.useDeferredLabel;
|
|
15
15
|
var _a = tooltip_1.getTooltipMapping(tooltip, [xField, yField, seriesField]), fields = _a.fields, formatter = _a.formatter;
|
|
16
16
|
return schema
|
|
17
17
|
? base_1.geometry(utils_1.deepAssign({}, params, {
|
|
@@ -20,6 +20,7 @@ function schema(params) {
|
|
|
20
20
|
colorField: seriesField,
|
|
21
21
|
tooltipFields: fields,
|
|
22
22
|
mapping: tslib_1.__assign({ tooltip: formatter }, schema),
|
|
23
|
+
args: { useDeferredLabel: useDeferredLabel },
|
|
23
24
|
},
|
|
24
25
|
}))
|
|
25
26
|
: params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/schema.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAanE;;;GAGG;AACH,SAAgB,MAAM,CAAkC,MAAiB;IAC/D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/schema.ts"],"names":[],"mappings":";;;;AACA,+CAAwD;AACxD,qCAAyC;AACzC,+BAAmE;AAanE;;;GAGG;AACH,SAAgB,MAAM,CAAkC,MAAiB;IAC/D,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,MAAM,GAA6D,OAAO,OAApE,EAAE,MAAM,GAAqD,OAAO,OAA5D,EAAE,MAAM,GAA6C,OAAO,OAApD,EAAE,WAAW,GAAgC,OAAO,YAAvC,EAAE,OAAO,GAAuB,OAAO,QAA9B,EAAE,gBAAgB,GAAK,OAAO,iBAAZ,CAAa;IAE7E,IAAA,KAAwB,2BAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAA/E,MAAM,YAAA,EAAE,SAAS,eAA8D,CAAC;IAExF,OAAO,MAAM;QACX,CAAC,CAAC,eAAQ,CACN,kBAAU,CAAC,EAAE,EAAE,MAAM,EAAE;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,WAAW;gBACvB,aAAa,EAAE,MAAM;gBACrB,OAAO,qBACL,OAAO,EAAE,SAAS,IACf,MAAM,CACV;gBACD,IAAI,EAAE,EAAE,gBAAgB,kBAAA,EAAE;aAC3B;SACF,CAAC,CACH;QACH,CAAC,CAAC,MAAM,CAAC;AACb,CAAC;AAtBD,wBAsBC","sourcesContent":["import { Params } from '../../core/adaptor';\nimport { getTooltipMapping } from '../../utils/tooltip';\nimport { deepAssign } from '../../utils';\nimport { geometry, MappingOptions, GeometryOptions } from './base';\n\nexport interface SchemaGeometryOptions extends GeometryOptions {\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly seriesField?: string;\n /** point 图形映射规则 */\n readonly schema?: MappingOptions;\n}\n\n/**\n * schema 的配置处理\n * @param params\n */\nexport function schema<O extends SchemaGeometryOptions>(params: Params<O>): Params<O> {\n const { options } = params;\n const { schema, xField, yField, seriesField, tooltip, useDeferredLabel } = options;\n\n const { fields, formatter } = getTooltipMapping(tooltip, [xField, yField, seriesField]);\n\n return schema\n ? geometry(\n deepAssign({}, params, {\n options: {\n type: 'schema',\n colorField: seriesField,\n tooltipFields: fields,\n mapping: {\n tooltip: formatter,\n ...schema,\n },\n args: { useDeferredLabel },\n },\n })\n )\n : params;\n}\n"]}
|
package/lib/adaptor/pattern.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ import { Options } from '../types';
|
|
|
7
7
|
* @param key key of style property
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare function pattern(key: string): <O extends Pick<Options, "label" | "legend" | "meta" | "padding" | "animation" | "color" | "height" | "width" | "appendPadding" | "renderer" | "pixelRatio" | "autoFit" | "syncViewPadding" | "supportCSSTransform" | "limitInPlot" | "locale" | "defaultInteractions" | "localRefresh" | "theme" | "pattern" | "xAxis" | "yAxis" | "tooltip" | "slider" | "scrollbar" | "interactions" | "annotations" | "state"> = Pick<Options, "label" | "legend" | "meta" | "padding" | "animation" | "color" | "height" | "width" | "appendPadding" | "renderer" | "pixelRatio" | "autoFit" | "syncViewPadding" | "supportCSSTransform" | "limitInPlot" | "locale" | "defaultInteractions" | "localRefresh" | "theme" | "pattern" | "xAxis" | "yAxis" | "tooltip" | "slider" | "scrollbar" | "interactions" | "annotations" | "state">>(params: Params<O>) => Params<O>;
|
|
10
|
+
export declare function pattern(key: string): <O extends Pick<Options, "label" | "legend" | "meta" | "padding" | "animation" | "color" | "height" | "width" | "appendPadding" | "renderer" | "pixelRatio" | "autoFit" | "syncViewPadding" | "supportCSSTransform" | "limitInPlot" | "locale" | "defaultInteractions" | "localRefresh" | "useDeferredLabel" | "theme" | "pattern" | "xAxis" | "yAxis" | "tooltip" | "slider" | "scrollbar" | "interactions" | "annotations" | "state"> = Pick<Options, "label" | "legend" | "meta" | "padding" | "animation" | "color" | "height" | "width" | "appendPadding" | "renderer" | "pixelRatio" | "autoFit" | "syncViewPadding" | "supportCSSTransform" | "limitInPlot" | "locale" | "defaultInteractions" | "localRefresh" | "useDeferredLabel" | "theme" | "pattern" | "xAxis" | "yAxis" | "tooltip" | "slider" | "scrollbar" | "interactions" | "annotations" | "state">>(params: Params<O>) => Params<O>;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.adaptors = exports.registerLocale = exports.G2 = exports.version = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
exports.version = '2.4.
|
|
5
|
+
exports.version = '2.4.18';
|
|
6
6
|
// G2 自定义能力透出
|
|
7
7
|
var G2 = tslib_1.__importStar(require("@antv/g2"));
|
|
8
8
|
exports.G2 = G2;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,mDAA+B;AACtB,gBAAE;AAEX,QAAQ;AACR,wCAA+C;AAOtC,+FAPA,uBAAc,OAOA;AANvB,yCAA+C;AAC/C,yCAA+C;AAC/C,8BAA8B;AAC9B,uBAAc,CAAC,OAAO,EAAE,oBAAY,CAAC,CAAC;AACtC,uBAAc,CAAC,OAAO,EAAE,oBAAY,CAAC,CAAC;AAItC,WAAW;AACX,wCAA0C;AAAjC,mGAAA,SAAS,OAAA;AAElB,uBAAuB;AACvB,oCAAmC;AAA1B,4FAAA,IAAI,OAAA;AAKb,SAAS;AACT,kDAAwB;AAExB,2DAA2D;AAC3D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AAGb,2DAA2D;AAC3D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AAGb,uDAAuD;AACvD,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AAGf,yDAAyD;AACzD,mCAAkC;AAAzB,0FAAA,GAAG,OAAA;AAGZ,0DAA0D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pD,6BAA4B;AAAnB,0FAAA,GAAG,OAAA","sourcesContent":["export const version = '2.4.15';\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, addWaterWave } 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,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,mDAA+B;AACtB,gBAAE;AAEX,QAAQ;AACR,wCAA+C;AAOtC,+FAPA,uBAAc,OAOA;AANvB,yCA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B,8FAAA,KAAK,OAAA;AAGd,uCAAuC;AACvC,iCAAiD;AAAxC,6FAAA,IAAI,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAE/B,0CAA0C;AAC1C,mDAAoF;AAA3E,kGAAA,IAAI,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,kGAAA,IAAI,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,qGAAA,OAAO,OAAA;AAAE,oGAAA,MAAM,OAAA;AASrD,uCAAuC;AACvC,2CAAqG;AACxF,QAAA,QAAQ,GAAG,EAAE,KAAK,gBAAA,EAAE,MAAM,iBAAA,EAAE,OAAO,kBAAA,EAAE,UAAU,qBAAA,EAAE,WAAW,sBAAA,EAAE,KAAK,gBAAA,EAAE,SAAS,oBAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,6BAA4B;AAAnB,0FAAA,GAAG,OAAA","sourcesContent":["export const version = '2.4.18';\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, addWaterWave } 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"]}
|
package/lib/plots/pie/adaptor.js
CHANGED
|
@@ -169,11 +169,14 @@ function transformStatisticOptions(options) {
|
|
|
169
169
|
if (titleOpt_1 !== false) {
|
|
170
170
|
titleOpt_1 = utils_1.deepAssign({}, {
|
|
171
171
|
formatter: function (datum) {
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
// 交互中, datum existed.
|
|
173
|
+
var text = datum
|
|
174
|
+
? datum[colorField]
|
|
175
|
+
: !util_1.isNil(titleOpt_1.content)
|
|
176
|
+
? titleOpt_1.content
|
|
177
|
+
: i18n.get(['statistic', 'total']);
|
|
178
|
+
var metaFormatter = util_1.get(meta, [colorField, 'formatter']) || (function (v) { return v; });
|
|
179
|
+
return metaFormatter(text);
|
|
177
180
|
},
|
|
178
181
|
}, titleOpt_1);
|
|
179
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/pie/adaptor.ts"],"names":[],"mappings":";;;;AAAA,mCAA0G;AAE1G,+CAAmF;AACnF,sDAAmE;AACnE,uDAAoD;AACpD,iDAAgD;AAChD,4CAA8C;AAE9C,qCAA8G;AAE9G,uCAA6C;AAC7C,iCAAgE;AAChE,+CAA+C;AAG/C;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAA0B;IAClC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,IAAI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EACP,KAAK,EACL,cAAK;IACL,mBAAmB;IACnB,aAAa,EACb,WAAW,EACX,kBAAS,CACV,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAjBD,0BAiBC","sourcesContent":["import { isFunction, isString, isNil, get, isArray, isNumber, each, toString, isEmpty } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { legend, animation, theme, state, annotation } from '../../adaptor/common';\nimport { getMappingFunction } from '../../adaptor/geometries/base';\nimport { interval } from '../../adaptor/geometries';\nimport { pattern } from '../../adaptor/pattern';\nimport { getLocale } from '../../core/locale';\nimport { Interaction } from '../../types/interaction';\nimport { flow, template, transformLabel, deepAssign, renderStatistic, processIllegalData } from '../../utils';\nimport { Data, Datum } from '../../types';\nimport { DEFAULT_OPTIONS } from './contants';\nimport { adaptOffset, getTotalValue, isAllZero } from './utils';\nimport { PIE_STATISTIC } from './interactions';\nimport { PieOptions } from './types';\n\n/**\n * 字段\n * @param params\n */\nfunction geometry(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { data, angleField, colorField, color, pieStyle } = options;\n\n // 处理不合法的数据\n let processData = processIllegalData(data, angleField);\n\n if (isAllZero(processData, angleField)) {\n // 数据全 0 处理,调整 position 映射\n const percentageField = '$$percentage$$';\n processData = processData.map((d) => ({ ...d, [percentageField]: 1 / processData.length }));\n chart.data(processData);\n\n const p = deepAssign({}, params, {\n options: {\n xField: '1',\n yField: percentageField,\n seriesField: colorField,\n isStack: true,\n interval: {\n color,\n style: pieStyle,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n },\n });\n\n interval(p);\n } else {\n chart.data(processData);\n\n const p = deepAssign({}, params, {\n options: {\n xField: '1',\n yField: angleField,\n seriesField: colorField,\n isStack: true,\n interval: {\n color,\n style: pieStyle,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n },\n });\n\n interval(p);\n }\n\n return params;\n}\n\n/**\n * meta 配置\n * @param params\n */\nfunction meta(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { meta, colorField } = options;\n\n // meta 直接是 scale 的信息\n const scales = deepAssign({}, meta);\n chart.scale(scales, {\n [colorField]: { type: 'cat' },\n });\n\n return params;\n}\n\n/**\n * coord 配置\n * @param params\n */\nfunction coordinate(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { radius, innerRadius, startAngle, endAngle } = options;\n\n chart.coordinate({\n type: 'theta',\n cfg: {\n radius,\n innerRadius,\n startAngle,\n endAngle,\n },\n });\n\n return params;\n}\n\n/**\n * label 配置\n * @param params\n */\nfunction label(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { label, colorField, angleField } = options;\n\n const geometry = chart.geometries[0];\n // label 为 false, 空 则不显示 label\n if (!label) {\n geometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n const labelCfg = transformLabel(cfg);\n\n // ① 提供模板字符串的 label content 配置\n if (labelCfg.content) {\n const { content } = labelCfg;\n labelCfg.content = (data: object, dataum: any, index: number) => {\n const name = data[colorField];\n const value = data[angleField];\n // dymatic get scale, scale is ready this time\n const angleScale = chart.getScaleByField(angleField);\n const percent = angleScale?.scale(value);\n return isFunction(content)\n ? // append percent (number) to data, users can get origin data from `dataum._origin`\n content({ ...data, percent }, dataum, index)\n : isString(content)\n ? template(content as string, {\n value,\n name,\n // percentage (string), default keep 2\n percentage: isNumber(percent) && !isNil(value) ? `${(percent * 100).toFixed(2)}%` : null,\n })\n : content;\n };\n }\n\n const LABEL_LAYOUT_TYPE_MAP = {\n inner: '',\n outer: 'pie-outer',\n spider: 'pie-spider',\n };\n const labelLayoutType = labelCfg.type ? LABEL_LAYOUT_TYPE_MAP[labelCfg.type] : 'pie-outer';\n const labelLayoutCfg = labelCfg.layout ? (!isArray(labelCfg.layout) ? [labelCfg.layout] : labelCfg.layout) : [];\n labelCfg.layout = (labelLayoutType ? [{ type: labelLayoutType }] : []).concat(labelLayoutCfg);\n\n geometry.label({\n // fix: could not create scale, when field is undefined(attributes 中的 fields 定义都会被用来创建 scale)\n fields: colorField ? [angleField, colorField] : [angleField],\n callback,\n cfg: {\n ...labelCfg,\n offset: adaptOffset(labelCfg.type, labelCfg.offset),\n type: 'pie',\n },\n });\n }\n return params;\n}\n\n/**\n * statistic options 处理\n * 1. 默认继承 default options 的样式\n * 2. 默认使用 meta 的 formatter\n */\nexport function transformStatisticOptions(options: PieOptions): PieOptions {\n const { innerRadius, statistic, angleField, colorField, meta, locale } = options;\n\n const i18n = getLocale(locale);\n\n if (innerRadius && statistic) {\n let { title: titleOpt, content: contentOpt } = deepAssign({}, DEFAULT_OPTIONS.statistic, statistic);\n if (titleOpt !== false) {\n titleOpt = deepAssign(\n {},\n {\n formatter: (datum: Datum) => {\n // 交互中\n if (datum) {\n return datum[colorField];\n }\n return !isNil(titleOpt.content) ? titleOpt.content : i18n.get(['statistic', 'total']);\n },\n },\n titleOpt\n );\n }\n if (contentOpt !== false) {\n contentOpt = deepAssign(\n {},\n {\n formatter: (datum: Datum, data: Data) => {\n const dataValue = datum ? datum[angleField] : getTotalValue(data, angleField);\n const metaFormatter = get(meta, [angleField, 'formatter']) || ((v) => v);\n // 交互中\n if (datum) {\n return metaFormatter(dataValue);\n }\n return !isNil(contentOpt.content) ? contentOpt.content : metaFormatter(dataValue);\n },\n },\n contentOpt\n );\n }\n\n return deepAssign({}, { statistic: { title: titleOpt, content: contentOpt } }, options);\n }\n return options;\n}\n\n/**\n * statistic 中心文本配置\n * @param params\n */\nexport function pieAnnotation(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { innerRadius, statistic } = transformStatisticOptions(options);\n // 先清空标注,再重新渲染\n chart.getController('annotation').clear(true);\n\n // 先进行其他 annotations,再去渲染统计文本\n flow(annotation())(params);\n\n /** 中心文本 指标卡 */\n if (innerRadius && statistic) {\n renderStatistic(chart, { statistic, plotType: 'pie' });\n }\n\n return params;\n}\n\n/**\n * 饼图 tooltip 配置\n * 1. 强制 tooltip.shared 为 false\n * @param params\n */\nfunction tooltip(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { tooltip, colorField, angleField, data } = options;\n\n if (tooltip === false) {\n chart.tooltip(tooltip);\n } else {\n chart.tooltip(deepAssign({}, tooltip, { shared: false }));\n\n // 主要解决 all zero, 对于非 all zero 不再适用\n if (isAllZero(data, angleField)) {\n let fields = get(tooltip, 'fields');\n let formatter = get(tooltip, 'formatter');\n\n if (isEmpty(get(tooltip, 'fields'))) {\n fields = [colorField, angleField];\n formatter = formatter || ((datum) => ({ name: datum[colorField], value: toString(datum[angleField]) }));\n }\n chart.geometries[0].tooltip(fields.join('*'), getMappingFunction(fields, formatter));\n }\n }\n\n return params;\n}\n\n/**\n * Interaction 配置 (饼图特殊的 interaction, 中心文本变更的时候,需要将一些配置参数传进去)\n * @param params\n */\nexport function interaction(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { interactions, statistic, annotations } = transformStatisticOptions(options);\n\n each(interactions, (i: Interaction) => {\n if (i.enable === false) {\n chart.removeInteraction(i.type);\n } else if (i.type === 'pie-statistic-active') {\n // 只针对 start 阶段的配置,进行添加参数信息\n let startStages = [];\n if (!i.cfg?.start) {\n startStages = [\n {\n trigger: 'element:mouseenter',\n action: `${PIE_STATISTIC}:change`,\n arg: { statistic, annotations },\n },\n ];\n }\n each(i.cfg?.start, (stage) => {\n startStages.push({ ...stage, arg: { statistic, annotations } });\n });\n chart.interaction(i.type, deepAssign({}, i.cfg, { start: startStages }));\n } else {\n chart.interaction(i.type, i.cfg || {});\n }\n });\n\n return params;\n}\n\n/**\n * 饼图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<PieOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow<Params<PieOptions>>(\n pattern('pieStyle'),\n geometry,\n meta,\n theme,\n coordinate,\n legend,\n tooltip,\n label,\n state,\n /** 指标卡中心文本 放在下层 */\n pieAnnotation,\n interaction,\n animation\n )(params);\n}\n"]}
|
|
1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,EAAE,WAAW,aAAA,EAAE,IAAG,CAAC;YAClE,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,kBAAU,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,aAAW,EAAE,CAAC,CAAC,CAAC;SAC1E;aAAM;YACL,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;SACxC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AA7BD,kCA6BC;AAED;;;;GAIG;AACH,SAAgB,OAAO,CAAC,MAA0B;IAChD,0BAA0B;IAC1B,OAAO,YAAI,CACT,iBAAO,CAAC,UAAU,CAAC,EACnB,QAAQ,EACR,IAAI,EACJ,cAAK,EACL,UAAU,EACV,eAAM,EACN,OAAO,EACP,KAAK,EACL,cAAK;IACL,mBAAmB;IACnB,aAAa,EACb,WAAW,EACX,kBAAS,CACV,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAjBD,0BAiBC","sourcesContent":["import { isFunction, isString, isNil, get, isArray, isNumber, each, toString, isEmpty } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { legend, animation, theme, state, annotation } from '../../adaptor/common';\nimport { getMappingFunction } from '../../adaptor/geometries/base';\nimport { interval } from '../../adaptor/geometries';\nimport { pattern } from '../../adaptor/pattern';\nimport { getLocale } from '../../core/locale';\nimport { Interaction } from '../../types/interaction';\nimport { flow, template, transformLabel, deepAssign, renderStatistic, processIllegalData } from '../../utils';\nimport { Data, Datum } from '../../types';\nimport { DEFAULT_OPTIONS } from './contants';\nimport { adaptOffset, getTotalValue, isAllZero } from './utils';\nimport { PIE_STATISTIC } from './interactions';\nimport { PieOptions } from './types';\n\n/**\n * 字段\n * @param params\n */\nfunction geometry(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { data, angleField, colorField, color, pieStyle } = options;\n\n // 处理不合法的数据\n let processData = processIllegalData(data, angleField);\n\n if (isAllZero(processData, angleField)) {\n // 数据全 0 处理,调整 position 映射\n const percentageField = '$$percentage$$';\n processData = processData.map((d) => ({ ...d, [percentageField]: 1 / processData.length }));\n chart.data(processData);\n\n const p = deepAssign({}, params, {\n options: {\n xField: '1',\n yField: percentageField,\n seriesField: colorField,\n isStack: true,\n interval: {\n color,\n style: pieStyle,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n },\n });\n\n interval(p);\n } else {\n chart.data(processData);\n\n const p = deepAssign({}, params, {\n options: {\n xField: '1',\n yField: angleField,\n seriesField: colorField,\n isStack: true,\n interval: {\n color,\n style: pieStyle,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n },\n });\n\n interval(p);\n }\n\n return params;\n}\n\n/**\n * meta 配置\n * @param params\n */\nfunction meta(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { meta, colorField } = options;\n\n // meta 直接是 scale 的信息\n const scales = deepAssign({}, meta);\n chart.scale(scales, {\n [colorField]: { type: 'cat' },\n });\n\n return params;\n}\n\n/**\n * coord 配置\n * @param params\n */\nfunction coordinate(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { radius, innerRadius, startAngle, endAngle } = options;\n\n chart.coordinate({\n type: 'theta',\n cfg: {\n radius,\n innerRadius,\n startAngle,\n endAngle,\n },\n });\n\n return params;\n}\n\n/**\n * label 配置\n * @param params\n */\nfunction label(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { label, colorField, angleField } = options;\n\n const geometry = chart.geometries[0];\n // label 为 false, 空 则不显示 label\n if (!label) {\n geometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n const labelCfg = transformLabel(cfg);\n\n // ① 提供模板字符串的 label content 配置\n if (labelCfg.content) {\n const { content } = labelCfg;\n labelCfg.content = (data: object, dataum: any, index: number) => {\n const name = data[colorField];\n const value = data[angleField];\n // dymatic get scale, scale is ready this time\n const angleScale = chart.getScaleByField(angleField);\n const percent = angleScale?.scale(value);\n return isFunction(content)\n ? // append percent (number) to data, users can get origin data from `dataum._origin`\n content({ ...data, percent }, dataum, index)\n : isString(content)\n ? template(content as string, {\n value,\n name,\n // percentage (string), default keep 2\n percentage: isNumber(percent) && !isNil(value) ? `${(percent * 100).toFixed(2)}%` : null,\n })\n : content;\n };\n }\n\n const LABEL_LAYOUT_TYPE_MAP = {\n inner: '',\n outer: 'pie-outer',\n spider: 'pie-spider',\n };\n const labelLayoutType = labelCfg.type ? LABEL_LAYOUT_TYPE_MAP[labelCfg.type] : 'pie-outer';\n const labelLayoutCfg = labelCfg.layout ? (!isArray(labelCfg.layout) ? [labelCfg.layout] : labelCfg.layout) : [];\n labelCfg.layout = (labelLayoutType ? [{ type: labelLayoutType }] : []).concat(labelLayoutCfg);\n\n geometry.label({\n // fix: could not create scale, when field is undefined(attributes 中的 fields 定义都会被用来创建 scale)\n fields: colorField ? [angleField, colorField] : [angleField],\n callback,\n cfg: {\n ...labelCfg,\n offset: adaptOffset(labelCfg.type, labelCfg.offset),\n type: 'pie',\n },\n });\n }\n return params;\n}\n\n/**\n * statistic options 处理\n * 1. 默认继承 default options 的样式\n * 2. 默认使用 meta 的 formatter\n */\nexport function transformStatisticOptions(options: PieOptions): PieOptions {\n const { innerRadius, statistic, angleField, colorField, meta, locale } = options;\n\n const i18n = getLocale(locale);\n\n if (innerRadius && statistic) {\n let { title: titleOpt, content: contentOpt } = deepAssign({}, DEFAULT_OPTIONS.statistic, statistic);\n if (titleOpt !== false) {\n titleOpt = deepAssign(\n {},\n {\n formatter: (datum: Datum) => {\n // 交互中, datum existed.\n const text = datum\n ? datum[colorField]\n : !isNil(titleOpt.content)\n ? titleOpt.content\n : i18n.get(['statistic', 'total']);\n const metaFormatter = get(meta, [colorField, 'formatter']) || ((v) => v);\n return metaFormatter(text);\n },\n },\n titleOpt\n );\n }\n if (contentOpt !== false) {\n contentOpt = deepAssign(\n {},\n {\n formatter: (datum: Datum, data: Data) => {\n const dataValue = datum ? datum[angleField] : getTotalValue(data, angleField);\n const metaFormatter = get(meta, [angleField, 'formatter']) || ((v) => v);\n // 交互中\n if (datum) {\n return metaFormatter(dataValue);\n }\n return !isNil(contentOpt.content) ? contentOpt.content : metaFormatter(dataValue);\n },\n },\n contentOpt\n );\n }\n\n return deepAssign({}, { statistic: { title: titleOpt, content: contentOpt } }, options);\n }\n return options;\n}\n\n/**\n * statistic 中心文本配置\n * @param params\n */\nexport function pieAnnotation(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { innerRadius, statistic } = transformStatisticOptions(options);\n // 先清空标注,再重新渲染\n chart.getController('annotation').clear(true);\n\n // 先进行其他 annotations,再去渲染统计文本\n flow(annotation())(params);\n\n /** 中心文本 指标卡 */\n if (innerRadius && statistic) {\n renderStatistic(chart, { statistic, plotType: 'pie' });\n }\n\n return params;\n}\n\n/**\n * 饼图 tooltip 配置\n * 1. 强制 tooltip.shared 为 false\n * @param params\n */\nfunction tooltip(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { tooltip, colorField, angleField, data } = options;\n\n if (tooltip === false) {\n chart.tooltip(tooltip);\n } else {\n chart.tooltip(deepAssign({}, tooltip, { shared: false }));\n\n // 主要解决 all zero, 对于非 all zero 不再适用\n if (isAllZero(data, angleField)) {\n let fields = get(tooltip, 'fields');\n let formatter = get(tooltip, 'formatter');\n\n if (isEmpty(get(tooltip, 'fields'))) {\n fields = [colorField, angleField];\n formatter = formatter || ((datum) => ({ name: datum[colorField], value: toString(datum[angleField]) }));\n }\n chart.geometries[0].tooltip(fields.join('*'), getMappingFunction(fields, formatter));\n }\n }\n\n return params;\n}\n\n/**\n * Interaction 配置 (饼图特殊的 interaction, 中心文本变更的时候,需要将一些配置参数传进去)\n * @param params\n */\nexport function interaction(params: Params<PieOptions>): Params<PieOptions> {\n const { chart, options } = params;\n const { interactions, statistic, annotations } = transformStatisticOptions(options);\n\n each(interactions, (i: Interaction) => {\n if (i.enable === false) {\n chart.removeInteraction(i.type);\n } else if (i.type === 'pie-statistic-active') {\n // 只针对 start 阶段的配置,进行添加参数信息\n let startStages = [];\n if (!i.cfg?.start) {\n startStages = [\n {\n trigger: 'element:mouseenter',\n action: `${PIE_STATISTIC}:change`,\n arg: { statistic, annotations },\n },\n ];\n }\n each(i.cfg?.start, (stage) => {\n startStages.push({ ...stage, arg: { statistic, annotations } });\n });\n chart.interaction(i.type, deepAssign({}, i.cfg, { start: startStages }));\n } else {\n chart.interaction(i.type, i.cfg || {});\n }\n });\n\n return params;\n}\n\n/**\n * 饼图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<PieOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow<Params<PieOptions>>(\n pattern('pieStyle'),\n geometry,\n meta,\n theme,\n coordinate,\n legend,\n tooltip,\n label,\n state,\n /** 指标卡中心文本 放在下层 */\n pieAnnotation,\n interaction,\n animation\n )(params);\n}\n"]}
|
|
@@ -58,7 +58,8 @@ function sankeyLayout(sankeyLayoutOptions, data) {
|
|
|
58
58
|
// 进行桑基图布局处理
|
|
59
59
|
var layoutData = sankeyProcessor(data);
|
|
60
60
|
// post process (x, y), etc.
|
|
61
|
-
layoutData.nodes
|
|
61
|
+
var nodes = layoutData.nodes
|
|
62
|
+
.map(function (node) {
|
|
62
63
|
var x0 = node.x0, x1 = node.x1, y0 = node.y0, y1 = node.y1;
|
|
63
64
|
/* points
|
|
64
65
|
* 3---2
|
|
@@ -67,16 +68,26 @@ function sankeyLayout(sankeyLayoutOptions, data) {
|
|
|
67
68
|
*/
|
|
68
69
|
node.x = [x0, x1, x1, x0];
|
|
69
70
|
node.y = [y0, y0, y1, y1];
|
|
71
|
+
return node;
|
|
72
|
+
})
|
|
73
|
+
.filter(function (node) {
|
|
74
|
+
return node.name !== null;
|
|
70
75
|
});
|
|
71
|
-
layoutData.links
|
|
76
|
+
var links = layoutData.links
|
|
77
|
+
.map(function (edge) {
|
|
72
78
|
var source = edge.source, target = edge.target;
|
|
73
79
|
var sx = source.x1;
|
|
74
80
|
var tx = target.x0;
|
|
75
81
|
edge.x = [sx, sx, tx, tx];
|
|
76
82
|
var offset = edge.width / 2;
|
|
77
83
|
edge.y = [edge.y0 + offset, edge.y0 - offset, edge.y1 + offset, edge.y1 - offset];
|
|
84
|
+
return edge;
|
|
85
|
+
})
|
|
86
|
+
.filter(function (edge) {
|
|
87
|
+
var source = edge.source, target = edge.target;
|
|
88
|
+
return source.name !== null && target.name !== null;
|
|
78
89
|
});
|
|
79
|
-
return
|
|
90
|
+
return { nodes: nodes, links: links };
|
|
80
91
|
}
|
|
81
92
|
exports.sankeyLayout = sankeyLayout;
|
|
82
93
|
//# sourceMappingURL=layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/plots/sankey/layout.ts"],"names":[],"mappings":";;;AAAA,mCAA0D;AAE1D,mCAAgE;AAEhE,IAAM,YAAY,GAAG;IACnB,IAAI,eAAA;IACJ,KAAK,gBAAA;IACL,MAAM,iBAAA;IACN,OAAO,kBAAA;CACR,CAAC;AAqFF;;GAEG;AACH,IAAM,eAAe,GAAiC;IACpD,MAAM,EAAE,UAAC,IAAW,IAAK,OAAA,IAAI,CAAC,KAAK,EAAV,CAAU;IACnC,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,SAAS;CACpB,CAAC;AAEF;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,SAAoB;IACvD,IAAM,IAAI,GAAG,eAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,iBAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAEtG,OAAO,IAAI,IAAI,gBAAO,CA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CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;QAElF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,MAAM,CAAC,UAAC,IAAI;QACH,IAAA,MAAM,GAAa,IAAI,OAAjB,EAAE,MAAM,GAAK,IAAI,OAAT,CAAU;QAChC,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;IACtD,CAAC,CAAC,CAAC;IAEL,OAAO,EAAE,KAAK,OAAA,EAAE,KAAK,OAAA,EAAE,CAAC;AAC1B,CAAC;AA5DD,oCA4DC","sourcesContent":["import { assign, isString, isFunction } from '@antv/util';\nimport { Datum } from '../../types';\nimport { sankey, left, right, center, justify } from './sankey';\n\nconst ALIGN_METHOD = {\n left,\n right,\n center,\n justify,\n};\n\ntype InputNode = {\n readonly name: string;\n};\n\ntype InputLink = {\n readonly source: number;\n readonly target: number;\n readonly value: number;\n};\n\ntype OutputNode = {\n readonly name: string;\n readonly x0: number;\n readonly x1: number;\n readonly y0: number;\n readonly y1: number;\n readonly depth: number;\n readonly value: number;\n\n // 用于绘制 polygon\n x: number[];\n y: number[];\n};\n\ntype OutputLink = {\n readonly source: OutputNode;\n readonly target: OutputNode;\n readonly value: number;\n readonly width: number;\n readonly y0: number;\n readonly y1: number;\n\n // 用于绘制 edge\n x?: number[];\n y?: number[];\n};\n\n/**\n * 桑基图布局的数据结构定义\n */\nexport type SankeyLayoutInputData = {\n readonly nodes: InputNode[];\n readonly links: InputLink[];\n};\n\ntype SankeyLayoutOutputData = {\n readonly nodes: OutputNode[];\n readonly links: OutputLink[];\n};\n\n/**\n * 对齐方式的类型定义\n */\nexport type NodeAlign = keyof typeof ALIGN_METHOD | Function;\n\n/**\n * 节点的 depth 自定义\n */\nexport type NodeDepth = (datum: Datum, maxDepth: number) => number;\n\n/**\n * 节点排序方法的类型定义\n */\nexport type NodeSort = (a: Datum, b: Datum) => number;\n\n/**\n * 布局参数的定义\n */\nexport type SankeyLayoutOptions = {\n readonly nodeId?: (node: Datum) => any;\n // readonly value?: (node: Datum) => any;\n // readonly source?: (edge: Datum) => any;\n // readonly target?: (edge: Datum) => any;\n // sankey.nodeSort(undefined) is the default and resorts by ascending breadth during each iteration.\n // sankey.nodeSort(null) specifies the input order of nodes and never sorts.\n // sankey.nodeSort(function) specifies the given order as a comparator function and sorts once on initialization.\n readonly nodeSort?: (a: any, b: any) => number;\n readonly nodeAlign?: NodeAlign;\n readonly nodeWidth?: number;\n readonly nodePadding?: number;\n readonly nodeDepth?: NodeDepth;\n};\n\n/**\n * 默认值\n */\nconst DEFAULT_OPTIONS: Partial<SankeyLayoutOptions> = {\n nodeId: (node: Datum) => node.index,\n nodeAlign: 'justify',\n nodeWidth: 0.008,\n nodePadding: 0.03,\n nodeSort: undefined,\n};\n\n/**\n * 获得 align function\n * @param nodeAlign\n * @param nodeDepth\n */\nexport function getNodeAlignFunction(nodeAlign: NodeAlign) {\n const func = isString(nodeAlign) ? ALIGN_METHOD[nodeAlign] : isFunction(nodeAlign) ? nodeAlign : null;\n\n return func || justify;\n}\n\nexport function getDefaultOptions(sankeyLayoutOptions: SankeyLayoutOptions) {\n return assign({}, DEFAULT_OPTIONS, sankeyLayoutOptions);\n}\n\n/**\n * 桑基图利用数据进行布局的函数,最终返回节点、边的位置(0 - 1 的信息)\n * 将会修改 data 数据\n * @param sankeyLayoutOptions\n * @param data\n */\nexport function sankeyLayout(\n sankeyLayoutOptions: SankeyLayoutOptions,\n data: SankeyLayoutInputData\n): SankeyLayoutOutputData {\n const options = getDefaultOptions(sankeyLayoutOptions);\n\n const { nodeId, nodeSort, nodeAlign, nodeWidth, nodePadding, nodeDepth } = options;\n\n const sankeyProcessor = sankey()\n // .links((d: any) => d.links)\n // .nodes((d: any) => d.nodes)\n .nodeSort(nodeSort)\n .nodeWidth(nodeWidth)\n .nodePadding(nodePadding)\n .nodeDepth(nodeDepth)\n .nodeAlign(getNodeAlignFunction(nodeAlign))\n .extent([\n [0, 0],\n [1, 1],\n ])\n .nodeId(nodeId);\n\n // 进行桑基图布局处理\n const layoutData: SankeyLayoutOutputData = sankeyProcessor(data);\n\n // post process (x, y), etc.\n const nodes = layoutData.nodes\n .map((node) => {\n const { x0, x1, y0, y1 } = node;\n /* points\n * 3---2\n * | |\n * 0---1\n */\n node.x = [x0, x1, x1, x0];\n node.y = [y0, y0, y1, y1];\n\n return node;\n })\n .filter((node) => {\n return node.name !== null;\n });\n\n const links = layoutData.links\n .map((edge) => {\n const { source, target } = edge;\n const sx = source.x1;\n const tx = target.x0;\n edge.x = [sx, sx, tx, tx];\n const offset = edge.width / 2;\n edge.y = [edge.y0 + offset, edge.y0 - offset, edge.y1 + offset, edge.y1 - offset];\n\n return edge;\n })\n .filter((edge) => {\n const { source, target } = edge;\n return source.name !== null && target.name !== null;\n });\n\n return { nodes, links };\n}\n"]}
|