@antv/g2plot 2.3.36 → 2.3.40
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 +67 -0
- package/dist/g2plot.min.js +18 -3
- package/dist/g2plot.min.js.map +1 -1
- package/esm/adaptor/geometries/base.d.ts +2 -0
- package/esm/adaptor/geometries/base.js +7 -1
- package/esm/adaptor/geometries/base.js.map +1 -1
- package/esm/adaptor/geometries/index.d.ts +1 -0
- package/esm/adaptor/geometries/index.js.map +1 -1
- package/esm/adaptor/pattern.d.ts +1 -1
- package/esm/core/plot.d.ts +1 -1
- package/esm/core/plot.js +2 -2
- package/esm/core/plot.js.map +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/actions/drill-down.d.ts +5 -1
- package/esm/interactions/actions/drill-down.js +12 -4
- package/esm/interactions/actions/drill-down.js.map +1 -1
- package/esm/interactions/drill-down.js +23 -0
- package/esm/interactions/drill-down.js.map +1 -1
- package/esm/plots/area/adaptor.js +5 -2
- package/esm/plots/area/adaptor.js.map +1 -1
- package/esm/plots/area/types.d.ts +2 -3
- package/esm/plots/area/types.js.map +1 -1
- package/esm/plots/bidirectional-bar/adaptor.js +45 -9
- package/esm/plots/bidirectional-bar/adaptor.js.map +1 -1
- package/esm/plots/bidirectional-bar/index.d.ts +2 -0
- package/esm/plots/bidirectional-bar/index.js +2 -0
- package/esm/plots/bidirectional-bar/index.js.map +1 -1
- package/esm/plots/box/adaptor.js +17 -2
- package/esm/plots/box/adaptor.js.map +1 -1
- package/esm/plots/column/adaptor.js +2 -1
- package/esm/plots/column/adaptor.js.map +1 -1
- package/esm/plots/column/types.d.ts +3 -0
- package/esm/plots/column/types.js.map +1 -1
- package/esm/plots/funnel/adaptor.js +3 -3
- package/esm/plots/funnel/adaptor.js.map +1 -1
- package/esm/plots/heatmap/adaptor.js +23 -1
- package/esm/plots/heatmap/adaptor.js.map +1 -1
- package/esm/plots/heatmap/types.d.ts +4 -2
- package/esm/plots/heatmap/types.js.map +1 -1
- package/esm/plots/line/adaptor.js +25 -4
- package/esm/plots/line/adaptor.js.map +1 -1
- package/esm/plots/line/types.d.ts +6 -2
- package/esm/plots/line/types.js.map +1 -1
- package/esm/plots/pie/interactions/{pie-legend-action.d.ts → actions/legend-active.d.ts} +0 -0
- package/esm/plots/pie/interactions/{pie-legend-action.js → actions/legend-active.js} +2 -2
- package/esm/plots/pie/interactions/actions/legend-active.js.map +1 -0
- package/{lib/plots/pie/interactions/pie-statistic-action.d.ts → esm/plots/pie/interactions/actions/statistic-active.d.ts} +1 -1
- package/esm/plots/pie/interactions/{pie-statistic-action.js → actions/statistic-active.js} +8 -2
- package/esm/plots/pie/interactions/actions/statistic-active.js.map +1 -0
- package/esm/plots/pie/interactions/index.js +2 -2
- package/esm/plots/pie/interactions/index.js.map +1 -1
- package/esm/plots/pie/interactions/util.d.ts +7 -0
- package/esm/plots/pie/interactions/util.js +15 -0
- package/esm/plots/pie/interactions/util.js.map +1 -0
- package/esm/plots/sankey/helper.js +16 -2
- package/esm/plots/sankey/helper.js.map +1 -1
- package/esm/plots/sankey/types.d.ts +51 -8
- package/esm/plots/sankey/types.js.map +1 -1
- package/esm/plots/sunburst/types.d.ts +3 -1
- package/esm/plots/sunburst/types.js.map +1 -1
- package/esm/plots/sunburst/utils.js +6 -1
- package/esm/plots/sunburst/utils.js.map +1 -1
- package/esm/plots/venn/adaptor.d.ts +1 -1
- package/esm/plots/venn/adaptor.js +53 -14
- package/esm/plots/venn/adaptor.js.map +1 -1
- package/esm/plots/venn/constant.js +22 -6
- package/esm/plots/venn/constant.js.map +1 -1
- package/esm/plots/venn/interactions/actions/active.d.ts +14 -0
- package/esm/plots/venn/interactions/actions/active.js +34 -0
- package/esm/plots/venn/interactions/actions/active.js.map +1 -0
- package/esm/plots/venn/interactions/actions/highlight.d.ts +16 -0
- package/esm/plots/venn/interactions/actions/highlight.js +39 -0
- package/esm/plots/venn/interactions/actions/highlight.js.map +1 -0
- package/esm/plots/venn/interactions/actions/selected.d.ts +33 -0
- package/esm/plots/venn/interactions/actions/selected.js +70 -0
- package/esm/plots/venn/interactions/actions/selected.js.map +1 -0
- package/esm/plots/venn/{interaction → interactions}/index.d.ts +0 -0
- package/esm/plots/venn/interactions/index.js +48 -0
- package/esm/plots/venn/interactions/index.js.map +1 -0
- package/esm/plots/venn/interactions/util.d.ts +3 -0
- package/esm/plots/venn/interactions/util.js +11 -0
- package/esm/plots/venn/interactions/util.js.map +1 -0
- package/esm/plots/venn/types.d.ts +2 -2
- package/esm/plots/venn/types.js.map +1 -1
- package/esm/plots/venn/utils.d.ts +3 -4
- package/esm/plots/venn/utils.js +2 -3
- package/esm/plots/venn/utils.js.map +1 -1
- package/esm/types/attr.d.ts +1 -1
- package/esm/types/attr.js.map +1 -1
- package/esm/types/common.d.ts +2 -0
- package/esm/types/common.js.map +1 -1
- package/lib/adaptor/geometries/base.d.ts +2 -0
- package/lib/adaptor/geometries/base.js +7 -1
- package/lib/adaptor/geometries/base.js.map +1 -1
- package/lib/adaptor/geometries/index.d.ts +1 -0
- package/lib/adaptor/geometries/index.js.map +1 -1
- package/lib/adaptor/pattern.d.ts +1 -1
- package/lib/core/plot.d.ts +1 -1
- package/lib/core/plot.js +2 -2
- package/lib/core/plot.js.map +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/actions/drill-down.d.ts +5 -1
- package/lib/interactions/actions/drill-down.js +11 -3
- package/lib/interactions/actions/drill-down.js.map +1 -1
- package/lib/interactions/drill-down.js +23 -0
- package/lib/interactions/drill-down.js.map +1 -1
- package/lib/plots/area/adaptor.js +5 -2
- package/lib/plots/area/adaptor.js.map +1 -1
- package/lib/plots/area/types.d.ts +2 -3
- package/lib/plots/area/types.js.map +1 -1
- package/lib/plots/bidirectional-bar/adaptor.js +45 -9
- package/lib/plots/bidirectional-bar/adaptor.js.map +1 -1
- package/lib/plots/bidirectional-bar/index.d.ts +2 -0
- package/lib/plots/bidirectional-bar/index.js +2 -0
- package/lib/plots/bidirectional-bar/index.js.map +1 -1
- package/lib/plots/box/adaptor.js +17 -2
- package/lib/plots/box/adaptor.js.map +1 -1
- package/lib/plots/column/adaptor.js +2 -1
- package/lib/plots/column/adaptor.js.map +1 -1
- package/lib/plots/column/types.d.ts +3 -0
- package/lib/plots/column/types.js.map +1 -1
- package/lib/plots/funnel/adaptor.js +2 -2
- package/lib/plots/funnel/adaptor.js.map +1 -1
- package/lib/plots/heatmap/adaptor.js +23 -1
- package/lib/plots/heatmap/adaptor.js.map +1 -1
- package/lib/plots/heatmap/types.d.ts +4 -2
- package/lib/plots/heatmap/types.js.map +1 -1
- package/lib/plots/line/adaptor.js +23 -2
- package/lib/plots/line/adaptor.js.map +1 -1
- package/lib/plots/line/types.d.ts +6 -2
- package/lib/plots/line/types.js.map +1 -1
- package/lib/plots/pie/interactions/{pie-legend-action.d.ts → actions/legend-active.d.ts} +0 -0
- package/lib/plots/pie/interactions/{pie-legend-action.js → actions/legend-active.js} +2 -2
- package/lib/plots/pie/interactions/actions/legend-active.js.map +1 -0
- package/{esm/plots/pie/interactions/pie-statistic-action.d.ts → lib/plots/pie/interactions/actions/statistic-active.d.ts} +1 -1
- package/lib/plots/pie/interactions/{pie-statistic-action.js → actions/statistic-active.js} +8 -2
- package/lib/plots/pie/interactions/actions/statistic-active.js.map +1 -0
- package/lib/plots/pie/interactions/index.js +4 -4
- package/lib/plots/pie/interactions/index.js.map +1 -1
- package/lib/plots/pie/interactions/util.d.ts +7 -0
- package/lib/plots/pie/interactions/util.js +19 -0
- package/lib/plots/pie/interactions/util.js.map +1 -0
- package/lib/plots/sankey/helper.js +16 -2
- package/lib/plots/sankey/helper.js.map +1 -1
- package/lib/plots/sankey/types.d.ts +51 -8
- package/lib/plots/sankey/types.js.map +1 -1
- package/lib/plots/sunburst/types.d.ts +3 -1
- package/lib/plots/sunburst/types.js.map +1 -1
- package/lib/plots/sunburst/utils.js +6 -1
- package/lib/plots/sunburst/utils.js.map +1 -1
- package/lib/plots/venn/adaptor.d.ts +1 -1
- package/lib/plots/venn/adaptor.js +52 -13
- package/lib/plots/venn/adaptor.js.map +1 -1
- package/lib/plots/venn/constant.js +22 -6
- package/lib/plots/venn/constant.js.map +1 -1
- package/lib/plots/venn/interactions/actions/active.d.ts +14 -0
- package/lib/plots/venn/interactions/actions/active.js +37 -0
- package/lib/plots/venn/interactions/actions/active.js.map +1 -0
- package/lib/plots/venn/interactions/actions/highlight.d.ts +16 -0
- package/lib/plots/venn/interactions/actions/highlight.js +42 -0
- package/lib/plots/venn/interactions/actions/highlight.js.map +1 -0
- package/lib/plots/venn/interactions/actions/selected.d.ts +33 -0
- package/lib/plots/venn/interactions/actions/selected.js +73 -0
- package/lib/plots/venn/interactions/actions/selected.js.map +1 -0
- package/lib/plots/venn/{interaction → interactions}/index.d.ts +0 -0
- package/lib/plots/venn/interactions/index.js +50 -0
- package/lib/plots/venn/interactions/index.js.map +1 -0
- package/lib/plots/venn/interactions/util.d.ts +3 -0
- package/lib/plots/venn/interactions/util.js +15 -0
- package/lib/plots/venn/interactions/util.js.map +1 -0
- package/lib/plots/venn/types.d.ts +2 -2
- package/lib/plots/venn/types.js.map +1 -1
- package/lib/plots/venn/utils.d.ts +3 -4
- package/lib/plots/venn/utils.js +2 -3
- package/lib/plots/venn/utils.js.map +1 -1
- package/lib/types/attr.d.ts +1 -1
- package/lib/types/attr.js.map +1 -1
- package/lib/types/common.d.ts +2 -0
- package/lib/types/common.js.map +1 -1
- package/package.json +5 -5
- package/src/adaptor/geometries/base.ts +23 -2
- package/src/adaptor/geometries/index.ts +1 -0
- package/src/core/plot.ts +3 -1
- package/src/index.ts +1 -1
- package/src/interactions/actions/drill-down.ts +13 -4
- package/src/interactions/drill-down.ts +24 -1
- package/src/plots/area/adaptor.ts +5 -2
- package/src/plots/area/types.ts +2 -3
- package/src/plots/bidirectional-bar/adaptor.ts +35 -7
- package/src/plots/bidirectional-bar/index.ts +3 -0
- package/src/plots/box/adaptor.ts +14 -2
- package/src/plots/column/adaptor.ts +2 -0
- package/src/plots/column/types.ts +5 -0
- package/src/plots/funnel/adaptor.ts +3 -3
- package/src/plots/heatmap/adaptor.ts +29 -11
- package/src/plots/heatmap/types.ts +6 -2
- package/src/plots/line/adaptor.ts +31 -3
- package/src/plots/line/types.ts +13 -2
- package/src/plots/pie/interactions/{pie-legend-action.ts → actions/legend-active.ts} +1 -1
- package/src/plots/pie/interactions/{pie-statistic-action.ts → actions/statistic-active.ts} +11 -3
- package/src/plots/pie/interactions/index.ts +2 -2
- package/src/plots/pie/interactions/util.ts +16 -0
- package/src/plots/sankey/helper.ts +26 -9
- package/src/plots/sankey/types.ts +52 -8
- package/src/plots/sunburst/types.ts +3 -1
- package/src/plots/sunburst/utils.ts +6 -1
- package/src/plots/venn/adaptor.ts +63 -13
- package/src/plots/venn/constant.ts +22 -6
- package/src/plots/venn/interactions/actions/active.ts +31 -0
- package/src/plots/venn/interactions/actions/highlight.ts +37 -0
- package/src/plots/venn/interactions/actions/selected.ts +65 -0
- package/src/plots/venn/interactions/index.ts +55 -0
- package/src/plots/venn/interactions/util.ts +12 -0
- package/src/plots/venn/types.ts +2 -2
- package/src/plots/venn/utils.ts +10 -4
- package/src/types/attr.ts +1 -1
- package/src/types/common.ts +2 -0
- package/esm/plots/pie/interactions/pie-legend-action.js.map +0 -1
- package/esm/plots/pie/interactions/pie-statistic-action.js.map +0 -1
- package/esm/plots/venn/interaction/action.d.ts +0 -18
- package/esm/plots/venn/interaction/action.js +0 -77
- package/esm/plots/venn/interaction/action.js.map +0 -1
- package/esm/plots/venn/interaction/index.js +0 -15
- package/esm/plots/venn/interaction/index.js.map +0 -1
- package/lib/plots/pie/interactions/pie-legend-action.js.map +0 -1
- package/lib/plots/pie/interactions/pie-statistic-action.js.map +0 -1
- package/lib/plots/venn/interaction/action.d.ts +0 -18
- package/lib/plots/venn/interaction/action.js +0 -80
- package/lib/plots/venn/interaction/action.js.map +0 -1
- package/lib/plots/venn/interaction/index.js +0 -17
- package/lib/plots/venn/interaction/index.js.map +0 -1
- package/src/plots/venn/interaction/action.ts +0 -67
- package/src/plots/venn/interaction/index.ts +0 -17
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { VennData, VennOptions } from './types';
|
|
2
|
+
declare type ColorMapFunction = (colorPalette: string[], data: VennData, blendMode: VennOptions['blendMode'], setsField: VennOptions['setsField']) => Map<string, string>;
|
|
2
3
|
/**
|
|
3
4
|
* 获取 颜色映射
|
|
4
5
|
* @usage colorMap.get(id) => color
|
|
5
6
|
*
|
|
6
7
|
* @returns Map<string, string>
|
|
7
8
|
*/
|
|
8
|
-
export declare const getColorMap:
|
|
9
|
-
(...args: any[]): any;
|
|
10
|
-
cache: Map<any, any>;
|
|
11
|
-
};
|
|
9
|
+
export declare const getColorMap: ColorMapFunction;
|
|
12
10
|
/**
|
|
13
11
|
* 给韦恩图数据进行布局
|
|
14
12
|
*
|
|
@@ -26,3 +24,4 @@ export declare function layoutVennData(options: VennOptions, width: number, heig
|
|
|
26
24
|
* @return boolean
|
|
27
25
|
*/
|
|
28
26
|
export declare function islegalSets(legalArr: any[], testArr: any[]): boolean;
|
|
27
|
+
export {};
|
package/lib/plots/venn/utils.js
CHANGED
|
@@ -14,8 +14,7 @@ var constant_1 = require("./constant");
|
|
|
14
14
|
*
|
|
15
15
|
* @returns Map<string, string>
|
|
16
16
|
*/
|
|
17
|
-
exports.getColorMap = util_1.memoize(function (colorPalette, data,
|
|
18
|
-
var blendMode = options.blendMode, setsField = options.setsField;
|
|
17
|
+
exports.getColorMap = util_1.memoize((function (colorPalette, data, blendMode, setsField) {
|
|
19
18
|
var colorMap = new Map();
|
|
20
19
|
var colorPaletteLen = colorPalette.length;
|
|
21
20
|
data.forEach(function (d, idx) {
|
|
@@ -29,7 +28,7 @@ exports.getColorMap = util_1.memoize(function (colorPalette, data, options) {
|
|
|
29
28
|
}
|
|
30
29
|
});
|
|
31
30
|
return colorMap;
|
|
32
|
-
}, function () {
|
|
31
|
+
}), function () {
|
|
33
32
|
var params = [];
|
|
34
33
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
35
34
|
params[_i] = arguments[_i];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/plots/venn/utils.ts"],"names":[],"mappings":";;;;AAAA,mCAA6C;AAC7C,iDAAgD;AAChD,qCAAyC;AACzC,0CAAsD;AACtD,4CAA4E;AAC5E,uCAAkD;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/plots/venn/utils.ts"],"names":[],"mappings":"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","sourcesContent":["import { assign, memoize } from '@antv/util';\nimport { blend } from '../../utils/color/blend';\nimport { log, LEVEL } from '../../utils';\nimport { venn, scaleSolution } from './layout/layout';\nimport { intersectionAreaPath, computeTextCentres } from './layout/diagram';\nimport { ID_FIELD, PATH_FIELD } from './constant';\nimport { VennData, VennOptions } from './types';\n\ntype ColorMapFunction = (\n colorPalette: string[],\n data: VennData,\n blendMode: VennOptions['blendMode'],\n setsField: VennOptions['setsField']\n) => Map<string, string>;\n\n/**\n * 获取 颜色映射\n * @usage colorMap.get(id) => color\n *\n * @returns Map<string, string>\n */\nexport const getColorMap = memoize(\n ((colorPalette, data, blendMode, setsField) => {\n const colorMap = new Map<string /** id */, string /** color */>();\n const colorPaletteLen = colorPalette.length;\n data.forEach((d, idx) => {\n if (d[setsField].length === 1) {\n colorMap.set(d[ID_FIELD], colorPalette[(idx + colorPaletteLen) % colorPaletteLen]);\n } else {\n /** 一般都是可以获取到颜色的,如果不正确 就是输入了非法数据 */\n const colorArr = d[setsField].map((id) => colorMap.get(id));\n colorMap.set(\n d[ID_FIELD],\n colorArr.slice(1).reduce((a, b) => blend(a, b, blendMode), colorArr[0])\n );\n }\n });\n\n return colorMap;\n }) as ColorMapFunction,\n (...params) => JSON.stringify(params)\n) as ColorMapFunction;\n\n/**\n * 给韦恩图数据进行布局\n *\n * @param data\n * @param width\n * @param height\n * @param padding\n * @returns 韦恩图数据\n */\nexport function layoutVennData(options: VennOptions, width: number, height: number, padding: number = 0): VennData {\n const { data, setsField, sizeField } = options;\n\n // 处理空数据的情况\n if (data.length === 0) {\n log(LEVEL.WARN, false, 'warn: %s', '数据不能为空');\n return [];\n }\n\n const vennData: VennData = data.map((d) => ({\n ...d,\n sets: d[setsField] || [],\n size: d[sizeField],\n [PATH_FIELD]: '',\n [ID_FIELD]: '',\n }));\n // 1. 进行排序,避免图形元素遮挡\n vennData.sort((a, b) => a.sets.length - b.sets.length);\n // todo 2. 可以在这里处理下非法数据输入,避免直接 crash\n\n const solution = venn(vennData);\n const circles = scaleSolution(solution, width, height, padding);\n const textCenters = computeTextCentres(circles, vennData);\n vennData.forEach((row) => {\n const sets = row.sets;\n const id = sets.join(',');\n row[ID_FIELD] = id;\n // 保留 vennText 布局方法\n const setCircles = sets.map((set) => circles[set]);\n let path = intersectionAreaPath(setCircles);\n if (!/[zZ]$/.test(path)) {\n path += ' Z';\n }\n row[PATH_FIELD] = path;\n const center = textCenters[id] || { x: 0, y: 0 };\n assign(row, center);\n });\n return vennData;\n}\n\n/**\n * 检查是否存在 非法元素\n * @param legalArr 合法集合:['A', 'B']\n * @param testArr 检查集合:['A', 'B', 'C'] or ['A', 'C'](存在非法 'C')\n * @return boolean\n */\nexport function islegalSets(legalArr: any[], testArr: any[]): boolean {\n for (let i = 0; i < testArr.length; i++) {\n if (!legalArr.includes(testArr[i])) {\n return false;\n }\n }\n return true;\n}\n"]}
|
package/lib/types/attr.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Datum } from './common';
|
|
|
4
4
|
/** 图形属性 */
|
|
5
5
|
export declare type ShapeStyle = ShapeAttrs;
|
|
6
6
|
/** 颜色映射 */
|
|
7
|
-
export declare type ColorAttr = string | string[] | ((datum: Datum) => string)
|
|
7
|
+
export declare type ColorAttr = string | string[] | ((datum: Datum, defaultColor?: string) => string);
|
|
8
8
|
/** pattern 映射*/
|
|
9
9
|
export declare type PatternAttr = CanvasPattern | PatternOption | ((datum: Datum, color: string /** inherit color */) => PatternOption | CanvasPattern);
|
|
10
10
|
/** 尺寸大小映射 */
|
package/lib/types/attr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attr.js","sourceRoot":"","sources":["../../src/types/attr.ts"],"names":[],"mappings":"","sourcesContent":["import { ShapeAttrs } from '@antv/g-base';\nimport { PatternOption } from '../utils/pattern/index';\nimport { Datum } from './common';\n\n/** 图形属性 */\nexport type ShapeStyle = ShapeAttrs;\n\n/** 颜色映射 */\nexport type ColorAttr = string | string[] | ((datum: Datum) => string)
|
|
1
|
+
{"version":3,"file":"attr.js","sourceRoot":"","sources":["../../src/types/attr.ts"],"names":[],"mappings":"","sourcesContent":["import { ShapeAttrs } from '@antv/g-base';\nimport { PatternOption } from '../utils/pattern/index';\nimport { Datum } from './common';\n\n/** 图形属性 */\nexport type ShapeStyle = ShapeAttrs;\n\n/** 颜色映射 */\nexport type ColorAttr = string | string[] | ((datum: Datum, defaultColor?: string) => string);\n/** pattern 映射*/\nexport type PatternAttr =\n | CanvasPattern\n | PatternOption\n | ((datum: Datum, color: string /** inherit color */) => PatternOption | CanvasPattern);\n/** 尺寸大小映射 */\nexport type SizeAttr = number | [number, number] | ((datum: Datum) => number);\n/** 图形 shape 映射 */\nexport type ShapeAttr = string | string[] | ((datum: Datum) => string);\n/** 图形样式 style 映射 */\nexport type StyleAttr = ShapeStyle | ((datum: Datum) => ShapeStyle);\n/** tooltip 的回调 */\nexport type TooltipAttr = (datum: Datum) => { name: string; value: string | number };\n"]}
|
package/lib/types/common.d.ts
CHANGED
package/lib/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 /** the top-left corner of layer-range, range from 0 to 1, relative to parent layer's range */\n readonly start: Point;\n /** the bottom-right corner of layer-range, range from 0 to 1, relative to parent layer's range */\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 readonly fontSize?: number;\n /** 字体系列 */\n readonly fontFamily?: string;\n /** 文本粗细 */\n readonly fontWeight?: number;\n /** 文本行高 */\n readonly lineHeight?: number;\n /** 文本对齐方式 */\n readonly textAlign?: 'center' | 'left' | 'right';\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 /** 画布宽度 */\n readonly width?: number;\n /** 画布高度 */\n readonly height?: number;\n /** 画布是否自动适配容器大小,默认为 true */\n readonly autoFit?: boolean;\n /** 画布的 padding 值,或者开启 'auto' */\n readonly padding?: number[] | number | 'auto';\n /** 额外怎加的 padding 值 */\n readonly appendPadding?: number[] | number;\n /** 是否同步子 view 的 padding */\n readonly syncViewPadding?: boolean | Types.SyncViewPaddingFn;\n\n /** 国际化 */\n readonly locale?: string;\n\n // G 相关\n /** 渲染引擎 */\n readonly renderer?: 'svg' | 'canvas';\n /** 屏幕像素比,默认为 window.devicePixelRatio */\n readonly pixelRatio?: number;\n /** 是否开启局部渲染,默认为 true */\n readonly localRefresh?: boolean;\n /** 支持 CSS transform,开启后图表的交互以及事件将在页面设置了 css transform 属性时生效,默认关闭。 */\n readonly supportCSSTransform?: boolean;\n\n // 通用数据配置\n /** 具体的数据 */\n readonly data: Record<string, any>[];\n /** 数据字段元信息 */\n readonly meta?: Record<string, Meta>;\n\n // G2 相关\n /** 主题,G2 主题,字符串或者 theme object */\n readonly theme?: string | object;\n /** 颜色色板 */\n readonly color?: ColorAttr;\n /** pattern 配置 */\n readonly pattern?: PatternAttr;\n /** xAxis 的配置项 */\n readonly xAxis?: Axis;\n /** yAxis 的配置项 */\n readonly yAxis?: Axis;\n /** 数据标签的配置 */\n readonly label?: Label;\n /** tooltip 的配置项 */\n readonly tooltip?: Tooltip;\n /** 图例 legend 的配置项 */\n readonly legend?: Legend;\n /** 缩略轴 slider 的配置项 */\n readonly slider?: Slider;\n /** 缩略轴 scrollbar 的配置项 */\n readonly scrollbar?: Scrollbar;\n readonly animation?: Animation;\n readonly interactions?: Interaction[];\n readonly annotations?: Annotation[];\n // 配置 active,inactive,selected 三种状态的样式,也可在 Theme 主题中配置\n readonly state?: State;\n /** 是否对超出坐标系范围的 Geometry 进行剪切 */\n readonly limitInPlot?: boolean;\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 /** the top-left corner of layer-range, range from 0 to 1, relative to parent layer's range */\n readonly start: Point;\n /** the bottom-right corner of layer-range, range from 0 to 1, relative to parent layer's range */\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 readonly fontSize?: number;\n /** 字体系列 */\n readonly fontFamily?: string;\n /** 文本粗细 */\n readonly fontWeight?: number;\n /** 文本行高 */\n readonly lineHeight?: number;\n /** 文本对齐方式 */\n readonly textAlign?: 'center' | 'left' | 'right';\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 /** 画布宽度 */\n readonly width?: number;\n /** 画布高度 */\n readonly height?: number;\n /** 画布是否自动适配容器大小,默认为 true */\n readonly autoFit?: boolean;\n /** 画布的 padding 值,或者开启 'auto' */\n readonly padding?: number[] | number | 'auto';\n /** 额外怎加的 padding 值 */\n readonly appendPadding?: number[] | number;\n /** 是否同步子 view 的 padding */\n readonly syncViewPadding?: boolean | Types.SyncViewPaddingFn;\n\n /** 国际化 */\n readonly locale?: string;\n\n // G 相关\n /** 渲染引擎 */\n readonly renderer?: 'svg' | 'canvas';\n /** 屏幕像素比,默认为 window.devicePixelRatio */\n readonly pixelRatio?: number;\n /** 是否开启局部渲染,默认为 true */\n readonly localRefresh?: boolean;\n /** 支持 CSS transform,开启后图表的交互以及事件将在页面设置了 css transform 属性时生效,默认关闭。 */\n readonly supportCSSTransform?: boolean;\n\n // 通用数据配置\n /** 具体的数据 */\n readonly data: Record<string, any>[];\n /** 数据字段元信息 */\n readonly meta?: Record<string, Meta>;\n\n // G2 相关\n /** 主题,G2 主题,字符串或者 theme object */\n readonly theme?: string | object;\n /** 颜色色板 */\n readonly color?: ColorAttr;\n /** pattern 配置 */\n readonly pattern?: PatternAttr;\n /** xAxis 的配置项 */\n readonly xAxis?: Axis;\n /** yAxis 的配置项 */\n readonly yAxis?: Axis;\n /** 数据标签的配置 */\n readonly label?: Label;\n /** tooltip 的配置项 */\n readonly tooltip?: Tooltip;\n /** 图例 legend 的配置项 */\n readonly legend?: Legend;\n /** 缩略轴 slider 的配置项 */\n readonly slider?: Slider;\n /** 缩略轴 scrollbar 的配置项 */\n readonly scrollbar?: Scrollbar;\n readonly animation?: Animation;\n readonly interactions?: Interaction[];\n readonly annotations?: Annotation[];\n // 配置 active,inactive,selected 三种状态的样式,也可在 Theme 主题中配置\n readonly state?: State;\n /** 是否对超出坐标系范围的 Geometry 进行剪切 */\n readonly limitInPlot?: boolean;\n /** 内置注册的交互 */\n readonly defaultInteractions?: string[];\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g2plot",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.40",
|
|
4
4
|
"description": "An nteractive and responsive charting library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chart",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"homepage": "https://g2plot.antv.vision",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/antvis/
|
|
24
|
+
"url": "https://github.com/antvis/G2plot"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"start": "npm run site:clean && npm run site:develop",
|
|
28
28
|
"site:develop": "cross-env PORT=8080 gatsby develop --open -H 0.0.0.0",
|
|
29
|
-
"site:build": "npm run site:clean && gatsby build --prefix-paths",
|
|
29
|
+
"site:build": "NODE_OPTIONS=--max_old_space_size=8192 npm run site:clean && gatsby build --prefix-paths",
|
|
30
30
|
"site:clean": "gatsby clean",
|
|
31
|
-
"site:deploy": "
|
|
31
|
+
"site:deploy": "npm run build && npm run site:build && gh-pages -d public",
|
|
32
32
|
"fix": "eslint --ext .ts ./src ./__tests__ --fix && prettier --write ./src ./__tests__ && lint-md --fix ./examples ./docs",
|
|
33
33
|
"build": "run-s clean lib dist size",
|
|
34
34
|
"size": "limit-size",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"limit-size": [
|
|
145
145
|
{
|
|
146
146
|
"path": "dist/g2plot.min.js",
|
|
147
|
-
"limit": "
|
|
147
|
+
"limit": "995 Kb"
|
|
148
148
|
},
|
|
149
149
|
{
|
|
150
150
|
"path": "dist/g2plot.min.js",
|
|
@@ -50,6 +50,8 @@ export type Geometry = {
|
|
|
50
50
|
readonly label?: Label;
|
|
51
51
|
/** 不同状态的样式 */
|
|
52
52
|
readonly state?: State;
|
|
53
|
+
/** 自定义信息,一般在 registerShape 中使用 */
|
|
54
|
+
readonly customInfo?: any;
|
|
53
55
|
/** geometry params */
|
|
54
56
|
readonly args?: any;
|
|
55
57
|
};
|
|
@@ -139,8 +141,20 @@ export function getMappingFunction(mappingFields: string[], func: (datum: Datum)
|
|
|
139
141
|
*/
|
|
140
142
|
export function geometry<O extends GeometryOptions>(params: Params<O>): Params<O> {
|
|
141
143
|
const { chart, options } = params;
|
|
142
|
-
const {
|
|
143
|
-
|
|
144
|
+
const {
|
|
145
|
+
type,
|
|
146
|
+
args,
|
|
147
|
+
mapping,
|
|
148
|
+
xField,
|
|
149
|
+
yField,
|
|
150
|
+
colorField,
|
|
151
|
+
shapeField,
|
|
152
|
+
sizeField,
|
|
153
|
+
tooltipFields,
|
|
154
|
+
label,
|
|
155
|
+
state,
|
|
156
|
+
customInfo,
|
|
157
|
+
} = options;
|
|
144
158
|
|
|
145
159
|
// 如果没有 mapping 信息,那么直接返回
|
|
146
160
|
if (!mapping) {
|
|
@@ -244,6 +258,13 @@ export function geometry<O extends GeometryOptions>(params: Params<O>): Params<O
|
|
|
244
258
|
geometry.state(state);
|
|
245
259
|
}
|
|
246
260
|
|
|
261
|
+
/**
|
|
262
|
+
* 自定义信息
|
|
263
|
+
*/
|
|
264
|
+
if (customInfo) {
|
|
265
|
+
geometry.customInfo(customInfo);
|
|
266
|
+
}
|
|
267
|
+
|
|
247
268
|
// 防止因为 x y 字段做了通道映射,导致生成图例
|
|
248
269
|
[xField, yField]
|
|
249
270
|
.filter((f: string) => f !== colorField)
|
package/src/core/plot.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type PickOptions = Pick<
|
|
|
20
20
|
| 'supportCSSTransform'
|
|
21
21
|
| 'limitInPlot'
|
|
22
22
|
| 'locale'
|
|
23
|
+
| 'defaultInteractions'
|
|
23
24
|
>;
|
|
24
25
|
|
|
25
26
|
const SOURCE_ATTRIBUTE_NAME = 'data-chart-source-type';
|
|
@@ -90,7 +91,7 @@ export abstract class Plot<O extends PickOptions> extends EE {
|
|
|
90
91
|
* 创建 G2 实例
|
|
91
92
|
*/
|
|
92
93
|
private createG2() {
|
|
93
|
-
const { width, height } = this.options;
|
|
94
|
+
const { width, height, defaultInteractions } = this.options;
|
|
94
95
|
|
|
95
96
|
this.chart = new Chart({
|
|
96
97
|
container: this.container,
|
|
@@ -98,6 +99,7 @@ export abstract class Plot<O extends PickOptions> extends EE {
|
|
|
98
99
|
...this.getChartSize(width, height),
|
|
99
100
|
localRefresh: false, // 默认关闭,目前 G 还有一些位置问题,难以排查!
|
|
100
101
|
...pick(this.options, PLOT_CONTAINER_OPTIONS),
|
|
102
|
+
defaultInteractions,
|
|
101
103
|
});
|
|
102
104
|
|
|
103
105
|
// 给容器增加标识,知道图表的来源区别于 G2
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Action, IGroup, Util } from '@antv/g2';
|
|
2
|
-
import { get, last, isNil } from '@antv/util';
|
|
2
|
+
import { get, last, isNil, size } from '@antv/util';
|
|
3
3
|
import { Data } from '../../types';
|
|
4
4
|
import { DrillDownCfg } from '../../types/drill-down';
|
|
5
5
|
import { deepAssign } from '../../utils/deep-assign';
|
|
@@ -112,12 +112,21 @@ export class DrillDownAction extends Action {
|
|
|
112
112
|
breadCrumbGroup.setMatrix(matrix);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* 返回上一层
|
|
117
|
+
*/
|
|
118
|
+
public back(): void {
|
|
119
|
+
if (size(this.historyCache)) {
|
|
120
|
+
this.backTo(this.historyCache.slice(0, -1));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
115
124
|
/**
|
|
116
125
|
* 重置
|
|
117
126
|
*/
|
|
118
127
|
public reset(): void {
|
|
119
128
|
if (this.historyCache[0]) {
|
|
120
|
-
this.
|
|
129
|
+
this.backTo(this.historyCache.slice(0, 1));
|
|
121
130
|
}
|
|
122
131
|
// 清空
|
|
123
132
|
this.historyCache = [];
|
|
@@ -158,7 +167,7 @@ export class DrillDownAction extends Action {
|
|
|
158
167
|
* 回退事件,点击面包屑时触发
|
|
159
168
|
* @param historyCache 当前要回退到的历史
|
|
160
169
|
*/
|
|
161
|
-
protected
|
|
170
|
+
protected backTo(historyCache: HistoryCache) {
|
|
162
171
|
if (!historyCache || historyCache.length <= 0) {
|
|
163
172
|
return;
|
|
164
173
|
}
|
|
@@ -236,7 +245,7 @@ export class DrillDownAction extends Action {
|
|
|
236
245
|
const targetId = event.target.get('id');
|
|
237
246
|
if (targetId !== last(cache)?.id) {
|
|
238
247
|
const newHistoryCache = cache.slice(0, cache.findIndex((d) => d.id === targetId) + 1);
|
|
239
|
-
this.
|
|
248
|
+
this.backTo(newHistoryCache);
|
|
240
249
|
}
|
|
241
250
|
});
|
|
242
251
|
// active 效果内置
|
|
@@ -10,12 +10,29 @@ export function isParentNode(context) {
|
|
|
10
10
|
return isArray(data.children) && data.children.length > 0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* 判断是否在中心
|
|
15
|
+
*/
|
|
16
|
+
function inCenter(context) {
|
|
17
|
+
const coordinate = context.view.getCoordinate();
|
|
18
|
+
const { innerRadius } = coordinate;
|
|
19
|
+
if (innerRadius) {
|
|
20
|
+
const { x, y } = context.event;
|
|
21
|
+
const { x: centerX, y: centerY } = coordinate.center;
|
|
22
|
+
const r = coordinate.getRadius() * innerRadius;
|
|
23
|
+
const distance = Math.sqrt((centerX - x) ** 2 + (centerY - y) ** 2);
|
|
24
|
+
return distance < r;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
14
28
|
|
|
29
|
+
registerAction('drill-down-action', DrillDownAction);
|
|
15
30
|
registerInteraction('drill-down', {
|
|
16
31
|
showEnable: [
|
|
17
32
|
{ trigger: 'element:mouseenter', action: 'cursor:pointer', isEnable: isParentNode },
|
|
18
33
|
{ trigger: 'element:mouseleave', action: 'cursor:default' },
|
|
34
|
+
// 中心处,肯定会触发 element:mouseleave 操作
|
|
35
|
+
{ trigger: 'element:mouseleave', action: 'cursor:pointer', isEnable: inCenter },
|
|
19
36
|
],
|
|
20
37
|
start: [
|
|
21
38
|
{
|
|
@@ -27,5 +44,11 @@ registerInteraction('drill-down', {
|
|
|
27
44
|
trigger: 'afterchangesize',
|
|
28
45
|
action: ['drill-down-action:resetPosition'],
|
|
29
46
|
},
|
|
47
|
+
{
|
|
48
|
+
// 点击中心,返回上一层
|
|
49
|
+
trigger: 'click',
|
|
50
|
+
isEnable: inCenter,
|
|
51
|
+
action: ['drill-down-action:back'],
|
|
52
|
+
},
|
|
30
53
|
],
|
|
31
54
|
});
|
|
@@ -66,12 +66,15 @@ function geometry(params: Params<AreaOptions>): Params<AreaOptions> {
|
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
// 线默认 2px
|
|
70
|
+
const lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {
|
|
71
|
+
options: { sizeField: seriesField, tooltip: false },
|
|
72
|
+
});
|
|
70
73
|
const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
71
74
|
|
|
72
75
|
// area geometry 处理
|
|
73
76
|
area(primary);
|
|
74
|
-
line(
|
|
77
|
+
line(lineParams);
|
|
75
78
|
point(pointParams);
|
|
76
79
|
|
|
77
80
|
return params;
|
package/src/plots/area/types.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { PointGeometryOptions } from '../../adaptor/geometries';
|
|
1
|
+
import { GeometryOptions, LineGeometryOptions, PointGeometryOptions } from '../../adaptor/geometries';
|
|
2
2
|
import { Options, StyleAttr } from '../../types';
|
|
3
|
-
import { LineGeometryOptions } from '../../adaptor/geometries';
|
|
4
3
|
|
|
5
4
|
/** 面积图的配置类型定义 */
|
|
6
|
-
export interface AreaOptions extends Options {
|
|
5
|
+
export interface AreaOptions extends Options, Pick<GeometryOptions, 'customInfo'> {
|
|
7
6
|
/** x 轴字段 */
|
|
8
7
|
readonly xField?: string;
|
|
9
8
|
/** y 轴字段 */
|
|
@@ -76,10 +76,7 @@ function geometry(params: Params<BidirectionalBarOptions>): Params<Bidirectional
|
|
|
76
76
|
},
|
|
77
77
|
id: SECOND_AXES_VIEW,
|
|
78
78
|
});
|
|
79
|
-
secondView
|
|
80
|
-
.coordinate()
|
|
81
|
-
.reflect('y')
|
|
82
|
-
.rotate(Math.PI * 0); // 旋转
|
|
79
|
+
secondView.coordinate().reflect('y');
|
|
83
80
|
|
|
84
81
|
firstView.data(firstViewData);
|
|
85
82
|
secondView.data(secondViewData);
|
|
@@ -277,12 +274,12 @@ export function animation(params: Params<BidirectionalBarOptions>): Params<Bidir
|
|
|
277
274
|
}
|
|
278
275
|
|
|
279
276
|
/**
|
|
280
|
-
* label 配置
|
|
277
|
+
* label 配置 (1. 设置 offset 偏移量默认值 2. leftView 偏移量需要 *= -1)
|
|
281
278
|
* @param params
|
|
282
279
|
*/
|
|
283
280
|
function label(params: Params<BidirectionalBarOptions>): Params<BidirectionalBarOptions> {
|
|
284
281
|
const { chart, options } = params;
|
|
285
|
-
const { label, yField } = options;
|
|
282
|
+
const { label, yField, layout } = options;
|
|
286
283
|
|
|
287
284
|
const firstView = findViewById(chart, FIRST_AXES_VIEW);
|
|
288
285
|
const secondView = findViewById(chart, SECOND_AXES_VIEW);
|
|
@@ -294,10 +291,41 @@ function label(params: Params<BidirectionalBarOptions>): Params<BidirectionalBar
|
|
|
294
291
|
rightGeometry.label(false);
|
|
295
292
|
} else {
|
|
296
293
|
const { callback, ...cfg } = label;
|
|
294
|
+
/** ---- 设置默认配置 ---- */
|
|
295
|
+
// 默认居中
|
|
296
|
+
if (!cfg.position) {
|
|
297
|
+
cfg.position = 'middle';
|
|
298
|
+
}
|
|
299
|
+
if (cfg.offset === undefined) {
|
|
300
|
+
cfg.offset = 2;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** ---- leftView label 设置 ---- */
|
|
304
|
+
const leftLabelCfg = { ...cfg };
|
|
305
|
+
if (isHorizontal(layout)) {
|
|
306
|
+
// 设置 textAlign 默认值
|
|
307
|
+
const textAlign = leftLabelCfg.style?.textAlign || (cfg.position === 'middle' ? 'center' : 'left');
|
|
308
|
+
cfg.style = deepAssign({}, cfg.style, { textAlign });
|
|
309
|
+
const textAlignMap = { left: 'right', right: 'left', center: 'center' };
|
|
310
|
+
leftLabelCfg.style = deepAssign({}, leftLabelCfg.style, { textAlign: textAlignMap[textAlign] });
|
|
311
|
+
} else {
|
|
312
|
+
const positionMap = { top: 'bottom', bottom: 'top', middle: 'middle' };
|
|
313
|
+
if (typeof cfg.position === 'string') {
|
|
314
|
+
cfg.position = positionMap[cfg.position];
|
|
315
|
+
} else if (typeof cfg.position === 'function') {
|
|
316
|
+
cfg.position = (...args) => positionMap[(cfg.position as Function).apply(this, args)];
|
|
317
|
+
}
|
|
318
|
+
// 设置 textBaseline 默认值
|
|
319
|
+
const textBaseline = leftLabelCfg.style?.textBaseline || 'bottom';
|
|
320
|
+
leftLabelCfg.style = deepAssign({}, leftLabelCfg.style, { textBaseline });
|
|
321
|
+
const textBaselineMap = { top: 'bottom', bottom: 'top', middle: 'middle' };
|
|
322
|
+
cfg.style = deepAssign({}, cfg.style, { textBaseline: textBaselineMap[textBaseline] });
|
|
323
|
+
}
|
|
324
|
+
|
|
297
325
|
leftGeometry.label({
|
|
298
326
|
fields: [yField[0]],
|
|
299
327
|
callback,
|
|
300
|
-
cfg: transformLabel(
|
|
328
|
+
cfg: transformLabel(leftLabelCfg),
|
|
301
329
|
});
|
|
302
330
|
rightGeometry.label({
|
|
303
331
|
fields: [yField[1]],
|
package/src/plots/box/adaptor.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isArray } from '@antv/util';
|
|
2
|
+
import { Types } from '@antv/g2';
|
|
2
3
|
import { Params } from '../../core/adaptor';
|
|
3
4
|
import { interaction, animation, theme, tooltip } from '../../adaptor/common';
|
|
4
5
|
import { point, schema } from '../../adaptor/geometries';
|
|
@@ -34,6 +35,8 @@ function field(params: Params<BoxOptions>): Params<BoxOptions> {
|
|
|
34
35
|
seriesField: groupField,
|
|
35
36
|
tooltip: tooltipOptions,
|
|
36
37
|
rawFields,
|
|
38
|
+
// 只有异常点视图展示 label
|
|
39
|
+
label: false,
|
|
37
40
|
schema: {
|
|
38
41
|
shape: 'box',
|
|
39
42
|
color,
|
|
@@ -50,21 +53,30 @@ function field(params: Params<BoxOptions>): Params<BoxOptions> {
|
|
|
50
53
|
return params;
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
/**
|
|
57
|
+
* 创建异常点 view
|
|
58
|
+
*/
|
|
53
59
|
function outliersPoint(params: Params<BoxOptions>): Params<BoxOptions> {
|
|
54
60
|
const { chart, options } = params;
|
|
55
|
-
const { xField, data, outliersField, outliersStyle, padding } = options;
|
|
61
|
+
const { xField, data, outliersField, outliersStyle, padding, label } = options;
|
|
56
62
|
|
|
57
63
|
if (!outliersField) return params;
|
|
58
64
|
|
|
59
65
|
const outliersView = chart.createView({ padding, id: OUTLIERS_VIEW_ID });
|
|
60
|
-
|
|
66
|
+
const outliersViewData = data.reduce((ret, datum) => {
|
|
67
|
+
const outliersData = datum[outliersField];
|
|
68
|
+
outliersData.forEach((d) => ret.push({ ...datum, [outliersField]: d }));
|
|
69
|
+
return ret;
|
|
70
|
+
}, []) as Types.Datum[];
|
|
61
71
|
|
|
72
|
+
outliersView.data(outliersViewData);
|
|
62
73
|
point({
|
|
63
74
|
chart: outliersView,
|
|
64
75
|
options: {
|
|
65
76
|
xField,
|
|
66
77
|
yField: outliersField,
|
|
67
78
|
point: { shape: 'circle', style: outliersStyle },
|
|
79
|
+
label,
|
|
68
80
|
},
|
|
69
81
|
});
|
|
70
82
|
|
|
@@ -67,6 +67,7 @@ function geometry(params: Params<ColumnOptions>): Params<ColumnOptions> {
|
|
|
67
67
|
seriesField,
|
|
68
68
|
groupField,
|
|
69
69
|
tooltip,
|
|
70
|
+
shape,
|
|
70
71
|
} = options;
|
|
71
72
|
|
|
72
73
|
const percentData =
|
|
@@ -110,6 +111,7 @@ function geometry(params: Params<ColumnOptions>): Params<ColumnOptions> {
|
|
|
110
111
|
widthRatio: columnWidthRatio,
|
|
111
112
|
tooltip: tooltipOptions,
|
|
112
113
|
interval: {
|
|
114
|
+
shape,
|
|
113
115
|
style: columnStyle,
|
|
114
116
|
color,
|
|
115
117
|
},
|
|
@@ -40,6 +40,11 @@ export interface ColumnOptions
|
|
|
40
40
|
/** 分组字段,优先级高于 seriesField , isGroup: true 时会根据 groupField 进行分组。*/
|
|
41
41
|
readonly groupField?: string;
|
|
42
42
|
|
|
43
|
+
// 自定义相关
|
|
44
|
+
/** 自定义柱状图 interval 图形元素展示形状 */
|
|
45
|
+
readonly shape?: string;
|
|
46
|
+
|
|
43
47
|
// 图表交互
|
|
48
|
+
/** 开启下钻交互,以及进行下钻交互的配置 */
|
|
44
49
|
readonly brush?: BrushCfg;
|
|
45
50
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction } from '@antv/util';
|
|
1
|
+
import { isFunction, clone } from '@antv/util';
|
|
2
2
|
import { Params } from '../../core/adaptor';
|
|
3
3
|
import { interaction, animation, theme, scale, annotation, tooltip } from '../../adaptor/common';
|
|
4
4
|
import { getLocale } from '../../core/locale';
|
|
@@ -27,7 +27,7 @@ import { FUNNEL_CONVERSATION, FUNNEL_PERCENT } from './constant';
|
|
|
27
27
|
*/
|
|
28
28
|
function defaultOptions(params: Params<FunnelOptions>): Params<FunnelOptions> {
|
|
29
29
|
const { options } = params;
|
|
30
|
-
const { compareField, xField, yField, locale, funnelStyle } = options;
|
|
30
|
+
const { compareField, xField, yField, locale, funnelStyle, data } = options;
|
|
31
31
|
const i18n = getLocale(locale);
|
|
32
32
|
|
|
33
33
|
const defaultOption = {
|
|
@@ -70,7 +70,7 @@ function defaultOptions(params: Params<FunnelOptions>): Params<FunnelOptions> {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
return deepAssign({ options: defaultOption }, params, { options: { funnelStyle: style } });
|
|
73
|
+
return deepAssign({ options: defaultOption }, params, { options: { funnelStyle: style, data: clone(data) } });
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
@@ -2,17 +2,7 @@ import { get } from '@antv/util';
|
|
|
2
2
|
import { Params } from '../../core/adaptor';
|
|
3
3
|
import { deepAssign, findGeometry } from '../../utils';
|
|
4
4
|
import { flow, transformLabel } from '../../utils';
|
|
5
|
-
import {
|
|
6
|
-
tooltip,
|
|
7
|
-
interaction,
|
|
8
|
-
animation,
|
|
9
|
-
theme,
|
|
10
|
-
scale,
|
|
11
|
-
annotation,
|
|
12
|
-
state,
|
|
13
|
-
legend,
|
|
14
|
-
pattern,
|
|
15
|
-
} from '../../adaptor/common';
|
|
5
|
+
import { tooltip, interaction, animation, theme, scale, annotation, state, pattern } from '../../adaptor/common';
|
|
16
6
|
import { geometry as geometryAdaptor } from '../../adaptor/geometries/base';
|
|
17
7
|
import { getTooltipMapping } from '../../utils/tooltip';
|
|
18
8
|
import { HeatmapOptions } from './types';
|
|
@@ -116,6 +106,34 @@ function axis(params: Params<HeatmapOptions>): Params<HeatmapOptions> {
|
|
|
116
106
|
return params;
|
|
117
107
|
}
|
|
118
108
|
|
|
109
|
+
/**
|
|
110
|
+
* legend 配置
|
|
111
|
+
* @param params
|
|
112
|
+
*/
|
|
113
|
+
function legend(params: Params<HeatmapOptions>): Params<HeatmapOptions> {
|
|
114
|
+
const { chart, options } = params;
|
|
115
|
+
const { legend, colorField, sizeField, sizeLegend } = options;
|
|
116
|
+
|
|
117
|
+
/** legend 不为 false, 则展示图例, 优先展示 color 分类图例 */
|
|
118
|
+
const showLegend = legend !== false;
|
|
119
|
+
|
|
120
|
+
if (colorField) {
|
|
121
|
+
chart.legend(colorField, showLegend ? legend : false);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 旧版本: 有 sizeField 就有 sizeLegend. 这里默认继承下 legend 配置
|
|
125
|
+
if (sizeField) {
|
|
126
|
+
chart.legend(sizeField, sizeLegend === undefined ? legend : sizeLegend);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** 默认没有 sizeField,则隐藏连续图例 */
|
|
130
|
+
if (!showLegend && !sizeLegend) {
|
|
131
|
+
chart.legend(false);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return params;
|
|
135
|
+
}
|
|
136
|
+
|
|
119
137
|
/**
|
|
120
138
|
* fixme 后续确认下,数据标签的逻辑为啥和通用的不一致
|
|
121
139
|
* 数据标签
|
|
@@ -10,8 +10,6 @@ export interface HeatmapOptions extends Options {
|
|
|
10
10
|
readonly yField: string;
|
|
11
11
|
/** 颜色字段,可选 */
|
|
12
12
|
readonly colorField?: string;
|
|
13
|
-
/** 点大小映射对应的数据字段名,可选 */
|
|
14
|
-
readonly sizeField?: string;
|
|
15
13
|
/** 热力格子中的形状,可选 */
|
|
16
14
|
readonly shape?: string;
|
|
17
15
|
/** 热力格子中图形的尺寸比例,可选,只有当 shape 和 sizeField 至少指定一项后才生效 */
|
|
@@ -21,6 +19,12 @@ export interface HeatmapOptions extends Options {
|
|
|
21
19
|
/** 极坐标属性 */
|
|
22
20
|
readonly coordinate?: Types.CoordinateOption;
|
|
23
21
|
|
|
22
|
+
// 图例相关
|
|
23
|
+
/** 点大小映射对应的数据字段名,可选 */
|
|
24
|
+
readonly sizeField?: string;
|
|
25
|
+
/** size 对应的图例 */
|
|
26
|
+
readonly sizeLegend?: Options['legend'];
|
|
27
|
+
|
|
24
28
|
// 样式相关
|
|
25
29
|
/** 热力图形样式 */
|
|
26
30
|
readonly heatmapStyle?: StyleAttr;
|