@visactor/vchart 2.0.10-alpha.0 → 2.0.10

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 (60) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +265 -33
  3. package/build/index.js +265 -33
  4. package/build/index.min.js +2 -2
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/chart/base/base-chart.d.ts +2 -0
  7. package/cjs/chart/base/base-chart.js +16 -2
  8. package/cjs/chart/base/base-chart.js.map +1 -1
  9. package/cjs/chart/box-plot/box-plot-transformer.js +1 -1
  10. package/cjs/chart/box-plot/box-plot-transformer.js.map +1 -1
  11. package/cjs/chart/interface/chart.d.ts +2 -0
  12. package/cjs/chart/interface/chart.js.map +1 -1
  13. package/cjs/component/axis/base-axis.js +2 -2
  14. package/cjs/component/axis/base-axis.js.map +1 -1
  15. package/cjs/core/index.d.ts +1 -1
  16. package/cjs/core/index.js +1 -1
  17. package/cjs/core/index.js.map +1 -1
  18. package/cjs/core/vchart.d.ts +2 -0
  19. package/cjs/core/vchart.js +4 -0
  20. package/cjs/core/vchart.js.map +1 -1
  21. package/cjs/mark/base/base-mark.d.ts +1 -1
  22. package/cjs/mark/base/base-mark.js +3 -3
  23. package/cjs/mark/base/base-mark.js.map +1 -1
  24. package/cjs/series/box-plot/box-plot.d.ts +3 -1
  25. package/cjs/series/box-plot/box-plot.js +54 -29
  26. package/cjs/series/box-plot/box-plot.js.map +1 -1
  27. package/cjs/series/box-plot/interface.d.ts +7 -2
  28. package/cjs/series/box-plot/interface.js.map +1 -1
  29. package/cjs/theme/token/builtin/default.js +1 -1
  30. package/cjs/theme/token/builtin/default.js.map +1 -1
  31. package/cjs/typings/visual.d.ts +3 -3
  32. package/cjs/typings/visual.js.map +1 -1
  33. package/esm/chart/base/base-chart.d.ts +2 -0
  34. package/esm/chart/base/base-chart.js +15 -2
  35. package/esm/chart/base/base-chart.js.map +1 -1
  36. package/esm/chart/box-plot/box-plot-transformer.js +1 -1
  37. package/esm/chart/box-plot/box-plot-transformer.js.map +1 -1
  38. package/esm/chart/interface/chart.d.ts +2 -0
  39. package/esm/chart/interface/chart.js.map +1 -1
  40. package/esm/component/axis/base-axis.js +2 -2
  41. package/esm/component/axis/base-axis.js.map +1 -1
  42. package/esm/core/index.d.ts +1 -1
  43. package/esm/core/index.js +1 -1
  44. package/esm/core/index.js.map +1 -1
  45. package/esm/core/vchart.d.ts +2 -0
  46. package/esm/core/vchart.js +4 -0
  47. package/esm/core/vchart.js.map +1 -1
  48. package/esm/mark/base/base-mark.d.ts +1 -1
  49. package/esm/mark/base/base-mark.js +3 -3
  50. package/esm/mark/base/base-mark.js.map +1 -1
  51. package/esm/series/box-plot/box-plot.d.ts +3 -1
  52. package/esm/series/box-plot/box-plot.js +56 -29
  53. package/esm/series/box-plot/box-plot.js.map +1 -1
  54. package/esm/series/box-plot/interface.d.ts +7 -2
  55. package/esm/series/box-plot/interface.js.map +1 -1
  56. package/esm/theme/token/builtin/default.js +1 -1
  57. package/esm/theme/token/builtin/default.js.map +1 -1
  58. package/esm/typings/visual.d.ts +3 -3
  59. package/esm/typings/visual.js.map +1 -1
  60. package/package.json +7 -7
package/build/index.js CHANGED
@@ -9506,7 +9506,7 @@
9506
9506
 
9507
9507
  const EnvContribution = Symbol.for("EnvContribution");
9508
9508
  const VGlobal = Symbol.for("VGlobal");
9509
- const DEFAULT_TEXT_FONT_FAMILY$1 = "PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol";
9509
+ const DEFAULT_TEXT_FONT_FAMILY$1 = "PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,'-apple-system',segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol";
9510
9510
 
9511
9511
  const container = new Container();
9512
9512
 
@@ -11247,7 +11247,7 @@
11247
11247
  textAlign: "left",
11248
11248
  textBaseline: "alphabetic",
11249
11249
  fontSize: 16,
11250
- fontFamily: "PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,\n Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol",
11250
+ fontFamily: "PingFang SC,Microsoft Yahei,system-ui,'-apple-system',segoe ui,\n Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol",
11251
11251
  fontWeight: "",
11252
11252
  ellipsis: "…",
11253
11253
  fontVariant: "",
@@ -16315,7 +16315,7 @@
16315
16315
  }
