@antv/g2plot 2.3.37 → 2.4.0
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 +73 -0
- package/README.en-US.md +0 -1
- package/README.md +0 -1
- package/dist/g2plot.min.js +4 -4
- package/dist/g2plot.min.js.map +1 -1
- package/esm/adaptor/conversion-tag.js +3 -3
- package/esm/adaptor/conversion-tag.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/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.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/bar/adaptor.d.ts +7 -2
- package/esm/plots/bar/adaptor.js +72 -25
- package/esm/plots/bar/adaptor.js.map +1 -1
- package/esm/plots/bar/index.js +1 -2
- package/esm/plots/bar/index.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/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/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/esm/plots/pie/interactions/{pie-statistic-action.d.ts → 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/adaptor.js +1 -11
- package/esm/plots/sunburst/adaptor.js.map +1 -1
- package/esm/plots/sunburst/constant.js +1 -0
- package/esm/plots/sunburst/constant.js.map +1 -1
- package/esm/plots/sunburst/types.d.ts +1 -1
- package/esm/plots/sunburst/types.js.map +1 -1
- package/esm/plots/venn/types.d.ts +1 -1
- package/esm/plots/venn/types.js.map +1 -1
- package/esm/utils/data.js +2 -0
- package/esm/utils/data.js.map +1 -1
- package/lib/adaptor/conversion-tag.js +3 -3
- package/lib/adaptor/conversion-tag.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/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.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/bar/adaptor.d.ts +7 -2
- package/lib/plots/bar/adaptor.js +74 -26
- package/lib/plots/bar/adaptor.js.map +1 -1
- package/lib/plots/bar/index.js +1 -2
- package/lib/plots/bar/index.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/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/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/lib/plots/pie/interactions/{pie-statistic-action.d.ts → 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/adaptor.js +1 -11
- package/lib/plots/sunburst/adaptor.js.map +1 -1
- package/lib/plots/sunburst/constant.js +1 -0
- package/lib/plots/sunburst/constant.js.map +1 -1
- package/lib/plots/sunburst/types.d.ts +1 -1
- package/lib/plots/sunburst/types.js.map +1 -1
- package/lib/plots/venn/types.d.ts +1 -1
- package/lib/plots/venn/types.js.map +1 -1
- package/lib/utils/data.js +2 -0
- package/lib/utils/data.js.map +1 -1
- package/package.json +8 -7
- package/src/adaptor/conversion-tag.ts +3 -3
- package/src/adaptor/geometries/base.ts +23 -2
- package/src/adaptor/geometries/index.ts +1 -0
- package/src/index.ts +1 -1
- package/src/plots/area/adaptor.ts +5 -2
- package/src/plots/area/types.ts +2 -3
- package/src/plots/bar/adaptor.ts +90 -47
- package/src/plots/bar/index.ts +1 -2
- package/src/plots/bidirectional-bar/adaptor.ts +35 -7
- package/src/plots/bidirectional-bar/index.ts +3 -0
- package/src/plots/column/adaptor.ts +2 -0
- package/src/plots/column/types.ts +5 -0
- 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/adaptor.ts +9 -13
- package/src/plots/sunburst/constant.ts +1 -0
- package/src/plots/sunburst/types.ts +1 -1
- package/src/plots/venn/types.ts +1 -1
- package/src/utils/data.ts +1 -0
- package/esm/plots/bar/utils.d.ts +0 -6
- package/esm/plots/bar/utils.js +0 -8
- package/esm/plots/bar/utils.js.map +0 -1
- 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/lib/plots/bar/utils.d.ts +0 -6
- package/lib/plots/bar/utils.js +0 -12
- package/lib/plots/bar/utils.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/src/plots/bar/utils.ts +0 -9
|
@@ -77,7 +77,7 @@ exports.getMappingFunction = getMappingFunction;
|
|
|
77
77
|
*/
|
|
78
78
|
function geometry(params) {
|
|
79
79
|
var chart = params.chart, options = params.options;
|
|
80
|
-
var type = options.type, args = options.args, mapping = options.mapping, xField = options.xField, yField = options.yField, colorField = options.colorField, shapeField = options.shapeField, sizeField = options.sizeField, tooltipFields = options.tooltipFields, label = options.label, state = options.state;
|
|
80
|
+
var type = options.type, args = options.args, mapping = options.mapping, xField = options.xField, yField = options.yField, colorField = options.colorField, shapeField = options.shapeField, sizeField = options.sizeField, tooltipFields = options.tooltipFields, label = options.label, state = options.state, customInfo = options.customInfo;
|
|
81
81
|
// 如果没有 mapping 信息,那么直接返回
|
|
82
82
|
if (!mapping) {
|
|
83
83
|
return params;
|
|
@@ -179,6 +179,12 @@ function geometry(params) {
|
|
|
179
179
|
if (state) {
|
|
180
180
|
geometry.state(state);
|
|
181
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* 自定义信息
|
|
184
|
+
*/
|
|
185
|
+
if (customInfo) {
|
|
186
|
+
geometry.customInfo(customInfo);
|
|
187
|
+
}
|
|
182
188
|
// 防止因为 x y 字段做了通道映射,导致生成图例
|
|
183
189
|
[xField, yField]
|
|
184
190
|
.filter(function (f) { return f !== colorField; })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/base.ts"],"names":[],"mappings":";;;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AAE,EAAE,QAAQ,UAAA,EAAE,IACjB;AACJ,CAAC;AAtHD,4BAsHC","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 /** 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 { type, args, mapping, xField, yField, colorField, shapeField, sizeField, tooltipFields, label, state } =\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 // 防止因为 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,mCAAqF;AAKrF,qCAA6C;AA0D7C;;;;GAIG;AACH,SAAgB,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,GAAiC,CAAC,UAAlC,EAAE,UAAU,GAAqB,CAAC,WAAtB,EAAE,KAAmB,CAAC,UAAN,EAAd,SAAS,mBAAG,EAAE,KAAA,CAAO;IAElG,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,4DAA4D;IAC5D,gDAAgD;IAChD,iBAAiB;IACjB,IAAI,KAAK,KAAK,OAAO,EAAE;QACrB,MAAM,2BAAI,UAAU,IAAI,MAAM,GAAK,SAAS,CAAC,CAAC;KAC/C;SAAM,IAAI,KAAK,KAAK,OAAO,EAAE;QAC5B,MAAM,2BAAI,UAAU,IAAI,MAAM,GAAK,SAAS,CAAC,CAAC;KAC/C;SAAM,IAAI,KAAK,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;QAC3C,QAAQ,CAAC,KAAK,CAAC;YACb,MAAM,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC;YAC1B,QAAQ,UAAA;YACR,GAAG,EAAE,sBAAc,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,6CACK,MAAM;QACT,gFAAgF;QAChF,GAAG,EAAE,EAAE,QAAQ,UAAA,EAAE,IACjB;AACJ,CAAC;AAzID,4BAyIC","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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/index.ts"],"names":[],"mappings":";;AACA,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAEb,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAEb,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AAEd,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAEjB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAEb,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAEf,mCAAkC;AAAzB,gGAAA,MAAM,OAAA","sourcesContent":["export type { GeometryOptions } from './base';\nexport { area } from './area';\nexport type { AreaGeometryOptions } from './area';\nexport { line } from './line';\nexport type { LineGeometryOptions } from './line';\nexport { point } from './point';\nexport type { PointGeometryOptions } from './point';\nexport { interval } from './interval';\nexport type { IntervalGeometryOptions } from './interval';\nexport { polygon } from './polygon';\nexport type { PolygonGeometryOptions } from './polygon';\nexport { edge } from './edge';\nexport type { EdgeGeometryOptions } from './edge';\nexport { schema } from './schema';\nexport type { SchemaGeometryOptions } from './schema';\nexport { violin } from './violin';\nexport type { ViolinGeometryOptions } from './violin';\n"]}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.adaptors = exports.registerLocale = exports.G2 = exports.version = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
exports.version = '2.
|
|
5
|
+
exports.version = '2.4.0';
|
|
6
6
|
// G2 自定义能力透出
|
|
7
7
|
var G2 = tslib_1.__importStar(require("@antv/g2"));
|
|
8
8
|
exports.G2 = G2;
|
package/lib/index.js.map
CHANGED
|
@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EV,8BAA8B;AAC9B,2CAAmD;AAA1C,2GAAA,gBAAgB,OAAA;AAEzB,eAAe;AACf,mCAA+C;AAAtC,gGAAA,GAAG,OAAa;AAEzB,oBAAoB;AACpB,mCAAyC;AAAhC,0FAAA,GAAG,OAAO;AAGnB,2DAA2D;AAC3D,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AAGd,uCAAuC;AACvC,iCAAiD;AAAxC,6FAAA,IAAI,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAE/B,0CAA0C;AAC1C,mDAAoF;AAA3E,kGAAA,IAAI,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,kGAAA,IAAI,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,qGAAA,OAAO,OAAA;AAAE,oGAAA,MAAM,OAAA;AASrD,uCAAuC;AACvC,2CAAqG;AACxF,QAAA,QAAQ,GAAG,EAAE,KAAK,gBAAA,EAAE,MAAM,iBAAA,EAAE,OAAO,kBAAA,EAAE,UAAU,qBAAA,EAAE,WAAW,sBAAA,EAAE,KAAK,gBAAA,EAAE,SAAS,oBAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,6BAA4B;AAAnB,0FAAA,GAAG,OAAA","sourcesContent":["export const version = '2.3.37';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\nexport { G2 };\n\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n\n// 类型定义导出\nexport * from './types';\n\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\n\n// 已经废弃,更名为 Mix\nexport { Mix as MultiView } from './plots/mix';\nexport type { MixOptions as MultiViewOptions } from './plots/mix';\n/** 开放多图层图表 (mix) */\nexport { Mix as Mix } from './plots/mix';\nexport type { MixOptions } from './plots/mix';\n\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { line, interval, area, point, polygon, schema } from './adaptor/geometries';\nexport type {\n LineGeometryOptions,\n IntervalGeometryOptions,\n AreaGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common';\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC;AAE/B,aAAa;AACb,mDAA+B;AACtB,gBAAE;AAEX,QAAQ;AACR,wCAA+C;AAOtC,+FAPA,uBAAc,OAOA;AANvB,yCAA+C;AAC/C,yCAA+C;AAC/C,8BAA8B;AAC9B,uBAAc,CAAC,OAAO,EAAE,oBAAY,CAAC,CAAC;AACtC,uBAAc,CAAC,OAAO,EAAE,oBAAY,CAAC,CAAC;AAItC,WAAW;AACX,wCAA0C;AAAjC,mGAAA,SAAS,OAAA;AAElB,uBAAuB;AACvB,oCAAmC;AAA1B,4FAAA,IAAI,OAAA;AAKb,SAAS;AACT,kDAAwB;AAExB,2DAA2D;AAC3D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AAGb,2DAA2D;AAC3D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AAGb,uDAAuD;AACvD,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AAGf,yDAAyD;AACzD,mCAAkC;AAAzB,0FAAA,GAAG,OAAA;AAGZ,0DAA0D;AAC1D,mCAAkC;AAAz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export const version = '2.4.0';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\nexport { G2 };\n\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n\n// 类型定义导出\nexport * from './types';\n\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\n\n// 已经废弃,更名为 Mix\nexport { Mix as MultiView } from './plots/mix';\nexport type { MixOptions as MultiViewOptions } from './plots/mix';\n/** 开放多图层图表 (mix) */\nexport { Mix as Mix } from './plots/mix';\nexport type { MixOptions } from './plots/mix';\n\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { line, interval, area, point, polygon, schema } from './adaptor/geometries';\nexport type {\n LineGeometryOptions,\n IntervalGeometryOptions,\n AreaGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common';\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n"]}
|
|
@@ -41,11 +41,14 @@ function geometry(params) {
|
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
// 线默认 2px
|
|
45
|
+
var lineParams = utils_2.deepAssign({ options: { line: { size: 2 } } }, primary, {
|
|
46
|
+
options: { sizeField: seriesField, tooltip: false },
|
|
47
|
+
});
|
|
45
48
|
var pointParams = utils_2.deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
46
49
|
// area geometry 处理
|
|
47
50
|
geometries_1.area(primary);
|
|
48
|
-
geometries_1.line(
|
|
51
|
+
geometries_1.line(lineParams);
|
|
49
52
|
geometries_1.point(pointParams);
|
|
50
53
|
return params;
|
|
51
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/area/adaptor.ts"],"names":[],"mappings":";;;;AACA,mCAAkC;AAClC,+CAAwH;AACxH,qCAA2C;AAE3C,uDAA6D;AAC7D,qCAA+D;AAC/D,yDAAwE;AAExE,2CAAqD;AAG5C,qFAHA,cAAI,OAGA;AAEb;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAA2B;IACnC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAEhC,IAAA,IAAI,GAWF,OAAO,KAXL,EACJ,SAAS,GAUP,OAAO,UAVA,EACT,KAAK,GASH,OAAO,MATJ,EACE,YAAY,GAQjB,OAAO,MARU,EACb,WAAW,GAOf,OAAO,KAPQ,EACjB,SAAS,GAMP,OAAO,UANA,EACT,MAAM,GAKJ,OAAO,OALH,EACN,MAAM,GAIJ,OAAO,OAJH,EACN,OAAO,GAGL,OAAO,QAHF,EACP,WAAW,GAET,OAAO,YAFE,EACX,WAAW,GACT,OAAO,YADE,CACD;IACZ,IAAM,UAAU,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,CAAC;IAEvC,IAAM,SAAS,GAAG,iCAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACnF,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtB,gCAAgC;IAChC,IAAM,cAAc,GAAG,SAAS;QAC9B,CAAC,oBACG,SAAS,EAAE,UAAC,KAAY,IAAK,OAAA,CAAC;gBAC5B,IAAI,EAAE,KAAK,CAAC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AAG,CAAC,CACvB;SACF,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,MAAM,CAAC,MAA2B;IACjC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,OAAO,GAA6B,OAAO,QAApC,EAAE,SAAS,GAAkB,OAAO,UAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IACpD,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,WAAW,EAAE;QACzC,WAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAC,CAAW;YACjC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAgB,OAAO,CAAC,MAA2B;IACjD,0BAA0B;IAC1B,OAAO,YAAI,CACT,cAAK,EACL,gBAAO,CAAC,WAAW,CAAC,EACpB,QAAQ,EACR,cAAI,EACJ,MAAM,EACN,cAAI,EACJ,gBAAM,EACN,gBAAO,EACP,KAAK,EACL,eAAM,EACN,mBAAU,EAAE,EACZ,oBAAW,EACX,kBAAS,EACT,oBAAW,CACZ,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAlBD,0BAkBC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { each } from '@antv/util';\nimport { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';\nimport { findGeometry } from '../../utils';\nimport { Params } from '../../core/adaptor';\nimport { area, point, line } from '../../adaptor/geometries';\nimport { flow, transformLabel, deepAssign } from '../../utils';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { Datum } from '../../types';\nimport { meta, legend, axis } from '../line/adaptor';\nimport { AreaOptions } from './types';\n\nexport { meta };\n\n/**\n * geometry 处理\n * @param params\n */\nfunction geometry(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const {\n data,\n areaStyle,\n color,\n point: pointMapping,\n line: lineMapping,\n isPercent,\n xField,\n yField,\n tooltip,\n seriesField,\n startOnZero,\n } = options;\n const pointState = pointMapping?.state;\n\n const chartData = getDataWhetherPecentage(data, yField, xField, yField, isPercent);\n chart.data(chartData);\n // 百分比堆积图,默认会给一个 % 格式化逻辑, 用户可自定义\n const tooltipOptions = isPercent\n ? {\n formatter: (datum: Datum) => ({\n name: datum[seriesField] || datum[xField],\n value: (Number(datum[yField]) * 100).toFixed(2) + '%',\n }),\n ...tooltip,\n }\n : tooltip;\n const primary = deepAssign({}, params, {\n options: {\n area: { color, style: areaStyle },\n // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。\n // 如果存在,才设置,否则为空\n line: lineMapping && {\n color,\n ...lineMapping,\n },\n point: pointMapping && {\n color,\n ...pointMapping,\n },\n tooltip: tooltipOptions,\n // label 不传递给各个 geometry adaptor,由 label adaptor 处理\n label: undefined,\n args: {\n startOnZero,\n },\n },\n });\n // 线默认 2px\n const lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {\n options: { sizeField: seriesField, tooltip: false },\n });\n const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n\n // area geometry 处理\n area(primary);\n line(lineParams);\n point(pointParams);\n\n return params;\n}\n\n/**\n * 数据标签\n * @param params\n */\nfunction label(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { label, yField } = options;\n\n const areaGeometry = findGeometry(chart, 'area');\n\n // label 为 false, 空 则不显示 label\n if (!label) {\n areaGeometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n areaGeometry.label({\n fields: [yField],\n callback,\n cfg: {\n layout: [\n { type: 'limit-in-plot' },\n { type: 'path-adjust-position' },\n { type: 'point-adjust-position' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ],\n ...transformLabel(cfg),\n },\n });\n }\n\n return params;\n}\n\n/**\n * 处理 adjust\n * @param params\n */\nfunction adjust(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { isStack, isPercent, seriesField } = options;\n if ((isPercent || isStack) && seriesField) {\n each(chart.geometries, (g: Geometry) => {\n g.adjust('stack');\n });\n }\n\n return params;\n}\n\n/**\n * 折线图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<AreaOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n theme,\n pattern('areaStyle'),\n geometry,\n meta,\n adjust,\n axis,\n legend,\n tooltip,\n label,\n slider,\n annotation(),\n interaction,\n animation,\n limitInPlot\n )(params);\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
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
|
-
export interface AreaOptions extends Options {
|
|
4
|
+
export interface AreaOptions extends Options, Pick<GeometryOptions, 'customInfo'> {
|
|
6
5
|
/** x 轴字段 */
|
|
7
6
|
readonly xField?: string;
|
|
8
7
|
/** y 轴字段 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/area/types.ts"],"names":[],"mappings":"","sourcesContent":["import { PointGeometryOptions } from '../../adaptor/geometries';\nimport { Options, StyleAttr } from '../../types';\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/area/types.ts"],"names":[],"mappings":"","sourcesContent":["import { GeometryOptions, LineGeometryOptions, PointGeometryOptions } from '../../adaptor/geometries';\nimport { Options, StyleAttr } from '../../types';\n\n/** 面积图的配置类型定义 */\nexport interface AreaOptions extends Options, Pick<GeometryOptions, 'customInfo'> {\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly seriesField?: string;\n /** 是否堆积 */\n readonly isStack?: boolean;\n /** 是否百分比 */\n readonly isPercent?: boolean;\n /** 是否平滑 */\n readonly smooth?: boolean;\n /** 面积图形样式 */\n readonly areaStyle?: StyleAttr;\n /** 面积中折线的样式 */\n readonly line?: LineGeometryOptions['line'];\n /** 面积图数据点图形样式 */\n readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;\n /** 积图是否从 0 基准线开始填充 */\n readonly startOnZero?: boolean;\n}\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Params } from '../../core/adaptor';
|
|
2
|
-
import { BarOptions } from './types';
|
|
3
2
|
export { meta } from '../column/adaptor';
|
|
3
|
+
import { BarOptions } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* 柱形图适配器
|
|
6
6
|
* @param params
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function geometry(params: Params<BarOptions>): Params<BarOptions>;
|
|
9
|
+
/**
|
|
10
|
+
* @param chart
|
|
11
|
+
* @param options
|
|
12
|
+
*/
|
|
13
|
+
export declare function adaptor(params: Params<BarOptions>): Params<BarOptions>;
|
package/lib/plots/bar/adaptor.js
CHANGED
|
@@ -1,18 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.adaptor = void 0;
|
|
3
|
+
exports.adaptor = exports.geometry = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var common_1 = require("../../adaptor/common");
|
|
6
|
+
var utils_1 = require("../../utils");
|
|
5
7
|
var adaptor_1 = require("../column/adaptor");
|
|
6
|
-
var utils_1 = require("./utils");
|
|
7
8
|
var adaptor_2 = require("../column/adaptor");
|
|
8
9
|
Object.defineProperty(exports, "meta", { enumerable: true, get: function () { return adaptor_2.meta; } });
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* 处理默认配置项
|
|
12
|
+
* 1. switch xField、 yField
|
|
13
|
+
* 2. switch xAxis、 yAxis and adjust axis.position configuration
|
|
14
|
+
*/
|
|
15
|
+
function defaultOptions(params) {
|
|
16
|
+
var options = params.options;
|
|
17
|
+
var xField = options.xField, yField = options.yField, xAxis = options.xAxis, yAxis = options.yAxis;
|
|
18
|
+
var position = {
|
|
19
|
+
left: 'bottom',
|
|
20
|
+
right: 'top',
|
|
21
|
+
top: 'left',
|
|
22
|
+
bottom: 'right',
|
|
23
|
+
};
|
|
24
|
+
var verticalAxis = yAxis !== false
|
|
25
|
+
? tslib_1.__assign({ position: position[(yAxis === null || yAxis === void 0 ? void 0 : yAxis.position) || 'left'] }, yAxis) : false;
|
|
26
|
+
var horizontalAxis = xAxis !== false
|
|
27
|
+
? tslib_1.__assign({ position: position[(xAxis === null || xAxis === void 0 ? void 0 : xAxis.position) || 'bottom'] }, xAxis) : false;
|
|
28
|
+
return utils_1.deepAssign({}, params, {
|
|
29
|
+
options: {
|
|
30
|
+
xField: yField,
|
|
31
|
+
yField: xField,
|
|
32
|
+
xAxis: verticalAxis,
|
|
33
|
+
yAxis: horizontalAxis,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* label 适配器
|
|
11
39
|
* @param params
|
|
12
40
|
*/
|
|
13
|
-
function
|
|
14
|
-
var
|
|
15
|
-
var
|
|
41
|
+
function label(params) {
|
|
42
|
+
var options = params.options;
|
|
43
|
+
var label = options.label;
|
|
16
44
|
// label of bar charts default position is left, if plot has label
|
|
17
45
|
if (label && !label.position) {
|
|
18
46
|
label.position = 'left';
|
|
@@ -26,39 +54,59 @@ function adaptor(params) {
|
|
|
26
54
|
];
|
|
27
55
|
}
|
|
28
56
|
}
|
|
57
|
+
return utils_1.deepAssign({}, params, { options: { label: label } });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* legend 适配器
|
|
61
|
+
* @param params
|
|
62
|
+
*/
|
|
63
|
+
function legend(params) {
|
|
64
|
+
var options = params.options;
|
|
29
65
|
// 默认 legend 位置
|
|
66
|
+
var seriesField = options.seriesField, isStack = options.isStack;
|
|
30
67
|
var legend = options.legend;
|
|
31
68
|
if (seriesField) {
|
|
32
69
|
if (legend !== false) {
|
|
33
|
-
legend = tslib_1.__assign({ position: isStack ? 'top-left' : 'right-top'
|
|
70
|
+
legend = tslib_1.__assign({ position: isStack ? 'top-left' : 'right-top' }, (legend || {}));
|
|
34
71
|
}
|
|
35
72
|
}
|
|
36
73
|
else {
|
|
37
74
|
legend = false;
|
|
38
75
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
params
|
|
50
|
-
|
|
51
|
-
|
|
76
|
+
return utils_1.deepAssign({}, params, { options: { legend: legend } });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* coordinate 适配器
|
|
80
|
+
* @param params
|
|
81
|
+
*/
|
|
82
|
+
function coordinate(params) {
|
|
83
|
+
var chart = params.chart;
|
|
84
|
+
// transpose column to bar 对角变换 & y 方向镜像变换
|
|
85
|
+
chart.coordinate({ actions: [['transpose'], ['reflect', 'y']] });
|
|
86
|
+
return params;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 柱形图适配器
|
|
90
|
+
* @param params
|
|
91
|
+
*/
|
|
92
|
+
function geometry(params) {
|
|
93
|
+
var chart = params.chart, options = params.options;
|
|
94
|
+
var barStyle = options.barStyle, barWidthRatio = options.barWidthRatio, minBarWidth = options.minBarWidth, maxBarWidth = options.maxBarWidth, barBackground = options.barBackground;
|
|
52
95
|
return adaptor_1.adaptor({
|
|
53
96
|
chart: chart,
|
|
54
|
-
options: tslib_1.__assign(tslib_1.__assign({}, options), {
|
|
55
|
-
// switch xField and yField
|
|
56
|
-
xField: yField, yField: xField, xAxis: yAxis, yAxis: xAxis,
|
|
97
|
+
options: tslib_1.__assign(tslib_1.__assign({}, options), {
|
|
57
98
|
// rename attrs as column
|
|
58
|
-
columnStyle: barStyle, columnWidthRatio: barWidthRatio, minColumnWidth: minBarWidth, maxColumnWidth: maxBarWidth, columnBackground:
|
|
59
|
-
// bar 调整数据顺序
|
|
60
|
-
data: utils_1.transformBarData(data) }),
|
|
99
|
+
columnStyle: barStyle, columnWidthRatio: barWidthRatio, minColumnWidth: minBarWidth, maxColumnWidth: maxBarWidth, columnBackground: barBackground }),
|
|
61
100
|
}, true);
|
|
62
101
|
}
|
|
102
|
+
exports.geometry = geometry;
|
|
103
|
+
/**
|
|
104
|
+
* @param chart
|
|
105
|
+
* @param options
|
|
106
|
+
*/
|
|
107
|
+
function adaptor(params) {
|
|
108
|
+
// flow 的方式处理所有的配置到 G2 API
|
|
109
|
+
return utils_1.flow(defaultOptions, label, legend, common_1.tooltip, coordinate, geometry)(params);
|
|
110
|
+
}
|
|
63
111
|
exports.adaptor = adaptor;
|
|
64
112
|
//# sourceMappingURL=adaptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/bar/adaptor.ts"],"names":[],"mappings":";;;;AACA,
|
|
1
|
+
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/bar/adaptor.ts"],"names":[],"mappings":";;;;AACA,+CAA+C;AAC/C,qCAA+C;AAC/C,6CAA6D;AAC7D,6CAAyC;AAAhC,+FAAA,IAAI,OAAA;AAGb;;;;GAIG;AACH,SAAS,cAAc,CAAC,MAA0B;IACxC,IAAA,OAAO,GAAK,MAAM,QAAX,CAAY;IACnB,IAAA,MAAM,GAA2B,OAAO,OAAlC,EAAE,MAAM,GAAmB,OAAO,OAA1B,EAAE,KAAK,GAAY,OAAO,MAAnB,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;IAEjD,IAAM,QAAQ,GAA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oB,OAAO,YAA3B,EAAE,aAAa,GAAK,OAAO,cAAZ,CAAa;IAErF,OAAO,iBAAa,CAClB;QACE,KAAK,OAAA;QACL,OAAO,wCACF,OAAO;YACV,yBAAyB;YACzB,WAAW,EAAE,QAAQ,EACrB,gBAAgB,EAAE,aAAa,EAC/B,cAAc,EAAE,WAAW,EAC3B,cAAc,EAAE,WAAW,EAC3B,gBAAgB,EAAE,aAAa,GAChC;KACF,EACD,IAAI,CACiB,CAAC;AAC1B,CAAC;AApBD,4BAoBC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,MAA0B;IAChD,0BAA0B;IAC1B,OAAO,YAAI,CAAqB,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AACxG,CAAC;AAHD,0BAGC","sourcesContent":["import { Params } from '../../core/adaptor';\nimport { tooltip } from '../../adaptor/common';\nimport { deepAssign, flow } from '../../utils';\nimport { adaptor as columnAdaptor } from '../column/adaptor';\nexport { meta } from '../column/adaptor';\nimport { BarOptions } from './types';\n\n/**\n * 处理默认配置项\n * 1. switch xField、 yField\n * 2. switch xAxis、 yAxis and adjust axis.position configuration\n */\nfunction defaultOptions(params: Params<BarOptions>): Params<BarOptions> {\n const { options } = params;\n const { xField, yField, xAxis, yAxis } = options;\n\n const position = {\n left: 'bottom',\n right: 'top',\n top: 'left',\n bottom: 'right',\n };\n\n const verticalAxis =\n yAxis !== false\n ? {\n position: position[yAxis?.position || 'left'],\n ...yAxis,\n }\n : false;\n const horizontalAxis =\n xAxis !== false\n ? {\n position: position[xAxis?.position || 'bottom'],\n ...xAxis,\n }\n : false;\n\n return deepAssign({}, params, {\n options: {\n xField: yField,\n yField: xField,\n xAxis: verticalAxis,\n yAxis: horizontalAxis,\n },\n });\n}\n\n/**\n * label 适配器\n * @param params\n */\nfunction label(params: Params<BarOptions>): Params<BarOptions> {\n const { options } = params;\n const { label } = options;\n // label of bar charts default position is left, if plot has label\n if (label && !label.position) {\n label.position = 'left';\n // 配置默认的 label layout: 如果用户没有指定 layout 和 position, 则自动配置 layout\n if (!label.layout) {\n label.layout = [\n { type: 'interval-adjust-position' },\n { type: 'interval-hide-overlap' },\n { type: 'adjust-color' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ];\n }\n }\n\n return deepAssign({}, params, { options: { label } });\n}\n\n/**\n * legend 适配器\n * @param params\n */\nfunction legend(params: Params<BarOptions>): Params<BarOptions> {\n const { options } = params;\n\n // 默认 legend 位置\n const { seriesField, isStack } = options;\n let { legend } = options;\n if (seriesField) {\n if (legend !== false) {\n legend = {\n position: isStack ? 'top-left' : 'right-top',\n ...(legend || {}),\n };\n }\n } else {\n legend = false;\n }\n\n return deepAssign({}, params, { options: { legend } });\n}\n\n/**\n * coordinate 适配器\n * @param params\n */\nfunction coordinate(params: Params<BarOptions>): Params<BarOptions> {\n const { chart } = params;\n // transpose column to bar 对角变换 & y 方向镜像变换\n chart.coordinate({ actions: [['transpose'], ['reflect', 'y']] });\n return params;\n}\n\n/**\n * 柱形图适配器\n * @param params\n */\nexport function geometry(params: Params<BarOptions>) {\n const { chart, options } = params;\n\n const { barStyle, barWidthRatio, minBarWidth, maxBarWidth, barBackground } = options;\n\n return columnAdaptor(\n {\n chart,\n options: {\n ...options,\n // rename attrs as column\n columnStyle: barStyle,\n columnWidthRatio: barWidthRatio,\n minColumnWidth: minBarWidth,\n maxColumnWidth: maxBarWidth,\n columnBackground: barBackground,\n },\n },\n true\n ) as Params<BarOptions>;\n}\n\n/**\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<BarOptions>): Params<BarOptions> {\n // flow 的方式处理所有的配置到 G2 API\n return flow<Params<BarOptions>>(defaultOptions, label, legend, tooltip, coordinate, geometry)(params);\n}\n"]}
|
package/lib/plots/bar/index.js
CHANGED
|
@@ -6,7 +6,6 @@ var plot_1 = require("../../core/plot");
|
|
|
6
6
|
var percent_1 = require("../../utils/transform/percent");
|
|
7
7
|
var adaptor_1 = require("./adaptor");
|
|
8
8
|
var constants_1 = require("./constants");
|
|
9
|
-
var utils_1 = require("./utils");
|
|
10
9
|
/**
|
|
11
10
|
* 条形图
|
|
12
11
|
*/
|
|
@@ -34,7 +33,7 @@ var Bar = /** @class */ (function (_super) {
|
|
|
34
33
|
var xField = options.xField, yField = options.yField, isPercent = options.isPercent;
|
|
35
34
|
var switchedFieldOptions = tslib_1.__assign(tslib_1.__assign({}, options), { xField: yField, yField: xField });
|
|
36
35
|
adaptor_1.meta({ chart: chart, options: switchedFieldOptions });
|
|
37
|
-
chart.changeData(percent_1.getDataWhetherPecentage(
|
|
36
|
+
chart.changeData(percent_1.getDataWhetherPecentage(data, xField, yField, xField, isPercent));
|
|
38
37
|
};
|
|
39
38
|
/**
|
|
40
39
|
* 获取 条形图 默认配置
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/bar/index.ts"],"names":[],"mappings":";;;;AAAA,wCAAuC;AAEvC,yDAAwE;AAExE,qCAA0C;AAC1C,yCAA8C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/bar/index.ts"],"names":[],"mappings":";;;;AAAA,wCAAuC;AAEvC,yDAAwE;AAExE,qCAA0C;AAC1C,yCAA8C;AAI9C;;GAEG;AACH;IAAyB,+BAAgB;IAAzC;QAAA,qEAqCC;QA5BC,WAAW;QACK,UAAI,GAAW,KAAK,CAAC;;IA2BvC,CAAC;IApCC;;;OAGG;IACI,qBAAiB,GAAxB;QACE,OAAO,2BAAe,CAAC;IACzB,CAAC;IAKD;;OAEG;IACI,wBAAU,GAAjB,UAAkB,IAAwB;QACxC,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;QACtB,IAAA,KAAqB,IAAI,EAAvB,KAAK,WAAA,EAAE,OAAO,aAAS,CAAC;QACxB,IAAA,MAAM,GAAwB,OAAO,OAA/B,EAAE,MAAM,GAAgB,OAAO,OAAvB,EAAE,SAAS,GAAK,OAAO,UAAZ,CAAa;QAC9C,IAAM,oBAAoB,yCAAQ,OAAO,KAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,CAAC;QAC5E,cAAI,CAAC,EAAE,KAAK,OAAA,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAC;QAC/C,KAAK,CAAC,UAAU,CAAC,iCAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACrF,CAAC;IAED;;OAEG;IACO,+BAAiB,GAA3B;QACE,OAAO,GAAG,CAAC,iBAAiB,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACO,8BAAgB,GAA1B;QACE,OAAO,iBAAO,CAAC;IACjB,CAAC;IACH,UAAC;AAAD,CAAC,AArCD,CAAyB,WAAI,GAqC5B;AArCY,kBAAG","sourcesContent":["import { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { BarOptions } from './types';\nimport { adaptor, meta } from './adaptor';\nimport { DEFAULT_OPTIONS } from './constants';\n\nexport type { BarOptions };\n\n/**\n * 条形图\n */\nexport class Bar extends Plot<BarOptions> {\n /**\n * 获取 条形图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<BarOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public readonly type: string = 'bar';\n\n /**\n * @override\n */\n public changeData(data: BarOptions['data']) {\n this.updateOption({ data });\n const { chart, options } = this;\n const { xField, yField, isPercent } = options;\n const switchedFieldOptions = { ...options, xField: yField, yField: xField };\n meta({ chart, options: switchedFieldOptions });\n chart.changeData(getDataWhetherPecentage(data, xField, yField, xField, isPercent));\n }\n\n /**\n * 获取 条形图 默认配置\n */\n protected getDefaultOptions() {\n return Bar.getDefaultOptions();\n }\n\n /**\n * 获取 条形图 的适配器\n */\n protected getSchemaAdaptor(): Adaptor<BarOptions> {\n return adaptor;\n }\n}\n"]}
|
|
@@ -66,10 +66,7 @@ function geometry(params) {
|
|
|
66
66
|
},
|
|
67
67
|
id: constant_1.SECOND_AXES_VIEW,
|
|
68
68
|
});
|
|
69
|
-
secondView
|
|
70
|
-
.coordinate()
|
|
71
|
-
.reflect('y')
|
|
72
|
-
.rotate(Math.PI * 0); // 旋转
|
|
69
|
+
secondView.coordinate().reflect('y');
|
|
73
70
|
firstView.data(firstViewData);
|
|
74
71
|
secondView.data(secondViewData);
|
|
75
72
|
}
|
|
@@ -240,12 +237,14 @@ function animation(params) {
|
|
|
240
237
|
}
|
|
241
238
|
exports.animation = animation;
|
|
242
239
|
/**
|
|
243
|
-
* label 配置
|
|
240
|
+
* label 配置 (1. 设置 offset 偏移量默认值 2. leftView 偏移量需要 *= -1)
|
|
244
241
|
* @param params
|
|
245
242
|
*/
|
|
246
243
|
function label(params) {
|
|
244
|
+
var _this = this;
|
|
245
|
+
var _a, _b;
|
|
247
246
|
var chart = params.chart, options = params.options;
|
|
248
|
-
var label = options.label, yField = options.yField;
|
|
247
|
+
var label = options.label, yField = options.yField, layout = options.layout;
|
|
249
248
|
var firstView = utils_1.findViewById(chart, constant_1.FIRST_AXES_VIEW);
|
|
250
249
|
var secondView = utils_1.findViewById(chart, constant_1.SECOND_AXES_VIEW);
|
|
251
250
|
var leftGeometry = utils_1.findGeometry(firstView, 'interval');
|
|
@@ -255,16 +254,53 @@ function label(params) {
|
|
|
255
254
|
rightGeometry.label(false);
|
|
256
255
|
}
|
|
257
256
|
else {
|
|
258
|
-
var callback = label.callback,
|
|
257
|
+
var callback = label.callback, cfg_1 = tslib_1.__rest(label, ["callback"]);
|
|
258
|
+
/** ---- 设置默认配置 ---- */
|
|
259
|
+
// 默认居中
|
|
260
|
+
if (!cfg_1.position) {
|
|
261
|
+
cfg_1.position = 'middle';
|
|
262
|
+
}
|
|
263
|
+
if (cfg_1.offset === undefined) {
|
|
264
|
+
cfg_1.offset = 2;
|
|
265
|
+
}
|
|
266
|
+
/** ---- leftView label 设置 ---- */
|
|
267
|
+
var leftLabelCfg = tslib_1.__assign({}, cfg_1);
|
|
268
|
+
if (utils_2.isHorizontal(layout)) {
|
|
269
|
+
// 设置 textAlign 默认值
|
|
270
|
+
var textAlign = ((_a = leftLabelCfg.style) === null || _a === void 0 ? void 0 : _a.textAlign) || (cfg_1.position === 'middle' ? 'center' : 'left');
|
|
271
|
+
cfg_1.style = utils_1.deepAssign({}, cfg_1.style, { textAlign: textAlign });
|
|
272
|
+
var textAlignMap = { left: 'right', right: 'left', center: 'center' };
|
|
273
|
+
leftLabelCfg.style = utils_1.deepAssign({}, leftLabelCfg.style, { textAlign: textAlignMap[textAlign] });
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
var positionMap_1 = { top: 'bottom', bottom: 'top', middle: 'middle' };
|
|
277
|
+
if (typeof cfg_1.position === 'string') {
|
|
278
|
+
cfg_1.position = positionMap_1[cfg_1.position];
|
|
279
|
+
}
|
|
280
|
+
else if (typeof cfg_1.position === 'function') {
|
|
281
|
+
cfg_1.position = function () {
|
|
282
|
+
var args = [];
|
|
283
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
284
|
+
args[_i] = arguments[_i];
|
|
285
|
+
}
|
|
286
|
+
return positionMap_1[cfg_1.position.apply(_this, args)];
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
// 设置 textBaseline 默认值
|
|
290
|
+
var textBaseline = ((_b = leftLabelCfg.style) === null || _b === void 0 ? void 0 : _b.textBaseline) || 'bottom';
|
|
291
|
+
leftLabelCfg.style = utils_1.deepAssign({}, leftLabelCfg.style, { textBaseline: textBaseline });
|
|
292
|
+
var textBaselineMap = { top: 'bottom', bottom: 'top', middle: 'middle' };
|
|
293
|
+
cfg_1.style = utils_1.deepAssign({}, cfg_1.style, { textBaseline: textBaselineMap[textBaseline] });
|
|
294
|
+
}
|
|
259
295
|
leftGeometry.label({
|
|
260
296
|
fields: [yField[0]],
|
|
261
297
|
callback: callback,
|
|
262
|
-
cfg: utils_1.transformLabel(
|
|
298
|
+
cfg: utils_1.transformLabel(leftLabelCfg),
|
|
263
299
|
});
|
|
264
300
|
rightGeometry.label({
|
|
265
301
|
fields: [yField[1]],
|
|
266
302
|
callback: callback,
|
|
267
|
-
cfg: utils_1.transformLabel(
|
|
303
|
+
cfg: utils_1.transformLabel(cfg_1),
|
|
268
304
|
});
|
|
269
305
|
}
|
|
270
306
|
return params;
|