@antv/g2 4.1.40 → 4.1.44

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/lib/core.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Util = exports.Scale = exports.Coordinate = exports.DIRECTION = exports.LAYER = exports.getAnimation = exports.registerAnimation = exports.getEngine = exports.registerEngine = exports.registerTheme = exports.getTheme = exports.registerFacet = exports.getFacet = exports.getActionClass = exports.registerAction = exports.registerInteraction = exports.getInteraction = exports.getGeometryLabelLayout = exports.getGeometryLabel = exports.registerGeometryLabelLayout = exports.registerGeometryLabel = exports.getShapeFactory = exports.registerShapeFactory = exports.registerShape = exports.registerGeometry = exports.registerComponentController = exports.InteractionAction = exports.Facet = exports.Action = exports.Interaction = exports.GeometryLabel = exports.Element = exports.Geometry = exports.TooltipController = exports.ComponentController = exports.Event = exports.View = exports.Chart = exports.VERSION = void 0;
5
5
  var tslib_1 = require("tslib");
6
- exports.VERSION = '4.1.40';
6
+ exports.VERSION = '4.1.44';
7
7
  // 核心基类导出
8
8
  var chart_1 = require("./chart"); // Chart, View 类
9
9
  Object.defineProperty(exports, "Chart", { enumerable: true, get: function () { return chart_1.Chart; } });