16316
16316
  }]), noAnimateAttrs && this.setAttributesAndPreventAnimate(noAnimateAttrs, !1, {
16317
16317
  type: AttributeUpdateType.STATE
16318
- });
16318
+ }), this.finalAttribute && Object.assign(this.finalAttribute, attrs);
16319
16319
  } else this.stopStateAnimates(), this.setAttributesAndPreventAnimate(attrs, !1, {
16320
16320
  type: AttributeUpdateType.STATE
16321
16321
  }), this.finalAttribute && Object.assign(this.finalAttribute, attrs);
@@ -16341,7 +16341,7 @@
16341
16341
  getNormalAttribute(key) {
16342
16342
  var _a, _b;
16343
16343
  const value = this.attribute[key];
16344
- return this.animates ? null === (_a = this.finalAttribute) || void 0 === _a ? void 0 : _a[key] : null != value ? value : null === (_b = this.finalAttribute) || void 0 === _b ? void 0 : _b[key];
16344
+ return this.animates && this.animates.size ? null === (_a = this.finalAttribute) || void 0 === _a ? void 0 : _a[key] : null != value ? value : null === (_b = this.finalAttribute) || void 0 === _b ? void 0 : _b[key];
16345
16345
  }
16346
16346
  clearStates(hasAnimation) {
16347
16347
  this.hasState() && this.normalAttrs ? (this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
@@ -33191,7 +33191,7 @@
33191
33191
 
33192
33192
  var AXIS_ELEMENT_NAME;
33193
33193
  !function (AXIS_ELEMENT_NAME) {
33194
- AXIS_ELEMENT_NAME.innerView = "inner-view", AXIS_ELEMENT_NAME.axisContainer = "axis-container", AXIS_ELEMENT_NAME.labelContainer = "axis-label-container", AXIS_ELEMENT_NAME.tickContainer = "axis-tick-container", AXIS_ELEMENT_NAME.tick = "axis-tick", AXIS_ELEMENT_NAME.subTick = "axis-sub-tick", AXIS_ELEMENT_NAME.label = "axis-label", AXIS_ELEMENT_NAME.title = "axis-title", AXIS_ELEMENT_NAME.gridContainer = "axis-grid-container", AXIS_ELEMENT_NAME.grid = "axis-grid", AXIS_ELEMENT_NAME.gridRegion = "axis-grid-region", AXIS_ELEMENT_NAME.line = "axis-line", AXIS_ELEMENT_NAME.background = "axis-background", AXIS_ELEMENT_NAME.axisLabelBackground = "axis-label-background", AXIS_ELEMENT_NAME.axisBreak = "axis-break", AXIS_ELEMENT_NAME.axisBreakSymbol = "axis-break-symbol";
33194
+ AXIS_ELEMENT_NAME.innerView = "inner-view", AXIS_ELEMENT_NAME.axisContainer = "axis-container", AXIS_ELEMENT_NAME.labelContainer = "axis-label-container", AXIS_ELEMENT_NAME.tickContainer = "axis-tick-container", AXIS_ELEMENT_NAME.tick = "axis-tick", AXIS_ELEMENT_NAME.subTick = "axis-sub-tick", AXIS_ELEMENT_NAME.label = "axis-label", AXIS_ELEMENT_NAME.title = "axis-title", AXIS_ELEMENT_NAME.labelHoverOnAxis = "axis-label-hover-on-axis", AXIS_ELEMENT_NAME.gridContainer = "axis-grid-container", AXIS_ELEMENT_NAME.grid = "axis-grid", AXIS_ELEMENT_NAME.gridRegion = "axis-grid-region", AXIS_ELEMENT_NAME.line = "axis-line", AXIS_ELEMENT_NAME.background = "axis-background", AXIS_ELEMENT_NAME.axisLabelBackground = "axis-label-background", AXIS_ELEMENT_NAME.axisBreak = "axis-break", AXIS_ELEMENT_NAME.axisBreakSymbol = "axis-break-symbol";
33195
33195
  }(AXIS_ELEMENT_NAME || (AXIS_ELEMENT_NAME = {}));
33196
33196
  var AxisStateValue;
33197
33197
  !function (AxisStateValue) {
@@ -33228,6 +33228,26 @@
33228
33228
  fillOpacity: 1
33229
33229
  }
33230
33230
  },
33231
+ labelHoverOnAxis: {
33232
+ visible: !1,
33233
+ space: 7,
33234
+ padding: 2,
33235
+ position: 0,
33236
+ autoRotate: !1,
33237
+ textStyle: {
33238
+ fontSize: 12,
33239
+ fill: "red",
33240
+ fontWeight: "normal",
33241
+ fillOpacity: 1
33242
+ },
33243
+ background: {
33244
+ visible: !0,
33245
+ style: {
33246
+ cornerRadius: 2,
33247
+ fill: "black"
33248
+ }
33249
+ }
33250
+ },
33231
33251
  tick: {
33232
33252
  visible: !0,
33233
33253
  inside: !1,
@@ -40393,7 +40413,17 @@
40393
40413
  loadLineAxisComponent();
40394
40414
  class LineAxis extends AxisBase {
40395
40415
  constructor(attributes, options) {
40396
- super((null == options ? void 0 : options.skipDefault) ? attributes : merge$1({}, LineAxis.defaultAttributes, attributes), options);
40416
+ var _a;
40417
+ if (attributes.labelHoverOnAxis && (attributes.labelHoverOnAxis.textStyle = Object.assign({}, attributes.label.style, attributes.labelHoverOnAxis.textStyle), void 0 === attributes.labelHoverOnAxis.space)) {
40418
+ const {
40419
+ padding = 2
40420
+ } = attributes.labelHoverOnAxis,
40421
+ parsedPadding = normalizePadding(padding),
40422
+ toDiffPadding = "bottom" === attributes.orient ? parsedPadding[0] : "left" === attributes.orient ? parsedPadding[1] : "top" === attributes.orient ? parsedPadding[2] : parsedPadding[3],
40423
+ space = (null !== (_a = attributes.label.space) && void 0 !== _a ? _a : LineAxis.defaultAttributes.label.space) - toDiffPadding;
40424
+ attributes.labelHoverOnAxis.space = space;
40425
+ }
40426
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge$1({}, LineAxis.defaultAttributes, attributes), options), this.labelHoverOnAxisGroup = null;
40397
40427
  }
40398
40428
  _renderInner(container) {
40399
40429
  var _a;
@@ -40455,6 +40485,15 @@
40455
40485
  }, panel.style));
