@visactor/vchart 1.1.1-beta.1 → 1.2.0-beta.1

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.
Files changed (163) hide show
  1. package/build/index.js +247 -180
  2. package/build/index.min.js +1 -1
  3. package/cjs/chart/base-chart.d.ts +1 -0
  4. package/cjs/chart/base-chart.js +17 -12
  5. package/cjs/chart/base-chart.js.map +1 -1
  6. package/cjs/chart/interface/chart.d.ts +1 -0
  7. package/cjs/chart/interface/chart.js.map +1 -1
  8. package/cjs/chart/sequence/sequence.js +5 -3
  9. package/cjs/chart/sequence/sequence.js.map +1 -1
  10. package/cjs/compile/compiler.js +9 -5
  11. package/cjs/compile/compiler.js.map +1 -1
  12. package/cjs/compile/interface/compiler.d.ts +1 -0
  13. package/cjs/compile/interface/compiler.js.map +1 -1
  14. package/cjs/component/axis/cartesian/axis.js +1 -1
  15. package/cjs/component/axis/cartesian/axis.js.map +1 -1
  16. package/cjs/component/axis/interface.d.ts +25 -27
  17. package/cjs/component/axis/interface.js.map +1 -1
  18. package/cjs/component/axis/polar/axis.js +2 -2
  19. package/cjs/component/axis/polar/axis.js.map +1 -1
  20. package/cjs/component/geo/geo-coordinate.js +1 -1
  21. package/cjs/component/geo/geo-coordinate.js.map +1 -1
  22. package/cjs/component/geo/projection.js +1 -2
  23. package/cjs/component/geo/projection.js.map +1 -1
  24. package/cjs/component/label/label.d.ts +7 -0
  25. package/cjs/component/label/label.js +4 -0
  26. package/cjs/component/label/label.js.map +1 -1
  27. package/cjs/component/marker/base-marker.js +1 -1
  28. package/cjs/component/marker/base-marker.js.map +1 -1
  29. package/cjs/component/marker/interface.d.ts +2 -2
  30. package/cjs/component/marker/interface.js.map +1 -1
  31. package/cjs/constant/event.d.ts +2 -0
  32. package/cjs/constant/event.js +2 -1
  33. package/cjs/constant/event.js.map +1 -1
  34. package/cjs/core/index.d.ts +1 -1
  35. package/cjs/core/index.js +1 -1
  36. package/cjs/core/index.js.map +1 -1
  37. package/cjs/core/vchart.d.ts +6 -0
  38. package/cjs/core/vchart.js +66 -23
  39. package/cjs/core/vchart.js.map +1 -1
  40. package/cjs/data/initialize.d.ts +2 -1
  41. package/cjs/data/initialize.js +8 -5
  42. package/cjs/data/initialize.js.map +1 -1
  43. package/cjs/event/events/dimension/base.js +5 -3
  44. package/cjs/event/events/dimension/base.js.map +1 -1
  45. package/cjs/layout/base-layout.d.ts +3 -0
  46. package/cjs/layout/base-layout.js +8 -4
  47. package/cjs/layout/base-layout.js.map +1 -1
  48. package/cjs/layout/grid-layout/grid-layout.d.ts +3 -1
  49. package/cjs/layout/grid-layout/grid-layout.js +3 -2
  50. package/cjs/layout/grid-layout/grid-layout.js.map +1 -1
  51. package/cjs/layout/interface.d.ts +2 -1
  52. package/cjs/layout/interface.js.map +1 -1
  53. package/cjs/model/interface.d.ts +1 -0
  54. package/cjs/model/interface.js.map +1 -1
  55. package/cjs/series/base/base-series.js +2 -4
  56. package/cjs/series/base/base-series.js.map +1 -1
  57. package/cjs/series/geo/geo.js +3 -3
  58. package/cjs/series/geo/geo.js.map +1 -1
  59. package/cjs/series/map/map.js +6 -6
  60. package/cjs/series/map/map.js.map +1 -1
  61. package/cjs/series/scatter/scatter.js +7 -4
  62. package/cjs/series/scatter/scatter.js.map +1 -1
  63. package/cjs/series/sunburst/sunburst.d.ts +1 -1
  64. package/cjs/typings/params.d.ts +5 -0
  65. package/cjs/typings/params.js.map +1 -1
  66. package/cjs/typings/spec/common.d.ts +1 -0
  67. package/cjs/typings/spec/common.js.map +1 -1
  68. package/cjs/typings/visual.js.map +1 -1
  69. package/cjs/util/debug.d.ts +2 -2
  70. package/cjs/util/debug.js +4 -3
  71. package/cjs/util/debug.js.map +1 -1
  72. package/cjs/util/image.d.ts +2 -1
  73. package/cjs/util/image.js +10 -6
  74. package/cjs/util/image.js.map +1 -1
  75. package/cjs/util/math.js +5 -3
  76. package/cjs/util/math.js.map +1 -1
  77. package/esm/chart/base-chart.d.ts +1 -0
  78. package/esm/chart/base-chart.js +17 -12
  79. package/esm/chart/base-chart.js.map +1 -1
  80. package/esm/chart/interface/chart.d.ts +1 -0
  81. package/esm/chart/interface/chart.js.map +1 -1
  82. package/esm/chart/sequence/sequence.js +5 -3
  83. package/esm/chart/sequence/sequence.js.map +1 -1
  84. package/esm/compile/compiler.js +10 -6
  85. package/esm/compile/compiler.js.map +1 -1
  86. package/esm/compile/interface/compiler.d.ts +1 -0
  87. package/esm/compile/interface/compiler.js.map +1 -1
  88. package/esm/component/axis/cartesian/axis.js +1 -1
  89. package/esm/component/axis/cartesian/axis.js.map +1 -1
  90. package/esm/component/axis/interface.d.ts +25 -27
  91. package/esm/component/axis/interface.js.map +1 -1
  92. package/esm/component/axis/polar/axis.js +2 -2
  93. package/esm/component/axis/polar/axis.js.map +1 -1
  94. package/esm/component/geo/geo-coordinate.js +1 -1
  95. package/esm/component/geo/geo-coordinate.js.map +1 -1
  96. package/esm/component/geo/projection.js +1 -1
  97. package/esm/component/geo/projection.js.map +1 -1
  98. package/esm/component/label/label.d.ts +7 -0
  99. package/esm/component/label/label.js +4 -0
  100. package/esm/component/label/label.js.map +1 -1
  101. package/esm/component/marker/base-marker.js +1 -1
  102. package/esm/component/marker/base-marker.js.map +1 -1
  103. package/esm/component/marker/interface.d.ts +2 -2
  104. package/esm/component/marker/interface.js.map +1 -1
  105. package/esm/constant/event.d.ts +2 -0
  106. package/esm/constant/event.js +2 -1
  107. package/esm/constant/event.js.map +1 -1
  108. package/esm/core/index.d.ts +1 -1
  109. package/esm/core/index.js +1 -1
  110. package/esm/core/index.js.map +1 -1
  111. package/esm/core/vchart.d.ts +6 -0
  112. package/esm/core/vchart.js +68 -23
  113. package/esm/core/vchart.js.map +1 -1
  114. package/esm/data/initialize.d.ts +2 -1
  115. package/esm/data/initialize.js +9 -4
  116. package/esm/data/initialize.js.map +1 -1
  117. package/esm/event/events/dimension/base.js +6 -2
  118. package/esm/event/events/dimension/base.js.map +1 -1
  119. package/esm/layout/base-layout.d.ts +3 -0
  120. package/esm/layout/base-layout.js +8 -4
  121. package/esm/layout/base-layout.js.map +1 -1
  122. package/esm/layout/grid-layout/grid-layout.d.ts +3 -1
  123. package/esm/layout/grid-layout/grid-layout.js +3 -2
  124. package/esm/layout/grid-layout/grid-layout.js.map +1 -1
  125. package/esm/layout/interface.d.ts +2 -1
  126. package/esm/layout/interface.js.map +1 -1
  127. package/esm/model/interface.d.ts +1 -0
  128. package/esm/model/interface.js.map +1 -1
  129. package/esm/series/base/base-series.js +1 -4
  130. package/esm/series/base/base-series.js.map +1 -1
  131. package/esm/series/geo/geo.js +3 -3
  132. package/esm/series/geo/geo.js.map +1 -1
  133. package/esm/series/map/map.js +6 -6
  134. package/esm/series/map/map.js.map +1 -1
  135. package/esm/series/scatter/scatter.js +5 -4
  136. package/esm/series/scatter/scatter.js.map +1 -1
  137. package/esm/series/sunburst/sunburst.d.ts +1 -1
  138. package/esm/typings/params.d.ts +5 -0
  139. package/esm/typings/params.js.map +1 -1
  140. package/esm/typings/spec/common.d.ts +1 -0
  141. package/esm/typings/spec/common.js.map +1 -1
  142. package/esm/typings/visual.js.map +1 -1
  143. package/esm/util/debug.d.ts +2 -2
  144. package/esm/util/debug.js +4 -3
  145. package/esm/util/debug.js.map +1 -1
  146. package/esm/util/image.d.ts +2 -1
  147. package/esm/util/image.js +6 -3
  148. package/esm/util/image.js.map +1 -1
  149. package/esm/util/math.js +4 -2
  150. package/esm/util/math.js.map +1 -1
  151. package/package.json +9 -19
  152. package/chart.d.ts +0 -1
  153. package/chart.js +0 -1
  154. package/component.d.ts +0 -1
  155. package/component.js +0 -1
  156. package/core.d.ts +0 -1
  157. package/core.js +0 -1
  158. package/layout.d.ts +0 -1
  159. package/layout.js +0 -1
  160. package/mark.d.ts +0 -1
  161. package/mark.js +0 -1
  162. package/series.d.ts +0 -1
  163. package/series.js +0 -1
