@antv/g2plot 2.4.19 → 2.4.22
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/CHANGELOG.md +1626 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/dist/g2plot.min.js +2 -2
- package/dist/g2plot.min.js.map +1 -1
- package/esm/adaptor/brush.js +2 -3
- package/esm/adaptor/brush.js.map +1 -1
- package/esm/adaptor/common.js +2 -11
- package/esm/adaptor/common.js.map +1 -1
- package/esm/adaptor/geometries/base.d.ts +2 -2
- package/esm/adaptor/geometries/base.js +3 -1
- package/esm/adaptor/geometries/base.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/interactions/brush.d.ts +18 -6
- package/esm/interactions/brush.js +35 -25
- package/esm/interactions/brush.js.map +1 -1
- package/esm/plots/box/adaptor.js +2 -2
- package/esm/plots/box/adaptor.js.map +1 -1
- package/esm/plots/chord/adaptor.js +2 -13
- package/esm/plots/chord/adaptor.js.map +1 -1
- package/esm/plots/chord/constant.d.ts +4 -4
- package/esm/plots/chord/constant.js +4 -4
- package/esm/plots/chord/constant.js.map +1 -1
- package/esm/plots/column/adaptor.js +3 -1
- package/esm/plots/column/adaptor.js.map +1 -1
- package/esm/plots/facet/types.d.ts +1 -2
- package/esm/plots/facet/types.js.map +1 -1
- package/esm/plots/facet/utils.js +2 -11
- package/esm/plots/facet/utils.js.map +1 -1
- package/esm/plots/funnel/adaptor.d.ts +5 -0
- package/esm/plots/funnel/adaptor.js +31 -2
- package/esm/plots/funnel/adaptor.js.map +1 -1
- package/esm/plots/funnel/geometries/basic.d.ts +5 -0
- package/esm/plots/funnel/geometries/basic.js +8 -4
- package/esm/plots/funnel/geometries/basic.js.map +1 -1
- package/esm/plots/funnel/geometries/common.d.ts +1 -0
- package/esm/plots/funnel/geometries/common.js +5 -2
- package/esm/plots/funnel/geometries/common.js.map +1 -1
- package/esm/plots/funnel/geometries/compare.d.ts +1 -0
- package/esm/plots/funnel/geometries/compare.js +37 -30
- package/esm/plots/funnel/geometries/compare.js.map +1 -1
- package/esm/plots/funnel/index.d.ts +1 -0
- package/esm/plots/funnel/index.js +1 -0
- package/esm/plots/funnel/index.js.map +1 -1
- package/esm/plots/funnel/interactions/funnel-conversion-tag.d.ts +9 -0
- package/esm/plots/funnel/interactions/funnel-conversion-tag.js +57 -0
- package/esm/plots/funnel/interactions/funnel-conversion-tag.js.map +1 -0
- package/esm/plots/funnel/interactions/index.d.ts +5 -0
- package/esm/plots/funnel/interactions/index.js +10 -0
- package/esm/plots/funnel/interactions/index.js.map +1 -0
- package/esm/plots/funnel/types.d.ts +1 -0
- package/esm/plots/funnel/types.js.map +1 -1
- package/esm/plots/gauge/utils.js +6 -5
- package/esm/plots/gauge/utils.js.map +1 -1
- package/esm/plots/heatmap/adaptor.js +9 -11
- package/esm/plots/heatmap/adaptor.js.map +1 -1
- package/esm/plots/histogram/adaptor.js +3 -0
- package/esm/plots/histogram/adaptor.js.map +1 -1
- package/esm/plots/pie/adaptor.js +3 -1
- package/esm/plots/pie/adaptor.js.map +1 -1
- package/esm/plots/pie/types.d.ts +6 -1
- package/esm/plots/pie/types.js.map +1 -1
- package/esm/plots/progress/adaptor.js +1 -2
- package/esm/plots/progress/adaptor.js.map +1 -1
- package/esm/plots/progress/utils.d.ts +1 -0
- package/esm/plots/progress/utils.js +4 -1
- package/esm/plots/progress/utils.js.map +1 -1
- package/esm/plots/sankey/adaptor.js +2 -11
- package/esm/plots/sankey/adaptor.js.map +1 -1
- package/esm/plots/stock/utils.d.ts +3 -1
- package/esm/plots/stock/utils.js +4 -2
- package/esm/plots/stock/utils.js.map +1 -1
- package/esm/plots/violin/adaptor.js +2 -10
- package/esm/plots/violin/adaptor.js.map +1 -1
- package/esm/types/common.d.ts +4 -3
- package/esm/types/common.js.map +1 -1
- package/esm/types/interaction.d.ts +5 -0
- package/esm/types/interaction.js.map +1 -1
- package/esm/utils/conversion.js +4 -3
- package/esm/utils/conversion.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/view.d.ts +8 -1
- package/esm/utils/view.js +27 -0
- package/esm/utils/view.js.map +1 -1
- package/lib/adaptor/brush.js +2 -3
- package/lib/adaptor/brush.js.map +1 -1
- package/lib/adaptor/common.js +1 -10
- package/lib/adaptor/common.js.map +1 -1
- package/lib/adaptor/geometries/base.d.ts +2 -2
- package/lib/adaptor/geometries/base.js +3 -1
- package/lib/adaptor/geometries/base.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/interactions/brush.d.ts +18 -6
- package/lib/interactions/brush.js +35 -25
- package/lib/interactions/brush.js.map +1 -1
- package/lib/plots/box/adaptor.js +1 -1
- package/lib/plots/box/adaptor.js.map +1 -1
- package/lib/plots/chord/adaptor.js +1 -12
- package/lib/plots/chord/adaptor.js.map +1 -1
- package/lib/plots/chord/constant.d.ts +4 -4
- package/lib/plots/chord/constant.js +4 -4
- package/lib/plots/chord/constant.js.map +1 -1
- package/lib/plots/column/adaptor.js +3 -1
- package/lib/plots/column/adaptor.js.map +1 -1
- package/lib/plots/facet/types.d.ts +1 -2
- package/lib/plots/facet/types.js.map +1 -1
- package/lib/plots/facet/utils.js +1 -10
- package/lib/plots/facet/utils.js.map +1 -1
- package/lib/plots/funnel/adaptor.d.ts +5 -0
- package/lib/plots/funnel/adaptor.js +32 -2
- package/lib/plots/funnel/adaptor.js.map +1 -1
- package/lib/plots/funnel/geometries/basic.d.ts +5 -0
- package/lib/plots/funnel/geometries/basic.js +8 -3
- package/lib/plots/funnel/geometries/basic.js.map +1 -1
- package/lib/plots/funnel/geometries/common.d.ts +1 -0
- package/lib/plots/funnel/geometries/common.js +6 -3
- package/lib/plots/funnel/geometries/common.js.map +1 -1
- package/lib/plots/funnel/geometries/compare.d.ts +1 -0
- package/lib/plots/funnel/geometries/compare.js +38 -30
- package/lib/plots/funnel/geometries/compare.js.map +1 -1
- package/lib/plots/funnel/index.d.ts +1 -0
- package/lib/plots/funnel/index.js +1 -0
- package/lib/plots/funnel/index.js.map +1 -1
- package/lib/plots/funnel/interactions/funnel-conversion-tag.d.ts +9 -0
- package/lib/plots/funnel/interactions/funnel-conversion-tag.js +60 -0
- package/lib/plots/funnel/interactions/funnel-conversion-tag.js.map +1 -0
- package/lib/plots/funnel/interactions/index.d.ts +5 -0
- package/lib/plots/funnel/interactions/index.js +13 -0
- package/lib/plots/funnel/interactions/index.js.map +1 -0
- package/lib/plots/funnel/types.d.ts +1 -0
- package/lib/plots/funnel/types.js.map +1 -1
- package/lib/plots/gauge/utils.js +5 -4
- package/lib/plots/gauge/utils.js.map +1 -1
- package/lib/plots/heatmap/adaptor.js +8 -10
- package/lib/plots/heatmap/adaptor.js.map +1 -1
- package/lib/plots/histogram/adaptor.js +3 -0
- package/lib/plots/histogram/adaptor.js.map +1 -1
- package/lib/plots/pie/adaptor.js +3 -1
- package/lib/plots/pie/adaptor.js.map +1 -1
- package/lib/plots/pie/types.d.ts +6 -1
- package/lib/plots/pie/types.js.map +1 -1
- package/lib/plots/progress/adaptor.js +1 -2
- package/lib/plots/progress/adaptor.js.map +1 -1
- package/lib/plots/progress/utils.d.ts +1 -0
- package/lib/plots/progress/utils.js +4 -1
- package/lib/plots/progress/utils.js.map +1 -1
- package/lib/plots/sankey/adaptor.js +2 -11
- package/lib/plots/sankey/adaptor.js.map +1 -1
- package/lib/plots/stock/utils.d.ts +3 -1
- package/lib/plots/stock/utils.js +4 -2
- package/lib/plots/stock/utils.js.map +1 -1
- package/lib/plots/violin/adaptor.js +2 -10
- package/lib/plots/violin/adaptor.js.map +1 -1
- package/lib/types/common.d.ts +4 -3
- package/lib/types/common.js.map +1 -1
- package/lib/types/interaction.d.ts +5 -0
- package/lib/types/interaction.js.map +1 -1
- package/lib/utils/conversion.js +4 -3
- package/lib/utils/conversion.js.map +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/view.d.ts +8 -1
- package/lib/utils/view.js +29 -1
- package/lib/utils/view.js.map +1 -1
- package/package.json +4 -2
- package/src/adaptor/brush.ts +2 -2
- package/src/adaptor/common.ts +2 -11
- package/src/adaptor/geometries/base.ts +5 -3
- package/src/index.ts +1 -1
- package/src/interactions/brush.ts +38 -25
- package/src/plots/box/adaptor.ts +2 -2
- package/src/plots/chord/adaptor.ts +2 -14
- package/src/plots/chord/constant.ts +4 -4
- package/src/plots/column/adaptor.ts +3 -1
- package/src/plots/facet/types.ts +1 -1
- package/src/plots/facet/utils.ts +4 -12
- package/src/plots/funnel/adaptor.ts +32 -2
- package/src/plots/funnel/geometries/basic.ts +10 -5
- package/src/plots/funnel/geometries/common.ts +6 -3
- package/src/plots/funnel/geometries/compare.ts +50 -41
- package/src/plots/funnel/index.ts +1 -0
- package/src/plots/funnel/interactions/funnel-conversion-tag.ts +57 -0
- package/src/plots/funnel/interactions/index.ts +11 -0
- package/src/plots/funnel/types.ts +1 -0
- package/src/plots/gauge/utils.ts +5 -4
- package/src/plots/heatmap/adaptor.ts +10 -11
- package/src/plots/histogram/adaptor.ts +2 -0
- package/src/plots/pie/adaptor.ts +3 -1
- package/src/plots/pie/types.ts +6 -1
- package/src/plots/progress/adaptor.ts +1 -2
- package/src/plots/progress/utils.ts +4 -1
- package/src/plots/sankey/adaptor.ts +2 -11
- package/src/plots/stock/utils.ts +4 -3
- package/src/plots/violin/adaptor.ts +2 -11
- package/src/types/common.ts +5 -3
- package/src/types/interaction.ts +6 -0
- package/src/utils/conversion.ts +6 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/view.ts +34 -1
package/esm/adaptor/brush.js
CHANGED
|
@@ -15,7 +15,6 @@ export function brushInteraction(params) {
|
|
|
15
15
|
// 设置 brush 交互
|
|
16
16
|
if (brush === null || brush === void 0 ? void 0 : brush.enabled) {
|
|
17
17
|
BRUSH_TYPES.forEach(function (type) {
|
|
18
|
-
var _a;
|
|
19
18
|
var enable = false;
|
|
20
19
|
switch (brush.type) {
|
|
21
20
|
case 'x-rect':
|
|
@@ -29,8 +28,8 @@ export function brushInteraction(params) {
|
|
|
29
28
|
break;
|
|
30
29
|
}
|
|
31
30
|
var obj = { type: type, enable: enable };
|
|
32
|
-
if (
|
|
33
|
-
obj.cfg = getInteractionCfg(type, brush.type, brush
|
|
31
|
+
if (brush) {
|
|
32
|
+
obj.cfg = getInteractionCfg(type, brush.type, brush);
|
|
34
33
|
}
|
|
35
34
|
interactions.push(obj);
|
|
36
35
|
});
|
package/esm/adaptor/brush.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brush.js","sourceRoot":"","sources":["../../src/adaptor/brush.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,kBAAkB;AAClB,OAAO,uBAAuB,CAAC;AAI/B,IAAM,WAAW,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;AAEjH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAA8B,MAAiB;IACrE,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IAEnB,IAAA,KAAK,GAAK,OAAO,MAAZ,CAAa;IAE1B,iBAAiB;IACjB,IAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,EAAE,UAAC,CAAC,IAAK,OAAA,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAA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AK,QAAQ;oBACX,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;oBACnF,MAAM;gBACR;oBACE,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;oBAC/E,MAAM;aACT;YACD,IAAM,GAAG,GAA0B,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC;YAEpD,IAAI,KAAK,EAAE;gBACT,GAAG,CAAC,GAAG,GAAG,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACtD;YACD,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,4BAA4B;QAC5B,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,MAAK,WAAW,EAAE;YACjC,YAAY,CAAC,IAAI,CAAC;gBAChB,IAAI,EAAE,eAAe;gBACrB,GAAG,EAAE;oBACH,YAAY,EAAE,KAAK,CAAC,MAAM;iBAC3B;aACF,CAAC,CAAC;SACJ;KACF;IACD,OAAO,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,YAAY,cAAA,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import { filter } from '@antv/util';\nimport { Params } from '../core/adaptor';\nimport { getInteractionCfg } from '../interactions/brush';\nimport { deepAssign } from '../utils';\nimport { Options as BaseOptions, BrushCfg, Interaction, Writable } from '../types';\n\n/** 先引入brush 交互 */\nimport '../interactions/brush';\n\ntype Options = Pick<BaseOptions, 'interactions'> & { brush?: BrushCfg };\n\nconst BRUSH_TYPES = ['brush', 'brush-x', 'brush-y', 'brush-highlight', 'brush-x-highlight', 'brush-y-highlight'];\n\n/**\n * brush 交互\n */\nexport function brushInteraction<O extends Options = Options>(params: Params<O>): Params<O> {\n const { options } = params;\n\n const { brush } = options;\n\n // 先过滤掉 brush 等交互\n const interactions = filter(options.interactions || [], (i) => BRUSH_TYPES.indexOf(i.type) === -1);\n\n // 设置 brush 交互\n if (brush?.enabled) {\n BRUSH_TYPES.forEach((type) => {\n let enable = false;\n switch (brush.type) {\n case 'x-rect':\n enable = type === (brush.action === 'highlight' ? 'brush-x-highlight' : 'brush-x');\n break;\n case 'y-rect':\n enable = type === (brush.action === 'highlight' ? 'brush-y-highlight' : 'brush-y');\n break;\n default:\n enable = type === (brush.action === 'highlight' ? 'brush-highlight' : 'brush');\n break;\n }\n const obj: Writable<Interaction> = { type, enable };\n\n if (brush) {\n obj.cfg = getInteractionCfg(type, brush.type, brush);\n }\n interactions.push(obj);\n });\n\n // 塞入 button 配置 (G2Plot 的封装)\n if (brush?.action !== 'highlight') {\n interactions.push({\n type: 'filter-action',\n cfg: {\n buttonConfig: brush.button,\n },\n });\n }\n }\n return deepAssign({}, params, { options: { interactions } });\n}\n"]}
|
package/esm/adaptor/common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __spreadArrays } from "tslib";
|
|
2
2
|
import { each, isNil, isObject } from '@antv/util';
|
|
3
3
|
import { AXIS_META_CONFIG_KEYS } from '../constant';
|
|
4
|
-
import { pick, deepAssign } from '../utils';
|
|
4
|
+
import { pick, deepAssign, addViewAnimation } from '../utils';
|
|
5
5
|
/**
|
|
6
6
|
* 通用 legend 配置, 适用于带 colorField 或 seriesField 的图表
|
|
7
7
|
* @param params
|
|
@@ -53,17 +53,8 @@ export function interaction(params) {
|
|
|
53
53
|
export function animation(params) {
|
|
54
54
|
var chart = params.chart, options = params.options;
|
|
55
55
|
var animation = options.animation;
|
|
56
|
-
// 同时设置整个 view 动画选项
|
|
57
|
-
if (typeof animation === 'boolean') {
|
|
58
|
-
chart.animate(animation);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
chart.animate(true);
|
|
62
|
-
}
|
|
63
56
|
// 所有的 Geometry 都使用同一动画(各个图形如有区别,自行覆盖)
|
|
64
|
-
|
|
65
|
-
g.animate(animation);
|
|
66
|
-
});
|
|
57
|
+
addViewAnimation(chart, animation);
|
|
67
58
|
return params;
|
|
68
59
|
}
|
|
69
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/adaptor/common.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,MAAM,CACpB,MAAiB;IAET,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,MAAM,GAA8B,OAAO,OAArC,EAAE,UAAU,GAAkB,OAAO,WAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IAEpD,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KACrB;SAAM,IAAI,UAAU,IAAI,WAAW,EAAE;QACpC,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,WAAW,EAAE,MAAM,CAAC,CAAC;KACjD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAqC,MAAiB;IACnE,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;IAE5B,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,KAAK,CAAC,OAAO,CAAC,OA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AC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC","sourcesContent":["import { Geometry, Types } from '@antv/g2';\nimport { each, isNil, isObject } from '@antv/util';\nimport { Params } from '../core/adaptor';\nimport { Options } from '../types';\nimport { Interaction } from '../types/interaction';\nimport { Transformations } from '../types/coordinate';\nimport { Axis } from '../types/axis';\nimport { AXIS_META_CONFIG_KEYS } from '../constant';\nimport { pick, deepAssign } from '../utils';\n\n/**\n * 通用 legend 配置, 适用于带 colorField 或 seriesField 的图表\n * @param params\n */\nexport function legend<O extends Pick<Options, 'legend'> & { colorField?: string; seriesField?: string }>(\n params: Params<O>\n): Params<O> {\n const { chart, options } = params;\n const { legend, colorField, seriesField } = options;\n\n if (legend === false) {\n chart.legend(false);\n } else if (colorField || seriesField) {\n chart.legend(colorField || seriesField, legend);\n }\n\n return params;\n}\n\n/**\n * 通用 tooltip 配置\n * @param params\n */\nexport function tooltip<O extends Pick<Options, 'tooltip'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { tooltip } = options;\n\n if (tooltip !== undefined) {\n chart.tooltip(tooltip);\n }\n\n return params;\n}\n\n/**\n * Interaction 配置\n * @param params\n */\nexport function interaction<O extends Pick<Options, 'interactions'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { interactions } = options;\n\n each(interactions, (i: Interaction) => {\n if (i.enable === false) {\n chart.removeInteraction(i.type);\n } else {\n chart.interaction(i.type, i.cfg || {});\n }\n });\n\n return params;\n}\n\n/**\n * 动画\n * @param params\n */\nexport function animation<O extends Pick<Options, 'animation'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { animation } = options;\n\n // 同时设置整个 view 动画选项\n if (typeof animation === 'boolean') {\n chart.animate(animation);\n } else {\n chart.animate(true);\n }\n\n // 所有的 Geometry 都使用同一动画(各个图形如有区别,自行覆盖)\n each(chart.geometries, (g: Geometry) => {\n g.animate(animation);\n });\n\n return params;\n}\n\n/**\n * 设置全局主题配置\n * @param params\n */\nexport function theme<O extends Pick<Options, 'theme'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { theme } = options;\n\n // 存在主题才设置主题\n if (theme) {\n chart.theme(theme);\n }\n return params;\n}\n\n/**\n * 状态 state 配置\n * @param params\n */\nexport function state<O extends Options>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { state } = options;\n\n if (state) {\n each(chart.geometries, (geometry: Geometry) => {\n geometry.state(state);\n });\n }\n\n return params;\n}\n\n/**\n * 处理缩略轴的 adaptor\n * @param params\n */\nexport function slider(params: Params<Options>): Params<Options> {\n const { chart, options } = params;\n const { slider } = options;\n\n chart.option('slider', slider);\n\n return params;\n}\n\n/**\n * 处理缩略轴的 adaptor\n * @param params\n */\nexport function scrollbar(params: Params<Options>): Params<Options> {\n const { chart, options } = params;\n const { scrollbar } = options;\n\n chart.option('scrollbar', scrollbar);\n\n return params;\n}\n\n/**\n * scale 的 adaptor\n * @param axes\n */\nexport function scale(axes: Record<string, Axis>, meta?: Options['meta']) {\n return function <O extends Pick<Options, 'meta'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n\n // 1. 轴配置中的 scale 信息\n let scales: Record<string, any> = {};\n each(axes, (axis: Axis, field: string) => {\n scales[field] = pick(axis, AXIS_META_CONFIG_KEYS);\n });\n\n // 2. meta 直接是 scale 的信息\n scales = deepAssign({}, meta, options.meta, scales);\n\n chart.scale(scales);\n\n return params;\n };\n}\n\n/**\n * annotation 配置\n * @param params\n */\nexport function annotation(annotationOptions?: Options['annotations']) {\n return function <O extends Pick<Options, 'annotations'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n\n const annotationController = chart.getController('annotation');\n\n /** 自定义 annotation */\n each([...(options.annotations || []), ...(annotationOptions || [])], (annotationOption) => {\n // @ts-ignore\n annotationController.annotation(annotationOption);\n });\n\n return params;\n };\n}\n\n/**\n * 自动设置 limitInPlot\n * @param params\n */\nexport function limitInPlot(params: Params<Options>): Params<Options> {\n const { chart, options } = params;\n const { yAxis, limitInPlot } = options;\n\n let value = limitInPlot;\n\n // 用户没有设置 limitInPlot,则自动根据 yAxis 是否有 min/max 来设置 limitInPlot\n if (isObject(yAxis) && isNil(limitInPlot)) {\n if (Object.values(pick(yAxis, ['min', 'max', 'minLimit', 'maxLimit'])).some((value) => !isNil(value))) {\n value = true;\n } else {\n value = false;\n }\n }\n chart.limitInPlot = value;\n\n return params;\n}\n\n/**\n * 坐标系转换\n */\nexport function transformations(coordinateType: Types.CoordinateOption['type'] = 'rect') {\n return (params: Params<Options & { coordinate: Transformations }>) => {\n const { chart, options } = params;\n const { coordinate } = options;\n\n const actions: Types.CoordinateActions[] = Array.from(coordinate || [])\n .map((cfg) => {\n if (cfg.type === 'reflectX') return ['reflect', 'x'] as Types.CoordinateActions;\n if (cfg.type === 'reflectY') return ['reflect', 'y'] as Types.CoordinateActions;\n if (cfg.type === 'transpose') return ['transpose'] as Types.CoordinateActions;\n\n return null;\n })\n .filter((d) => !!d);\n\n if (actions.length !== 0) {\n chart.coordinate({ type: coordinateType, actions });\n }\n\n return params;\n };\n}\n\nexport { pattern } from './pattern';\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/adaptor/common.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE9D;;;GAGG;AACH,MAAM,UAAU,MAAM,CACpB,MAAiB;IAET,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,MAAM,GAA8B,OAAO,OAArC,EAAE,UAAU,GAAkB,OAAO,WAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IAEpD,IAAI,MAAM,KAAK,K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CAAC,EAAH,CAAG,CAAC,CAAC;QAEtB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,KAAK,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;SACrD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC","sourcesContent":["import { Geometry, Types } from '@antv/g2';\nimport { each, isNil, isObject } from '@antv/util';\nimport { Params } from '../core/adaptor';\nimport { Options } from '../types';\nimport { Interaction } from '../types/interaction';\nimport { Transformations } from '../types/coordinate';\nimport { Axis } from '../types/axis';\nimport { AXIS_META_CONFIG_KEYS } from '../constant';\nimport { pick, deepAssign, addViewAnimation } from '../utils';\n\n/**\n * 通用 legend 配置, 适用于带 colorField 或 seriesField 的图表\n * @param params\n */\nexport function legend<O extends Pick<Options, 'legend'> & { colorField?: string; seriesField?: string }>(\n params: Params<O>\n): Params<O> {\n const { chart, options } = params;\n const { legend, colorField, seriesField } = options;\n\n if (legend === false) {\n chart.legend(false);\n } else if (colorField || seriesField) {\n chart.legend(colorField || seriesField, legend);\n }\n\n return params;\n}\n\n/**\n * 通用 tooltip 配置\n * @param params\n */\nexport function tooltip<O extends Pick<Options, 'tooltip'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { tooltip } = options;\n\n if (tooltip !== undefined) {\n chart.tooltip(tooltip);\n }\n\n return params;\n}\n\n/**\n * Interaction 配置\n * @param params\n */\nexport function interaction<O extends Pick<Options, 'interactions'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { interactions } = options;\n\n each(interactions, (i: Interaction) => {\n if (i.enable === false) {\n chart.removeInteraction(i.type);\n } else {\n chart.interaction(i.type, i.cfg || {});\n }\n });\n\n return params;\n}\n\n/**\n * 动画\n * @param params\n */\nexport function animation<O extends Pick<Options, 'animation'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { animation } = options;\n\n // 所有的 Geometry 都使用同一动画(各个图形如有区别,自行覆盖)\n addViewAnimation(chart, animation);\n\n return params;\n}\n\n/**\n * 设置全局主题配置\n * @param params\n */\nexport function theme<O extends Pick<Options, 'theme'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { theme } = options;\n\n // 存在主题才设置主题\n if (theme) {\n chart.theme(theme);\n }\n return params;\n}\n\n/**\n * 状态 state 配置\n * @param params\n */\nexport function state<O extends Options>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { state } = options;\n\n if (state) {\n each(chart.geometries, (geometry: Geometry) => {\n geometry.state(state);\n });\n }\n\n return params;\n}\n\n/**\n * 处理缩略轴的 adaptor\n * @param params\n */\nexport function slider(params: Params<Options>): Params<Options> {\n const { chart, options } = params;\n const { slider } = options;\n\n chart.option('slider', slider);\n\n return params;\n}\n\n/**\n * 处理缩略轴的 adaptor\n * @param params\n */\nexport function scrollbar(params: Params<Options>): Params<Options> {\n const { chart, options } = params;\n const { scrollbar } = options;\n\n chart.option('scrollbar', scrollbar);\n\n return params;\n}\n\n/**\n * scale 的 adaptor\n * @param axes\n */\nexport function scale(axes: Record<string, Axis>, meta?: Options['meta']) {\n return function <O extends Pick<Options, 'meta'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n\n // 1. 轴配置中的 scale 信息\n let scales: Record<string, any> = {};\n each(axes, (axis: Axis, field: string) => {\n scales[field] = pick(axis, AXIS_META_CONFIG_KEYS);\n });\n\n // 2. meta 直接是 scale 的信息\n scales = deepAssign({}, meta, options.meta, scales);\n\n chart.scale(scales);\n\n return params;\n };\n}\n\n/**\n * annotation 配置\n * @param params\n */\nexport function annotation(annotationOptions?: Options['annotations']) {\n return function <O extends Pick<Options, 'annotations'>>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n\n const annotationController = chart.getController('annotation');\n\n /** 自定义 annotation */\n each([...(options.annotations || []), ...(annotationOptions || [])], (annotationOption) => {\n // @ts-ignore\n annotationController.annotation(annotationOption);\n });\n\n return params;\n };\n}\n\n/**\n * 自动设置 limitInPlot\n * @param params\n */\nexport function limitInPlot(params: Params<Options>): Params<Options> {\n const { chart, options } = params;\n const { yAxis, limitInPlot } = options;\n\n let value = limitInPlot;\n\n // 用户没有设置 limitInPlot,则自动根据 yAxis 是否有 min/max 来设置 limitInPlot\n if (isObject(yAxis) && isNil(limitInPlot)) {\n if (Object.values(pick(yAxis, ['min', 'max', 'minLimit', 'maxLimit'])).some((value) => !isNil(value))) {\n value = true;\n } else {\n value = false;\n }\n }\n chart.limitInPlot = value;\n\n return params;\n}\n\n/**\n * 坐标系转换\n */\nexport function transformations(coordinateType: Types.CoordinateOption['type'] = 'rect') {\n return (params: Params<Options & { coordinate: Transformations }>) => {\n const { chart, options } = params;\n const { coordinate } = options;\n\n const actions: Types.CoordinateActions[] = Array.from(coordinate || [])\n .map((cfg) => {\n if (cfg.type === 'reflectX') return ['reflect', 'x'] as Types.CoordinateActions;\n if (cfg.type === 'reflectY') return ['reflect', 'y'] as Types.CoordinateActions;\n if (cfg.type === 'transpose') return ['transpose'] as Types.CoordinateActions;\n\n return null;\n })\n .filter((d) => !!d);\n\n if (actions.length !== 0) {\n chart.coordinate({ type: coordinateType, actions });\n }\n\n return params;\n };\n}\n\nexport { pattern } from './pattern';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Params } from '../../core/adaptor';
|
|
2
|
-
import { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum } from '../../types';
|
|
2
|
+
import { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum, RawFields } from '../../types';
|
|
3
3
|
import { Label } from '../../types/label';
|
|
4
4
|
import { State } from '../../types/state';
|
|
5
5
|
/**
|
|
@@ -39,7 +39,7 @@ export declare type Geometry = {
|
|
|
39
39
|
/** tooltip 的映射字段 */
|
|
40
40
|
readonly tooltipFields?: string[] | false;
|
|
41
41
|
/** 其他原始字段, 用于 mapping 回调参数 */
|
|
42
|
-
readonly rawFields?:
|
|
42
|
+
readonly rawFields?: RawFields;
|
|
43
43
|
/** 图形映射规则 */
|
|
44
44
|
readonly mapping?: MappingOptions;
|
|
45
45
|
/** label 映射通道,因为历史原因导致实现略有区别 */
|
|
@@ -7,8 +7,10 @@ import { transformLabel } from '../../utils';
|
|
|
7
7
|
* @param field
|
|
8
8
|
*/
|
|
9
9
|
export function getMappingField(o, field) {
|
|
10
|
-
var type = o.type, xField = o.xField, yField = o.yField, colorField = o.colorField, shapeField = o.shapeField, sizeField = o.sizeField, styleField = o.styleField
|
|
10
|
+
var type = o.type, xField = o.xField, yField = o.yField, colorField = o.colorField, shapeField = o.shapeField, sizeField = o.sizeField, styleField = o.styleField;
|
|
11
|
+
var rawFields = o.rawFields;
|
|
11
12
|
var fields = [];
|
|
13
|
+
rawFields = (isFunction(rawFields) ? rawFields(type, field) : rawFields) || [];
|
|
12
14
|
// 因为 color 会影响到数据分组,以及最后的图形映射。所以导致 bar 图中的 widthRatio 设置不生效
|
|
13
15
|
// 所以对于 color 字段,仅仅保留 colorField 好了! + rawFields
|
|
14
16
|
// shape, size 同理
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA0D7C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,CAAkB,EAClB,KAA2C;IAKnC,IAAA,IAAI,GAAoF,CAAC,KAArF,EAAE,MAAM,GAA4E,CAAC,OAA7E,EAAE,MAAM,GAAoE,CAAC,OAArE,EAAE,UAAU,GAAwD,CAAC,WAAzD,EAAE,UAAU,GAA4C,CAAC,WAA7C,EAAE,SAAS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O,CAAC,aAAa,CAAC,EAAE;QAClC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;KACvF;IAED;;OAEG;IACH,IAAI,KAAK,KAAK,KAAK,EAAE;QACnB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACvB;SAAM,IAAI,KAAK,EAAE;QACR,IAAA,QAAQ,GAAqB,KAAK,SAA1B,EAAE,MAAM,GAAa,KAAK,OAAlB,EAAK,GAAG,UAAK,KAAK,EAApC,sBAA4B,CAAF,CAAW;QAC3C,QAAQ,CAAC,KAAK,CAAC;YACb,MAAM,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC;YAC1B,QAAQ,UAAA;YACR,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC;SACzB,CAAC,CAAC;KACJ;IAED;;OAEG;IACH,IAAI,KAAK,EAAE;QACT,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACvB;IAED;;OAEG;IACH,IAAI,UAAU,EAAE;QACd,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;KACjC;IAED,2BAA2B;IAC3B,CAAC,MAAM,EAAE,MAAM,CAAC;SACb,MAAM,CAAC,UAAC,CAAS,IAAK,OAAA,CAAC,KAAK,UAAU,EAAhB,CAAgB,CAAC;SACvC,OAAO,CAAC,UAAC,CAAS;QACjB,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IACL,6BACK,MAAM;QACT,gFAAgF;QAChF,GAAG,EAAE,EAAE,QAAQ,UAAA,EAAE,IACjB;AACJ,CAAC","sourcesContent":["import { uniq, isFunction, isObject, isString, isNumber, isEmpty } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum } from '../../types';\nimport { Label } from '../../types/label';\nimport { State } from '../../types/state';\nimport { transformLabel } from '../../utils';\n\n/**\n * 图形映射属性,按照优先级来的\n */\nexport type MappingOptions = {\n /** color 映射 */\n readonly color?: ColorAttr;\n /** shape 映射 */\n readonly shape?: ShapeAttr;\n /** 大小映射, 提供回调的方式 */\n readonly size?: SizeAttr;\n /** 样式映射 */\n readonly style?: StyleAttr;\n /** tooltip 映射 */\n readonly tooltip?: TooltipAttr;\n};\n\n/**\n * 一个图形映射的逻辑,纯粹的图形语法\n * // TODO 后续需要处理 adjust 的配置,然后通过 field 信息。比如 styleField,labelField 等一定是一个数组形式\n */\nexport type Geometry = {\n /** geometry 类型, 'line' | 'interval' | 'point' | 'area' | 'polygon' */\n readonly type?: string;\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly colorField?: string;\n /** shape 的映射字段 */\n readonly shapeField?: string;\n /** size 映射字段 */\n readonly sizeField?: string;\n /** style 的映射字段 */\n readonly styleField?: string;\n /** tooltip 的映射字段 */\n readonly tooltipFields?: string[] | false;\n /** 其他原始字段, 用于 mapping 回调参数 */\n readonly rawFields?: string[];\n /** 图形映射规则 */\n readonly mapping?: MappingOptions;\n /** label 映射通道,因为历史原因导致实现略有区别 */\n readonly label?: Label;\n /** 不同状态的样式 */\n readonly state?: State;\n /** 自定义信息,一般在 registerShape 中使用 */\n readonly customInfo?: any;\n /** geometry params */\n readonly args?: any;\n};\n\n/**\n * geometry options\n */\nexport type GeometryOptions = Geometry & Partial<Options>;\n\n/**\n * 获得映射的字段列表\n * @param options\n * @param field\n */\nexport function getMappingField(\n o: GeometryOptions,\n field: 'color' | 'shape' | 'size' | 'style'\n): {\n mappingFields: string[];\n tileMappingField: string;\n} {\n const { type, xField, yField, colorField, shapeField, sizeField, styleField, rawFields = [] } = o;\n\n let fields = [];\n\n // 因为 color 会影响到数据分组,以及最后的图形映射。所以导致 bar 图中的 widthRatio 设置不生效\n // 所以对于 color 字段,仅仅保留 colorField 好了! + rawFields\n // shape, size 同理\n if (field === 'color') {\n fields = [colorField || xField, ...rawFields];\n } else if (field === 'shape') {\n fields = [shapeField || xField, ...rawFields];\n } else if (field === 'size') {\n fields = [sizeField || xField, ...rawFields];\n } else {\n fields = [xField, yField, colorField, shapeField, sizeField, styleField, ...rawFields];\n\n // 一定能找到的!\n const idx = ['x', 'y', 'color', 'shape', 'size', 'style'].indexOf(field);\n\n const f = fields[idx];\n // 删除当前字段\n fields.splice(idx, 1);\n // 插入到第一个\n fields.unshift(f);\n }\n\n const mappingFields = uniq(fields.filter((f) => !!f));\n /**\n * 修复 line geometry 无拆分时 color 回调错误\n * eg:\n * geometry.color(xField, ()=> '#f24')\n */\n const tileMappingField =\n type === 'line' && [xField, yField].includes(mappingFields.join('*')) ? '' : mappingFields.join('*');\n return {\n mappingFields,\n tileMappingField,\n };\n}\n\n/**\n * 获得映射函数\n * @param mappingFields\n * @param func\n */\nexport function getMappingFunction(mappingFields: string[], func: (datum: Datum) => any) {\n if (!func) return undefined;\n // 返回函数\n return (...args: any[]) => {\n const params: Datum = {};\n\n mappingFields.forEach((f: string, idx: number) => {\n params[f] = args[idx];\n });\n\n // 删除 undefined\n delete params['undefined'];\n\n return func(params);\n };\n}\n\n/**\n * 通用 geometry 的配置处理的 adaptor\n * @param params\n */\nexport function geometry<O extends GeometryOptions>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const {\n type,\n args,\n mapping,\n xField,\n yField,\n colorField,\n shapeField,\n sizeField,\n tooltipFields,\n label,\n state,\n customInfo,\n } = options;\n\n // 如果没有 mapping 信息,那么直接返回\n if (!mapping) {\n return params;\n }\n\n const { color, shape, size, style, tooltip } = mapping;\n\n // 创建 geometry\n const geometry = chart[type](args).position(`${xField}*${yField}`);\n\n /**\n * color 的几种情况\n * g.color('red');\n * g.color('color', ['red', 'blue']);\n * g.color('x', (x, y) => 'red');\n * g.color('color', (color, x, y) => 'red');\n */\n if (isString(color)) {\n colorField ? geometry.color(colorField, color) : geometry.color(color);\n } else if (isFunction(color)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'color');\n geometry.color(tileMappingField, getMappingFunction(mappingFields, color));\n } else {\n colorField && geometry.color(colorField, color);\n }\n\n /**\n * shape 的几种情况\n * g.shape('rect');\n * g.shape('shape', ['rect', 'circle']);\n * g.shape('x*y', (x, y) => 'rect');\n * g.shape('shape*x*y', (shape, x, y) => 'rect');\n */\n if (isString(shape)) {\n shapeField ? geometry.shape(shapeField, [shape]) : geometry.shape(shape); // [shape] 需要在 G2 做掉\n } else if (isFunction(shape)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'shape');\n geometry.shape(tileMappingField, getMappingFunction(mappingFields, shape));\n } else {\n shapeField && geometry.shape(shapeField, shape);\n }\n\n /**\n * size 的几种情况\n * g.size(10);\n * g.size('size', [10, 20]);\n * g.size('x*y', (x, y) => 10);\n * g.color('size*x*y', (size, x, y) => 1-);\n */\n if (isNumber(size)) {\n sizeField ? geometry.size(sizeField, size) : geometry.size(size);\n } else if (isFunction(size)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'size');\n geometry.size(tileMappingField, getMappingFunction(mappingFields, size));\n } else {\n sizeField && geometry.size(sizeField, size);\n }\n\n /**\n * style 的几种情况\n * g.style({ fill: 'red' });\n * g.style('x*y*color', (x, y, color) => ({ fill: 'red' }));\n */\n if (isFunction(style)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'style');\n geometry.style(tileMappingField, getMappingFunction(mappingFields, style));\n } else if (isObject(style)) {\n geometry.style(style);\n }\n\n /**\n * tooltip 的 API\n * g.tooltip('x*y*color', (x, y, color) => ({ name, value }));\n * g.tooltip(false);\n */\n if (tooltipFields === false) {\n geometry.tooltip(false);\n } else if (!isEmpty(tooltipFields)) {\n geometry.tooltip(tooltipFields.join('*'), getMappingFunction(tooltipFields, tooltip));\n }\n\n /**\n * label 的映射\n */\n if (label === false) {\n geometry.label(false);\n } else if (label) {\n const { callback, fields, ...cfg } = label;\n geometry.label({\n fields: fields || [yField],\n callback,\n cfg: transformLabel(cfg),\n });\n }\n\n /**\n * state 状态样式\n */\n if (state) {\n geometry.state(state);\n }\n\n /**\n * 自定义信息\n */\n if (customInfo) {\n geometry.customInfo(customInfo);\n }\n\n // 防止因为 x y 字段做了通道映射,导致生成图例\n [xField, yField]\n .filter((f: string) => f !== colorField)\n .forEach((f: string) => {\n chart.legend(f, false);\n });\n return {\n ...params,\n // geometry adaptor 额外需要做的事情,就是将创建好的 geometry 返回到下一层 adaptor,防止通过 type 查询的时候容易误判\n ext: { geometry },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA0D7C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,CAAkB,EAClB,KAA2C;IAKnC,IAAA,IAAI,GAAoE,CAAC,KAArE,EAAE,MAAM,GAA4D,CAAC,OAA7D,EAAE,MAAM,GAAoD,CAAC,OAArD,EAAE,UAAU,GAAwC,CAAC,WAAzC,EAAE,UAAU,GAA4B,CAAC,WAA7B,EAAE,SAAS,GAAiB,CAAC,UAAlB,EAAE,UAAU,GAAK,CAAC,WAAN,CAAO;IAC5E,IAAA,SAAS,GAAK,CAAC,UAAN,CAAO;IAEtB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,SAAS,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAE/E,4DAA4D;IAC5D,gDAAgD;IAChD,iBAAiB;IACjB,IAAI,KAAK,KAAK,OAAO,EAAE;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KAAK,CAAC,CAAC;KACvB;SAAM,IAAI,KAAK,EAAE;QACR,IAAA,QAAQ,GAAqB,KAAK,SAA1B,EAAE,MAAM,GAAa,KAAK,OAAlB,EAAK,GAAG,UAAK,KAAK,EAApC,sBAA4B,CAAF,CAAW;QAC3C,QAAQ,CAAC,KAAK,CAAC;YACb,MAAM,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC;YAC1B,QAAQ,UAAA;YACR,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC;SACzB,CAAC,CAAC;KACJ;IAED;;OAEG;IACH,IAAI,KAAK,EAAE;QACT,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACvB;IAED;;OAEG;IACH,IAAI,UAAU,EAAE;QACd,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;KACjC;IAED,2BAA2B;IAC3B,CAAC,MAAM,EAAE,MAAM,CAAC;SACb,MAAM,CAAC,UAAC,CAAS,IAAK,OAAA,CAAC,KAAK,UAAU,EAAhB,CAAgB,CAAC;SACvC,OAAO,CAAC,UAAC,CAAS;QACjB,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IACL,6BACK,MAAM;QACT,gFAAgF;QAChF,GAAG,EAAE,EAAE,QAAQ,UAAA,EAAE,IACjB;AACJ,CAAC","sourcesContent":["import { uniq, isFunction, isObject, isString, isNumber, isEmpty } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum, RawFields } from '../../types';\nimport { Label } from '../../types/label';\nimport { State } from '../../types/state';\nimport { transformLabel } from '../../utils';\n\n/**\n * 图形映射属性,按照优先级来的\n */\nexport type MappingOptions = {\n /** color 映射 */\n readonly color?: ColorAttr;\n /** shape 映射 */\n readonly shape?: ShapeAttr;\n /** 大小映射, 提供回调的方式 */\n readonly size?: SizeAttr;\n /** 样式映射 */\n readonly style?: StyleAttr;\n /** tooltip 映射 */\n readonly tooltip?: TooltipAttr;\n};\n\n/**\n * 一个图形映射的逻辑,纯粹的图形语法\n * // TODO 后续需要处理 adjust 的配置,然后通过 field 信息。比如 styleField,labelField 等一定是一个数组形式\n */\nexport type Geometry = {\n /** geometry 类型, 'line' | 'interval' | 'point' | 'area' | 'polygon' */\n readonly type?: string;\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly colorField?: string;\n /** shape 的映射字段 */\n readonly shapeField?: string;\n /** size 映射字段 */\n readonly sizeField?: string;\n /** style 的映射字段 */\n readonly styleField?: string;\n /** tooltip 的映射字段 */\n readonly tooltipFields?: string[] | false;\n /** 其他原始字段, 用于 mapping 回调参数 */\n readonly rawFields?: RawFields;\n /** 图形映射规则 */\n readonly mapping?: MappingOptions;\n /** label 映射通道,因为历史原因导致实现略有区别 */\n readonly label?: Label;\n /** 不同状态的样式 */\n readonly state?: State;\n /** 自定义信息,一般在 registerShape 中使用 */\n readonly customInfo?: any;\n /** geometry params */\n readonly args?: any;\n};\n\n/**\n * geometry options\n */\nexport type GeometryOptions = Geometry & Partial<Options>;\n\n/**\n * 获得映射的字段列表\n * @param options\n * @param field\n */\nexport function getMappingField(\n o: GeometryOptions,\n field: 'color' | 'shape' | 'size' | 'style'\n): {\n mappingFields: string[];\n tileMappingField: string;\n} {\n const { type, xField, yField, colorField, shapeField, sizeField, styleField } = o;\n let { rawFields } = o;\n\n let fields = [];\n rawFields = (isFunction(rawFields) ? rawFields(type, field) : rawFields) || [];\n\n // 因为 color 会影响到数据分组,以及最后的图形映射。所以导致 bar 图中的 widthRatio 设置不生效\n // 所以对于 color 字段,仅仅保留 colorField 好了! + rawFields\n // shape, size 同理\n if (field === 'color') {\n fields = [colorField || xField, ...rawFields];\n } else if (field === 'shape') {\n fields = [shapeField || xField, ...rawFields];\n } else if (field === 'size') {\n fields = [sizeField || xField, ...rawFields];\n } else {\n fields = [xField, yField, colorField, shapeField, sizeField, styleField, ...rawFields];\n\n // 一定能找到的!\n const idx = ['x', 'y', 'color', 'shape', 'size', 'style'].indexOf(field);\n\n const f = fields[idx];\n // 删除当前字段\n fields.splice(idx, 1);\n // 插入到第一个\n fields.unshift(f);\n }\n\n const mappingFields = uniq(fields.filter((f) => !!f));\n /**\n * 修复 line geometry 无拆分时 color 回调错误\n * eg:\n * geometry.color(xField, ()=> '#f24')\n */\n const tileMappingField =\n type === 'line' && [xField, yField].includes(mappingFields.join('*')) ? '' : mappingFields.join('*');\n return {\n mappingFields,\n tileMappingField,\n };\n}\n\n/**\n * 获得映射函数\n * @param mappingFields\n * @param func\n */\nexport function getMappingFunction(mappingFields: string[], func: (datum: Datum) => any) {\n if (!func) return undefined;\n // 返回函数\n return (...args: any[]) => {\n const params: Datum = {};\n\n mappingFields.forEach((f: string, idx: number) => {\n params[f] = args[idx];\n });\n\n // 删除 undefined\n delete params['undefined'];\n\n return func(params);\n };\n}\n\n/**\n * 通用 geometry 的配置处理的 adaptor\n * @param params\n */\nexport function geometry<O extends GeometryOptions>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const {\n type,\n args,\n mapping,\n xField,\n yField,\n colorField,\n shapeField,\n sizeField,\n tooltipFields,\n label,\n state,\n customInfo,\n } = options;\n\n // 如果没有 mapping 信息,那么直接返回\n if (!mapping) {\n return params;\n }\n\n const { color, shape, size, style, tooltip } = mapping;\n\n // 创建 geometry\n const geometry = chart[type](args).position(`${xField}*${yField}`);\n\n /**\n * color 的几种情况\n * g.color('red');\n * g.color('color', ['red', 'blue']);\n * g.color('x', (x, y) => 'red');\n * g.color('color', (color, x, y) => 'red');\n */\n if (isString(color)) {\n colorField ? geometry.color(colorField, color) : geometry.color(color);\n } else if (isFunction(color)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'color');\n geometry.color(tileMappingField, getMappingFunction(mappingFields, color));\n } else {\n colorField && geometry.color(colorField, color);\n }\n\n /**\n * shape 的几种情况\n * g.shape('rect');\n * g.shape('shape', ['rect', 'circle']);\n * g.shape('x*y', (x, y) => 'rect');\n * g.shape('shape*x*y', (shape, x, y) => 'rect');\n */\n if (isString(shape)) {\n shapeField ? geometry.shape(shapeField, [shape]) : geometry.shape(shape); // [shape] 需要在 G2 做掉\n } else if (isFunction(shape)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'shape');\n geometry.shape(tileMappingField, getMappingFunction(mappingFields, shape));\n } else {\n shapeField && geometry.shape(shapeField, shape);\n }\n\n /**\n * size 的几种情况\n * g.size(10);\n * g.size('size', [10, 20]);\n * g.size('x*y', (x, y) => 10);\n * g.color('size*x*y', (size, x, y) => 1-);\n */\n if (isNumber(size)) {\n sizeField ? geometry.size(sizeField, size) : geometry.size(size);\n } else if (isFunction(size)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'size');\n geometry.size(tileMappingField, getMappingFunction(mappingFields, size));\n } else {\n sizeField && geometry.size(sizeField, size);\n }\n\n /**\n * style 的几种情况\n * g.style({ fill: 'red' });\n * g.style('x*y*color', (x, y, color) => ({ fill: 'red' }));\n */\n if (isFunction(style)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'style');\n geometry.style(tileMappingField, getMappingFunction(mappingFields, style));\n } else if (isObject(style)) {\n geometry.style(style);\n }\n\n /**\n * tooltip 的 API\n * g.tooltip('x*y*color', (x, y, color) => ({ name, value }));\n * g.tooltip(false);\n */\n if (tooltipFields === false) {\n geometry.tooltip(false);\n } else if (!isEmpty(tooltipFields)) {\n geometry.tooltip(tooltipFields.join('*'), getMappingFunction(tooltipFields, tooltip));\n }\n\n /**\n * label 的映射\n */\n if (label === false) {\n geometry.label(false);\n } else if (label) {\n const { callback, fields, ...cfg } = label;\n geometry.label({\n fields: fields || [yField],\n callback,\n cfg: transformLabel(cfg),\n });\n }\n\n /**\n * state 状态样式\n */\n if (state) {\n geometry.state(state);\n }\n\n /**\n * 自定义信息\n */\n if (customInfo) {\n geometry.customInfo(customInfo);\n }\n\n // 防止因为 x y 字段做了通道映射,导致生成图例\n [xField, yField]\n .filter((f: string) => f !== colorField)\n .forEach((f: string) => {\n chart.legend(f, false);\n });\n return {\n ...params,\n // geometry adaptor 额外需要做的事情,就是将创建好的 geometry 返回到下一层 adaptor,防止通过 type 查询的时候容易误判\n ext: { geometry },\n };\n}\n"]}
|
package/esm/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" | "
|
|
10
|
+
export declare function pattern(key: string): <O extends Pick<Options, "label" | "legend" | "meta" | "padding" | "color" | "animation" | "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" | "color" | "animation" | "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/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,CAAC;AAEd,QAAQ;AACR,OAAO,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化处理\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,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,CAAC;AAEd,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,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AAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,6GAA6G;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,2BAA2B;AAC3B,mEAAmE;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAE7B,8BAA8B;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,eAAe;AACf,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,oBAAoB;AACpB,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;AAGzC,2DAA2D;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjD,0CAA0C;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASpF,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrG,MAAM,CAAC,IAAM,QAAQ,GAAG,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,OAAO,SAAA,EAAE,UAAU,YAAA,EAAE,WAAW,aAAA,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export const version = '2.4.22';\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"]}
|
|
@@ -9,11 +9,16 @@ declare function isPointInView(context: any): any;
|
|
|
9
9
|
/**
|
|
10
10
|
* 获取 交互 start 阶段的相关配置
|
|
11
11
|
*/
|
|
12
|
-
export declare function getInteractionCfg(interactionType: string, brushType?: string,
|
|
13
|
-
showEnable: {
|
|
12
|
+
export declare function getInteractionCfg(interactionType: string, brushType?: string, options?: BrushCfg): {
|
|
13
|
+
showEnable: ({
|
|
14
14
|
trigger: string;
|
|
15
15
|
action: string;
|
|
16
|
-
|
|
16
|
+
isEnable: ((context: any) => boolean) | (() => true);
|
|
17
|
+
} | {
|
|
18
|
+
trigger: string;
|
|
19
|
+
action: string;
|
|
20
|
+
isEnable?: undefined;
|
|
21
|
+
})[];
|
|
17
22
|
start: {
|
|
18
23
|
trigger: string;
|
|
19
24
|
isEnable: typeof isPointInView;
|
|
@@ -37,13 +42,18 @@ export declare function getInteractionCfg(interactionType: string, brushType?: s
|
|
|
37
42
|
action: string[];
|
|
38
43
|
}[];
|
|
39
44
|
} | {
|
|
40
|
-
showEnable: {
|
|
45
|
+
showEnable: ({
|
|
41
46
|
trigger: string;
|
|
42
47
|
action: string;
|
|
43
|
-
|
|
48
|
+
isEnable: ((context: any) => boolean) | (() => true);
|
|
49
|
+
} | {
|
|
50
|
+
trigger: string;
|
|
51
|
+
action: string;
|
|
52
|
+
isEnable?: undefined;
|
|
53
|
+
})[];
|
|
44
54
|
start: ({
|
|
45
55
|
trigger: string;
|
|
46
|
-
isEnable(context: any)
|
|
56
|
+
isEnable: (context: any) => boolean;
|
|
47
57
|
action: string[];
|
|
48
58
|
arg: {
|
|
49
59
|
maskStyle: import("@antv/g2").ShapeAttrs;
|
|
@@ -51,6 +61,7 @@ export declare function getInteractionCfg(interactionType: string, brushType?: s
|
|
|
51
61
|
} | {
|
|
52
62
|
trigger: string;
|
|
53
63
|
action: string[];
|
|
64
|
+
isEnable?: undefined;
|
|
54
65
|
arg?: undefined;
|
|
55
66
|
})[];
|
|
56
67
|
processing: {
|
|
@@ -60,6 +71,7 @@ export declare function getInteractionCfg(interactionType: string, brushType?: s
|
|
|
60
71
|
end: ({
|
|
61
72
|
trigger: string;
|
|
62
73
|
action: string[];
|
|
74
|
+
isEnable?: undefined;
|
|
63
75
|
} | {
|
|
64
76
|
trigger: string;
|
|
65
77
|
isEnable(context: any): boolean;
|
|
@@ -16,19 +16,20 @@ function isPointInView(context) {
|
|
|
16
16
|
/**
|
|
17
17
|
* 获取 交互 start 阶段的相关配置
|
|
18
18
|
*/
|
|
19
|
-
export function getInteractionCfg(interactionType, brushType,
|
|
19
|
+
export function getInteractionCfg(interactionType, brushType, options) {
|
|
20
|
+
var _a = options || {}, mask = _a.mask, isStartEnable = _a.isStartEnable;
|
|
20
21
|
var maskType = brushType || 'rect';
|
|
21
22
|
switch (interactionType) {
|
|
22
23
|
case 'brush':
|
|
23
24
|
return {
|
|
24
25
|
showEnable: [
|
|
25
|
-
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
|
|
26
|
+
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (function () { return true; }) },
|
|
26
27
|
{ trigger: 'plot:mouseleave', action: 'cursor:default' },
|
|
27
28
|
],
|
|
28
29
|
start: [
|
|
29
30
|
{
|
|
30
31
|
trigger: 'mousedown',
|
|
31
|
-
isEnable: isPointInView,
|
|
32
|
+
isEnable: isStartEnable || isPointInView,
|
|
32
33
|
action: ['brush:start', maskType + "-mask:start", maskType + "-mask:show"],
|
|
33
34
|
// 对应第二个action的参数
|
|
34
35
|
arg: [null, { maskStyle: mask === null || mask === void 0 ? void 0 : mask.style }],
|
|
@@ -64,18 +65,25 @@ export function getInteractionCfg(interactionType, brushType, mask) {
|
|
|
64
65
|
case 'brush-highlight':
|
|
65
66
|
return {
|
|
66
67
|
showEnable: [
|
|
67
|
-
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
|
|
68
|
-
{ trigger: '
|
|
68
|
+
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (function () { return true; }) },
|
|
69
|
+
{ trigger: 'plot:mousemove', action: 'cursor:crosshair', isEnable: isStartEnable || (function () { return true; }) },
|
|
70
|
+
{
|
|
71
|
+
trigger: 'plot:mousemove',
|
|
72
|
+
action: 'cursor:default',
|
|
73
|
+
isEnable: function (context) { return (isStartEnable ? !isStartEnable(context) : false); },
|
|
74
|
+
},
|
|
75
|
+
{ trigger: 'mask:mouseenter', action: 'cursor:move', isEnable: isStartEnable || (function () { return true; }) },
|
|
69
76
|
{ trigger: 'plot:mouseleave', action: 'cursor:default' },
|
|
70
77
|
{ trigger: 'mask:mouseleave', action: 'cursor:crosshair' },
|
|
71
78
|
],
|
|
72
79
|
start: [
|
|
73
80
|
{
|
|
74
81
|
trigger: 'plot:mousedown',
|
|
75
|
-
isEnable:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
isEnable: isStartEnable ||
|
|
83
|
+
(function (context) {
|
|
84
|
+
// 不要点击在 mask 上重新开始
|
|
85
|
+
return !context.isInShape('mask');
|
|
86
|
+
}),
|
|
79
87
|
action: [maskType + "-mask:start", maskType + "-mask:show"],
|
|
80
88
|
// 对应第 1 个action的参数
|
|
81
89
|
arg: [{ maskStyle: mask === null || mask === void 0 ? void 0 : mask.style }],
|
|
@@ -115,13 +123,13 @@ export function getInteractionCfg(interactionType, brushType, mask) {
|
|
|
115
123
|
case 'brush-x':
|
|
116
124
|
return {
|
|
117
125
|
showEnable: [
|
|
118
|
-
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
|
|
126
|
+
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (function () { return true; }) },
|
|
119
127
|
{ trigger: 'plot:mouseleave', action: 'cursor:default' },
|
|
120
128
|
],
|
|
121
129
|
start: [
|
|
122
130
|
{
|
|
123
131
|
trigger: 'mousedown',
|
|
124
|
-
isEnable: isPointInView,
|
|
132
|
+
isEnable: isStartEnable || isPointInView,
|
|
125
133
|
action: ['brush-x:start', maskType + "-mask:start", maskType + "-mask:show"],
|
|
126
134
|
// 对应第二个action的参数
|
|
127
135
|
arg: [null, { maskStyle: mask === null || mask === void 0 ? void 0 : mask.style }],
|
|
@@ -146,18 +154,19 @@ export function getInteractionCfg(interactionType, brushType, mask) {
|
|
|
146
154
|
case 'brush-x-highlight':
|
|
147
155
|
return {
|
|
148
156
|
showEnable: [
|
|
149
|
-
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
|
|
150
|
-
{ trigger: 'mask:mouseenter', action: 'cursor:move' },
|
|
157
|
+
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (function () { return true; }) },
|
|
158
|
+
{ trigger: 'mask:mouseenter', action: 'cursor:move', isEnable: isStartEnable || (function () { return true; }) },
|
|
151
159
|
{ trigger: 'plot:mouseleave', action: 'cursor:default' },
|
|
152
160
|
{ trigger: 'mask:mouseleave', action: 'cursor:crosshair' },
|
|
153
161
|
],
|
|
154
162
|
start: [
|
|
155
163
|
{
|
|
156
164
|
trigger: 'plot:mousedown',
|
|
157
|
-
isEnable:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
165
|
+
isEnable: isStartEnable ||
|
|
166
|
+
(function (context) {
|
|
167
|
+
// 不要点击在 mask 上重新开始
|
|
168
|
+
return !context.isInShape('mask');
|
|
169
|
+
}),
|
|
161
170
|
action: [maskType + "-mask:start", maskType + "-mask:show"],
|
|
162
171
|
// 对应第 1 个action的参数
|
|
163
172
|
arg: [{ maskStyle: mask === null || mask === void 0 ? void 0 : mask.style }],
|
|
@@ -197,13 +206,13 @@ export function getInteractionCfg(interactionType, brushType, mask) {
|
|
|
197
206
|
case 'brush-y':
|
|
198
207
|
return {
|
|
199
208
|
showEnable: [
|
|
200
|
-
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
|
|
209
|
+
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (function () { return true; }) },
|
|
201
210
|
{ trigger: 'plot:mouseleave', action: 'cursor:default' },
|
|
202
211
|
],
|
|
203
212
|
start: [
|
|
204
213
|
{
|
|
205
214
|
trigger: 'mousedown',
|
|
206
|
-
isEnable: isPointInView,
|
|
215
|
+
isEnable: isStartEnable || isPointInView,
|
|
207
216
|
action: ['brush-y:start', maskType + "-mask:start", maskType + "-mask:show"],
|
|
208
217
|
// 对应第二个action的参数
|
|
209
218
|
arg: [null, { maskStyle: mask === null || mask === void 0 ? void 0 : mask.style }],
|
|
@@ -228,18 +237,19 @@ export function getInteractionCfg(interactionType, brushType, mask) {
|
|
|
228
237
|
case 'brush-y-highlight':
|
|
229
238
|
return {
|
|
230
239
|
showEnable: [
|
|
231
|
-
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
|
|
232
|
-
{ trigger: 'mask:mouseenter', action: 'cursor:move' },
|
|
240
|
+
{ trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (function () { return true; }) },
|
|
241
|
+
{ trigger: 'mask:mouseenter', action: 'cursor:move', isEnable: isStartEnable || (function () { return true; }) },
|
|
233
242
|
{ trigger: 'plot:mouseleave', action: 'cursor:default' },
|
|
234
243
|
{ trigger: 'mask:mouseleave', action: 'cursor:crosshair' },
|
|
235
244
|
],
|
|
236
245
|
start: [
|
|
237
246
|
{
|
|
238
247
|
trigger: 'plot:mousedown',
|
|
239
|
-
isEnable:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
isEnable: isStartEnable ||
|
|
249
|
+
(function (context) {
|
|
250
|
+
// 不要点击在 mask 上重新开始
|
|
251
|
+
return !context.isInShape('mask');
|
|
252
|
+
}),
|
|
243
253
|
action: [maskType + "-mask:start", maskType + "-mask:show"],
|
|
244
254
|
// 对应第 1 个action的参数
|
|
245
255
|
arg: [{ maskStyle: mask === null || mask === void 0 ? void 0 : mask.style }],
|