40456
40486
  bgRect.name = AXIS_ELEMENT_NAME.background, bgRect.id = this._getNodeId("background"), bgRect.states = merge$1({}, DEFAULT_STATES$1, null !== (_a = panel.state) && void 0 !== _a ? _a : {}), axisContainer.insertBefore(bgRect, axisContainer.firstChild);
40457
40487
  }
40488
+ const {
40489
+ labelHoverOnAxis: labelHoverOnAxis
40490
+ } = this.attribute;
40491
+ labelHoverOnAxis && labelHoverOnAxis.visible && this.renderLabelHoverOnAxis();
40492
+ }
40493
+ renderLabelHoverOnAxis() {
40494
+ const hoverOnLabelAttributes = this.getLabelHoverOnAxisAttribute(),
40495
+ hoverOnLabel = new Tag(Object.assign({}, hoverOnLabelAttributes));
40496
+ hoverOnLabel.name = AXIS_ELEMENT_NAME.title, hoverOnLabel.id = this._getNodeId("hover-on-label"), this.labelHoverOnAxisGroup = hoverOnLabel, this.axisContainer.add(hoverOnLabel);
40458
40497
  }
40459
40498
  renderLine(container) {
40460
40499
  const {
@@ -40595,6 +40634,66 @@
40595
40634
  visible: !0
40596
40635
  }, background.style)), attrs;
40597
40636
  }
40637
+ getLabelHoverOnAxisAttribute() {
40638
+ var _a, _b;
40639
+ const {
40640
+ orient: orient
40641
+ } = this.attribute,
40642
+ _c = this.attribute.labelHoverOnAxis,
40643
+ {
40644
+ position = 0,
40645
+ space = 4,
40646
+ autoRotate = !0,
40647
+ textStyle = {},
40648
+ background = {},
40649
+ formatMethod: formatMethod,
40650
+ text: textContent = "",
40651
+ maxWidth: maxWidth
40652
+ } = _c,
40653
+ restAttrs = __rest$b(_c, ["position", "space", "autoRotate", "textStyle", "background", "formatMethod", "text", "maxWidth"]),
40654
+ point = this.getTickCoord(0);
40655
+ "bottom" === orient || "top" === orient ? point.x = position : point.y = position;
40656
+ let tickLength = 0;
40657
+ (null === (_a = this.attribute.tick) || void 0 === _a ? void 0 : _a.visible) && !1 === this.attribute.tick.inside && (tickLength = this.attribute.tick.length || 4), (null === (_b = this.attribute.subTick) || void 0 === _b ? void 0 : _b.visible) && !1 === this.attribute.subTick.inside && (tickLength = Math.max(tickLength, this.attribute.subTick.length || 2));
40658
+ const offset = tickLength + 0 + space,
40659
+ labelPoint = this.getVerticalCoord(point, offset, !1),
40660
+ vector = this.getVerticalVector(offset, !1, {
40661
+ x: 0,
40662
+ y: 0
40663
+ });
40664
+ let textBaseline,
40665
+ {
40666
+ angle: angle
40667
+ } = restAttrs,
40668
+ textAlign = "center";
40669
+ if (isNil$1(angle) && autoRotate) {
40670
+ const axisVector = this.getRelativeVector();
40671
+ angle = angleTo(axisVector, [1, 0], !0);
40672
+ const {
40673
+ verticalFactor = 1
40674
+ } = this.attribute;
40675
+ textBaseline = 1 === -1 * verticalFactor ? "bottom" : "top";
40676
+ } else {
40677
+ const {
40678
+ textAlign: textAlign2,
40679
+ textBaseline: textBaseline2
40680
+ } = this.getLabelAlign(vector, !1, textStyle.angle);
40681
+ textAlign = textAlign2, textBaseline = textBaseline2;
40682
+ }
40683
+ const maxTagWidth = maxWidth,
40684
+ text = formatMethod ? formatMethod(textContent) : textContent,
40685
+ attrs = Object.assign(Object.assign(Object.assign({}, labelPoint), restAttrs), {
40686
+ maxWidth: maxTagWidth,
40687
+ textStyle: Object.assign({
40688
+ textAlign: textAlign,
40689
+ textBaseline: textBaseline
40690
+ }, textStyle),
40691
+ text: text
40692
+ });
40693
+ return attrs.angle = angle, background && background.visible && (attrs.panel = Object.assign(Object.assign({
40694
+ visible: !0
40695
+ }, restAttrs.panel), background.style)), attrs;
40696
+ }
40598
40697
  getTextBaseline(vector, inside) {
40599
40698
  let base = "middle";
40600
40699
  const {
@@ -40785,6 +40884,40 @@
40785
40884
  }
40786
40885
  return limitLength && (limitLength = (limitLength - labelSpace - titleSpacing - titleHeight - axisLineWidth - tickLength) / layerCount), limitLength;
40787
40886
  }
