@visactor/vchart-extension 2.0.3 → 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/funnel-3d/constant.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/funnel-3d/constant.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 +6 -6
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/candlestick/candlestick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EACL,SAAS,EACT,OAAO,EACP,4BAA4B,EAC5B,iCAAiC,EACjC,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACpF,MAAM,OAAO,gBAA0E,SAAQ,SAAY;IAI/F,eAAe;QACvB,IAAI,CAAC,YAAY,CAAC,gBAAgB,GAAG,yBAAyB,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;QACpE,IAAI,CAAC,YAAY,CAAC,sBAAsB,GAAG,yBAAyB,CAAC;IACvE,CAAC;;AAPe,qBAAI,GAAW,sBAAsB,CAAC;AACtC,2BAAU,GAAW,uBAAuB,CAAC;AAC7C,uCAAsB,GAAG,+BAA+B,CAAC;AAQ3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,iCAAiC,EAAE,CAAC;IACpC,4BAA4B,EAAE,CAAC;IAC/B,uBAAuB,EAAE,CAAC;IAC1B,sBAAsB,EAAE,CAAC;IACzB,yBAAyB,EAAE,CAAC;IAC5B,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AACjE,CAAC,CAAC","file":"candlestick.js","sourcesContent":["import { CandlestickChartSpecTransformer } from './candlestick-transformer';\nimport { ICandlestickChartSpec } from './interface';\nimport { registerCandlestickSeries } from './series/candlestick';\nimport {\n BaseChart,\n Factory,\n registerMarkTooltipProcessor,\n registerDimensionTooltipProcessor,\n registerDimensionEvents,\n registerDimensionHover,\n getCartesianDimensionInfo,\n getDimensionInfoByValue,\n getCartesianCrosshairRect\n} from '@visactor/vchart';\nimport { CANDLESTICK_CHART_TYPE, CANDLESTICK_SERIES_TYPE } from './series/constant';\nexport class CandlestickChart<T extends ICandlestickChartSpec = ICandlestickChartSpec> extends BaseChart<T> {\n static readonly type: string = CANDLESTICK_CHART_TYPE;\n static readonly seriesType: string = CANDLESTICK_SERIES_TYPE;\n static readonly transformerConstructor = CandlestickChartSpecTransformer; // CandlestickChartSpecTransformer;\n protected _setModelOption() {\n this._modelOption.getDimensionInfo = getCartesianDimensionInfo;\n this._modelOption.getDimensionInfoByValue = getDimensionInfoByValue;\n this._modelOption.getRectByDimensionData = getCartesianCrosshairRect;\n }\n}\n\nexport const registerCandlestickChart = () => {\n registerDimensionTooltipProcessor();\n registerMarkTooltipProcessor();\n registerDimensionEvents();\n registerDimensionHover();\n registerCandlestickSeries();\n Factory.registerChart(CandlestickChart.type, CandlestickChart);\n};\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './candlestick';
2
+ export * from './interface';
3
+ export * from './candlestick-transformer';
@@ -0,0 +1,6 @@
1
+ export * from "./candlestick";
2
+
3
+ export * from "./interface";
4
+
5
+ export * from "./candlestick-transformer";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/candlestick/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC","file":"index.js","sourcesContent":["export * from './candlestick';\nexport * from './interface';\nexport * from './candlestick-transformer';\n"]}
@@ -0,0 +1,6 @@
1
+ import type { IChartExtendsSeriesSpec, ICartesianChartSpec } from '@visactor/vchart';
2
+ import type { ICandlestickSeriesSpec } from './series/interface';
3
+ export interface ICandlestickChartSpec extends ICartesianChartSpec, IChartExtendsSeriesSpec<ICandlestickSeriesSpec> {
4
+ type: 'candlestick';
5
+ series?: ICandlestickSeriesSpec[];
6
+ }
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/candlestick/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { IChartExtendsSeriesSpec, ICartesianChartSpec } from '@visactor/vchart';\nimport type { ICandlestickSeriesSpec } from './series/interface';\n\nexport interface ICandlestickChartSpec extends ICartesianChartSpec, IChartExtendsSeriesSpec<ICandlestickSeriesSpec> {\n type: 'candlestick';\n /** 系列配置 */\n series?: ICandlestickSeriesSpec[];\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { GlyphMark, IMarkRaw, IMarkStyle } from '@visactor/vchart';
2
+ import type { ICandlestickMarkSpec } from './interface';
3
+ export type ICandlestickMark = IMarkRaw<ICandlestickMarkSpec>;
4
+ export declare const CANDLESTICK_MARK_TYPE = "candlestick";
5
+ export declare class CandlestickMark extends GlyphMark<ICandlestickMarkSpec> implements ICandlestickMark {
6
+ static readonly type = "candlestick";
7
+ readonly type = "candlestick";
8
+ setGlyphConfig(cfg: any): void;
9
+ protected _getDefaultStyle(): IMarkStyle<ICandlestickMarkSpec>;
10
+ }
11
+ export declare const registerCandlestickMark: () => void;
@@ -0,0 +1,58 @@
1
+ import { registerLine, registerRect } from "@visactor/vrender-kits";
2
+
3
+ import { GlyphMark, registerGlyphMark } from "@visactor/vchart";
4
+
5
+ import { createLine, createRect } from "@visactor/vrender-core";
6
+
7
+ import { Factory } from "@visactor/vchart";
8
+
9
+ export const CANDLESTICK_MARK_TYPE = "candlestick";
10
+
11
+ export class CandlestickMark extends GlyphMark {
12
+ constructor() {
13
+ super(...arguments), this.type = CandlestickMark.type;
14
+ }
15
+ setGlyphConfig(cfg) {
16
+ super.setGlyphConfig(cfg), this._subMarks = {
17
+ line: {
18
+ type: "line",
19
+ defaultAttributes: {
20
+ x: 0,
21
+ y: 0
22
+ }
23
+ },
24
+ box: {
25
+ type: "rect"
26
+ }
27
+ }, this._positionChannels = [ "x", "boxWidth", "open", "close", "high", "low" ],
28
+ this._channelEncoder = null, this._positionEncoder = (glyphAttrs, datum, g) => {
29
+ const {x: x = g.attribute.x, boxWidth: boxWidth = g.attribute.boxWidth, open: open = g.attribute.open, close: close = g.attribute.close, low: low = g.attribute.low, high: high = g.attribute.high} = glyphAttrs, attributes = {};
30
+ return attributes.line = {
31
+ points: [ {
32
+ x: x,
33
+ y: low
34
+ }, {
35
+ x: x,
36
+ y: high
37
+ } ]
38
+ }, attributes.box = {
39
+ x: x - boxWidth / 2,
40
+ x1: x + boxWidth / 2,
41
+ y: Math.min(open, close),
42
+ y1: Math.max(open, close),
43
+ drawStrokeWhenZeroWH: !0
44
+ }, attributes;
45
+ };
46
+ }
47
+ _getDefaultStyle() {
48
+ return Object.assign({}, super._getDefaultStyle());
49
+ }
50
+ }
51
+
52
+ CandlestickMark.type = "candlestick";
53
+
54
+ export const registerCandlestickMark = () => {
55
+ registerGlyphMark(), registerLine(), registerRect(), Factory.registerGraphicComponent("line", (attrs => createLine(attrs))),
56
+ Factory.registerGraphicComponent("rect", (attrs => createRect(attrs))), Factory.registerMark(CandlestickMark.type, CandlestickMark);
57
+ };
58
+ //# sourceMappingURL=candlestick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/candlestick/mark/candlestick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAwB,MAAM,kBAAkB,CAAC;AACtF,OAAO,EACL,UAAU,EACV,UAAU,EAIX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAS,MAAM,kBAAkB,CAAC;AAIlD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAEnD,MAAM,OAAO,eAAgB,SAAQ,SAA+B;IAApE;;QAEW,SAAI,GAAG,eAAe,CAAC,IAAI,CAAC;IAkDvC,CAAC;IAhDC,cAAc,CAAC,GAAQ;QACrB,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG;YACf,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,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I;aAC3B,CAAC;YACF,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC;IAES,gBAAgB;QACxB,MAAM,YAAY,qBACb,KAAK,CAAC,gBAAgB,EAAE,CAC5B,CAAC;QACF,OAAO,YAAY,CAAC;IACtB,CAAC;;AAlDe,oBAAI,GAAG,qBAAqB,CAAC;AAqD/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,iBAAiB,EAAE,CAAC;IACpB,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,OAAO,CAAC,wBAAwB,CAAC,MAAM,EAAE,CAAC,KAA4B,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9F,OAAO,CAAC,wBAAwB,CAAC,MAAM,EAAE,CAAC,KAA4B,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9F,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC9D,CAAC,CAAC","file":"candlestick.js","sourcesContent":["import { registerLine, registerRect } from '@visactor/vrender-kits';\nimport { GlyphMark, registerGlyphMark, IMarkRaw, IMarkStyle } from '@visactor/vchart';\nimport {\n createLine,\n createRect,\n type IGlyph,\n type ILineGraphicAttribute,\n IRectGraphicAttribute\n} from '@visactor/vrender-core';\nimport { Factory, Datum } from '@visactor/vchart';\nimport type { ICandlestickMarkSpec } from './interface';\n\nexport type ICandlestickMark = IMarkRaw<ICandlestickMarkSpec>;\nexport const CANDLESTICK_MARK_TYPE = 'candlestick';\n\nexport class CandlestickMark extends GlyphMark<ICandlestickMarkSpec> implements ICandlestickMark {\n static readonly type = CANDLESTICK_MARK_TYPE;\n readonly type = CandlestickMark.type;\n\n setGlyphConfig(cfg: any): void {\n super.setGlyphConfig(cfg);\n this._subMarks = {\n line: { type: 'line', defaultAttributes: { x: 0, y: 0 } },\n box: { type: 'rect' }\n };\n this._positionChannels = ['x', 'boxWidth', 'open', 'close', 'high', 'low'];\n this._channelEncoder = null;\n this._positionEncoder = (glyphAttrs: any, datum: Datum, g: IGlyph) => {\n const {\n x = g.attribute.x,\n boxWidth = (g.attribute as any).boxWidth,\n open = (g.attribute as any).open,\n close = (g.attribute as any).close,\n low = (g.attribute as any).low,\n high = (g.attribute as any).high\n } = glyphAttrs;\n const attributes: any = {};\n attributes.line = {\n points: [\n {\n x: x,\n y: low\n },\n {\n x: x,\n y: high\n }\n ]\n };\n attributes.box = {\n x: x - boxWidth / 2,\n x1: x + boxWidth / 2,\n y: Math.min(open, close),\n y1: Math.max(open, close),\n // 开盘收盘相同时绘制水平线\n drawStrokeWhenZeroWH: true\n };\n return attributes;\n };\n }\n\n protected _getDefaultStyle() {\n const defaultStyle: IMarkStyle<ICandlestickMarkSpec> = {\n ...super._getDefaultStyle()\n };\n return defaultStyle;\n }\n}\n\nexport const registerCandlestickMark = () => {\n registerGlyphMark();\n registerLine();\n registerRect();\n Factory.registerGraphicComponent('line', (attrs: ILineGraphicAttribute) => createLine(attrs));\n Factory.registerGraphicComponent('rect', (attrs: IRectGraphicAttribute) => createRect(attrs));\n Factory.registerMark(CandlestickMark.type, CandlestickMark);\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import type { Datum, ICommonSpec } from '@visactor/vchart';
2
+ export interface ICandlestickMarkSpec extends ICommonSpec {
3
+ boxWidth?: number;
4
+ boxFill?: string | ((datum: Datum) => string);
5
+ low?: (datum: Datum) => number;
6
+ close?: (datum: Datum) => number;
7
+ open?: (datum: Datum) => number;
8
+ high?: (datum: Datum) => number;
9
+ }
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/candlestick/mark/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { Datum, ICommonSpec } from '@visactor/vchart';\n\nexport interface ICandlestickMarkSpec extends ICommonSpec {\n /**\n * box宽度\n */\n boxWidth?: number;\n /**\n * 盒子填充颜色,为空则不填充\n */\n boxFill?: string | ((datum: Datum) => string);\n /**\n * 最低价\n */\n low?: (datum: Datum) => number;\n /**\n * 收盘价\n */\n close?: (datum: Datum) => number;\n /**\n * 开盘价\n */\n open?: (datum: Datum) => number;\n /**\n * 最高价\n */\n high?: (datum: Datum) => number;\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import type { EasingType } from '@visactor/vrender-core';
2
+ import { ACustomAnimate } from '@visactor/vrender-animate';
3
+ export interface ICandlestickScaleAnimationOptions {
4
+ center?: number;
5
+ }
6
+ export declare class CandlestickScaleIn extends ACustomAnimate<Record<string, number>> {
7
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: ICandlestickScaleAnimationOptions);
8
+ onBind(): void;
9
+ computeAttribute(): {
10
+ from?: {
11
+ [channel: string]: any;
12
+ };
13
+ to?: {
14
+ [channel: string]: any;
15
+ };
16
+ };
17
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
18
+ }
19
+ export declare class CandlestickScaleOut extends ACustomAnimate<Record<string, number>> {
20
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: ICandlestickScaleAnimationOptions);
21
+ onBind(): void;
22
+ computeAttribute(): {
23
+ from?: {
24
+ [channel: string]: any;
25
+ };
26
+ to?: {
27
+ [channel: string]: any;
28
+ };
29
+ };
30
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
31
+ }
32
+ export declare const registerCandlestickScaleAnimation: () => void;
@@ -0,0 +1,124 @@
1
+ import { isValidNumber } from "@visactor/vutils";
2
+
3
+ import { ACustomAnimate, AnimateExecutor } from "@visactor/vrender-animate";
4
+
5
+ const scaleIn = () => graphic => {
6
+ const finalAttribute = graphic.getFinalAttribute(), {x: x, y: y, open: open, high: high, low: low, close: close} = finalAttribute, animateAttributes = {
7
+ from: {
8
+ x: x,
9
+ y: y
10
+ },
11
+ to: {
12
+ x: x,
13
+ y: y
14
+ }
15
+ };
16
+ return isValidNumber(open) && isValidNumber(close) && (open > close ? (animateAttributes.from.open = low,
17
+ animateAttributes.to.open = open, animateAttributes.from.close = low, animateAttributes.to.close = close,
18
+ isValidNumber(high) && (animateAttributes.from.high = low, animateAttributes.to.high = high)) : (animateAttributes.from.open = high,
19
+ animateAttributes.to.open = open, animateAttributes.from.close = high, animateAttributes.to.close = close,
20
+ isValidNumber(low) && (animateAttributes.from.low = high, animateAttributes.to.low = low))),
21
+ animateAttributes;
22
+ }, scaleOut = () => graphic => {
23
+ const finalAttribute = graphic.getFinalAttribute(), {x: x, y: y, open: open, high: high, low: low, close: close} = finalAttribute, animateAttributes = {
24
+ from: {
25
+ x: x,
26
+ y: y
27
+ },
28
+ to: {
29
+ x: x,
30
+ y: y
31
+ }
32
+ };
33
+ return isValidNumber(open) && isValidNumber(close) && (open > close ? (animateAttributes.from.open = open,
34
+ animateAttributes.to.open = low, animateAttributes.from.close = close, animateAttributes.to.close = low,
35
+ isValidNumber(high) && (animateAttributes.from.high = high, animateAttributes.to.high = low)) : (animateAttributes.from.open = open,
36
+ animateAttributes.to.open = high, animateAttributes.from.close = close, animateAttributes.to.close = high,
37
+ isValidNumber(low) && (animateAttributes.from.low = low, animateAttributes.to.low = high))),
38
+ animateAttributes;
39
+ };
40
+
41
+ export class CandlestickScaleIn extends ACustomAnimate {
42
+ constructor(from, to, duration, easing, params) {
43
+ super(from, to, duration, easing, params);
44
+ }
45
+ onBind() {
46
+ super.onBind();
47
+ const finalAttribute = this.target.getFinalAttribute();
48
+ finalAttribute && this.target.setAttributes(finalAttribute);
49
+ const {from: from, to: to} = this.computeAttribute();
50
+ this.propKeys = Object.keys(to).filter((key => null != to[key])), this.animate.reSyncProps(),
51
+ this.from = from, this.to = to, this.target.setAttributes(this.from);
52
+ }
53
+ computeAttribute() {
54
+ return (graphic => {
55
+ const finalAttribute = graphic.getFinalAttribute(), {x: x, y: y, open: open, high: high, low: low, close: close} = finalAttribute, animateAttributes = {
56
+ from: {
57
+ x: x,
58
+ y: y
59
+ },
60
+ to: {
61
+ x: x,
62
+ y: y
63
+ }
64
+ };
65
+ return isValidNumber(open) && isValidNumber(close) && (open > close ? (animateAttributes.from.open = low,
66
+ animateAttributes.to.open = open, animateAttributes.from.close = low, animateAttributes.to.close = close,
67
+ isValidNumber(high) && (animateAttributes.from.high = low, animateAttributes.to.high = high)) : (animateAttributes.from.open = high,
68
+ animateAttributes.to.open = open, animateAttributes.from.close = high, animateAttributes.to.close = close,
69
+ isValidNumber(low) && (animateAttributes.from.low = high, animateAttributes.to.low = low))),
70
+ animateAttributes;
71
+ })(this.target, this.params, this.params.options);
72
+ }
73
+ onUpdate(end, ratio, out) {
74
+ const attribute = this.target.attribute;
75
+ this.propKeys.forEach((key => {
76
+ attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
77
+ })), this.target.setAttributes(attribute);
78
+ }
79
+ }
80
+
81
+ export class CandlestickScaleOut extends ACustomAnimate {
82
+ constructor(from, to, duration, easing, params) {
83
+ super(from, to, duration, easing, params);
84
+ }
85
+ onBind() {
86
+ var _a;
87
+ (null === (_a = this.params) || void 0 === _a ? void 0 : _a.diffAttrs) && this.target.setAttributes(this.params.diffAttrs);
88
+ const {from: from, to: to} = this.computeAttribute();
89
+ this.propKeys = Object.keys(to).filter((key => null != to[key])), this.animate.reSyncProps(),
90
+ this.from = from, this.to = to, this.target.setAttributes(this.from);
91
+ }
92
+ computeAttribute() {
93
+ return (graphic => {
94
+ const finalAttribute = graphic.getFinalAttribute(), {x: x, y: y, open: open, high: high, low: low, close: close} = finalAttribute, animateAttributes = {
95
+ from: {
96
+ x: x,
97
+ y: y
98
+ },
99
+ to: {
100
+ x: x,
101
+ y: y
102
+ }
103
+ };
104
+ return isValidNumber(open) && isValidNumber(close) && (open > close ? (animateAttributes.from.open = open,
105
+ animateAttributes.to.open = low, animateAttributes.from.close = close, animateAttributes.to.close = low,
106
+ isValidNumber(high) && (animateAttributes.from.high = high, animateAttributes.to.high = low)) : (animateAttributes.from.open = open,
107
+ animateAttributes.to.open = high, animateAttributes.from.close = close, animateAttributes.to.close = high,
108
+ isValidNumber(low) && (animateAttributes.from.low = low, animateAttributes.to.low = high))),
109
+ animateAttributes;
110
+ })(this.target, this.params, this.params.options);
111
+ }
112
+ onUpdate(end, ratio, out) {
113
+ const attribute = this.target.attribute;
114
+ this.propKeys.forEach((key => {
115
+ attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
116
+ })), this.target.setAttributes(attribute);
117
+ }
118
+ }
119
+
120
+ export const registerCandlestickScaleAnimation = () => {
121
+ AnimateExecutor.registerBuiltInAnimate("candlestickScaleIn", CandlestickScaleIn),
122
+ AnimateExecutor.registerBuiltInAnimate("candlestickScaleOut", CandlestickScaleOut);
123
+ };
124
+ //# sourceMappingURL=animation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/candlestick/series/animation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAY5E,MAAM,OAAO,GAAG,GAAkB,EAAE;IAClC,OAAO,CAAC,OAAe,EAAE,EAAE;QACzB,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;QACnD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC;QACxD,MAAM,iBAAiB,GAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAChE,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE;YAC/C,IAAI,IAAI,GAAG,KAAK,EAAE;gBAChB,iBAAiB,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;gBAClC,iBAAiB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AAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC5E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,eAAe,CAAC,sBAAsB,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;IACjF,eAAe,CAAC,sBAAsB,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;AACrF,CAAC,CAAC","file":"animation.js","sourcesContent":["import type { EasingType } from '@visactor/vrender-core';\nimport type { IGlyph } from '@visactor/vrender-core';\nimport type { IAnimationParameters } from '@visactor/vchart';\nimport { isValidNumber } from '@visactor/vutils';\nimport { ACustomAnimate, AnimateExecutor } from '@visactor/vrender-animate';\n\nexport interface ICandlestickScaleAnimationOptions {\n center?: number;\n}\n\ntype TypeAnimation = (\n graphic: IGlyph,\n options: ICandlestickScaleAnimationOptions,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nconst scaleIn = (): TypeAnimation => {\n return (graphic: IGlyph) => {\n const finalAttribute = graphic.getFinalAttribute();\n const { x, y, open, high, low, close } = finalAttribute;\n const animateAttributes: any = { from: { x, y }, to: { x, y } };\n if (isValidNumber(open) && isValidNumber(close)) {\n if (open > close) {\n animateAttributes.from.open = low;\n animateAttributes.to.open = open;\n animateAttributes.from.close = low;\n animateAttributes.to.close = close;\n if (isValidNumber(high)) {\n animateAttributes.from.high = low;\n animateAttributes.to.high = high;\n }\n } else {\n animateAttributes.from.open = high;\n animateAttributes.to.open = open;\n animateAttributes.from.close = high;\n animateAttributes.to.close = close;\n if (isValidNumber(low)) {\n animateAttributes.from.low = high;\n animateAttributes.to.low = low;\n }\n }\n }\n return animateAttributes;\n };\n};\n\nconst scaleOut = (): TypeAnimation => {\n return (graphic: IGlyph) => {\n const finalAttribute = graphic.getFinalAttribute();\n const { x, y, open, high, low, close } = finalAttribute;\n\n const animateAttributes: any = { from: { x, y }, to: { x, y } };\n if (isValidNumber(open) && isValidNumber(close)) {\n if (open > close) {\n animateAttributes.from.open = open;\n animateAttributes.to.open = low;\n animateAttributes.from.close = close;\n animateAttributes.to.close = low;\n if (isValidNumber(high)) {\n animateAttributes.from.high = high;\n animateAttributes.to.high = low;\n }\n } else {\n animateAttributes.from.open = open;\n animateAttributes.to.open = high;\n animateAttributes.from.close = close;\n animateAttributes.to.close = high;\n if (isValidNumber(low)) {\n animateAttributes.from.low = low;\n animateAttributes.to.low = high;\n }\n }\n }\n return animateAttributes;\n };\n};\n\nexport class CandlestickScaleIn extends ACustomAnimate<Record<string, number>> {\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: ICandlestickScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n const { from, to } = this.computeAttribute();\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.animate.reSyncProps();\n this.from = from;\n this.to = to;\n this.target.setAttributes(this.from);\n }\n\n computeAttribute() {\n const attr = scaleIn()(this.target as IGlyph, this.params, this.params.options);\n return attr;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(attribute);\n }\n}\n\nexport class CandlestickScaleOut extends ACustomAnimate<Record<string, number>> {\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: ICandlestickScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n if (this.params?.diffAttrs) {\n this.target.setAttributes(this.params.diffAttrs);\n }\n const { from, to } = this.computeAttribute();\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.animate.reSyncProps();\n this.from = from;\n this.to = to;\n this.target.setAttributes(this.from);\n }\n\n computeAttribute() {\n const attr = scaleOut()(this.target as IGlyph, this.params, this.params.options);\n return attr;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(attribute);\n }\n}\n\nexport const registerCandlestickScaleAnimation = () => {\n AnimateExecutor.registerBuiltInAnimate('candlestickScaleIn', CandlestickScaleIn);\n AnimateExecutor.registerBuiltInAnimate('candlestickScaleOut', CandlestickScaleOut);\n};\n"]}
@@ -0,0 +1,105 @@
1
+ import { CartesianSeries, IMark, Datum, IModelInitOption } from '@visactor/vchart';
2
+ import type { ICandlestickSeriesSpec } from './interface';
3
+ export declare const DEFAULT_STROKE_COLOR = "#000";
4
+ export declare class CandlestickSeries<T extends ICandlestickSeriesSpec = ICandlestickSeriesSpec> extends CartesianSeries<T> {
5
+ static readonly type: string;
6
+ type: string;
7
+ static readonly builtInTheme: {
8
+ candlestick: import("./interface").ICandlestickSeriesTheme;
9
+ };
10
+ static readonly mark: {
11
+ candlestick: {
12
+ name: import("./constant").CandlestickMarkNameEnum;
13
+ type: string;
14
+ };
15
+ label?: import("@visactor/vchart").ISeriesMarkInfo;
16
+ point?: import("@visactor/vchart").ISeriesMarkInfo;
17
+ line?: import("@visactor/vchart").ISeriesMarkInfo;
18
+ area?: import("@visactor/vchart").ISeriesMarkInfo;
19
+ bar?: import("@visactor/vchart").ISeriesMarkInfo;
20
+ boxPlot?: import("@visactor/vchart").ISeriesMarkInfo;
21
+ outlier?: import("@visactor/vchart").ISeriesMarkInfo;
22
+ circlePacking?: import("@visactor/vchart").ISeriesMarkInfo;
23
+ group?: import("@visactor/vchart").ISeriesMarkInfo;
24
+ gridBackground?: import("@visactor/vchart").ISeriesMarkInfo;
25
+ grid?: import("@visactor/vchart").ISeriesMarkInfo;
26
+ dot?: import("@visactor/vchart").ISeriesMarkInfo;
27
+ title?: import("@visactor/vchart").ISeriesMarkInfo;
28
+ subTitle?: import("@visactor/vchart").ISeriesMarkInfo;
29
+ symbol?: import("@visactor/vchart").ISeriesMarkInfo;
30
+ funnel?: import("@visactor/vchart").ISeriesMarkInfo;
31
+ transform?: import("@visactor/vchart").ISeriesMarkInfo;
32
+ transformLabel?: import("@visactor/vchart").ISeriesMarkInfo;
33
+ outerLabel?: import("@visactor/vchart").ISeriesMarkInfo;
34
+ outerLabelLine?: import("@visactor/vchart").ISeriesMarkInfo;
35
+ pin?: import("@visactor/vchart").ISeriesMarkInfo;
36
+ pinBackground?: import("@visactor/vchart").ISeriesMarkInfo;
37
+ pointer?: import("@visactor/vchart").ISeriesMarkInfo;
38
+ segment?: import("@visactor/vchart").ISeriesMarkInfo;
39
+ track?: import("@visactor/vchart").ISeriesMarkInfo;
40
+ cell?: import("@visactor/vchart").ISeriesMarkInfo;
41
+ cellBackground?: import("@visactor/vchart").ISeriesMarkInfo;
42
+ link?: import("@visactor/vchart").ISeriesMarkInfo;
43
+ arrow?: import("@visactor/vchart").ISeriesMarkInfo;
44
+ pie?: import("@visactor/vchart").ISeriesMarkInfo;
45
+ labelLine?: import("@visactor/vchart").ISeriesMarkInfo;
46
+ progress?: import("@visactor/vchart").ISeriesMarkInfo;
47
+ minLabel?: import("@visactor/vchart").ISeriesMarkInfo;
48
+ maxLabel?: import("@visactor/vchart").ISeriesMarkInfo;
49
+ rose?: import("@visactor/vchart").ISeriesMarkInfo;
50
+ node?: import("@visactor/vchart").ISeriesMarkInfo;
51
+ sunburst?: import("@visactor/vchart").ISeriesMarkInfo;
52
+ nonLeaf?: import("@visactor/vchart").ISeriesMarkInfo;
53
+ leaf?: import("@visactor/vchart").ISeriesMarkInfo;
54
+ nonLeafLabel?: import("@visactor/vchart").ISeriesMarkInfo;
55
+ leaderLine?: import("@visactor/vchart").ISeriesMarkInfo;
56
+ stackLabel?: import("@visactor/vchart").ISeriesMarkInfo;
57
+ word?: import("@visactor/vchart").ISeriesMarkInfo;
58
+ fillingWord?: import("@visactor/vchart").ISeriesMarkInfo;
59
+ wordMask?: import("@visactor/vchart").ISeriesMarkInfo;
60
+ nodePoint?: import("@visactor/vchart").ISeriesMarkInfo;
61
+ ripplePoint?: import("@visactor/vchart").ISeriesMarkInfo;
62
+ centerPoint?: import("@visactor/vchart").ISeriesMarkInfo;
63
+ centerLabel?: import("@visactor/vchart").ISeriesMarkInfo;
64
+ barBackground?: import("@visactor/vchart").ISeriesMarkInfo;
65
+ lineLabel?: import("@visactor/vchart").ISeriesMarkInfo;
66
+ areaLabel?: import("@visactor/vchart").ISeriesMarkInfo;
67
+ liquidGroup?: import("@visactor/vchart").ISeriesMarkInfo;
68
+ liquid?: import("@visactor/vchart").ISeriesMarkInfo;
69
+ liquidBackground?: import("@visactor/vchart").ISeriesMarkInfo;
70
+ liquidOutline?: import("@visactor/vchart").ISeriesMarkInfo;
71
+ circle?: import("@visactor/vchart").ISeriesMarkInfo;
72
+ overlap?: import("@visactor/vchart").ISeriesMarkInfo;
73
+ overlapLabel?: import("@visactor/vchart").ISeriesMarkInfo;
74
+ };
75
+ protected _openField: string;
76
+ getOpenField(): string;
77
+ protected _highField: string;
78
+ getHighField(): string;
79
+ protected _lowField: string;
80
+ getLowField(): string;
81
+ protected _closeField: string;
82
+ getCloseField(): string;
83
+ protected _boxWidth: number;
84
+ protected _boxFill: string | ((datum: Datum) => string);
85
+ getBoxFill(): string | ((datum: Datum) => string);
86
+ protected _strokeColor: string;
87
+ getStrokeColor(): string;
88
+ private _autoBoxWidth;
89
+ private _mergedStyles;
90
+ setAttrFromSpec(): void;
91
+ private _candlestickMark?;
92
+ initMark(): void;
93
+ initMarkStyle(): void;
94
+ initCandlestickMarkStyle(): void;
95
+ init(option: IModelInitOption): void;
96
+ private _initAnimationSpec;
97
+ initAnimation(): void;
98
+ protected initTooltip(): void;
99
+ private _buildMergedStyles;
100
+ protected mergeStyle(datum: Datum): any;
101
+ private _getMarkWidth;
102
+ onLayoutEnd(): void;
103
+ getActiveMarks(): IMark[];
104
+ }
105
+ export declare const registerCandlestickSeries: () => void;
@@ -0,0 +1,145 @@
1
+ import { registerCandlestickMark } from "../mark/candlestick";
2
+
3
+ import { registerSymbolMark, registerScaleInOutAnimation, registerCartesianBandAxis, registerCartesianLinearAxis, CartesianSeries, Factory, STATE_VALUE_ENUM, AttributeLevel, getGroupAnimationParams, animationConfig, userAnimationConfig } from "@visactor/vchart";
4
+
5
+ import { valueInScaleRange } from "@visactor/vchart";
6
+
7
+ import { merge } from "@visactor/vutils";
8
+
9
+ import { registerCandlestickScaleAnimation } from "./animation";
10
+
11
+ import { CANDLESTICK_SERIES_TYPE, CandlestickSeriesMark } from "./constant";
12
+
13
+ import { CandlestickSeriesTooltipHelper } from "./tooltip-helper";
14
+
15
+ import { candlestick } from "./theme";
16
+
17
+ export const DEFAULT_STROKE_COLOR = "#000";
18
+
19
+ export class CandlestickSeries extends CartesianSeries {
20
+ constructor() {
21
+ super(...arguments), this.type = CANDLESTICK_SERIES_TYPE, this._mergedStyles = {
22
+ rising: {},
23
+ falling: {},
24
+ doji: {}
25
+ };
26
+ }
27
+ getOpenField() {
28
+ return this._openField;
29
+ }
30
+ getHighField() {
31
+ return this._highField;
32
+ }
33
+ getLowField() {
34
+ return this._lowField;
35
+ }
36
+ getCloseField() {
37
+ return this._closeField;
38
+ }
39
+ getBoxFill() {
40
+ return this._boxFill;
41
+ }
42
+ getStrokeColor() {
43
+ return this._strokeColor;
44
+ }
45
+ setAttrFromSpec() {
46
+ var _a, _b, _c, _d, _e, _f, _g, _h;
47
+ super.setAttrFromSpec();
48
+ const spec = this._spec, CandlestickStyle = null !== (_b = null === (_a = spec.candlestick) || void 0 === _a ? void 0 : _a.style) && void 0 !== _b ? _b : {};
49
+ this._openField = spec.openField, this._highField = spec.highField, this._lowField = spec.lowField,
50
+ this._closeField = spec.closeField, this._boxWidth = CandlestickStyle.boxWidth,
51
+ this._boxFill = CandlestickStyle.boxFill, this._strokeColor = CandlestickStyle.strokeColor,
52
+ this._buildMergedStyles(CandlestickStyle, null !== (_d = null === (_c = spec.rising) || void 0 === _c ? void 0 : _c.style) && void 0 !== _d ? _d : {}, null !== (_f = null === (_e = spec.falling) || void 0 === _e ? void 0 : _e.style) && void 0 !== _f ? _f : {}, null !== (_h = null === (_g = spec.doji) || void 0 === _g ? void 0 : _g.style) && void 0 !== _h ? _h : {});
53
+ }
54
+ initMark() {
55
+ this._candlestickMark = this._createMark(CandlestickSeries.mark.candlestick, {
56
+ groupKey: this._seriesField,
57
+ isSeriesMark: !0
58
+ });
59
+ }
60
+ initMarkStyle() {
61
+ var _a;
62
+ const candlestickMark = this._candlestickMark;
63
+ if (candlestickMark) {
64
+ const CandlestickStyles = {
65
+ fill: datum => this.mergeStyle(datum).boxFill,
66
+ stroke: datum => this.mergeStyle(datum).stroke,
67
+ lineWidth: datum => this.mergeStyle(datum).lineWidth,
68
+ boxWidth: null !== (_a = this._boxWidth) && void 0 !== _a ? _a : this._getMarkWidth.bind(this),
69
+ x: this.dataToPositionX.bind(this)
70
+ };
71
+ candlestickMark.setGlyphConfig({}), this.setMarkStyle(candlestickMark, CandlestickStyles, STATE_VALUE_ENUM.STATE_NORMAL, AttributeLevel.Series);
72
+ }
73
+ }
74
+ initCandlestickMarkStyle() {
75
+ var _a;
76
+ const candlestickMark = this._candlestickMark, axisHelper = this._yAxisHelper;
77
+ if (candlestickMark && axisHelper) {
78
+ const {dataToPosition: dataToPosition} = axisHelper, scale = null === (_a = null == axisHelper ? void 0 : axisHelper.getScale) || void 0 === _a ? void 0 : _a.call(axisHelper, 0);
79
+ this.setMarkStyle(candlestickMark, {
80
+ open: datum => valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._openField), {
81
+ bandPosition: this._bandPosition
82
+ }), scale),
83
+ high: datum => valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._highField), {
84
+ bandPosition: this._bandPosition
85
+ }), scale),
86
+ low: datum => valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._lowField), {
87
+ bandPosition: this._bandPosition
88
+ }), scale),
89
+ close: datum => valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._closeField), {
90
+ bandPosition: this._bandPosition
91
+ }), scale)
92
+ }, STATE_VALUE_ENUM.STATE_NORMAL, AttributeLevel.Series);
93
+ }
94
+ }
95
+ init(option) {
96
+ super.init(option), this.initCandlestickMarkStyle();
97
+ }
98
+ _initAnimationSpec(config = {}) {
99
+ const newConfig = merge({}, config);
100
+ return [ "appear", "enter", "update", "exit", "disappear" ].forEach((state => {
101
+ newConfig[state] && "scaleIn" === newConfig[state].type ? newConfig[state].type = "candlestickScaleIn" : newConfig[state] && "scaleOut" === newConfig[state].type && (newConfig[state].type = "candlestickScaleOut");
102
+ })), newConfig;
103
+ }
104
+ initAnimation() {
105
+ var _a;
106
+ const animationParams = getGroupAnimationParams(this);
107
+ if (this._candlestickMark) {
108
+ const newDefaultConfig = this._initAnimationSpec(null === (_a = Factory.getAnimationInKey("scaleInOut")) || void 0 === _a ? void 0 : _a()), newConfig = this._initAnimationSpec(userAnimationConfig(CANDLESTICK_SERIES_TYPE, this._spec, this._markAttributeContext));
109
+ this._candlestickMark.setAnimationConfig(animationConfig(newDefaultConfig, newConfig, animationParams));
110
+ }
111
+ }
112
+ initTooltip() {
113
+ this._tooltipHelper = new CandlestickSeriesTooltipHelper(this), this._candlestickMark && this._tooltipHelper.activeTriggerSet.mark.add(this._candlestickMark);
114
+ }
115
+ _buildMergedStyles(baseStyle, risingStyle, fallingStyle, dojiStyle) {
116
+ this._mergedStyles.rising = merge({}, baseStyle, risingStyle), this._mergedStyles.falling = merge({}, baseStyle, fallingStyle),
117
+ this._mergedStyles.doji = merge({}, baseStyle, dojiStyle);
118
+ }
119
+ mergeStyle(datum) {
120
+ const open = this.getDatumPositionValues(datum, this._openField)[0], close = this.getDatumPositionValues(datum, this._closeField)[0];
121
+ return open < close ? this._mergedStyles.rising : open > close ? this._mergedStyles.falling : this._mergedStyles.doji;
122
+ }
123
+ _getMarkWidth() {
124
+ if (this._autoBoxWidth) return this._autoBoxWidth;
125
+ const bandAxisHelper = this._xAxisHelper, xField = this._fieldX, autoBoxWidth = bandAxisHelper.getBandwidth(xField.length - 1) / xField.length;
126
+ return this._autoBoxWidth = autoBoxWidth, this._autoBoxWidth;
127
+ }
128
+ onLayoutEnd() {
129
+ super.onLayoutEnd(), this._autoBoxWidth = null;
130
+ }
131
+ getActiveMarks() {
132
+ return [ this._candlestickMark ];
133
+ }
134
+ }
135
+
136
+ CandlestickSeries.type = CANDLESTICK_SERIES_TYPE, CandlestickSeries.builtInTheme = {
137
+ candlestick: candlestick
138
+ }, CandlestickSeries.mark = CandlestickSeriesMark;
139
+
140
+ export const registerCandlestickSeries = () => {
141
+ registerCandlestickMark(), registerSymbolMark(), registerScaleInOutAnimation(),
142
+ registerCartesianBandAxis(), registerCartesianLinearAxis(), registerCandlestickScaleAnimation(),
143
+ Factory.registerSeries(CandlestickSeries.type, CandlestickSeries);
144
+ };
145
+ //# sourceMappingURL=candlestick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/candlestick/series/candlestick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAoB,MAAM,qBAAqB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAC3B,eAAe,EAEf,OAAO,EACP,gBAAgB,EAChB,cAAc,EAGd,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa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estickMark, ICandlestickMark } from '../mark/candlestick';\nimport {\n registerSymbolMark,\n registerScaleInOutAnimation,\n registerCartesianBandAxis,\n registerCartesianLinearAxis,\n CartesianSeries,\n IMark,\n Factory,\n STATE_VALUE_ENUM,\n AttributeLevel,\n Datum,\n IModelInitOption,\n getGroupAnimationParams,\n animationConfig,\n userAnimationConfig\n} from '@visactor/vchart';\nimport { valueInScaleRange } from '@visactor/vchart';\nimport { IGlyphMark } from '@visactor/vchart';\nimport { merge } from '@visactor/vutils';\nimport type { ICandlestickSeriesSpec } from './interface';\nimport { registerCandlestickScaleAnimation } from './animation';\nimport { CANDLESTICK_SERIES_TYPE, CandlestickSeriesMark } from './constant';\nimport { CandlestickSeriesTooltipHelper } from './tooltip-helper';\nimport { candlestick } from './theme';\n\nexport const DEFAULT_STROKE_COLOR = '#000';\nexport class CandlestickSeries<T extends ICandlestickSeriesSpec = ICandlestickSeriesSpec> extends CartesianSeries<T> {\n static readonly type: string = CANDLESTICK_SERIES_TYPE;\n type = CANDLESTICK_SERIES_TYPE;\n\n static readonly builtInTheme = { candlestick };\n static readonly mark = CandlestickSeriesMark;\n protected _openField: string;\n getOpenField(): string {\n return this._openField;\n }\n protected _highField: string;\n getHighField(): string {\n return this._highField;\n }\n protected _lowField: string;\n getLowField(): string {\n return this._lowField;\n }\n protected _closeField: string;\n getCloseField(): string {\n return this._closeField;\n }\n protected _boxWidth: number;\n protected _boxFill: string | ((datum: Datum) => string);\n getBoxFill(): string | ((datum: Datum) => string) {\n return this._boxFill;\n }\n protected _strokeColor: string;\n getStrokeColor(): string {\n return this._strokeColor;\n }\n private _autoBoxWidth: number;\n private _mergedStyles: { rising: any; falling: any; doji: any } = {\n rising: {},\n falling: {},\n doji: {}\n };\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n const spec = this._spec;\n const CandlestickStyle: any = spec.candlestick?.style ?? {};\n this._openField = spec.openField;\n this._highField = spec.highField;\n this._lowField = spec.lowField;\n this._closeField = spec.closeField;\n this._boxWidth = CandlestickStyle.boxWidth;\n this._boxFill = CandlestickStyle.boxFill;\n this._strokeColor = CandlestickStyle.strokeColor;\n this._buildMergedStyles(\n CandlestickStyle,\n spec.rising?.style ?? {},\n spec.falling?.style ?? {},\n spec.doji?.style ?? {}\n );\n }\n\n private _candlestickMark?: ICandlestickMark;\n\n initMark(): void {\n this._candlestickMark = this._createMark(CandlestickSeries.mark.candlestick, {\n groupKey: this._seriesField,\n isSeriesMark: true\n }) as ICandlestickMark;\n }\n\n initMarkStyle(): void {\n const candlestickMark = this._candlestickMark;\n if (candlestickMark) {\n const CandlestickStyles = {\n fill: (datum: Datum) => {\n const boxFill = this.mergeStyle(datum).boxFill;\n return boxFill;\n },\n stroke: (datum: Datum) => {\n const strokeColor = this.mergeStyle(datum).stroke;\n return strokeColor;\n },\n lineWidth: (datum: Datum) => {\n const lineWidth = this.mergeStyle(datum).lineWidth;\n return lineWidth;\n },\n boxWidth: this._boxWidth ?? this._getMarkWidth.bind(this),\n x: this.dataToPositionX.bind(this)\n };\n (candlestickMark as IGlyphMark).setGlyphConfig({});\n this.setMarkStyle(candlestickMark, CandlestickStyles, STATE_VALUE_ENUM.STATE_NORMAL, AttributeLevel.Series);\n }\n }\n\n initCandlestickMarkStyle() {\n const candlestickMark = this._candlestickMark;\n const axisHelper = this._yAxisHelper;\n if (candlestickMark && axisHelper) {\n const { dataToPosition } = axisHelper;\n const scale = axisHelper?.getScale?.(0);\n this.setMarkStyle(\n candlestickMark,\n {\n open: (datum: Datum) =>\n valueInScaleRange(\n dataToPosition(this.getDatumPositionValues(datum, this._openField), {\n bandPosition: this._bandPosition\n }),\n scale\n ),\n high: (datum: Datum) =>\n valueInScaleRange(\n dataToPosition(this.getDatumPositionValues(datum, this._highField), {\n bandPosition: this._bandPosition\n }),\n scale\n ),\n low: (datum: Datum) =>\n valueInScaleRange(\n dataToPosition(this.getDatumPositionValues(datum, this._lowField), {\n bandPosition: this._bandPosition\n }),\n scale\n ),\n close: (datum: Datum) =>\n valueInScaleRange(\n dataToPosition(this.getDatumPositionValues(datum, this._closeField), {\n bandPosition: this._bandPosition\n }),\n scale\n )\n },\n STATE_VALUE_ENUM.STATE_NORMAL,\n AttributeLevel.Series\n );\n }\n }\n\n init(option: IModelInitOption): void {\n super.init(option);\n //init在axis初始化之后才被执行,此时axisHelper不为空\n this.initCandlestickMarkStyle();\n }\n\n private _initAnimationSpec(config: any = {}) {\n const newConfig = merge({}, config);\n ['appear', 'enter', 'update', 'exit', 'disappear'].forEach(state => {\n if (newConfig[state] && newConfig[state].type === 'scaleIn') {\n newConfig[state].type = 'candlestickScaleIn';\n } else if (newConfig[state] && newConfig[state].type === 'scaleOut') {\n newConfig[state].type = 'candlestickScaleOut';\n }\n });\n return newConfig;\n }\n\n initAnimation() {\n const animationParams = getGroupAnimationParams(this);\n\n if (this._candlestickMark) {\n const newDefaultConfig = this._initAnimationSpec(Factory.getAnimationInKey('scaleInOut')?.());\n const newConfig = this._initAnimationSpec(\n userAnimationConfig(CANDLESTICK_SERIES_TYPE, this._spec, this._markAttributeContext)\n );\n this._candlestickMark.setAnimationConfig(animationConfig(newDefaultConfig, newConfig, animationParams));\n }\n }\n\n protected initTooltip() {\n this._tooltipHelper = new CandlestickSeriesTooltipHelper(this);\n this._candlestickMark && this._tooltipHelper.activeTriggerSet.mark.add(this._candlestickMark);\n }\n\n private _buildMergedStyles(baseStyle: any, risingStyle: any, fallingStyle: any, dojiStyle: any) {\n this._mergedStyles.rising = merge({}, baseStyle, risingStyle);\n this._mergedStyles.falling = merge({}, baseStyle, fallingStyle);\n this._mergedStyles.doji = merge({}, baseStyle, dojiStyle);\n }\n\n protected mergeStyle(datum: Datum): any {\n const open = this.getDatumPositionValues(datum, this._openField)[0];\n const close = this.getDatumPositionValues(datum, this._closeField)[0];\n if (open < close) {\n return this._mergedStyles.rising;\n } else if (open > close) {\n return this._mergedStyles.falling;\n } else {\n return this._mergedStyles.doji;\n }\n }\n\n private _getMarkWidth() {\n if (this._autoBoxWidth) {\n return this._autoBoxWidth;\n }\n //获取自适应的图元宽度\n const bandAxisHelper = this._xAxisHelper;\n const xField = this._fieldX;\n\n const innerBandWidth = bandAxisHelper.getBandwidth(xField.length - 1);\n const autoBoxWidth = innerBandWidth / xField.length;\n this._autoBoxWidth = autoBoxWidth;\n\n return this._autoBoxWidth;\n }\n\n onLayoutEnd() {\n super.onLayoutEnd();\n this._autoBoxWidth = null;\n }\n\n getActiveMarks(): IMark[] {\n return [this._candlestickMark];\n }\n}\n\nexport const registerCandlestickSeries = () => {\n registerCandlestickMark();\n registerSymbolMark();\n registerScaleInOutAnimation();\n registerCartesianBandAxis();\n registerCartesianLinearAxis();\n registerCandlestickScaleAnimation();\n Factory.registerSeries(CandlestickSeries.type, CandlestickSeries);\n};\n"]}