@visactor/vchart-extension 2.0.4-alpha.0 → 2.0.4-alpha.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 (95) hide show
  1. package/build/index.js +564 -17
  2. package/build/index.min.js +2 -2
  3. package/cjs/charts/candlestick/candlestick-transformer.d.ts +6 -0
  4. package/cjs/charts/candlestick/candlestick-transformer.js +24 -0
  5. package/cjs/charts/candlestick/candlestick-transformer.js.map +1 -0
  6. package/cjs/charts/candlestick/candlestick.d.ts +10 -0
  7. package/cjs/charts/candlestick/candlestick.js +25 -0
  8. package/cjs/charts/candlestick/candlestick.js.map +1 -0
  9. package/cjs/charts/candlestick/index.d.ts +3 -0
  10. package/cjs/charts/candlestick/index.js +22 -0
  11. package/cjs/charts/candlestick/index.js.map +1 -0
  12. package/cjs/charts/candlestick/interface.d.ts +6 -0
  13. package/cjs/charts/candlestick/interface.js +6 -0
  14. package/cjs/charts/candlestick/interface.js.map +1 -0
  15. package/cjs/charts/candlestick/mark/candlestick.d.ts +11 -0
  16. package/cjs/charts/candlestick/mark/candlestick.js +62 -0
  17. package/cjs/charts/candlestick/mark/candlestick.js.map +1 -0
  18. package/cjs/charts/candlestick/mark/interface.d.ts +9 -0
  19. package/cjs/charts/candlestick/mark/interface.js +6 -0
  20. package/cjs/charts/candlestick/mark/interface.js.map +1 -0
  21. package/cjs/charts/candlestick/series/animation.d.ts +32 -0
  22. package/cjs/charts/candlestick/series/animation.js +132 -0
  23. package/cjs/charts/candlestick/series/animation.js.map +1 -0
  24. package/cjs/charts/candlestick/series/candlestick.d.ts +105 -0
  25. package/cjs/charts/candlestick/series/candlestick.js +143 -0
  26. package/cjs/charts/candlestick/series/candlestick.js.map +1 -0
  27. package/cjs/charts/candlestick/series/constant.d.ts +77 -0
  28. package/cjs/charts/candlestick/series/constant.js +26 -0
  29. package/cjs/charts/candlestick/series/constant.js.map +1 -0
  30. package/cjs/charts/candlestick/series/interface.d.ts +20 -0
  31. package/cjs/charts/candlestick/series/interface.js +6 -0
  32. package/cjs/charts/candlestick/series/interface.js.map +1 -0
  33. package/cjs/charts/candlestick/series/theme.d.ts +3 -0
  34. package/cjs/charts/candlestick/series/theme.js +34 -0
  35. package/cjs/charts/candlestick/series/theme.js.map +1 -0
  36. package/cjs/charts/candlestick/series/tooltip-helper.d.ts +9 -0
  37. package/cjs/charts/candlestick/series/tooltip-helper.js +70 -0
  38. package/cjs/charts/candlestick/series/tooltip-helper.js.map +1 -0
  39. package/cjs/charts/conversion-funnel/constants.js +2 -1
  40. package/cjs/charts/funnel-3d/theme.js +1 -2
  41. package/cjs/charts/image-cloud/image-cloud-transformer.js +2 -1
  42. package/cjs/charts/pictogram/element-highlight-by-graphic-name.js +1 -1
  43. package/cjs/charts/pictogram/element-select-by-graphic-name.js +1 -1
  44. package/cjs/charts/pictogram/index.js +1 -1
  45. package/cjs/charts/pictogram/interface.js +1 -1
  46. package/cjs/index.d.ts +1 -0
  47. package/cjs/index.js +3 -2
  48. package/cjs/index.js.map +1 -1
  49. package/esm/charts/candlestick/candlestick-transformer.d.ts +6 -0
  50. package/esm/charts/candlestick/candlestick-transformer.js +16 -0
  51. package/esm/charts/candlestick/candlestick-transformer.js.map +1 -0
  52. package/esm/charts/candlestick/candlestick.d.ts +10 -0
  53. package/esm/charts/candlestick/candlestick.js +22 -0
  54. package/esm/charts/candlestick/candlestick.js.map +1 -0
  55. package/esm/charts/candlestick/index.d.ts +3 -0
  56. package/esm/charts/candlestick/index.js +6 -0
  57. package/esm/charts/candlestick/index.js.map +1 -0
  58. package/esm/charts/candlestick/interface.d.ts +6 -0
  59. package/esm/charts/candlestick/interface.js +2 -0
  60. package/esm/charts/candlestick/interface.js.map +1 -0
  61. package/esm/charts/candlestick/mark/candlestick.d.ts +11 -0
  62. package/esm/charts/candlestick/mark/candlestick.js +58 -0
  63. package/esm/charts/candlestick/mark/candlestick.js.map +1 -0
  64. package/esm/charts/candlestick/mark/interface.d.ts +9 -0
  65. package/esm/charts/candlestick/mark/interface.js +2 -0
  66. package/esm/charts/candlestick/mark/interface.js.map +1 -0
  67. package/esm/charts/candlestick/series/animation.d.ts +32 -0
  68. package/esm/charts/candlestick/series/animation.js +124 -0
  69. package/esm/charts/candlestick/series/animation.js.map +1 -0
  70. package/esm/charts/candlestick/series/candlestick.d.ts +105 -0
  71. package/esm/charts/candlestick/series/candlestick.js +145 -0
  72. package/esm/charts/candlestick/series/candlestick.js.map +1 -0
  73. package/esm/charts/candlestick/series/constant.d.ts +77 -0
  74. package/esm/charts/candlestick/series/constant.js +27 -0
  75. package/esm/charts/candlestick/series/constant.js.map +1 -0
  76. package/esm/charts/candlestick/series/interface.d.ts +20 -0
  77. package/esm/charts/candlestick/series/interface.js +2 -0
  78. package/esm/charts/candlestick/series/interface.js.map +1 -0
  79. package/esm/charts/candlestick/series/theme.d.ts +3 -0
  80. package/esm/charts/candlestick/series/theme.js +52 -0
  81. package/esm/charts/candlestick/series/theme.js.map +1 -0
  82. package/esm/charts/candlestick/series/tooltip-helper.d.ts +9 -0
  83. package/esm/charts/candlestick/series/tooltip-helper.js +64 -0
  84. package/esm/charts/candlestick/series/tooltip-helper.js.map +1 -0
  85. package/esm/charts/conversion-funnel/constants.js +2 -1
  86. package/esm/charts/funnel-3d/theme.js +1 -2
  87. package/esm/charts/image-cloud/image-cloud-transformer.js +2 -1
  88. package/esm/charts/pictogram/element-highlight-by-graphic-name.js +1 -1
  89. package/esm/charts/pictogram/element-select-by-graphic-name.js +1 -1
  90. package/esm/charts/pictogram/index.js +1 -1
  91. package/esm/charts/pictogram/interface.js +1 -1
  92. package/esm/index.d.ts +1 -0
  93. package/esm/index.js +2 -0
  94. package/esm/index.js.map +1 -1
  95. package/package.json +8 -8