package/build/index.js CHANGED
@@ -7937,8 +7937,11 @@
7937
7937
  return Logger.getInstance().warn(`[VChart warn]: ${msg}`);
7938
7938
  };
7939
7939
  const error$1 = (msg, detail, err) => {
7940
- const errIns = new Error(msg);
7941
- return Logger.getInstance().error(`[VChart error]: ${errIns}`, detail);
7940
+ if (isFunction(config.errorHandler)) {
7941
+ config.errorHandler.call(null, msg, detail);
7942
+ return;
7943
+ }
7944
+ throw new Error(msg);
7942
7945
  };
7943
7946
  const config = {
7944
7947
  silent: false,
@@ -8341,7 +8344,8 @@
8341
8344
  function min$2(data, field) {
8342
8345
  const initialData = field ? +data[0][field] : +data[0];
8343
8346
  if (!isValidNumber(initialData)) {
8344
- throw new Error('invalid data');
8347
+ warn('invalid data');
8348
+ return 0;
8345
8349
  }
8346
8350
  const min = data.reduce((pre, _cur) => {
8347
8351
  const cur = field ? +_cur[field] : +_cur;
@@ -8355,7 +8359,8 @@
8355
8359
  function max$2(data, field) {
8356
8360
  const initialData = field ? +data[0][field] : +data[0];
8357
8361
  if (!isValidNumber(initialData)) {
8358
- throw new Error('invalid data');
8362
+ warn('invalid data');
8363
+ return 0;
8359
8364
  }
8360
8365
  const max = data.reduce((pre, _cur) => {
8361
8366
  const cur = field ? +_cur[field] : +_cur;
@@ -41365,24 +41370,6 @@
41365
41370
  function defaultLabelPosition(type) {
41366
41371
  return "rect" === type ? DefaultRectPositions : DefaultPositions;
41367
41372
  }
41368
- function clampText(text, width, height) {
41369
- const {
41370
- x1: x1,
41371
- x2: x2,
41372
- y1: y1,
41373
- y2: y2
41374
- } = text.AABBBounds,
41375
- minX = Math.min(x1, x2),
41376
- maxX = Math.max(x1, x2),
41377
- minY = Math.min(y1, y2),
41378
- maxY = Math.max(y1, y2);
41379
- let dx = 0,
41380
- dy = 0;
41381
- return minX < 0 && maxX - minX <= width ? dx = -minX : maxX > width && minX - (maxX - width) >= 0 && (dx = width - maxX), minY < 0 && maxY - minY <= height ? dy = -minY : maxY > height && minY - (maxY - height) >= 0 && (dy = height - maxY), {
41382
- dx: dx,
41383
- dy: dy
41384
- };
41385
- }
41386
41373
 
41387
41374
  const fadeIn = function () {
41388
41375
  let textAttribute = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -41461,17 +41448,9 @@
41461
41448
  this._bmpTool = bmpTool;
41462
41449
  }
41463
41450
  render() {
41464
- this._prepare();
41465
- const {
41466
- overlap: overlap,
41467
- smartInvert: smartInvert,
41468
- dataFilter: dataFilter,
41469
- customLayoutFunc: customLayoutFunc,
41470
- customOverlapFunc: customOverlapFunc
41471
- } = this.attribute;
41472
- let labels,
41473
- data = this.attribute.data;
41474
- isFunction(dataFilter) && (data = dataFilter(data)), isFunction(customLayoutFunc) ? labels = customLayoutFunc(data, d => this._idToGraphic.get(d.id)) : (labels = this.layout(data), isFunction(customOverlapFunc) ? labels = customOverlapFunc(labels, d => this._idToGraphic.get(d.id)) : !1 !== overlap && (labels = this._overlapping(labels))), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels);
41451
+ const currentBaseMarks = this._checkMarks(),
41452
+ labels = this.layout(currentBaseMarks);
41453
+ this._smartInvert(labels), this._renderLabels(labels);
41475
41454
  }
41476
41455
  _bindEvent(target) {
41477
41456
  if (!target) return;
@@ -41490,53 +41469,52 @@
41490
41469
  const text = createText(attributes);
41491
41470
  return this._bindEvent(text), this._setStates(text), text;
41492
41471
  }
41493
- _prepare() {
41472
+ _checkMarks() {
41494
41473
  var _a;
41495
41474
  const baseMarks = this.getBaseMarks(),
41496
41475
  currentBaseMarks = [];
41497
- if (baseMarks.forEach(mark => {
41476
+ return baseMarks.forEach(mark => {
41498
41477
  "willRelease" !== mark.releaseStatus && currentBaseMarks.push(mark);
41499
- }), null === (_a = this._idToGraphic) || void 0 === _a || _a.clear(), this._baseMarks = currentBaseMarks, !currentBaseMarks || 0 === currentBaseMarks.length) return;
41478
+ }), this._prevRelationMap = new Map(this._relationMap), null === (_a = this._relationMap) || void 0 === _a || _a.clear(), currentBaseMarks;
41479
+ }
41480
+ layout(currentMarks) {
41500
41481
  const {
41482
+ textStyle: textStyle,
41483
+ position: position,
41484
+ offset: offset
41485
+ } = this.attribute;
41486
+ let {
41501
41487
  data: data
41502
41488
  } = this.attribute;
41503
- if (data && 0 !== data.length) {
41504
- this._idToGraphic || (this._idToGraphic = new Map());
41505
- for (let i = 0; i < currentBaseMarks.length; i++) {
41506
- const textData = data[i],
41507
- baseMark = currentBaseMarks[i];
41508
- textData && baseMark && (isValid(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`), this._idToGraphic.set(textData.id, baseMark));
41509
- }
41510
- }
41511
- }
41512
- layout() {
41513
- let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
41514
- const {
41515
- textStyle = {},
41516
- position: position,
41517
- offset: offset
41518
- } = this.attribute,
41519
- labels = [];
41489
+ if (isFunction(data) && (data = data({})), !data || 0 === data.length) return [];
41490
+ let labels = [];
41491
+ isFunction(this.attribute.sort) && currentMarks && currentMarks.length && (currentMarks = currentMarks.sort(this.attribute.sort)), this._relationMap || (this._relationMap = new Map());
41520
41492
  for (let i = 0; i < data.length; i++) {
41521
41493
  const textData = data[i],
41522
- baseMark = this._idToGraphic.get(textData.id),
41523
- labelAttribute = Object.assign(Object.assign({}, textStyle), textData),
41524
- text = this._createLabelText(labelAttribute),
41525
- textBounds = this.getGraphicBounds(text),
41526
- graphicBounds = this.getGraphicBounds(baseMark, {
41527
- x: textData.x,
41528
- y: textData.y
41529
- }),
41530
- textLocation = this.labeling(textBounds, graphicBounds, isFunction(position) ? position(textData) : position, offset);
41531
- textLocation && (labelAttribute.x = textLocation.x, labelAttribute.y = textLocation.y, text.setAttributes(textLocation), labels.push(text));
41494
+ baseMark = null == currentMarks ? void 0 : currentMarks[i],
41495
+ labelAttribute = Object.assign(Object.assign(Object.assign({}, textStyle), textData), {
41496
+ _relatedIndex: i
41497
+ });
41498
+ if (this._relationMap.set(i, baseMark), textData) {
41499
+ const text = createText(labelAttribute);
41500
+ text.update();
41501
+ const textBounds = this.getGraphicBounds(text),
41502
+ graphicBounds = this.getGraphicBounds(baseMark, {
41503
+ x: textData.x,
41504
+ y: textData.y
41505
+ }),
41506
+ textAttributes = this.labeling(textBounds, graphicBounds, isFunction(position) ? position(textData) : position, offset);
41507
+ if (!textAttributes) continue;
41508
+ labelAttribute.x = textAttributes.x, labelAttribute.y = textAttributes.y, labels.push(labelAttribute);
41509
+ }
41532
41510
  }
41533
- return labels;
41511
+ return this._baseMarks = currentMarks, !1 !== this.attribute.overlap && (labels = this.overlapping(labels, this.attribute.overlap)), labels;
41534
41512
  }
41535
- _overlapping(labels) {
41536
- var _a, _b, _c, _d;
41513
+ overlapping(labels) {
41514
+ let option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
41515
+ var _a, _b, _c, _d, _e;
41537
41516
  if (0 === labels.length) return [];
41538
- const option = this.attribute.overlap,
41539
- result = [],
41517
+ const result = [],
41540
41518
  baseMarkGroup = this.getBaseMarkGroup(),
41541
41519
  size = null !== (_a = option.size) && void 0 !== _a ? _a : {
41542
41520
  width: null !== (_b = null == baseMarkGroup ? void 0 : baseMarkGroup.AABBBounds.width()) && void 0 !== _b ? _b : 0,
@@ -41557,45 +41535,27 @@
41557
41535
  }));
41558
41536
  for (let i = 0; i < labels.length; i++) {
41559
41537
  if (!1 === labels[i].visible) continue;
41560
- const text = labels[i],
41561
- baseMark = this._idToGraphic.get(text.attribute.id);
41538
+ const text = createText(labels[i]),
41539
+ baseMark = null === (_e = this._baseMarks) || void 0 === _e ? void 0 : _e[i];
41562
41540
  if (text.update(), canPlace(bmpTool, bitmap, text.AABBBounds, clampForce)) {
41563
41541
  if (!checkBounds) {
41564
- bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
41542
+ bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(Object.assign({}, text.attribute));
41565
41543
  continue;
41566
41544
  }
41567
41545
  if (checkBounds && (null == baseMark ? void 0 : baseMark.AABBBounds) && canPlaceInside(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds)) {
41568
- bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
41569
- continue;
41570
- }
41571
- }
41572
- if (clampForce) {
41573
- const {
41574
- dx = 0,
41575
- dy = 0
41576
- } = clampText(text, bmpTool.width, bmpTool.height);
41577
- if ((0 !== dx || 0 !== dy) && canPlace(bmpTool, bitmap, {
41578
- x1: text.AABBBounds.x1 + dx,
41579
- x2: text.AABBBounds.x2 + dx,
41580
- y1: text.AABBBounds.y1 + dy,
41581
- y2: text.AABBBounds.y2 + dy
41582
- })) {
41583
- text.setAttributes({
41584
- x: text.attribute.x + dx,
41585
- y: text.attribute.y + dy
41586
- }), result.push(text);
41546
+ bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(Object.assign({}, text.attribute));
41587
41547
  continue;
41588
41548
  }
41589
41549
  }
41590
41550
  let hasPlace = !1;
41591
41551
  for (let j = 0; j < strategy.length; j++) if (hasPlace = place$2(bmpTool, bitmap, strategy[j], this.attribute, text, this.getGraphicBounds(baseMark, labels[i]), this.labeling), !1 !== hasPlace) {
41592
- text.setAttributes({
41552
+ result.push(Object.assign(Object.assign({}, text.attribute), {
41593
41553
  x: hasPlace.x,
41594
41554
  y: hasPlace.y
41595
- }), result.push(text);
41555
+ }));
41596
41556
  break;
41597
41557
  }
41598
- !hasPlace && !hideOnHit && result.push(text);
41558
+ !hasPlace && !hideOnHit && result.push(Object.assign({}, text.attribute));
41599
41559
  }
41600
41560
  return isFunction(this.onAfterLabelOverlap) && this.onAfterLabelOverlap(bitmap), result;
41601
41561
  }
@@ -41627,16 +41587,17 @@
41627
41587
  easing = null !== (_d = animationConfig.easing) && void 0 !== _d ? _d : DefaultLabelAnimation.easing,
41628
41588
  delay = null !== (_e = animationConfig.delay) && void 0 !== _e ? _e : 0,
41629
41589
  currentTextMap = new Map(),
41630
- prevTextMap = this._graphicToText || new Map(),
41590
+ prevTextMap = this._textMap || new Map(),
41631
41591
  texts = [];
41632
- labels.forEach((text, index) => {
41633
- const relatedGraphic = this._idToGraphic.get(text.attribute.id),
41592
+ labels.forEach((label, index) => {
41593
+ const text = this._createLabelText(label),
41594
+ relatedGraphic = this._relationMap.get(label._relatedIndex),
41634
41595
  state = (null == prevTextMap ? void 0 : prevTextMap.get(relatedGraphic)) ? "update" : "enter";
41635
41596
  if ("enter" === state) if (texts.push(text), currentTextMap.set(relatedGraphic, text), !disableAnimation && relatedGraphic) {
41636
41597
  const {
41637
41598
  from: from,
41638
41599
  to: to
41639
- } = getAnimationAttributes(text.attribute, "fadeIn");
41600
+ } = getAnimationAttributes(label, "fadeIn");
41640
41601
  this.add(text), relatedGraphic.onAnimateBind = () => {
41641
41602
  text.setAttributes(from);
41642
41603
  const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, {
@@ -41661,7 +41622,7 @@
41661
41622
  disableAnimation ? this.removeChild(label) : null == label || label.animate().to(getAnimationAttributes(label.attribute, "fadeOut").to, duration, easing).onEnd(() => {
41662
41623
  this.removeChild(label);
41663
41624
  });
41664
- }), this._graphicToText = currentTextMap;
41625
+ }), this._textMap = currentTextMap;
41665
41626
  }
41666
41627
  _afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, _ref) {
41667
41628
  let {
@@ -41704,32 +41665,21 @@
41704
41665
  return listener;
41705
41666
  }
41706
41667
  _smartInvert(labels) {
41707
- const option = this.attribute.smartInvert || {},
41708
- {
41709
- textType: textType,
41710
- contrastRatiosThreshold: contrastRatiosThreshold,
41711
- alternativeColors: alternativeColors
41712
- } = option;
41713
- for (let i = 0; i < labels.length; i++) {
41714
- const label = labels[i];
41668
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
41669
+ if (!1 !== this.attribute.smartInvert) for (let i = 0; i < labels.length; i++) {
41670
+ const label = null == labels ? void 0 : labels[i];
41715
41671
  if (!label) continue;
41716
- const baseMark = this._idToGraphic.get(label.attribute.id),
41717
- isInside = canPlaceInside(label.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds);
41718
- if (label.attribute.stroke && label.attribute.lineWidth > 0) label.setAttributes({
41719
- fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors)
41720
- });else if (isInside) {
41721
- const backgroundColor = baseMark.attribute.fill,
41722
- foregroundColor = label.attribute.fill;
41723
- label.setAttributes({
41724
- fill: labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors)
41725
- });
41726
- } else if (label.attribute.lineWidth > 0) {
41727
- const backgroundColor = label.attribute.stroke,
41728
- foregroundColor = label.attribute.fill;
41729
- label.setAttributes({
41730
- stroke: baseMark.attribute.fill,
41731
- fill: labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors)
41732
- });
41672
+ const isInside = canPlaceInside(createText(label).AABBBounds, null === (_a = this._relationMap.get(label._relatedIndex)) || void 0 === _a ? void 0 : _a.AABBBounds);
41673
+ if (label.stroke && label.lineWidth > 0) label.fill = labelSmartInvert(label.fill, label.stroke, null === (_b = this.attribute.smartInvert) || void 0 === _b ? void 0 : _b.textType, null === (_c = this.attribute.smartInvert) || void 0 === _c ? void 0 : _c.contrastRatiosThreshold, null === (_d = this.attribute.smartInvert) || void 0 === _d ? void 0 : _d.alternativeColors);else if (isInside) {
41674
+ const backgroundColor = this._relationMap.get(label._relatedIndex).attribute.fill,
41675
+ foregroundColor = label.fill;
41676
+ label.fill = labelSmartInvert(foregroundColor, backgroundColor, null === (_e = this.attribute.smartInvert) || void 0 === _e ? void 0 : _e.textType, null === (_f = this.attribute.smartInvert) || void 0 === _f ? void 0 : _f.contrastRatiosThreshold, null === (_g = this.attribute.smartInvert) || void 0 === _g ? void 0 : _g.alternativeColors);
41677
+ } else if (label.lineWidth > 0) {
41678
+ const baseMark = this._relationMap.get(label._relatedIndex);
41679
+ label.stroke = baseMark.attribute.fill;
41680
+ const backgroundColor = label.stroke,
41681
+ foregroundColor = label.fill;
41682
+ label.fill = labelSmartInvert(foregroundColor, backgroundColor, null === (_h = this.attribute.smartInvert) || void 0 === _h ? void 0 : _h.textType, null === (_j = this.attribute.smartInvert) || void 0 === _j ? void 0 : _j.contrastRatiosThreshold, null === (_k = this.attribute.smartInvert) || void 0 === _k ? void 0 : _k.alternativeColors);
41733
41683
  }
41734
41684
  }
41735
41685
  }
@@ -51569,6 +51519,8 @@
51569
51519
  (function (ChartEvent) {
51570
51520
  ChartEvent["initialized"] = "initialized";
51571
51521
  ChartEvent["rendered"] = "rendered";
51522
+ ChartEvent["renderFinished"] = "renderFinished";
51523
+ ChartEvent["animationFinished"] = "animationFinished";
51572
51524
  ChartEvent["regionSeriesDataFilterOver"] = "regionSeriesDataFilterOver";
51573
51525
  ChartEvent["afterInitData"] = "afterInitData";
51574
51526
  ChartEvent["afterInitEvent"] = "afterInitEvent";
@@ -53516,10 +53468,10 @@
53516
53468
  this._chart = this._eventDispatcher.globalInstance.getChart?.();
53517
53469
  }
53518
53470
  register(eType, handler) {
53519
- throw new Error('Method not implemented.');
53471
+ (this._chart?.getOption().onError ?? error$1)('Method not implemented.');
53520
53472
  }
53521
53473
  unregister() {
53522
- throw new Error('Method not implemented.');
53474
+ (this._chart?.getOption().onError ?? error$1)('Method not implemented.');
53523
53475
  }
53524
53476
  getTargetDimensionInfo(x, y) {
53525
53477
  const cartesianInfo = getCartesianDimensionInfo(this._chart, { x, y }) ?? [];
@@ -54156,7 +54108,7 @@
54156
54108
  });
54157
54109
  return viewData;
54158
54110
  }
54159
- function dataToDataView(data, dataSet, sourceDataViews = []) {
54111
+ function dataToDataView(data, dataSet, sourceDataViews = [], ctx = {}) {
54160
54112
  if (data instanceof DataView) {
54161
54113
  return data;
54162
54114
  }
@@ -54175,7 +54127,8 @@
54175
54127
  if (typeof fromDataId === 'string') {
54176
54128
  const fromDataView = sourceDataViews.find(dv => dv.name === fromDataId);
54177
54129
  if (!fromDataView) {
54178
- throw new Error(`no data matches fromDataId ${fromDataId}`);
54130
+ (ctx.onError ?? error$1)(`no data matches fromDataId ${fromDataId}`);
54131
+ return null;
54179
54132
  }
54180
54133
  dataView.parse([fromDataView], {
54181
54134
  type: 'dataview'
@@ -54187,7 +54140,8 @@
54187
54140
  else if (typeof fromDataIndex === 'number') {
54188
54141
  const fromDataView = sourceDataViews[fromDataIndex];
54189
54142
  if (!fromDataView) {
54190
- throw new Error(`no data matches fromDataIndex ${fromDataIndex}`);
54143
+ (ctx.onError ?? error$1)(`no data matches fromDataIndex ${fromDataIndex}`);
54144
+ return null;
54191
54145
  }
54192
54146
  dataView.parse([fromDataView], {
54193
54147
  type: 'dataview'
@@ -54205,7 +54159,7 @@
54205
54159
  }
54206
54160
  else {
54207
54161
  dataView.parse([]);
54208
- error$1('values should be array');
54162
+ warn('values should be array');
54209
54163
  }
54210
54164
  if (transforms && transforms.length) {
54211
54165
  transforms.forEach((transform) => {
@@ -54342,6 +54296,12 @@
54342
54296
  if (this._view) {
54343
54297
  return;
54344
54298
  }
54299
+ const logger = new Logger(this._option.logLevel ?? LoggerLevel.Error);
54300
+ if (this._option.onError) {
54301
+ logger.addErrorHandler((...args) => {
54302
+ this._option.onError(...args);
54303
+ });
54304
+ }
54345
54305
  this._view = new View({
54346
54306
  width: this._width,
54347
54307
  height: this._height,
@@ -54361,7 +54321,8 @@
54361
54321
  doLayout: () => {
54362
54322
  this._compileChart?.onLayout(this._view);
54363
54323
  },
54364
- logLevel: Logger.getInstance().level()
54324
+ logger: logger,
54325
+ logLevel: logger.level()
54365
54326
  });
54366
54327
  this._setCanvasStyle();
54367
54328
  const interactive = this._option.interactive;
@@ -54615,7 +54576,7 @@
54615
54576
  });
54616
54577
  });
54617
54578
  }
54618
- async function getCanvasDataURL(c) {
54579
+ async function getCanvasDataURL(c, ctx) {
54619
54580
  if (!c) {
54620
54581
  return '';
54621
54582
  }
@@ -54624,8 +54585,8 @@
54624
54585
  return OffscreenCanvasToDataURL(c);
54625
54586
  }
54626
54587
  }
54627
- catch (error) {
54628
- console.error('getCanvasDataURL', error);
54588
+ catch (_error) {
54589
+ (ctx?.onError ?? error$1)(`getCanvasDataURL error : ${_error.toString()}`);
54629
54590
  }
54630
54591
  return c.toDataURL();
54631
54592
  }
@@ -54686,15 +54647,20 @@
54686
54647
  _autoSize = true;
54687
54648
  _option = {
54688
54649
  mode: exports.RenderModeEnum['desktop-browser'],
54689
- animation: true
54650
+ animation: true,
54651
+ onError: (msg) => {
54652
+ throw new Error(msg);
54653
+ }
54690
54654
  };
54691
54655
  _curSize = { width: 0, height: 0 };
54692
54656
  _observer = null;
54693
54657
  _currentThemeName;
54694
54658
  _currentTheme;
54659
+ _onError;
54695
54660
  _context = {};
54696
54661
  constructor(spec, options) {
54697
54662
  this._option = merge$2(this._option, options);
54663
+ this._onError = this._option.onError;
54698
54664
  const { dom, renderCanvas, mode, stage, poptip, ...restOptions } = this._option;
54699
54665
  if (dom) {
54700
54666
  this._container = isString(dom) ? document?.getElementById(dom) : dom;
@@ -54706,7 +54672,7 @@
54706
54672
  this._stage = stage;
54707
54673
  }
54708
54674
  if (mode !== 'node' && !this._container && !this._canvas && !this._stage) {
54709
- error$1('please specify container or renderCanvas!');
54675
+ this._option.onError('please specify container or renderCanvas!');
54710
54676
  return;
54711
54677
  }
54712
54678
  this._viewBox = this._option.viewBox;
@@ -54721,7 +54687,8 @@
54721
54687
  stage,
54722
54688
  pluginList: poptip !== false ? ['poptipForText'] : [],
54723
54689
  ...restOptions,
54724
- background: spec.background || this._currentTheme.background || this._option.background
54690
+ background: spec.background || this._currentTheme.background || this._option.background,
54691
+ onError: this._onError
54725
54692
  });
54726
54693
  this._eventDispatcher = new EventDispatcher(this, this._compiler);
54727
54694
  this._event = new Event$1(this._eventDispatcher, mode);
@@ -54736,6 +54703,7 @@
54736
54703
  height: spec.height || 0
54737
54704
  };
54738
54705
  this._bindResizeEvent();
54706
+ this._bindVGrammarViewEvent();
54739
54707
  this._event.emit(ChartEvent.initialized, {});
54740
54708
  InstanceManager.registerInstance(this);
54741
54709
  }
@@ -54754,13 +54722,15 @@
54754
54722
  const dataViewArr = [];
54755
54723
  for (let i = 0; i < specData.length; i++) {
54756
54724
  const curSpecData = specData[i];
54757
- dataViewArr.push(dataToDataView(curSpecData, this._dataSet, dataViewArr));
54725
+ dataViewArr.push(dataToDataView(curSpecData, this._dataSet, dataViewArr, {
54726
+ onError: this._option.onError
54727
+ }));
54758
54728
  }
54759
54729
  this._spec.data = dataViewArr;
54760
54730
  }
54761
54731
  _initChart(spec) {
54762
54732
  if (!this._compiler) {
54763
- error$1('compiler is not initialized');
54733
+ this._option.onError('compiler is not initialized');
54764
54734
  return;
54765
54735
  }
54766
54736
  this._initData();
@@ -54778,10 +54748,11 @@
54778
54748
  viewBox: this._viewBox,
54779
54749
  animation: this._option.animation,
54780
54750
  getTheme: () => this._currentTheme,
54781
- layout: this._option.layout
54751
+ layout: this._option.layout,
54752
+ onError: this._onError
54782
54753
  });
54783
54754
  if (!chart) {
54784
- error$1('init chart fail');
54755
+ this._option.onError('init chart fail');
54785
54756
  return;
54786
54757
  }
54787
54758
  this._chart = chart;
@@ -54794,6 +54765,17 @@
54794
54765
  this._dataSet = null;
54795
54766
  }
54796
54767
  }
54768
+ _bindVGrammarViewEvent() {
54769
+ if (!this._compiler || this._compiler.isReleased) {
54770
+ return;
54771
+ }
54772
+ this._compiler.getVGrammarView().addEventListener(HOOK_EVENT.ALL_ANIMATION_END, () => {
54773
+ this._event.emit(ChartEvent.animationFinished, {});
54774
+ });
54775
+ this._compiler.getVGrammarView().addEventListener(HOOK_EVENT.AFTER_VRENDER_NEXT_RENDER, () => {
54776
+ this._event.emit(ChartEvent.renderFinished, {});
54777
+ });
54778
+ }
54797
54779
  _bindResizeEvent() {
54798
54780
  if (this._autoSize) {
54799
54781
  if (this._container) {
@@ -54845,7 +54827,21 @@
54845
54827
  if (!isValid(result)) {
54846
54828
  return this;
54847
54829
  }
54848
- if (result.reMake) {
54830
+ this._reCompile(result);
54831
+ await this.renderAsync(morphConfig);
54832
+ return this;
54833
+ }
54834
+ updateCustomConfigAndRerenderSync(modifyConfig, morphConfig) {
54835
+ const result = modifyConfig();
54836
+ if (!isValid(result)) {
54837
+ return this;
54838
+ }
54839
+ this._reCompile(result);
54840
+ this.renderSync(morphConfig);
54841
+ return this;
54842
+ }
54843
+ _reCompile(updateResult) {
54844
+ if (updateResult.reMake) {
54849
54845
  this._releaseData();
54850
54846
  this._initDataSet();
54851
54847
  this._chart.release();
@@ -54853,13 +54849,11 @@
54853
54849
  this._compiler?.releaseGrammar();
54854
54850
  }
54855
54851
  else {
54856
- if (result.reCompile) {
54852
+ if (updateResult.reCompile) {
54857
54853
  this.getComponents().forEach(c => c.clear());
54858
54854
  this._compiler?.compile({ chart: this._chart, vChart: this }, {});
54859
54855
  }
54860
54856
  }
54861
- await this.renderAsync(morphConfig);
54862
- return this;
54863
54857
  }
54864
54858
  renderSync(morphConfig) {
54865
54859
  if (!this._chart) {
@@ -55019,6 +55013,25 @@
55019
55013
  }, morphConfig);
55020
55014
  return this;
55021
55015
  }
55016
+ updateSpecSync(spec, forceMerge = false, morphConfig) {
55017
+ if (!spec) {
55018
+ return this;
55019
+ }
55020
+ if (isString(spec)) {
55021
+ spec = JSON.parse(spec);
55022
+ }
55023
+ if (forceMerge) {
55024
+ spec = merge$2({}, this._spec, spec);
55025
+ }
55026
+ this.updateCustomConfigAndRerenderSync(() => {
55027
+ spec = specTransform(spec);
55028
+ this._spec = spec;
55029
+ this._updateCurrentTheme();
55030
+ this._compiler?.getVGrammarView()?.updateLayoutTag();
55031
+ return this._chart.updateSpec(spec, morphConfig);
55032
+ }, morphConfig);
55033
+ return this;
55034
+ }
55022
55035
  async resize(width, height) {
55023
55036
  if (!this._chart || !this._compiler) {
55024
55037
  return this;
@@ -55096,6 +55109,18 @@
55096
55109
  });
55097
55110
  return this;
55098
55111
  }
55112
+ setCurrentThemeSync(name) {
55113
+ if (!ThemeManager.themeExist(name)) {
55114
+ return this;
55115
+ }
55116
+ this.updateCustomConfigAndRerenderSync(() => {
55117
+ this._currentThemeName = name;
55118
+ this._updateCurrentTheme();
55119
+ this._chart?.setCurrentTheme(this._currentTheme, true);
55120
+ return { change: true, reMake: false };
55121
+ });
55122
+ return this;
55123
+ }
55099
55124
  _getTooltipComponent() {
55100
55125
  const tooltip = this._chart?.getAllComponents().find(c => c.type === ComponentTypeEnum.tooltip);
55101
55126
  return tooltip;
@@ -55177,15 +55202,17 @@
55177
55202
  if (this._chart && stage) {
55178
55203
  stage.render();
55179
55204
  const canvas = this._chart.getCanvas();
55180
- const url = await getCanvasDataURL(canvas);
55205
+ const url = await getCanvasDataURL(canvas, {
55206
+ onError: this._onError
55207
+ });
55181
55208
  return url;
55182
55209
  }
55183
- console.error(new ReferenceError(`render is not defined`));
55210
+ this._option.onError(new ReferenceError(`render is not defined`));
55184
55211
  return null;
55185
55212
  }
55186
55213
  async exportImg(name) {
55187
55214
  if (!isTrueBrowser(this._option.mode)) {
55188
- console.error(new TypeError(`non-browser environment can not export img`));
55215
+ this._option.onError(new TypeError(`non-browser environment can not export img`));
55189
55216
  return;
55190
55217
  }
55191
55218
  const dataURL = await this.getDataURL();
@@ -55193,12 +55220,12 @@
55193
55220
  URLToImage(name, dataURL);
55194
55221
  }
55195
55222
  else {
55196
- console.error(new ReferenceError(`render is not defined`));
55223
+ this._option.onError(new ReferenceError(`render is not defined`));
55197
55224
  }
55198
55225
  }
55199
55226
  getImageBuffer() {
55200
55227
  if (this._option.mode !== 'node') {
55201
- console.error(new TypeError('getImageBuffer() now only support node environment.'));
55228
+ this._option.onError(new TypeError('getImageBuffer() now only support node environment.'));
55202
55229
  return;
55203
55230
  }
55204
55231
  const stage = this.getStage();
@@ -55207,7 +55234,7 @@
55207
55234
  const buffer = stage.window.getImageBuffer();
55208
55235
  return buffer;
55209
55236
  }
55210
- console.error(new ReferenceError(`render is not defined`));
55237
+ this._option.onError(new ReferenceError(`render is not defined`));
55211
55238
  return null;
55212
55239
  }
55213
55240
  setLayout(layout) {
@@ -56734,6 +56761,10 @@
56734
56761
  _bottomCurrent = 0;
56735
56762
  _chartLayoutRect;
56736
56763
  _chartViewBox;
56764
+ _onError;
56765
+ constructor(_spec, ctx) {
56766
+ this._onError = ctx?.onError;
56767
+ }
56737
56768
  layoutItems(_chart, items, chartLayoutRect, chartViewBox) {
56738
56769
  this._chartLayoutRect = chartLayoutRect;
56739
56770
  this._chartViewBox = chartViewBox;
@@ -56994,7 +57025,7 @@
56994
57025
  filterRegionsWithID(regions, id) {
56995
57026
  const target = regions.find(x => x.id === id);
56996
57027
  if (!target) {
56997
- throw Error('can not find target region item, invalid id');
57028
+ (this._onError ?? error$1)('can not find target region item, invalid id');
56998
57029
  }
56999
57030
  return target;
57000
57031
  }
@@ -58088,7 +58119,7 @@
58088
58119
  VChart.useMark([ComponentMark, GroupMark, ImageMark]);
58089
58120
  Factory.registerRegion('region', Region);
58090
58121
  Factory.registerLayout('base', Layout);
58091
- const version = "1.1.1-beta.1";
58122
+ const version = "1.2.0-beta.1";
58092
58123
  Logger.getInstance(LoggerLevel.Error);
58093
58124
 
58094
58125
  var SeriesMarkNameEnum;
@@ -58577,6 +58608,9 @@
58577
58608
  this.transformSpec(s);
58578
58609
  this._spec = s;
58579
58610
  }
58611
+ getOption() {
58612
+ return this._option;
58613
+ }
58580
58614
  _theme;
58581
58615
  _regions = [];
58582
58616
  _series = [];
@@ -58644,7 +58678,8 @@
58644
58678
  getChartLayoutRect: () => this._layoutRect,
58645
58679
  getChartViewRect: () => this._viewRect,
58646
58680
  getChart: () => this,
58647
- globalScale: this._globalScale
58681
+ globalScale: this._globalScale,
58682
+ onError: this._option.onError
58648
58683
  };
58649
58684
  this._stack = new Stack(this);
58650
58685
  this._spec = spec;
@@ -58713,7 +58748,9 @@
58713
58748
  spec.data = this.getSeriesData(spec.dataId, spec.dataIndex);
58714
58749
  }
58715
58750
  else {
58716
- spec.data = dataToDataView(spec.data, this._dataSet, this._spec.data);
58751
+ spec.data = dataToDataView(spec.data, this._dataSet, this._spec.data, {
58752
+ onError: this._option.onError
58753
+ });
58717
58754
  }
58718
58755
  if (this._option.animation === false) {
58719
58756
  spec.animation = false;
@@ -58832,7 +58869,9 @@
58832
58869
  if (this._spec.zField || (this._spec.series && this._spec.series.some((s) => s.zField))) {
58833
58870
  use3dLayout = true;
58834
58871
  }
58835
- const layout = new (Factory.getLayout(this._spec.layout?.type ?? (use3dLayout ? 'layout3d' : 'base')))(this._spec.layout);
58872
+ const layout = new (Factory.getLayout(this._spec.layout?.type ?? (use3dLayout ? 'layout3d' : 'base')))(this._spec.layout, {
58873
+ onError: this._option.onError
58874
+ });
58836
58875
  this._layoutFunc = layout.layoutItems.bind(layout);
58837
58876
  }
58838
58877
  }
@@ -59050,7 +59089,8 @@
59050
59089
  }
59051
59090
  getSeriesData(id, index) {
59052
59091
  if (!this._spec.data) {
59053
- throw new Error('no data in spec!');
59092
+ this._option.onError('no data in spec!');
59093
+ return null;
59054
59094
  }
59055
59095
  if (typeof id === 'string') {
59056
59096
  const metchData = this._spec.data.filter((data) => {
@@ -59059,13 +59099,15 @@
59059
59099
  if (metchData[0]) {
59060
59100
  return metchData[0];
59061
59101
  }
59062
- throw new Error(`no data matches dataId ${id}!`);
59102
+ this._option.onError(`no data matches dataId ${id}!`);
59103
+ return null;
59063
59104
  }
59064
59105
  if (typeof index === 'number') {
59065
59106
  if (this._spec.data[index]) {
59066
59107
  return this._spec.data[index];
59067
59108
  }
59068
- throw new Error(`no data matches dataIndex ${index}!`);
59109
+ this._option.onError(`no data matches dataIndex ${index}!`);
59110
+ return null;
59069
59111
  }
59070
59112
  return this._spec.data[0];
59071
59113
  }
@@ -61123,7 +61165,7 @@
61123
61165
  if (isFunction(dataKey)) {
61124
61166
  return dataKey(datum, index);
61125
61167
  }
61126
- throw new Error(`invalid dataKey: ${dataKey}`);
61168
+ this._option.onError(`invalid dataKey: ${dataKey}`);
61127
61169
  }
61128
61170
  _addDataIndexAndKey() {
61129
61171
  if (this._rawData?.dataSet) {
@@ -65070,13 +65112,16 @@
65070
65112
  longitudeToData(lon) {
65071
65113
  }
65072
65114
  dataToPositionX(data) {
65073
- throw new Error('Method not implemented.');
65115
+ this._option.onError('Method not implemented.');
65116
+ return 0;
65074
65117
  }
65075
65118
  dataToPositionY(data) {
65076
- throw new Error('Method not implemented.');
65119
+ this._option.onError('Method not implemented.');
65120
+ return 0;
65077
65121
  }
65078
65122
  dataToPositionZ(data) {
65079
- throw new Error('Method not implemented.');
65123
+ this._option.onError('Method not implemented.');
65124
+ return 0;
65080
65125
  }
65081
65126
  release() {
65082
65127
  super.release();
@@ -65191,10 +65236,10 @@
65191
65236
  this._valueField = this._spec.valueField;
65192
65237
  this._spec.nameProperty && (this._nameProperty = this._spec.nameProperty);
65193
65238
  if (!this.map) {
65194
- throw new Error(`map type '${this.map}' is not specified !`);
65239
+ this._option.onError(`map type '${this.map}' is not specified !`);
65195
65240
  }
65196
65241
  if (!geoSourceMap.get(this.map)) {
65197
- throw new Error(`'${this.map}' data is not registered !`);
65242
+ this._option.onError(`'${this.map}' data is not registered !`);
65198
65243
  }
65199
65244
  }
65200
65245
  initData() {
@@ -65204,7 +65249,7 @@
65204
65249
  registerDataSetInstanceTransform(this._dataSet, 'lookup', lookup);
65205
65250
  const features = geoSourceMap.get(this.map);
65206
65251
  if (!features) {
65207
- throw Error('no valid map data found!');
65252
+ this._option.onError('no valid map data found!');
65208
65253
  }
65209
65254
  const mapData = new DataView(this._dataSet);
65210
65255
  mapData
@@ -65410,10 +65455,12 @@
65410
65455
  return '';
65411
65456
  }
65412
65457
  dataToPositionX(data) {
65413
- throw new Error('Method not implemented.');
65458
+ this._option.onError('Method not implemented.');
65459
+ return 0;
65414
65460
  }
65415
65461
  dataToPositionY(data) {
65416
- throw new Error('Method not implemented.');
65462
+ this._option.onError('Method not implemented.');
65463
+ return 0;
65417
65464
  }
65418
65465
  viewDataUpdate(d) {
65419
65466
  super.viewDataUpdate(d);
@@ -66960,10 +67007,12 @@
66960
67007
  }
66961
67008
  if (isArray$3(spec)) {
66962
67009
  if (isNil(field)) {
66963
- throw new Error(`${key}Field is required.`);
67010
+ this._option.onError(`${key}Field is required.`);
67011
+ return spec;
66964
67012
  }
66965
67013
  if (spec.length > 2) {
66966
- throw new Error(`${key} length is invalid, specify up to 2 ${key}s.`);
67014
+ this._option.onError(`${key} length is invalid, specify up to 2 ${key}s.`);
67015
+ return spec;
66967
67016
  }
66968
67017
  const scaleName = `${PREFIX}_series_scatter_${this.id}_scale_${key}`;
66969
67018
  this._option.globalScale.registerModelScale({
@@ -66984,7 +67033,8 @@
66984
67033
  }
66985
67034
  if (isObject$f(spec)) {
66986
67035
  if (isNil(field)) {
66987
- throw new Error(`${key}Field is required.`);
67036
+ this._option.onError(`${key}Field is required.`);
67037
+ return spec;
66988
67038
  }
66989
67039
  const scaleName = `${PREFIX}_series_scatter_${this.id}_scale_${key}`;
66990
67040
  const visualSpec = {
@@ -67005,7 +67055,8 @@
67005
67055
  field
67006
67056
  };
67007
67057
  }
67008
- throw new Error(`${key} attribute is invalid.`);
67058
+ this._option.onError(`${key} attribute is invalid.`);
67059
+ return spec;
67009
67060
  }
67010
67061
  getSizeAttribute(field, sizeSpec) {
67011
67062
  if (isNil(sizeSpec)) {
@@ -77044,9 +77095,13 @@
77044
77095
  }
77045
77096
  }
77046
77097
  else {
77047
- spec.data = dataToDataView(spec.data, this._dataSet, this._spec.data);
77098
+ spec.data = dataToDataView(spec.data, this._dataSet, this._spec.data, {
77099
+ onError: this._option.onError
77100
+ });
77048
77101
  if (spec.type === SeriesTypeEnum.link) {
77049
- spec.dataDot = dataToDataView(this._spec.series[spec.dotSeriesIndex].data, this._dataSet, this._spec.data);
77102
+ spec.dataDot = dataToDataView(this._spec.series[spec.dotSeriesIndex].data, this._dataSet, this._spec.data, {
77103
+ onError: this._option.onError
77104
+ });
77050
77105
  }
77051
77106
  }
77052
77107
  if (spec.type === SeriesTypeEnum.link) {
@@ -80517,7 +80572,8 @@
80517
80572
  inverse
80518
80573
  }, options);
80519
80574
  }
80520
- throw `Component ${componentName} not found`;
80575
+ options.onError(`Component ${componentName} not found`);
80576
+ return null;
80521
80577
  }
80522
80578
  static createComponent(spec, options) {
80523
80579
  if (!this.type.startsWith(CartesianAxis.type)) {
@@ -81525,7 +81581,8 @@
81525
81581
  if (C) {
81526
81582
  return new C(spec, options);
81527
81583
  }
81528
- throw `Component ${componentName} not found`;
81584
+ options.onError(`Component ${componentName} not found`);
81585
+ return null;
81529
81586
  }
81530
81587
  static createComponent(spec, options) {
81531
81588
  if (!this.type.startsWith(PolarAxis.type)) {
@@ -83021,9 +83078,6 @@
83021
83078
  projection;
83022
83079
  constructor(projectionSpec) {
83023
83080
  this.projection = projection(projectionSpec.type)();
83024
- if (this.projection === null) {
83025
- throw Error('unsupported projection type!');
83026
- }
83027
83081
  }
83028
83082
  fit(start, size, features) {
83029
83083
  const fitData = { type: 'FeatureCollection', features };
@@ -83174,6 +83228,10 @@
83174
83228
  }
83175
83229
  initProjection() {
83176
83230
  this._projection = new Projection(this._projectionSpec);
83231
+ if (this._projection.projection === null) {
83232
+ this._option.onError('unsupported projection type!');
83233
+ return;
83234
+ }
83177
83235
  }
83178
83236
  coordinateHelper() {
83179
83237
  const helper = {
@@ -85241,7 +85299,8 @@
85241
85299
  }
85242
85300
  }
85243
85301
  }
85244
- throw new Error('need at least one series');
85302
+ this._option.onError('need at least one series');
85303
+ return null;
85245
85304
  }
85246
85305
  clear() {
85247
85306
  if (this._markerComponent) {
@@ -88282,6 +88341,12 @@
88282
88341
  });
88283
88342
  });
88284
88343
  }
88344
+ updateSpec(spec) {
88345
+ const result = super.updateSpec(spec);
88346
+ result.reRender = true;
88347
+ result.reMake = true;
88348
+ return result;
88349
+ }
88285
88350
  onRender(ctx) {
88286
88351
  }
88287
88352
  changeRegions(regions) {
@@ -88308,7 +88373,8 @@
88308
88373
  _rowElements;
88309
88374
  _gridInfo;
88310
88375
  _elementMap = new Map();
88311
- constructor(gridInfo) {
88376
+ _onError;
88377
+ constructor(gridInfo, ctx) {
88312
88378
  this.standardizationSpec(gridInfo);
88313
88379
  this._gridInfo = gridInfo;
88314
88380
  this._col = gridInfo.col;
@@ -88317,6 +88383,7 @@
88317
88383
  this._rowSize = new Array(this._row).fill(null);
88318
88384
  this._colElements = new Array(this._col).fill([]);
88319
88385
  this._rowElements = new Array(this._row).fill([]);
88386
+ this._onError = ctx?.onError;
88320
88387
  this.initUserSetting();
88321
88388
  }
88322
88389
  standardizationSpec(gridInfo) {