40887
+ showLabelHoverOnAxis(position, text, adjustPosition = !0) {
40888
+ if (this.attribute.labelHoverOnAxis) {
40889
+ const preContainerBounds = this.axisContainer.AABBBounds,
40890
+ preWidth = preContainerBounds.width(),
40891
+ preHeight = preContainerBounds.height(),
40892
+ preX1 = preContainerBounds.x1,
40893
+ preY1 = preContainerBounds.y1,
40894
+ preX2 = preContainerBounds.x2,
40895
+ preY2 = preContainerBounds.y2;
40896
+ if (this.labelHoverOnAxisGroup) {
40897
+ const {
40898
+ formatMethod: formatMethod
40899
+ } = this.attribute.labelHoverOnAxis,
40900
+ textStr = formatMethod ? formatMethod(text) : text;
40901
+ this.labelHoverOnAxisGroup.setAttribute("text", textStr), this.labelHoverOnAxisGroup.setAttribute("visible", !0), this.labelHoverOnAxisGroup.setAttribute("visibleAll", !0), "left" === this.attribute.orient || "right" === this.attribute.orient ? this.labelHoverOnAxisGroup.setAttributes({
40902
+ y: position
40903
+ }) : this.labelHoverOnAxisGroup.setAttributes({
40904
+ x: position
40905
+ });
40906
+ } else this.attribute.labelHoverOnAxis.visible = !0, this.attribute.labelHoverOnAxis.position = position, this.attribute.labelHoverOnAxis.text = text, this.renderLabelHoverOnAxis();
40907
+ if (adjustPosition) {
40908
+ const afterContainerBounds = this.axisContainer.AABBBounds,
40909
+ diffWidth = afterContainerBounds.width() - preWidth,
40910
+ diffHeight = afterContainerBounds.height() - preHeight;
40911
+ diffWidth > 0 && ("top" === this.attribute.orient || "bottom" === this.attribute.orient) && (afterContainerBounds.x1 < preX1 ? this.showLabelHoverOnAxis(position + diffWidth, text, !1) : afterContainerBounds.x2 > preX2 && this.showLabelHoverOnAxis(position - diffWidth, text, !1)), diffHeight > 0 && ("left" === this.attribute.orient || "right" === this.attribute.orient) && (afterContainerBounds.y1 < preY1 ? this.showLabelHoverOnAxis(position + diffHeight, text, !1) : afterContainerBounds.y2 > preY2 && this.showLabelHoverOnAxis(position - diffHeight, text, !1));
40912
+ }
40913
+ }
40914
+ }
40915
+ hideLabelHoverOnAxis() {
40916
+ this.attribute.labelHoverOnAxis && this.labelHoverOnAxisGroup && this.labelHoverOnAxisGroup.setAttributes({
40917
+ visible: !1,
40918
+ visibleAll: !1
40919
+ });
40920
+ }
40788
40921
  release() {
40789
40922
  super.release(), this._breaks = null;
40790
40923
  }
@@ -52330,7 +52463,7 @@
52330
52463
  }
52331
52464
 
52332
52465
  const token = {
52333
- fontFamily: 'PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol',
52466
+ fontFamily: `PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,'-apple-system',segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol`,
52334
52467
  fontSize: 14,
52335
52468
  l1FontSize: 32,
52336
52469
  l1LineHeight: '150%',
@@ -57914,7 +58047,7 @@
57914
58047
  }
57915
58048
  }
57916
58049
  };