package/build/index.js CHANGED
@@ -7015,7 +7015,8 @@
7015
7015
  y1: 0,
7016
7016
  strokeBoundsBuffer: 0,
7017
7017
  cornerRadius: 0,
7018
- cornerType: "round"
7018
+ cornerType: "round",
7019
+ drawStrokeWhenZeroWH: !1
7019
7020
  });
7020
7021
  Object.assign(Object.assign({}, DefaultAttribute), {
7021
7022
  width: 0,
@@ -7024,7 +7025,8 @@
7024
7025
  y1: 0,
7025
7026
  cornerRadius: 0,
7026
7027
  length: 0,
7027
- cornerType: "round"
7028
+ cornerType: "round",
7029
+ drawStrokeWhenZeroWH: !1
7028
7030
  });
7029
7031
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
7030
7032
  symbolType: "circle",
@@ -10219,7 +10221,7 @@
10219
10221
  });
10220
10222
  }
10221
10223
  setAttributes(params, forceUpdateTag = !1, context) {
10222
- (params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context);
10224
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
10223
10225
  }
10224
10226
  _setAttributes(params, forceUpdateTag = !1, context) {
10225
10227
  const keys = Object.keys(params);
@@ -10854,8 +10856,8 @@
10854
10856
  function strokeVisible(opacity, strokeOpacity) {
10855
10857
  return opacity * strokeOpacity > 0;
10856
10858
  }
10857
- function rectStrokeVisible(opacity, strokeOpacity, width, height) {
10858
- return opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
10859
+ function rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH) {
10860
+ return drawStrokeWhenZeroWH ? opacity * strokeOpacity > 0 : opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
10859
10861
  }
10860
10862
  function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
10861
10863
  const x10 = x1 - x0,
@@ -14921,7 +14923,8 @@
14921
14923
  y1: y1,
14922
14924
  x: originX = rectAttribute.x,
14923
14925
  y: originY = rectAttribute.y,
14924
- fillStrokeOrder = rectAttribute.fillStrokeOrder
14926
+ fillStrokeOrder = rectAttribute.fillStrokeOrder,
14927
+ drawStrokeWhenZeroWH = rectAttribute.drawStrokeWhenZeroWH
14925
14928
  } = rect.attribute;
14926
14929
  let {
14927
14930
  width: width,
@@ -14929,7 +14932,7 @@
14929
14932
  } = rect.attribute;
14930
14933
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
14931
14934
  const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
14932
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
14935
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
14933
14936
  doFill = runFill(fill, background),
14934
14937
  doStroke = runStroke(stroke, lineWidth);
14935
14938
  if (!rect.valid || !visible) return;
@@ -15833,7 +15836,7 @@
15833
15836
  super(...arguments), this.type = "rect3d", this.numberType = RECT3D_NUMBER_TYPE;
15834
15837
  }
15835
15838
  drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
15836
- var _a;
15839
+ var _a, _b;
15837
15840
  const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect,