package/lib/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;AAE1B,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,SAAS;AACT,iCAA6C,CAAC,gBAAgB;AAArD,8FAAA,KAAK,OAAA;AAAE,6FAAA,IAAI,OAAA;AAAE,8FAAA,KAAK,OAAA;AAC3B,gDAA4E,CAAC,UAAU;AAA9E,2GAAA,UAAU,OAAuB;AAC1C,sDAA0E,CAAC,kBAAkB;AAApF,0IAAA,OAAO,OAAqB;AACrC,wCAAsD,CAAC,cAAc;AAA5D,8HAAA,OAAO,OAAY;AAC5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,wGAAA,UAAU,OAAA;AAAE,mGAAA,KAAK,OAAA;AAE9C,WAAW;AACX,oCAA8C;AAC9C,wCAA+C;AAC/C,4CAA4E;AAC5E,8CAAsE;AACtE,0CAAiD;AACjD,kDAAgE;AAChE,yEAAsE;AACtE,8CAAgD;AAEnC,QAAA,IAAI,GAAG;IAClB,cAAc,yBAAA;IACd,SAAS,uBAAA;IACT,MAAM,oBAAA;IACN,IAAI,kBAAA;IACJ,SAAS,uBAAA;IACT,QAAQ,qBAAA;IACR,aAAa,0BAAA;IACb,gBAAgB,6BAAA;IAChB,mBAAmB,4BAAA;IACnB,eAAe,2BAAA;IACf,eAAe,wBAAA;IACf,gBAAgB;IAChB,OAAO,gBAAA;IACP,aAAa,iCAAA;CACd,CAAC","sourcesContent":["/* G2 的一个壳子,不包含 Geometry,由开发者自己定义和引入 */\n\nexport const VERSION = '4.1.40';\n\n// 核心基类导出\nexport { Chart, View, Event } from './chart'; // Chart, View 类\nexport { Controller as ComponentController } from './chart/controller/base'; // G2 组件基类\nexport { default as TooltipController } from './chart/controller/tooltip'; // G2 tooltip 组件基类\nexport { default as Geometry } from './geometry/base'; // Geometry 基类\nexport { default as Element } from './geometry/element'; // Element 类\nexport { default as GeometryLabel } from './geometry/label/base'; // Geometry Label 基类\nexport { Interaction, Action } from './interaction'; // Interaction, Action 基类\nexport { Facet } from './facet'; // Facet 基类\nexport { default as InteractionAction } from './interaction/action/base'; // Interaction Action 基类\n\n// 注册 ComponentController\nexport { registerComponentController } from './chart';\n\n// 注册 Geometry\nexport { registerGeometry } from './chart';\n\n// 注册 Geometry Shape\nexport { registerShape, registerShapeFactory, getShapeFactory } from './geometry/shape/base';\n\n// 注册 Geometry label 以及 Geometry Label 布局函数\nexport {\n registerGeometryLabel,\n registerGeometryLabelLayout,\n getGeometryLabel,\n getGeometryLabelLayout,\n} from './geometry/label';\n\n// 注册 interaction\nexport { getInteraction, registerInteraction, registerAction, getActionClass } from './interaction';\n\n// 注册 facet\nexport { getFacet, registerFacet } from './facet';\n\n// 注册主题\nexport { getTheme, registerTheme } from './theme';\n\n// G engine 管理相关\nexport { registerEngine, getEngine } from './engine';\n\n// 注册动画函数\nexport { registerAnimation, getAnimation } from './animate/animation';\n\nexport { LAYER, DIRECTION } from './constant';\n\n// 因为 typescript 部分版本不支持 export * as 语法。\nimport * as Types from './interface';\nexport type { Types };\n\nexport { IGroup, ShapeAttrs, Coordinate, Scale, ScaleConfig } from './dependents';\n\n// 一些工具方法导出\nimport { getMappingValue } from './util/attr';\nimport { getLegendItems } from './util/legend';\nimport { getAngle, getSectorPath, polarToCartesian } from './util/graphics';\nimport { rotate, transform, translate, zoom } from './util/transform';\nimport { getTooltipItems } from './util/tooltip';\nimport { getDelegationObject } from './interaction/action/util';\nimport { getPathPoints } from './geometry/shape/util/get-path-points';\nimport { getPath } from './geometry/shape/line';\n\nexport const Util = {\n getLegendItems,\n translate,\n rotate,\n zoom,\n transform,\n getAngle,\n getSectorPath,\n polarToCartesian,\n getDelegationObject,\n getTooltipItems,\n getMappingValue,\n // shape 的一些操作方法\n getPath,\n getPathPoints,\n};\n"]}
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;AAE1B,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,SAAS;AACT,iCAA6C,CAAC,gBAAgB;AAArD,8FAAA,KAAK,OAAA;AAAE,6FAAA,IAAI,OAAA;AAAE,8FAAA,KAAK,OAAA;AAC3B,gDAA4E,CAAC,UAAU;AAA9E,2GAAA,UAAU,OAAuB;AAC1C,sDAA0E,CAAC,kBAAkB;AAApF,0IAAA,OAAO,OAAqB;AACrC,wCAAsD,CAAC,cAAc;AAA5D,8HAAA,OAAO,OAAY;AAC5B,8CAAwD,CAAC,YAAY;AAA5D,gIAAA,OAAO,OAAW;AAC3B,8CAAiE,CAAC,oBAAoB;AAA7E,mIAAA,OAAO,OAAiB;AACjC,6CAAoD,CAAC,yBAAyB;AA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,kDAAgE;AAChE,yEAAsE;AACtE,8CAAgD;AAEnC,QAAA,IAAI,GAAG;IAClB,cAAc,yBAAA;IACd,SAAS,uBAAA;IACT,MAAM,oBAAA;IACN,IAAI,kBAAA;IACJ,SAAS,uBAAA;IACT,QAAQ,qBAAA;IACR,aAAa,0BAAA;IACb,gBAAgB,6BAAA;IAChB,mBAAmB,4BAAA;IACnB,eAAe,2BAAA;IACf,eAAe,wBAAA;IACf,gBAAgB;IAChB,OAAO,gBAAA;IACP,aAAa,iCAAA;CACd,CAAC","sourcesContent":["/* G2 的一个壳子,不包含 Geometry,由开发者自己定义和引入 */\n\nexport const VERSION = '4.1.44';\n\n// 核心基类导出\nexport { Chart, View, Event } from './chart'; // Chart, View 类\nexport { Controller as ComponentController } from './chart/controller/base'; // G2 组件基类\nexport { default as TooltipController } from './chart/controller/tooltip'; // G2 tooltip 组件基类\nexport { default as Geometry } from './geometry/base'; // Geometry 基类\nexport { default as Element } from './geometry/element'; // Element 类\nexport { default as GeometryLabel } from './geometry/label/base'; // Geometry Label 基类\nexport { Interaction, Action } from './interaction'; // Interaction, Action 基类\nexport { Facet } from './facet'; // Facet 基类\nexport { default as InteractionAction } from './interaction/action/base'; // Interaction Action 基类\n\n// 注册 ComponentController\nexport { registerComponentController } from './chart';\n\n// 注册 Geometry\nexport { registerGeometry } from './chart';\n\n// 注册 Geometry Shape\nexport { registerShape, registerShapeFactory, getShapeFactory } from './geometry/shape/base';\n\n// 注册 Geometry label 以及 Geometry Label 布局函数\nexport {\n registerGeometryLabel,\n registerGeometryLabelLayout,\n getGeometryLabel,\n getGeometryLabelLayout,\n} from './geometry/label';\n\n// 注册 interaction\nexport { getInteraction, registerInteraction, registerAction, getActionClass } from './interaction';\n\n// 注册 facet\nexport { getFacet, registerFacet } from './facet';\n\n// 注册主题\nexport { getTheme, registerTheme } from './theme';\n\n// G engine 管理相关\nexport { registerEngine, getEngine } from './engine';\n\n// 注册动画函数\nexport { registerAnimation, getAnimation } from './animate/animation';\n\nexport { LAYER, DIRECTION } from './constant';\n\n// 因为 typescript 部分版本不支持 export * as 语法。\nimport * as Types from './interface';\nexport type { Types };\n\nexport { IGroup, ShapeAttrs, Coordinate, Scale, ScaleConfig } from './dependents';\n\n// 一些工具方法导出\nimport { getMappingValue } from './util/attr';\nimport { getLegendItems } from './util/legend';\nimport { getAngle, getSectorPath, polarToCartesian } from './util/graphics';\nimport { rotate, transform, translate, zoom } from './util/transform';\nimport { getTooltipItems } from './util/tooltip';\nimport { getDelegationObject } from './interaction/action/util';\nimport { getPathPoints } from './geometry/shape/util/get-path-points';\nimport { getPath } from './geometry/shape/line';\n\nexport const Util = {\n getLegendItems,\n translate,\n rotate,\n zoom,\n transform,\n getAngle,\n getSectorPath,\n polarToCartesian,\n getDelegationObject,\n getTooltipItems,\n getMappingValue,\n // shape 的一些操作方法\n getPath,\n getPathPoints,\n};\n"]}
@@ -15,6 +15,7 @@ var group_data_1 = require("./util/group-data");
15
15
  var is_model_change_1 = require("./util/is-model-change");