57917
- this._setStateOfGraphic = (g) => {
58050
+ this._setStateOfGraphic = (g, hasAnimation) => {
57918
58051
  g.clearStates();
57919
58052
  g.stateProxy = null;
57920
58053
  if (g.context.diffState === DiffState.enter || g.context.diffState === DiffState.update) {
@@ -57922,7 +58055,7 @@
57922
58055
  var _a;
57923
58056
  return this._runEncoderOfGraphic((_a = this._encoderOfState) === null || _a === void 0 ? void 0 : _a[stateName], g);
57924
58057
  };
57925
- g.context.states && g.useStates(g.context.states);
58058
+ g.context.states && g.useStates(g.context.states, hasAnimation);
57926
58059
  }
57927
58060
  };
57928
58061
  this.name = name;
@@ -58675,7 +58808,7 @@
58675
58808
  g.setFinalAttributes(finalAttrs);
58676
58809
  }
58677
58810
  }
58678
- this._setStateOfGraphic(g);
58811
+ this._setStateOfGraphic(g, hasStateAnimation);
58679
58812
  this._setGraphicFromMarkConfig(g);
58680
58813
  });
58681
58814
  }
@@ -61091,6 +61224,10 @@
61091
61224
  var _a;
61092
61225
  return (_a = this._chart) === null || _a === void 0 ? void 0 : _a.setDimensionIndex(value, opt);
61093
61226
  }
61227
+ showCrosshair(cb) {
61228
+ var _a;
61229
+ (_a = this._chart) === null || _a === void 0 ? void 0 : _a.showCrosshair(cb);
61230
+ }
61094
61231
  stopAnimation() {
61095
61232
  var _a;
61096
61233
  (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a.stopAnimation(true);
@@ -61400,7 +61537,7 @@
61400
61537
  });
61401
61538
  };
61402
61539
 
61403
- const version = "2.0.10-alpha.0";
61540
+ const version = "2.0.10";
61404
61541
 
61405
61542
  const addVChartProperty = (data, op) => {
61406
61543
  const context = op.beforeCall();
@@ -66086,7 +66223,7 @@
66086
66223
  _getGridAttributes() {
66087
66224
  const spec = this._spec;
66088
66225
  return {
66089
- alternateColor: isFunction$1(spec.grid.alternateColor) ? spec.grid.alternateColor() : spec.grid.alternateColor,
66226
+ alternateColor: spec.grid.alternateColor,
66090
66227
  alignWithLabel: spec.grid.alignWithLabel,
66091
66228
  style: isFunction$1(spec.grid.style)
66092
66229
  ? (datum, index) => {
@@ -66100,9 +66237,7 @@
66100
66237
  : {
66101
66238
  type: 'line',
66102
66239
  visible: spec.subGrid.visible,
66103
- alternateColor: isFunction$1(spec.subGrid.alternateColor)
66104
- ? spec.subGrid.alternateColor()
66105
- : spec.subGrid.alternateColor,
66240
+ alternateColor: spec.subGrid.alternateColor,
66106
66241
  style: transformToGraphic(spec.subGrid.style)
66107
66242
  }
66108
66243
  };
@@ -70151,10 +70286,12 @@
70151
70286
  }
70152
70287
  });
70153
70288
  const isUnableValue = isNil$1(value) || !dimensionInfo || dimensionInfo.every(d => isDiscrete(d.axis.getScale().type) && isNil$1(d.index));