15838
15841
  {
15839
15842
  fill = rectAttribute.fill,
@@ -15846,16 +15849,17 @@
15846
15849
  fillOpacity = rectAttribute.fillOpacity,
15847
15850
  lineWidth = rectAttribute.lineWidth,
15848
15851
  strokeOpacity = rectAttribute.strokeOpacity,
15849
- visible = rectAttribute.visible
15852
+ visible = rectAttribute.visible,
15853
+ drawStrokeWhenZeroWH = null !== (_a = rectAttribute.drawStrokeWhenZeroWH) && void 0 !== _a && _a
15850
15854
  } = rect.attribute;
15851
15855
  let {
15852
15856
  width: width,
15853
15857
  height: height
15854
15858
  } = rect.attribute;
15855
15859
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
15856
- const z = null !== (_a = this.z) && void 0 !== _a ? _a : 0,
15860
+ const z = null !== (_b = this.z) && void 0 !== _b ? _b : 0,
15857
15861
  fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
15858
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
15862
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
15859
15863
  doFill = runFill(fill),
15860
15864
  doStroke = runStroke(stroke, lineWidth);
15861
15865
  if (!rect.valid || !visible) return;
@@ -17848,6 +17852,7 @@
17848
17852
  return this.getEndProps();
17849
17853
  }
17850
17854
  stop() {}
17855
+ release() {}
17851
17856
  }