16
16
  var parse_fields_1 = require("./util/parse-fields");
17
17
  var diff_1 = require("./util/diff");
18
+ var scale_1 = require("../util/scale");
18
19
  var coordinate_1 = require("../util/coordinate");
19
20
  // 根据 elementId 查找对应的 label,因为有可能一个 element 对应多个 labels,所以在给 labels 打标识时做了处理
20
21
  // 打标规则详见 ./label/base.ts#L263
@@ -629,9 +630,6 @@ var Geometry = /** @class */ (function (_super) {
629
630
  id = "".concat(xVal, "-").concat(yVal);
630
631
  }
631
632
  var groupScales = this.groupScales;
632
- if ((0, util_1.isEmpty)(groupScales)) {
633
- groupScales = (0, util_1.get)(this.getAttribute('color'), 'scales', []);
634
- }
635
633
  for (var index = 0, length_2 = groupScales.length; index < length_2; index++) {
636
634
  var groupScale = groupScales[index];
637
635
  var field = groupScale.field;
@@ -1065,9 +1063,12 @@ var Geometry = /** @class */ (function (_super) {
1065
1063
  // 获取每一个字段对应的 scale
1066
1064
  var scales = fields.map(function (field) {
1067
1065
  var scale = _this.scales[field];
1068
- if (scale.isCategory && !tmpMap[field] && constant_1.GROUP_ATTRS.includes(attrType)) {
1069
- _this.groupScales.push(scale);
1070
- tmpMap[field] = true;
1066
+ if (!tmpMap[field] && constant_1.GROUP_ATTRS.includes(attrType)) {
1067
+ var inferedScaleType = (0, scale_1.inferScaleType)(scale, (0, util_1.get)(_this.scaleDefs, field), attrType, _this.type);
1068
+ if (inferedScaleType === 'cat') {
1069
+ _this.groupScales.push(scale);
1070
+ tmpMap[field] = true;
1071
+ }
1071
1072
  }
1072
1073
  return scale;
1073
1074
  });
@@ -1147,12 +1148,12 @@ var Geometry = /** @class */ (function (_super) {
1147
1148
  var columnWidthRatio = this.columnWidthRatio || theme.columnWidthRatio;
1148
1149
  var result = dataArray;
1149
1150
  if (adjustOption) {
1150
- var xScale = this.getXScale();
1151
+ var xScale_2 = this.getXScale();
1151
1152
  var yScale = this.getYScale();
1152
- var xField = xScale.field;
1153
+ var xField = xScale_2.field;
1153
1154
  var yField = yScale ? yScale.field : null;
1154
1155
  var xDimensionLength = (0, coordinate_1.getXDimensionLength)(this.coordinate);
1155
- var groupNum = xScale.values.length;
1156
+ var groupNum = xScale_2.values.length;
1156
1157
  // 传入size计算相关参数,默认宽度、最大最小宽度约束
1157
1158
  var sizeAttr = this.getAttribute('size');
1158
1159
  var defaultSize = void 0;
@@ -1165,7 +1166,7 @@ var Geometry = /** @class */ (function (_super) {
1165
1166
  var type = adjust.type;
1166
1167
  if (type === 'dodge') {
1167
1168
  var adjustNames = [];
1168
- if (xScale.isCategory || xScale.type === 'identity') {
1169
+ if (xScale_2.isCategory || xScale_2.type === 'identity') {
1169
1170
  adjustNames.push('x');
1170
1171
  }
1171
1172
  else if (!yScale) {
@@ -1193,6 +1194,11 @@ var Geometry = /** @class */ (function (_super) {
1193
1194
  }
1194
1195
  }
1195
1196
  var adjustCtor = (0, adjust_1.getAdjust)(type);
1197
+ adjustCfg.dimValuesMap = {};
1198
+ //生成dimValuesMap
1199
+ if (xScale_2 && xScale_2.values) {
1200
+ adjustCfg.dimValuesMap[xScale_2.field] = xScale_2.values.map(function (v) { return xScale_2.translate(v); });
1201
+ }
1196
1202
  var adjustInstance = new adjustCtor(adjustCfg);
1197
1203
  result = adjustInstance.process(result);
1198
1204
  this.adjusts[type] = adjustInstance;