70289
+ const isUnableTooltip = isUnableValue ||
70290
+ dimensionInfo.every(d => isDiscrete(d.axis.getScale().type) && d.data.every(_data => _data.datum.length === 0));
70154
70291
  if (opt.tooltip !== false) {
70155
70292
  const tooltip = this.getComponentsByType(ComponentTypeEnum.tooltip)[0];
70156
70293
  if (tooltip === null || tooltip === void 0 ? void 0 : tooltip.getVisible()) {
70157
- if (isUnableValue) {
70294
+ if (isUnableValue || isUnableTooltip) {
70158
70295
  (_b = (_a = tooltip).hideTooltip) === null || _b === void 0 ? void 0 : _b.call(_a);
70159
70296
  }
70160
70297
  else {
@@ -70184,6 +70321,25 @@
70184
70321
  }
70185
70322
  }
70186
70323
  }
70324
+ showCrosshair(cb) {
70325
+ var _a;
70326
+ const crosshair = (_a = this.getComponentsByType(ComponentTypeEnum.cartesianCrosshair)[0]) !== null && _a !== void 0 ? _a : this.getComponentsByType(ComponentTypeEnum.polarCrosshair)[0];
70327
+ if (!crosshair) {
70328
+ return;
70329
+ }
70330
+ const axes = this.getComponentsByKey('axes');
70331
+ const dimInfo = [];
70332
+ axes.forEach(axis => {
70333
+ const value = cb(axis);
70334
+ if (value !== false) {
70335
+ dimInfo.push({
70336
+ axis,
70337
+ value
70338
+ });
70339
+ }
70340
+ });
70341
+ crosshair.showCrosshair(dimInfo);
70342
+ }
70187
70343
  getColorScheme() {
70188
70344
  var _a, _b;
70189
70345
  return (_b = (_a = this._option).getTheme) === null || _b === void 0 ? void 0 : _b.call(_a, 'colorScheme');
@@ -76421,6 +76577,7 @@
76421
76577
  constructor() {
76422
76578
  super(...arguments);
76423
76579
  this.type = exports.SeriesTypeEnum.boxPlot;
76580
+ this._bandPosition = 0;
76424
76581
  }
76425
76582
  getMinField() {
76426
76583
  return this._minField;
@@ -76453,7 +76610,7 @@
76453
76610
  return this._outliersStyle;
76454
76611
  }
76455
76612
  setAttrFromSpec() {
76456
- var _a, _b, _c, _d, _e;
76613
+ var _a, _b, _c, _d, _e, _f, _g;
76457
76614
  super.setAttrFromSpec();
76458
76615
  const boxPlotStyle = (_b = (_a = this._spec.boxPlot) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {};
76459
76616
  this._minField = this._spec.minField;
@@ -76470,7 +76627,7 @@
76470
76627
  this._strokeColor = boxPlotStyle.stroke;
76471
76628
  this._shaftFillOpacity =
76472
76629
  this._shaftShape === 'bar' ? (_e = boxPlotStyle.shaftFillOpacity) !== null && _e !== void 0 ? _e : DEFAULT_SHAFT_FILL_OPACITY : undefined;
76473
- this._outliersStyle = this._spec.outliersStyle;
76630
+ this._outliersStyle = ((_f = this._spec.outliersStyle) !== null && _f !== void 0 ? _f : (_g = this._spec.outlier) === null || _g === void 0 ? void 0 : _g.style);
76474
76631
  }
76475
76632
  initMark() {
76476
76633
  this._boxPlotMark = this._createMark(BoxPlotSeries.mark.boxPlot, {
@@ -76492,24 +76649,37 @@
76492
76649
  if (boxPlotMark) {
76493
76650
  const commonBoxplotStyles = {
76494
76651
  lineWidth: this._lineWidth,
76495
- fill: (_a = this._boxFillColor) !== null && _a !== void 0 ? _a : (this._shaftShape === 'line' ? DEFAULT_FILL_COLOR : this.getColorAttribute()),
76652
+ fill: (_a = this._boxFillColor) !== null && _a !== void 0 ? _a : (this._shaftShape !== 'line' ? this.getColorAttribute() : DEFAULT_FILL_COLOR),
76496
76653
  minMaxFillOpacity: this._shaftFillOpacity,
76497
- stroke: (_b = this._strokeColor) !== null && _b !== void 0 ? _b : (this._shaftShape === 'line' ? this.getColorAttribute() : DEFAULT_STROKE_COLOR)
76654
+ stroke: (_b = this._strokeColor) !== null && _b !== void 0 ? _b : (this._shaftShape !== 'line' ? DEFAULT_STROKE_COLOR : this.getColorAttribute())
76498
76655
  };
76499
76656
  boxPlotMark.setGlyphConfig({
76500
76657
  direction: this._direction,
76501
76658
  shaftShape: this._shaftShape
76502
76659
  });
76503
76660
  const boxPlotMarkStyles = this._direction === "horizontal"
76504
- ? Object.assign(Object.assign({ y: this.dataToPositionY.bind(this) }, commonBoxplotStyles), { boxHeight: () => { var _a; return (_a = this._boxWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth(); }, ruleHeight: () => { var _a; return (_a = this._shaftWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth(); }, q1q3Height: () => { var _a; return (_a = this._boxWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth(); }, minMaxHeight: () => { var _a; return (_a = this._shaftWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth(); } }) : Object.assign(Object.assign({ x: this.dataToPositionX.bind(this) }, commonBoxplotStyles), { boxWidth: () => { var _a; return (_a = this._boxWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth(); }, ruleWidth: () => { var _a; return (_a = this._shaftWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth(); }, q1q3Width: () => { var _a; return (_a = this._boxWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth(); }, minMaxWidth: () => { var _a; return (_a = this._shaftWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth(); } });
76505
- this.setMarkStyle(boxPlotMark, boxPlotMarkStyles, exports.STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
76661
+ ? {
76662
+ y: (datum) => this._getPosition(this.direction, datum),
76663
+ boxHeight: () => { var _a; return getActualNumValue((_a = this._boxWidth) !== null && _a !== void 0 ? _a : '100%', this._getMarkWidth()); },
76664
+ ruleHeight: () => { var _a; return getActualNumValue((_a = this._shaftWidth) !== null && _a !== void 0 ? _a : '100%', this._getMarkWidth()); },
76665
+ q1q3Height: () => { var _a; return getActualNumValue((_a = this._boxWidth) !== null && _a !== void 0 ? _a : '100%', this._getMarkWidth()); },
76666
+ minMaxHeight: () => { var _a; return getActualNumValue((_a = this._shaftWidth) !== null && _a !== void 0 ? _a : '100%', this._getMarkWidth()); }
76667
+ }
76668
+ : {
76669
+ x: (datum) => this._getPosition(this.direction, datum),
76670
+ boxWidth: () => { var _a; return getActualNumValue((_a = this._boxWidth) !== null && _a !== void 0 ? _a : '100%', this._getMarkWidth()); },
76671
+ ruleWidth: () => { var _a; return getActualNumValue((_a = this._shaftWidth) !== null && _a !== void 0 ? _a : '100%', this._getMarkWidth()); },
76672
+ q1q3Width: () => { var _a; return getActualNumValue((_a = this._boxWidth) !== null && _a !== void 0 ? _a : '100%', this._getMarkWidth()); },
76673
+ minMaxWidth: () => { var _a; return getActualNumValue((_a = this._shaftWidth) !== null && _a !== void 0 ? _a : '100%', this._getMarkWidth()); }
76674
+ };
76675
+ this.setMarkStyle(boxPlotMark, commonBoxplotStyles, exports.STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
76676
+ this.setMarkStyle(boxPlotMark, boxPlotMarkStyles, exports.STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Built_In);
76506
76677
  }
76507
76678
  const outlierMark = this._outlierMark;
76508
76679
  if (outlierMark) {
76509
76680
  this.setMarkStyle(outlierMark, {
76510
76681
  fill: (_d = (_c = this._outliersStyle) === null || _c === void 0 ? void 0 : _c.fill) !== null && _d !== void 0 ? _d : this.getColorAttribute(),
76511
- size: isNumber$1((_e = this._outliersStyle) === null || _e === void 0 ? void 0 : _e.size) ? this._outliersStyle.size : DEFAULT_OUTLIER_SIZE,
76512
- symbolType: 'circle'
76682
+ size: isNumber$1((_e = this._outliersStyle) === null || _e === void 0 ? void 0 : _e.size) ? this._outliersStyle.size : DEFAULT_OUTLIER_SIZE
76513
76683
  }, exports.STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
76514
76684
  }
76515
76685
  }
@@ -76544,13 +76714,13 @@
76544
76714
  const scale = (_b = axisHelper === null || axisHelper === void 0 ? void 0 : axisHelper.getScale) === null || _b === void 0 ? void 0 : _b.call(axisHelper, 0);
76545
76715
  const outlierMarkPositionChannel = this._direction === "horizontal"
76546
76716
  ? {
76547
- y: this.dataToPositionY.bind(this),
76717
+ y: (datum) => this._getPosition(this.direction, datum),
76548
76718
  x: (datum) => valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, BOX_PLOT_OUTLIER_VALUE_FIELD), {
76549
76719
  bandPosition: this._bandPosition
76550
76720
  }), scale)
76551
76721
  }
76552
76722
  : {
76553
- x: this.dataToPositionX.bind(this),
76723
+ x: (datum) => this._getPosition(this.direction, datum),
76554
76724
  y: (datum) => valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, BOX_PLOT_OUTLIER_VALUE_FIELD), {
76555
76725
  bandPosition: this._bandPosition
76556
76726
  }), scale)
@@ -76596,16 +76766,73 @@
76596
76766
  this.initBoxPlotMarkStyle();
76597
76767
  }
76598
76768
  _getMarkWidth() {
76769
+ var _a;
76599
76770
  if (this._autoBoxWidth) {
76600
76771
  return this._autoBoxWidth;
76601
76772
  }
76602
76773
  const bandAxisHelper = this._direction === "horizontal" ? this._yAxisHelper : this._xAxisHelper;
76603
- const xField = this._direction === "horizontal" ? this._fieldY : this._fieldX;
76604
- const innerBandWidth = bandAxisHelper.getBandwidth(xField.length - 1);
76605
- const autoBoxWidth = innerBandWidth / xField.length;
76606
- this._autoBoxWidth = autoBoxWidth;
76774
+ const depthFromSpec = this._groups ? this._groups.fields.length : 1;
76775
+ const bandWidth = (_a = bandAxisHelper.getBandwidth) === null || _a === void 0 ? void 0 : _a.call(bandAxisHelper, depthFromSpec - 1);
76776
+ let width = bandWidth;
76777
+ if (isValid$1(this._spec.boxWidth)) {
76778
+ width = getActualNumValue(this._spec.boxWidth, bandWidth);
76779
+ }
76780
+ if (isValid$1(this._spec.boxMinWidth)) {
76781
+ width = Math.max(width, getActualNumValue(this._spec.boxMinWidth, bandWidth));
76782
+ }
76783
+ if (isValid$1(this._spec.boxMaxWidth)) {
76784
+ width = Math.min(width, getActualNumValue(this._spec.boxMaxWidth, bandWidth));
76785
+ }
76786
+ this._autoBoxWidth = width;
76607
76787
  return this._autoBoxWidth;
76608
76788
  }
76789
+ _getPosition(direction, datum) {
76790
+ var _a, _b, _c, _d;
76791
+ let axisHelper;
76792
+ let sizeAttribute;
76793
+ let dataToPosition;
76794
+ if (direction === "horizontal") {
76795
+ axisHelper = this.getYAxisHelper();
76796
+ sizeAttribute = 'boxHeight';
76797
+ dataToPosition = this.dataToPositionY.bind(this);
76798
+ }
76799
+ else {
76800
+ axisHelper = this.getXAxisHelper();
76801
+ sizeAttribute = 'boxWidth';
76802
+ dataToPosition = this.dataToPositionX.bind(this);
76803
+ }
76804
+ const scale = axisHelper.getScale(0);
76805
+ const depthFromSpec = this._groups ? this._groups.fields.length : 1;
76806
+ const depth = depthFromSpec;
76807
+ const bandWidth = (_a = axisHelper.getBandwidth) === null || _a === void 0 ? void 0 : _a.call(axisHelper, depth - 1);
76808
+ const size = this._boxPlotMark.getAttribute(sizeAttribute, datum);
76809
+ if (depth > 1 && isValid$1(this._spec.boxGapInGroup)) {
76810
+ const groupFields = this._groups.fields;
76811
+ const boxGapInGroup = array(this._spec.boxGapInGroup);
76812
+ let totalWidth = 0;
76813
+ let offSet = 0;
76814
+ for (let index = groupFields.length - 1; index >= 1; index--) {
76815
+ const groupField = groupFields[index];
76816
+ const groupValues = (_c = (_b = axisHelper.getScale(index)) === null || _b === void 0 ? void 0 : _b.domain()) !== null && _c !== void 0 ? _c : [];
76817
+ const groupCount = groupValues.length;
76818
+ const gap = getActualNumValue((_d = boxGapInGroup[index - 1]) !== null && _d !== void 0 ? _d : last(boxGapInGroup), bandWidth);
76819
+ const i = groupValues.indexOf(datum[groupField]);
76820
+ if (index === groupFields.length - 1) {
76821
+ totalWidth += groupCount * size + (groupCount - 1) * gap;
76822
+ offSet += i * (size + gap);
76823
+ }
76824
+ else {
76825
+ offSet += i * (totalWidth + gap);
76826
+ totalWidth += totalWidth + (groupCount - 1) * gap;
76827
+ }
76828
+ }
76829
+ const center = scale.scale(datum[groupFields[0]]) + axisHelper.getBandwidth(0) / 2;
76830
+ return center - totalWidth / 2 + offSet + size / 2;
76831
+ }
76832
+ const continuous = isContinuous(scale.type || 'band');
76833
+ const pos = dataToPosition(datum);
76834
+ return pos + bandWidth * 0.5 + (continuous ? -bandWidth / 2 : 0);
76835
+ }
76609
76836
  onLayoutEnd() {
76610
76837
  super.onLayoutEnd();
76611
76838
  this._autoBoxWidth = null;
@@ -76614,10 +76841,10 @@
76614
76841
  const newConfig = merge$1({}, config);
76615
76842
  ['appear', 'enter', 'update', 'exit', 'disappear'].forEach(state => {
76616
76843
  if (newConfig[state] && newConfig[state].type === 'scaleIn') {
76617
- newConfig[state].type = this._shaftShape === 'line' ? 'boxplotScaleIn' : 'barBoxplotScaleIn';
76844
+ newConfig[state].type = this._shaftShape === 'bar' ? 'barBoxplotScaleIn' : 'boxplotScaleIn';
76618
76845
  }
76619
76846
  else if (newConfig[state] && newConfig[state].type === 'scaleOut') {
76620
- newConfig[state].type = this._shaftShape === 'line' ? 'boxplotScaleOut' : 'barBoxplotScaleOut';
76847
+ newConfig[state].type = this._shaftShape === 'bar' ? 'barBoxplotScaleOut' : 'boxplotScaleOut';
76621
76848
  }
76622
76849
  });
76623
76850
  return newConfig;
@@ -93836,13 +94063,18 @@
93836
94063
  const dataFields = [spec.maxField, spec.medianField, spec.q1Field, spec.q3Field, spec.minField, spec.outliersField];
93837
94064
  const seriesSpec = super._getDefaultSeriesSpec(spec, [
93838
94065
  'boxPlot',
94066
+ 'outlier',
93839
94067
  'minField',
93840
94068
  'maxField',
93841
94069
  'q1Field',
93842
94070
  'medianField',
93843
94071
  'q3Field',
93844
94072
  'outliersField',
93845
- 'outliersStyle'
94073
+ 'outliersStyle',
94074
+ 'boxWidth',
94075
+ 'boxMaxWidth',
94076
+ 'boxMinWidth',
94077
+ 'boxGapInGroup'
93846
94078
  ]);
93847
94079
  seriesSpec.direction = (_a = spec.direction) !== null && _a !== void 0 ? _a : "vertical";
93848
94080
  seriesSpec[seriesSpec.direction === "horizontal" ? 'xField' : 'yField'] = dataFields;