17852
17857
  class WaitStep extends Step {
17853
17858
  constructor(type, props, duration, easing) {
@@ -18065,7 +18070,9 @@
18065
18070
  this.status !== AnimateStatus.END && this.onEnd(), this.status = AnimateStatus.END, this.target && ("start" === type ? this.target.setAttributes(this._startProps) : "end" === type ? this.target.setAttributes(this._endProps) : type && this.target.setAttributes(type));
18066
18071
  }
18067
18072
  release() {
18068
- this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
18073
+ this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [], this.forEachStep(step => {
18074
+ step.release();
18075
+ });
18069
18076
  }
18070
18077
  getDuration() {
18071
18078
  return this._duration;
@@ -18139,6 +18146,10 @@
18139
18146
  getLoop() {
18140
18147
  return this._loopCount;
18141
18148
  }
18149
+ forEachStep(cb) {
18150
+ let step = this._firstStep;
18151
+ for (; step;) cb(step), step = step.next;
18152
+ }
18142
18153
  }
18143
18154
 
18144
18155
  const performanceRAF = new PerformanceRAF();
@@ -18371,6 +18382,9 @@
18371
18382
  constructor(target) {
18372
18383
  this._animates = [], this._startCallbacks = [], this._endCallbacks = [], this._started = !1, this._activeCount = 0, this._target = target;
18373
18384
  }
18385
+ get started() {
18386
+ return this._started;
18387
+ }
18374
18388
  onStart(cb) {
18375
18389
  cb ? (this._startCallbacks.push(cb), this._started && this._activeCount > 0 && cb()) : this._startCallbacks.forEach(cb => {
18376
18390
  cb();
@@ -18511,14 +18525,14 @@
18511
18525
  return delayAfterValue > 0 && (totalDelay += delayAfterValue), totalDelay > 0 && animate.wait(totalDelay), loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0), animate;
18512
18526
  }
18513
18527
  _handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic) {
18514
- var _a, _b, _c, _d;
18528
+ var _a, _b, _c, _d, _e, _f;
18515
18529
  if (custom && customType) {
18516
18530
  const customParams = Object.assign({
18517
- width: graphic.stage.width,
18518
- height: graphic.stage.height,
18531
+ width: (null === (_a = graphic.stage) || void 0 === _a ? void 0 : _a.width) || 0,
18532
+ height: (null === (_b = graphic.stage) || void 0 === _b ? void 0 : _b.height) || 0,
18519
18533
  group: this._target.parent
18520
18534
  }, this.resolveValue(customParameters, graphic)),
18521
- objOptions = isFunction$1(options) ? options.call(null, null !== (_b = customParams && (null === (_a = customParams.data) || void 0 === _a ? void 0 : _a[0])) && void 0 !== _b ? _b : null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, customParams) : options;
18535
+ objOptions = isFunction$1(options) ? options.call(null, null !== (_d = customParams && (null === (_c = customParams.data) || void 0 === _c ? void 0 : _c[0])) && void 0 !== _d ? _d : null === (_f = null === (_e = graphic.context) || void 0 === _e ? void 0 : _e.data) || void 0 === _f ? void 0 : _f[0], graphic, customParams) : options;
18522
18536
  customParams.options = objOptions, customParams.controlOptions = controlOptions, 1 === customType ? this.createCustomAnimation(animate, custom, from, props, duration, easing, customParams) : 2 === customType && this.createCustomInterpolatorAnimation(animate, custom, props, duration, easing, customParams);
18523
18537
  } else "to" === type ? animate.to(props, duration, easing) : "from" === type && animate.from(props, duration, easing);
18524
18538
  }
@@ -18738,7 +18752,7 @@
18738
18752
  reApplyState(state) {
18739
18753
  var _a;
18740
18754
  const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find(stateInfo => stateInfo.state === state);
18741
- if (stateInfo) {
18755
+ if (stateInfo && stateInfo.executor.started) {
18742
18756
  const stateList = this.stateList.slice();
18743
18757
  stateInfo.executor.stop(), this.stateList = stateList, stateInfo.executor.execute(stateInfo.animationConfig);
18744
18758
  }
@@ -21974,6 +21988,536 @@
21974
21988
  vchart.Factory.registerChart(ImageCloudChart.type, ImageCloudChart);
21975
21989
  };
21976
21990
 
21991
+ class CandlestickChartSpecTransformer extends vchart.CartesianChartSpecTransformer {
21992
+ _getDefaultSeriesSpec(spec) {
21993
+ const dataFields = [spec.openField, spec.highField, spec.lowField, spec.closeField];
21994
+ const seriesSpec = super._getDefaultSeriesSpec(spec, [
21995
+ 'candlestick',
21996
+ 'openField',
21997
+ 'highField',
21998
+ 'lowField',
21999
+ 'closeField',
22000
+ 'rising',
22001
+ 'falling',
22002
+ 'doji'
22003
+ ]);
22004
+ seriesSpec.yField = dataFields;
22005
+ return seriesSpec;
22006
+ }
22007
+ transformSpec(spec) {
22008
+ super.transformSpec(spec);
22009
+ if (!spec.axes) {
22010
+ spec.axes = [
22011
+ {
22012
+ orient: 'bottom'
22013
+ },
22014
+ {
22015
+ orient: 'left'
22016
+ }
22017
+ ];
22018
+ }
22019
+ vchart.setDefaultCrosshairForCartesianChart(spec);
22020
+ }
22021
+ }
22022
+
22023
+ const CANDLESTICK_MARK_TYPE = 'candlestick';
22024
+ class CandlestickMark extends vchart.GlyphMark {
22025
+ constructor() {
22026
+ super(...arguments);
22027
+ this.type = CandlestickMark.type;
22028
+ }
22029
+ setGlyphConfig(cfg) {
22030
+ super.setGlyphConfig(cfg);
22031
+ this._subMarks = {
22032
+ line: { type: 'line', defaultAttributes: { x: 0, y: 0 } },
22033
+ box: { type: 'rect' }
22034
+ };
22035
+ this._positionChannels = ['x', 'boxWidth', 'open', 'close', 'high', 'low'];
22036
+ this._channelEncoder = null;
22037
+ this._positionEncoder = (glyphAttrs, datum, g) => {
22038
+ const { x = g.attribute.x, boxWidth = g.attribute.boxWidth, open = g.attribute.open, close = g.attribute.close, low = g.attribute.low, high = g.attribute.high } = glyphAttrs;
22039
+ const attributes = {};
22040
+ attributes.line = {
22041
+ points: [
22042
+ {
22043
+ x: x,
22044
+ y: low
22045
+ },
22046
+ {
22047
+ x: x,
22048
+ y: high
22049
+ }
22050
+ ]
22051
+ };
22052
+ attributes.box = {
22053
+ x: x - boxWidth / 2,
22054
+ x1: x + boxWidth / 2,
22055
+ y: Math.min(open, close),
22056
+ y1: Math.max(open, close),
22057
+ drawStrokeWhenZeroWH: true
22058
+ };
22059
+ return attributes;
22060
+ };
22061
+ }
22062
+ _getDefaultStyle() {
22063
+ const defaultStyle = Object.assign({}, super._getDefaultStyle());
22064
+ return defaultStyle;
22065
+ }
22066
+ }
22067
+ CandlestickMark.type = CANDLESTICK_MARK_TYPE;
22068
+ const registerCandlestickMark = () => {
22069
+ vchart.registerGlyphMark();
22070
+ registerLine();
22071
+ registerRect();
22072
+ vchart.Factory.registerGraphicComponent('line', (attrs) => createLine(attrs));
22073
+ vchart.Factory.registerGraphicComponent('rect', (attrs) => createRect(attrs));
22074
+ vchart.Factory.registerMark(CandlestickMark.type, CandlestickMark);
22075
+ };
22076
+
22077
+ const scaleIn = () => {
22078
+ return (graphic) => {
22079
+ const finalAttribute = graphic.getFinalAttribute();
22080
+ const { x, y, open, high, low, close } = finalAttribute;
22081
+ const animateAttributes = { from: { x, y }, to: { x, y } };
22082
+ if (isValidNumber$1(open) && isValidNumber$1(close)) {
22083
+ if (open > close) {
22084
+ animateAttributes.from.open = low;
22085
+ animateAttributes.to.open = open;
22086
+ animateAttributes.from.close = low;
22087
+ animateAttributes.to.close = close;
22088
+ if (isValidNumber$1(high)) {
22089
+ animateAttributes.from.high = low;
22090
+ animateAttributes.to.high = high;
22091
+ }
22092
+ }
22093
+ else {
22094
+ animateAttributes.from.open = high;
22095
+ animateAttributes.to.open = open;
22096
+ animateAttributes.from.close = high;
22097
+ animateAttributes.to.close = close;
22098
+ if (isValidNumber$1(low)) {
22099
+ animateAttributes.from.low = high;
22100
+ animateAttributes.to.low = low;
22101
+ }
22102
+ }
22103
+ }
22104
+ return animateAttributes;
22105
+ };
22106
+ };
22107
+ const scaleOut = () => {
22108
+ return (graphic) => {
22109
+ const finalAttribute = graphic.getFinalAttribute();
22110
+ const { x, y, open, high, low, close } = finalAttribute;
22111
+ const animateAttributes = { from: { x, y }, to: { x, y } };
22112
+ if (isValidNumber$1(open) && isValidNumber$1(close)) {
22113
+ if (open > close) {
22114
+ animateAttributes.from.open = open;
22115
+ animateAttributes.to.open = low;
22116
+ animateAttributes.from.close = close;
22117
+ animateAttributes.to.close = low;
22118
+ if (isValidNumber$1(high)) {
22119
+ animateAttributes.from.high = high;
22120
+ animateAttributes.to.high = low;
22121
+ }
22122
+ }
22123
+ else {
22124
+ animateAttributes.from.open = open;
22125
+ animateAttributes.to.open = high;
22126
+ animateAttributes.from.close = close;
22127
+ animateAttributes.to.close = high;
22128
+ if (isValidNumber$1(low)) {
22129
+ animateAttributes.from.low = low;
22130
+ animateAttributes.to.low = high;
22131
+ }
22132
+ }
22133
+ }
22134
+ return animateAttributes;
22135
+ };
22136
+ };
22137
+ class CandlestickScaleIn extends ACustomAnimate {
22138
+ constructor(from, to, duration, easing, params) {
22139
+ super(from, to, duration, easing, params);
22140
+ }
22141
+ onBind() {
22142
+ super.onBind();
22143
+ const finalAttribute = this.target.getFinalAttribute();
22144
+ if (finalAttribute) {
22145
+ this.target.setAttributes(finalAttribute);
22146
+ }
22147
+ const { from, to } = this.computeAttribute();
22148
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
22149
+ this.animate.reSyncProps();
22150
+ this.from = from;
22151
+ this.to = to;
22152
+ this.target.setAttributes(this.from);
22153
+ }
22154
+ computeAttribute() {
22155
+ const attr = scaleIn()(this.target, this.params, this.params.options);
22156
+ return attr;
22157
+ }
22158
+ onUpdate(end, ratio, out) {
22159
+ const attribute = this.target.attribute;
22160
+ this.propKeys.forEach(key => {
22161
+ attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
22162
+ });
22163
+ this.target.setAttributes(attribute);
22164
+ }
22165
+ }
22166
+ class CandlestickScaleOut extends ACustomAnimate {
22167
+ constructor(from, to, duration, easing, params) {
22168
+ super(from, to, duration, easing, params);
22169
+ }
22170
+ onBind() {
22171
+ var _a;
22172
+ if ((_a = this.params) === null || _a === void 0 ? void 0 : _a.diffAttrs) {
22173
+ this.target.setAttributes(this.params.diffAttrs);
22174
+ }
22175
+ const { from, to } = this.computeAttribute();
22176
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
22177
+ this.animate.reSyncProps();
22178
+ this.from = from;
22179
+ this.to = to;
22180
+ this.target.setAttributes(this.from);
22181
+ }
22182
+ computeAttribute() {
22183
+ const attr = scaleOut()(this.target, this.params, this.params.options);
22184
+ return attr;
22185
+ }
22186
+ onUpdate(end, ratio, out) {
22187
+ const attribute = this.target.attribute;
22188
+ this.propKeys.forEach(key => {
22189
+ attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
22190
+ });
22191
+ this.target.setAttributes(attribute);
22192
+ }
22193
+ }
22194
+ const registerCandlestickScaleAnimation = () => {
22195
+ AnimateExecutor.registerBuiltInAnimate('candlestickScaleIn', CandlestickScaleIn);
22196
+ AnimateExecutor.registerBuiltInAnimate('candlestickScaleOut', CandlestickScaleOut);
22197
+ };
22198
+
22199
+ const CANDLESTICK_CHART_TYPE = 'candlestick';
22200
+ const CANDLESTICK_SERIES_TYPE = 'candlestick';
22201
+ var CANDLESTICK_TOOLTIP_KEYS;
22202
+ (function (CANDLESTICK_TOOLTIP_KEYS) {
22203
+ CANDLESTICK_TOOLTIP_KEYS["OPEN"] = "open";
22204
+ CANDLESTICK_TOOLTIP_KEYS["HIGH"] = "high";
22205
+ CANDLESTICK_TOOLTIP_KEYS["LOW"] = "low";
22206
+ CANDLESTICK_TOOLTIP_KEYS["CLOSE"] = "close";
22207
+ CANDLESTICK_TOOLTIP_KEYS["SERIES_FIELD"] = "seriesField";
22208
+ })(CANDLESTICK_TOOLTIP_KEYS || (CANDLESTICK_TOOLTIP_KEYS = {}));
22209
+ var CandlestickMarkNameEnum;
22210
+ (function (CandlestickMarkNameEnum) {
22211
+ CandlestickMarkNameEnum["candlestick"] = "candlestick";
22212
+ })(CandlestickMarkNameEnum || (CandlestickMarkNameEnum = {}));
22213
+ const CandlestickSeriesMark = Object.assign(Object.assign({}, vchart.baseSeriesMark), { ["candlestick"]: { name: "candlestick", type: 'candlestick' } });
22214
+
22215
+ class CandlestickSeriesTooltipHelper extends vchart.BaseSeriesTooltipHelper {
22216
+ constructor() {
22217
+ super(...arguments);
22218
+ this.getContentKey = (contentType) => (datum) => {
22219
+ switch (contentType) {
22220
+ case CANDLESTICK_TOOLTIP_KEYS.OPEN: {
22221
+ const openField = this.series.getOpenField();
22222
+ return openField;
22223
+ }
22224
+ case CANDLESTICK_TOOLTIP_KEYS.HIGH: {
22225
+ const highField = this.series.getHighField();
22226
+ return highField;
22227
+ }
22228
+ case CANDLESTICK_TOOLTIP_KEYS.LOW: {
22229
+ const lowField = this.series.getLowField();
22230
+ return lowField;
22231
+ }
22232
+ case CANDLESTICK_TOOLTIP_KEYS.CLOSE: {
22233
+ const closeField = this.series.getCloseField();
22234
+ return closeField;
22235
+ }
22236
+ case CANDLESTICK_TOOLTIP_KEYS.SERIES_FIELD: {
22237
+ const seriesField = this.series.getSeriesField();
22238
+ return seriesField;
22239
+ }
22240
+ }
22241
+ return null;
22242
+ };
22243
+ this.getContentValue = (contentType) => (datum) => {
22244
+ switch (contentType) {
22245
+ case CANDLESTICK_TOOLTIP_KEYS.OPEN: {
22246
+ const openField = this.series.getOpenField();
22247
+ return datum[openField];
22248
+ }
22249
+ case CANDLESTICK_TOOLTIP_KEYS.HIGH: {
22250
+ const highField = this.series.getHighField();
22251
+ return datum[highField];
22252
+ }
22253
+ case CANDLESTICK_TOOLTIP_KEYS.LOW: {
22254
+ const lowField = this.series.getLowField();
22255
+ return datum[lowField];
22256
+ }
22257
+ case CANDLESTICK_TOOLTIP_KEYS.CLOSE: {
22258
+ const closeField = this.series.getCloseField();
22259
+ return datum[closeField];
22260
+ }
22261
+ case CANDLESTICK_TOOLTIP_KEYS.SERIES_FIELD: {
22262
+ const seriesField = this.series.getSeriesField();
22263
+ return datum[seriesField];
22264
+ }
22265
+ }
22266
+ return null;
22267
+ };
22268
+ this.shapeColorCallback = (datum) => {
22269
+ return this.series.getMarkInName('candlestick').getAttribute('stroke', datum);
22270
+ };
22271
+ }
22272
+ getDefaultContentList(activeType) {
22273
+ return [
22274
+ {
22275
+ key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.OPEN),
22276
+ value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.OPEN)
22277
+ },
22278
+ {
22279
+ key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.HIGH),
22280
+ value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.HIGH)
22281
+ },
22282
+ {
22283
+ key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.LOW),
22284
+ value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.LOW)
22285
+ },
22286
+ {
22287
+ key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.CLOSE),
22288
+ value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.CLOSE)
22289
+ },
22290
+ {
22291
+ key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.SERIES_FIELD),
22292
+ value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.SERIES_FIELD)
22293
+ }
22294
+ ];
22295
+ }
22296
+ }
22297
+
22298
+ const getCandlestickTheme = () => {
22299
+ const res = {
22300
+ rising: {
22301
+ style: {
22302
+ boxFill: '#FF0000',
22303
+ stroke: '#FF0000'
22304
+ }
22305
+ },
22306
+ falling: {
22307
+ style: {
22308
+ boxFill: '#00AA00',
22309
+ stroke: '#00AA00'
22310
+ }
22311
+ },
22312
+ doji: {
22313
+ style: {
22314
+ boxFill: '#000000',
22315
+ stroke: '#000000'
22316
+ }
22317
+ },
22318
+ candlestick: {
22319
+ style: {
22320
+ lineWidth: 1
22321
+ }
22322
+ }
22323
+ };
22324
+ return res;
22325
+ };
22326
+ const candlestick = getCandlestickTheme();
22327
+
22328
+ class CandlestickSeries extends vchart.CartesianSeries {
22329
+ constructor() {
22330
+ super(...arguments);
22331
+ this.type = CANDLESTICK_SERIES_TYPE;
22332
+ this._mergedStyles = {
22333
+ rising: {},
22334
+ falling: {},
22335
+ doji: {}
22336
+ };
22337
+ }
22338
+ getOpenField() {
22339
+ return this._openField;
22340
+ }
22341
+ getHighField() {
22342
+ return this._highField;
22343
+ }
22344
+ getLowField() {
22345
+ return this._lowField;
22346
+ }
22347
+ getCloseField() {
22348
+ return this._closeField;
22349
+ }
22350
+ getBoxFill() {
22351
+ return this._boxFill;
22352
+ }
22353
+ getStrokeColor() {
22354
+ return this._strokeColor;
22355
+ }
22356
+ setAttrFromSpec() {
22357
+ var _a, _b, _c, _d, _e, _f, _g, _h;
22358
+ super.setAttrFromSpec();
22359
+ const spec = this._spec;
22360
+ const CandlestickStyle = (_b = (_a = spec.candlestick) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {};
22361
+ this._openField = spec.openField;
22362
+ this._highField = spec.highField;
22363
+ this._lowField = spec.lowField;
22364
+ this._closeField = spec.closeField;
22365
+ this._boxWidth = CandlestickStyle.boxWidth;
22366
+ this._boxFill = CandlestickStyle.boxFill;
22367
+ this._strokeColor = CandlestickStyle.strokeColor;
22368
+ this._buildMergedStyles(CandlestickStyle, (_d = (_c = spec.rising) === null || _c === void 0 ? void 0 : _c.style) !== null && _d !== void 0 ? _d : {}, (_f = (_e = spec.falling) === null || _e === void 0 ? void 0 : _e.style) !== null && _f !== void 0 ? _f : {}, (_h = (_g = spec.doji) === null || _g === void 0 ? void 0 : _g.style) !== null && _h !== void 0 ? _h : {});
22369
+ }
22370
+ initMark() {
22371
+ this._candlestickMark = this._createMark(CandlestickSeries.mark.candlestick, {
22372
+ groupKey: this._seriesField,
22373
+ isSeriesMark: true
22374
+ });
22375
+ }
22376
+ initMarkStyle() {
22377
+ var _a;
22378
+ const candlestickMark = this._candlestickMark;
22379
+ if (candlestickMark) {
22380
+ const CandlestickStyles = {
22381
+ fill: (datum) => {
22382
+ const boxFill = this.mergeStyle(datum).boxFill;
22383
+ return boxFill;
22384
+ },
22385
+ stroke: (datum) => {
22386
+ const strokeColor = this.mergeStyle(datum).stroke;
22387
+ return strokeColor;
22388
+ },
22389
+ lineWidth: (datum) => {
22390
+ const lineWidth = this.mergeStyle(datum).lineWidth;
22391
+ return lineWidth;
22392
+ },
22393
+ boxWidth: (_a = this._boxWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth.bind(this),
22394
+ x: this.dataToPositionX.bind(this)
22395
+ };
22396
+ candlestickMark.setGlyphConfig({});
22397
+ this.setMarkStyle(candlestickMark, CandlestickStyles, vchart.STATE_VALUE_ENUM.STATE_NORMAL, vchart.AttributeLevel.Series);
22398
+ }
22399
+ }
22400
+ initCandlestickMarkStyle() {
22401
+ var _a;
22402
+ const candlestickMark = this._candlestickMark;
22403
+ const axisHelper = this._yAxisHelper;
22404
+ if (candlestickMark && axisHelper) {
22405
+ const { dataToPosition } = axisHelper;
22406
+ const scale = (_a = axisHelper === null || axisHelper === void 0 ? void 0 : axisHelper.getScale) === null || _a === void 0 ? void 0 : _a.call(axisHelper, 0);
22407
+ this.setMarkStyle(candlestickMark, {
22408
+ open: (datum) => vchart.valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._openField), {
22409
+ bandPosition: this._bandPosition
22410
+ }), scale),
22411
+ high: (datum) => vchart.valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._highField), {
22412
+ bandPosition: this._bandPosition
22413
+ }), scale),
22414
+ low: (datum) => vchart.valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._lowField), {
22415
+ bandPosition: this._bandPosition
22416
+ }), scale),
22417
+ close: (datum) => vchart.valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._closeField), {
22418
+ bandPosition: this._bandPosition
22419
+ }), scale)
22420
+ }, vchart.STATE_VALUE_ENUM.STATE_NORMAL, vchart.AttributeLevel.Series);
22421
+ }
22422
+ }
22423
+ init(option) {
22424
+ super.init(option);
22425
+ this.initCandlestickMarkStyle();
22426
+ }
22427
+ _initAnimationSpec(config = {}) {
22428
+ const newConfig = merge({}, config);
22429
+ ['appear', 'enter', 'update', 'exit', 'disappear'].forEach(state => {
22430
+ if (newConfig[state] && newConfig[state].type === 'scaleIn') {
22431
+ newConfig[state].type = 'candlestickScaleIn';
22432
+ }
22433
+ else if (newConfig[state] && newConfig[state].type === 'scaleOut') {
22434
+ newConfig[state].type = 'candlestickScaleOut';
22435
+ }
22436
+ });
22437
+ return newConfig;
22438
+ }
22439
+ initAnimation() {
22440
+ var _a;
22441
+ const animationParams = vchart.getGroupAnimationParams(this);
22442
+ if (this._candlestickMark) {
22443
+ const newDefaultConfig = this._initAnimationSpec((_a = vchart.Factory.getAnimationInKey('scaleInOut')) === null || _a === void 0 ? void 0 : _a());
22444
+ const newConfig = this._initAnimationSpec(vchart.userAnimationConfig(CANDLESTICK_SERIES_TYPE, this._spec, this._markAttributeContext));
22445
+ this._candlestickMark.setAnimationConfig(vchart.animationConfig(newDefaultConfig, newConfig, animationParams));
22446
+ }
22447
+ }
22448
+ initTooltip() {
22449
+ this._tooltipHelper = new CandlestickSeriesTooltipHelper(this);
22450
+ this._candlestickMark && this._tooltipHelper.activeTriggerSet.mark.add(this._candlestickMark);
22451
+ }
22452
+ _buildMergedStyles(baseStyle, risingStyle, fallingStyle, dojiStyle) {
22453
+ this._mergedStyles.rising = merge({}, baseStyle, risingStyle);
22454
+ this._mergedStyles.falling = merge({}, baseStyle, fallingStyle);
22455
+ this._mergedStyles.doji = merge({}, baseStyle, dojiStyle);
22456
+ }
22457
+ mergeStyle(datum) {
22458
+ const open = this.getDatumPositionValues(datum, this._openField)[0];
22459
+ const close = this.getDatumPositionValues(datum, this._closeField)[0];
22460
+ if (open < close) {
22461
+ return this._mergedStyles.rising;
22462
+ }
22463
+ else if (open > close) {
22464
+ return this._mergedStyles.falling;
22465
+ }
22466
+ else {
22467
+ return this._mergedStyles.doji;
22468
+ }
22469
+ }
22470
+ _getMarkWidth() {
22471
+ if (this._autoBoxWidth) {
22472
+ return this._autoBoxWidth;
22473
+ }
22474
+ const bandAxisHelper = this._xAxisHelper;
22475
+ const xField = this._fieldX;
22476
+ const innerBandWidth = bandAxisHelper.getBandwidth(xField.length - 1);
22477
+ const autoBoxWidth = innerBandWidth / xField.length;
22478
+ this._autoBoxWidth = autoBoxWidth;
22479
+ return this._autoBoxWidth;
22480
+ }
22481
+ onLayoutEnd() {
22482
+ super.onLayoutEnd();
22483
+ this._autoBoxWidth = null;
22484
+ }
22485
+ getActiveMarks() {
22486
+ return [this._candlestickMark];
22487
+ }
22488
+ }
22489
+ CandlestickSeries.type = CANDLESTICK_SERIES_TYPE;
22490
+ CandlestickSeries.builtInTheme = { candlestick };
22491
+ CandlestickSeries.mark = CandlestickSeriesMark;
22492
+ const registerCandlestickSeries = () => {
22493
+ registerCandlestickMark();
22494
+ vchart.registerSymbolMark();
22495
+ vchart.registerScaleInOutAnimation();
22496
+ vchart.registerCartesianBandAxis();
22497
+ vchart.registerCartesianLinearAxis();
22498
+ registerCandlestickScaleAnimation();
22499
+ vchart.Factory.registerSeries(CandlestickSeries.type, CandlestickSeries);
22500
+ };
22501
+
22502
+ class CandlestickChart extends vchart.BaseChart {
22503
+ _setModelOption() {
22504
+ this._modelOption.getDimensionInfo = vchart.getCartesianDimensionInfo;
22505
+ this._modelOption.getDimensionInfoByValue = vchart.getDimensionInfoByValue;
22506
+ this._modelOption.getRectByDimensionData = vchart.getCartesianCrosshairRect;
22507
+ }
22508
+ }
22509
+ CandlestickChart.type = CANDLESTICK_CHART_TYPE;
22510
+ CandlestickChart.seriesType = CANDLESTICK_SERIES_TYPE;
22511
+ CandlestickChart.transformerConstructor = CandlestickChartSpecTransformer;
22512
+ const registerCandlestickChart = () => {
22513
+ vchart.registerDimensionTooltipProcessor();
22514
+ vchart.registerMarkTooltipProcessor();
22515
+ vchart.registerDimensionEvents();
22516
+ vchart.registerDimensionHover();
22517
+ registerCandlestickSeries();
22518
+ vchart.Factory.registerChart(CandlestickChart.type, CandlestickChart);
22519
+ };
22520
+
21977
22521
  const GROUP_ATTRIBUTES = ["x", "y", "dx", "dy", "scaleX", "scaleY", "angle", "anchor", "postMatrix", "visible", "clip", "pickable", "childrenPickable", "zIndex", "cursor"];
21978
22522
  class AbstractComponent extends Group {
21979
22523
  constructor(attributes, options) {
@@ -25044,6 +25588,8 @@
25044
25588
  exports.Bar3dSeries = Bar3dSeries;
25045
25589
  exports.Bar3dSeriesSpecTransformer = Bar3dSeriesSpecTransformer;
25046
25590
  exports.BarLinkComponent = BarLinkComponent;
25591
+ exports.CandlestickChart = CandlestickChart;
25592
+ exports.CandlestickChartSpecTransformer = CandlestickChartSpecTransformer;
25047
25593
  exports.ConversionFunnelChart = ConversionFunnelChart;
25048
25594
  exports.ConversionFunnelSeries = ConversionFunnelSeries;
25049
25595
  exports.DefaultBandWidth = DefaultBandWidth;
@@ -25088,6 +25634,7 @@
25088
25634
  exports.registerBar3dChart = registerBar3dChart;
25089
25635
  exports.registerBar3dSeries = registerBar3dSeries;
25090
25636
  exports.registerBarLink = registerBarLink;
25637
+ exports.registerCandlestickChart = registerCandlestickChart;
25091
25638
  exports.registerConversionFunnelChart = registerConversionFunnelChart;
25092
25639
  exports.registerFunnel3dChart = registerFunnel3dChart;
25093
25640
  exports.registerFunnel3dSeries = registerFunnel3dSeries;