@visactor/vchart-extension 2.0.4-alpha.0 → 2.0.4-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +533 -0
- package/build/index.min.js +2 -2
- package/cjs/charts/candlestick/candlestick-transformer.d.ts +6 -0
- package/cjs/charts/candlestick/candlestick-transformer.js +24 -0
- package/cjs/charts/candlestick/candlestick-transformer.js.map +1 -0
- package/cjs/charts/candlestick/candlestick.d.ts +10 -0
- package/cjs/charts/candlestick/candlestick.js +25 -0
- package/cjs/charts/candlestick/candlestick.js.map +1 -0
- package/cjs/charts/candlestick/index.d.ts +3 -0
- package/cjs/charts/candlestick/index.js +22 -0
- package/cjs/charts/candlestick/index.js.map +1 -0
- package/cjs/charts/candlestick/interface.d.ts +6 -0
- package/cjs/charts/candlestick/interface.js +6 -0
- package/cjs/charts/candlestick/interface.js.map +1 -0
- package/cjs/charts/candlestick/mark/candlestick.d.ts +11 -0
- package/cjs/charts/candlestick/mark/candlestick.js +62 -0
- package/cjs/charts/candlestick/mark/candlestick.js.map +1 -0
- package/cjs/charts/candlestick/mark/interface.d.ts +9 -0
- package/cjs/charts/candlestick/mark/interface.js +6 -0
- package/cjs/charts/candlestick/mark/interface.js.map +1 -0
- package/cjs/charts/candlestick/series/animation.d.ts +32 -0
- package/cjs/charts/candlestick/series/animation.js +132 -0
- package/cjs/charts/candlestick/series/animation.js.map +1 -0
- package/cjs/charts/candlestick/series/candlestick.d.ts +105 -0
- package/cjs/charts/candlestick/series/candlestick.js +143 -0
- package/cjs/charts/candlestick/series/candlestick.js.map +1 -0
- package/cjs/charts/candlestick/series/constant.d.ts +77 -0
- package/cjs/charts/candlestick/series/constant.js +26 -0
- package/cjs/charts/candlestick/series/constant.js.map +1 -0
- package/cjs/charts/candlestick/series/interface.d.ts +20 -0
- package/cjs/charts/candlestick/series/interface.js +6 -0
- package/cjs/charts/candlestick/series/interface.js.map +1 -0
- package/cjs/charts/candlestick/series/theme.d.ts +3 -0
- package/cjs/charts/candlestick/series/theme.js +34 -0
- package/cjs/charts/candlestick/series/theme.js.map +1 -0
- package/cjs/charts/candlestick/series/tooltip-helper.d.ts +9 -0
- package/cjs/charts/candlestick/series/tooltip-helper.js +70 -0
- package/cjs/charts/candlestick/series/tooltip-helper.js.map +1 -0
- package/cjs/charts/conversion-funnel/constants.js +2 -1
- package/cjs/charts/funnel-3d/theme.js +1 -2
- package/cjs/charts/image-cloud/image-cloud-transformer.js +2 -1
- package/cjs/charts/pictogram/element-highlight-by-graphic-name.js +1 -1
- package/cjs/charts/pictogram/element-select-by-graphic-name.js +1 -1
- package/cjs/charts/pictogram/index.js +1 -1
- package/cjs/charts/pictogram/interface.js +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -2
- package/cjs/index.js.map +1 -1
- package/esm/charts/candlestick/candlestick-transformer.d.ts +6 -0
- package/esm/charts/candlestick/candlestick-transformer.js +16 -0
- package/esm/charts/candlestick/candlestick-transformer.js.map +1 -0
- package/esm/charts/candlestick/candlestick.d.ts +10 -0
- package/esm/charts/candlestick/candlestick.js +22 -0
- package/esm/charts/candlestick/candlestick.js.map +1 -0
- package/esm/charts/candlestick/index.d.ts +3 -0
- package/esm/charts/candlestick/index.js +6 -0
- package/esm/charts/candlestick/index.js.map +1 -0
- package/esm/charts/candlestick/interface.d.ts +6 -0
- package/esm/charts/candlestick/interface.js +2 -0
- package/esm/charts/candlestick/interface.js.map +1 -0
- package/esm/charts/candlestick/mark/candlestick.d.ts +11 -0
- package/esm/charts/candlestick/mark/candlestick.js +58 -0
- package/esm/charts/candlestick/mark/candlestick.js.map +1 -0
- package/esm/charts/candlestick/mark/interface.d.ts +9 -0
- package/esm/charts/candlestick/mark/interface.js +2 -0
- package/esm/charts/candlestick/mark/interface.js.map +1 -0
- package/esm/charts/candlestick/series/animation.d.ts +32 -0
- package/esm/charts/candlestick/series/animation.js +124 -0
- package/esm/charts/candlestick/series/animation.js.map +1 -0
- package/esm/charts/candlestick/series/candlestick.d.ts +105 -0
- package/esm/charts/candlestick/series/candlestick.js +145 -0
- package/esm/charts/candlestick/series/candlestick.js.map +1 -0
- package/esm/charts/candlestick/series/constant.d.ts +77 -0
- package/esm/charts/candlestick/series/constant.js +27 -0
- package/esm/charts/candlestick/series/constant.js.map +1 -0
- package/esm/charts/candlestick/series/interface.d.ts +20 -0
- package/esm/charts/candlestick/series/interface.js +2 -0
- package/esm/charts/candlestick/series/interface.js.map +1 -0
- package/esm/charts/candlestick/series/theme.d.ts +3 -0
- package/esm/charts/candlestick/series/theme.js +52 -0
- package/esm/charts/candlestick/series/theme.js.map +1 -0
- package/esm/charts/candlestick/series/tooltip-helper.d.ts +9 -0
- package/esm/charts/candlestick/series/tooltip-helper.js +64 -0
- package/esm/charts/candlestick/series/tooltip-helper.js.map +1 -0
- package/esm/charts/conversion-funnel/constants.js +2 -1
- package/esm/charts/funnel-3d/theme.js +1 -2
- package/esm/charts/image-cloud/image-cloud-transformer.js +2 -1
- package/esm/charts/pictogram/element-highlight-by-graphic-name.js +1 -1
- package/esm/charts/pictogram/element-select-by-graphic-name.js +1 -1
- package/esm/charts/pictogram/index.js +1 -1
- package/esm/charts/pictogram/interface.js +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/package.json +4 -4
package/build/index.js
CHANGED
|
@@ -21974,6 +21974,536 @@
|
|
|
21974
21974
|
vchart.Factory.registerChart(ImageCloudChart.type, ImageCloudChart);
|
|
21975
21975
|
};
|
|
21976
21976
|
|
|
21977
|
+
class CandlestickChartSpecTransformer extends vchart.CartesianChartSpecTransformer {
|
|
21978
|
+
_getDefaultSeriesSpec(spec) {
|
|
21979
|
+
const dataFields = [spec.openField, spec.highField, spec.lowField, spec.closeField];
|
|
21980
|
+
const seriesSpec = super._getDefaultSeriesSpec(spec, [
|
|
21981
|
+
'candlestick',
|
|
21982
|
+
'openField',
|
|
21983
|
+
'highField',
|
|
21984
|
+
'lowField',
|
|
21985
|
+
'closeField',
|
|
21986
|
+
'rising',
|
|
21987
|
+
'falling',
|
|
21988
|
+
'doji'
|
|
21989
|
+
]);
|
|
21990
|
+
seriesSpec.yField = dataFields;
|
|
21991
|
+
return seriesSpec;
|
|
21992
|
+
}
|
|
21993
|
+
transformSpec(spec) {
|
|
21994
|
+
super.transformSpec(spec);
|
|
21995
|
+
if (!spec.axes) {
|
|
21996
|
+
spec.axes = [
|
|
21997
|
+
{
|
|
21998
|
+
orient: 'bottom'
|
|
21999
|
+
},
|
|
22000
|
+
{
|
|
22001
|
+
orient: 'left'
|
|
22002
|
+
}
|
|
22003
|
+
];
|
|
22004
|
+
}
|
|
22005
|
+
vchart.setDefaultCrosshairForCartesianChart(spec);
|
|
22006
|
+
}
|
|
22007
|
+
}
|
|
22008
|
+
|
|
22009
|
+
const CANDLESTICK_MARK_TYPE = 'candlestick';
|
|
22010
|
+
class CandlestickMark extends vchart.GlyphMark {
|
|
22011
|
+
constructor() {
|
|
22012
|
+
super(...arguments);
|
|
22013
|
+
this.type = CandlestickMark.type;
|
|
22014
|
+
}
|
|
22015
|
+
setGlyphConfig(cfg) {
|
|
22016
|
+
super.setGlyphConfig(cfg);
|
|
22017
|
+
this._subMarks = {
|
|
22018
|
+
line: { type: 'line', defaultAttributes: { x: 0, y: 0 } },
|
|
22019
|
+
box: { type: 'rect' }
|
|
22020
|
+
};
|
|
22021
|
+
this._positionChannels = ['x', 'boxWidth', 'open', 'close', 'high', 'low'];
|
|
22022
|
+
this._channelEncoder = null;
|
|
22023
|
+
this._positionEncoder = (glyphAttrs, datum, g) => {
|
|
22024
|
+
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;
|
|
22025
|
+
const attributes = {};
|
|
22026
|
+
attributes.line = {
|
|
22027
|
+
points: [
|
|
22028
|
+
{
|
|
22029
|
+
x: x,
|
|
22030
|
+
y: low
|
|
22031
|
+
},
|
|
22032
|
+
{
|
|
22033
|
+
x: x,
|
|
22034
|
+
y: high
|
|
22035
|
+
}
|
|
22036
|
+
]
|
|
22037
|
+
};
|
|
22038
|
+
attributes.box = {
|
|
22039
|
+
x: x - boxWidth / 2,
|
|
22040
|
+
x1: x + boxWidth / 2,
|
|
22041
|
+
y: Math.min(open, close),
|
|
22042
|
+
y1: Math.max(open, close),
|
|
22043
|
+
drawStrokeWhenZeroWH: true
|
|
22044
|
+
};
|
|
22045
|
+
return attributes;
|
|
22046
|
+
};
|
|
22047
|
+
}
|
|
22048
|
+
_getDefaultStyle() {
|
|
22049
|
+
const defaultStyle = Object.assign({}, super._getDefaultStyle());
|
|
22050
|
+
return defaultStyle;
|
|
22051
|
+
}
|
|
22052
|
+
}
|
|
22053
|
+
CandlestickMark.type = CANDLESTICK_MARK_TYPE;
|
|
22054
|
+
const registerCandlestickMark = () => {
|
|
22055
|
+
vchart.registerGlyphMark();
|
|
22056
|
+
registerLine();
|
|
22057
|
+
registerRect();
|
|
22058
|
+
vchart.Factory.registerGraphicComponent('line', (attrs) => createLine(attrs));
|
|
22059
|
+
vchart.Factory.registerGraphicComponent('rect', (attrs) => createRect(attrs));
|
|
22060
|
+
vchart.Factory.registerMark(CandlestickMark.type, CandlestickMark);
|
|
22061
|
+
};
|
|
22062
|
+
|
|
22063
|
+
const scaleIn = () => {
|
|
22064
|
+
return (graphic) => {
|
|
22065
|
+
const finalAttribute = graphic.getFinalAttribute();
|
|
22066
|
+
const { x, y, open, high, low, close } = finalAttribute;
|
|
22067
|
+
const animateAttributes = { from: { x, y }, to: { x, y } };
|
|
22068
|
+
if (isValidNumber$1(open) && isValidNumber$1(close)) {
|
|
22069
|
+
if (open > close) {
|
|
22070
|
+
animateAttributes.from.open = low;
|
|
22071
|
+
animateAttributes.to.open = open;
|
|
22072
|
+
animateAttributes.from.close = low;
|
|
22073
|
+
animateAttributes.to.close = close;
|
|
22074
|
+
if (isValidNumber$1(high)) {
|
|
22075
|
+
animateAttributes.from.high = low;
|
|
22076
|
+
animateAttributes.to.high = high;
|
|
22077
|
+
}
|
|
22078
|
+
}
|
|
22079
|
+
else {
|
|
22080
|
+
animateAttributes.from.open = high;
|
|
22081
|
+
animateAttributes.to.open = open;
|
|
22082
|
+
animateAttributes.from.close = high;
|
|
22083
|
+
animateAttributes.to.close = close;
|
|
22084
|
+
if (isValidNumber$1(low)) {
|
|
22085
|
+
animateAttributes.from.low = high;
|
|
22086
|
+
animateAttributes.to.low = low;
|
|
22087
|
+
}
|
|
22088
|
+
}
|
|
22089
|
+
}
|
|
22090
|
+
return animateAttributes;
|
|
22091
|
+
};
|
|
22092
|
+
};
|
|
22093
|
+
const scaleOut = () => {
|
|
22094
|
+
return (graphic) => {
|
|
22095
|
+
const finalAttribute = graphic.getFinalAttribute();
|
|
22096
|
+
const { x, y, open, high, low, close } = finalAttribute;
|
|
22097
|
+
const animateAttributes = { from: { x, y }, to: { x, y } };
|
|
22098
|
+
if (isValidNumber$1(open) && isValidNumber$1(close)) {
|
|
22099
|
+
if (open > close) {
|
|
22100
|
+
animateAttributes.from.open = open;
|
|
22101
|
+
animateAttributes.to.open = low;
|
|
22102
|
+
animateAttributes.from.close = close;
|
|
22103
|
+
animateAttributes.to.close = low;
|
|
22104
|
+
if (isValidNumber$1(high)) {
|
|
22105
|
+
animateAttributes.from.high = high;
|
|
22106
|
+
animateAttributes.to.high = low;
|
|
22107
|
+
}
|
|
22108
|
+
}
|
|
22109
|
+
else {
|
|
22110
|
+
animateAttributes.from.open = open;
|
|
22111
|
+
animateAttributes.to.open = high;
|
|
22112
|
+
animateAttributes.from.close = close;
|
|
22113
|
+
animateAttributes.to.close = high;
|
|
22114
|
+
if (isValidNumber$1(low)) {
|
|
22115
|
+
animateAttributes.from.low = low;
|
|
22116
|
+
animateAttributes.to.low = high;
|
|
22117
|
+
}
|
|
22118
|
+
}
|
|
22119
|
+
}
|
|
22120
|
+
return animateAttributes;
|
|
22121
|
+
};
|
|
22122
|
+
};
|
|
22123
|
+
class CandlestickScaleIn extends ACustomAnimate {
|
|
22124
|
+
constructor(from, to, duration, easing, params) {
|
|
22125
|
+
super(from, to, duration, easing, params);
|
|
22126
|
+
}
|
|
22127
|
+
onBind() {
|
|
22128
|
+
super.onBind();
|
|
22129
|
+
const finalAttribute = this.target.getFinalAttribute();
|
|
22130
|
+
if (finalAttribute) {
|
|
22131
|
+
this.target.setAttributes(finalAttribute);
|
|
22132
|
+
}
|
|
22133
|
+
const { from, to } = this.computeAttribute();
|
|
22134
|
+
this.propKeys = Object.keys(to).filter(key => to[key] != null);
|
|
22135
|
+
this.animate.reSyncProps();
|
|
22136
|
+
this.from = from;
|
|
22137
|
+
this.to = to;
|
|
22138
|
+
this.target.setAttributes(this.from);
|
|
22139
|
+
}
|
|
22140
|
+
computeAttribute() {
|
|
22141
|
+
const attr = scaleIn()(this.target, this.params, this.params.options);
|
|
22142
|
+
return attr;
|
|
22143
|
+
}
|
|
22144
|
+
onUpdate(end, ratio, out) {
|
|
22145
|
+
const attribute = this.target.attribute;
|
|
22146
|
+
this.propKeys.forEach(key => {
|
|
22147
|
+
attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
|
|
22148
|
+
});
|
|
22149
|
+
this.target.setAttributes(attribute);
|
|
22150
|
+
}
|
|
22151
|
+
}
|
|
22152
|
+
class CandlestickScaleOut extends ACustomAnimate {
|
|
22153
|
+
constructor(from, to, duration, easing, params) {
|
|
22154
|
+
super(from, to, duration, easing, params);
|
|
22155
|
+
}
|
|
22156
|
+
onBind() {
|
|
22157
|
+
var _a;
|
|
22158
|
+
if ((_a = this.params) === null || _a === void 0 ? void 0 : _a.diffAttrs) {
|
|
22159
|
+
this.target.setAttributes(this.params.diffAttrs);
|
|
22160
|
+
}
|
|
22161
|
+
const { from, to } = this.computeAttribute();
|
|
22162
|
+
this.propKeys = Object.keys(to).filter(key => to[key] != null);
|
|
22163
|
+
this.animate.reSyncProps();
|
|
22164
|
+
this.from = from;
|
|
22165
|
+
this.to = to;
|
|
22166
|
+
this.target.setAttributes(this.from);
|
|
22167
|
+
}
|
|
22168
|
+
computeAttribute() {
|
|
22169
|
+
const attr = scaleOut()(this.target, this.params, this.params.options);
|
|
22170
|
+
return attr;
|
|
22171
|
+
}
|
|
22172
|
+
onUpdate(end, ratio, out) {
|
|
22173
|
+
const attribute = this.target.attribute;
|
|
22174
|
+
this.propKeys.forEach(key => {
|
|
22175
|
+
attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
|
|
22176
|
+
});
|
|
22177
|
+
this.target.setAttributes(attribute);
|
|
22178
|
+
}
|
|
22179
|
+
}
|
|
22180
|
+
const registerCandlestickScaleAnimation = () => {
|
|
22181
|
+
AnimateExecutor.registerBuiltInAnimate('candlestickScaleIn', CandlestickScaleIn);
|
|
22182
|
+
AnimateExecutor.registerBuiltInAnimate('candlestickScaleOut', CandlestickScaleOut);
|
|
22183
|
+
};
|
|
22184
|
+
|
|
22185
|
+
const CANDLESTICK_CHART_TYPE = 'candlestick';
|
|
22186
|
+
const CANDLESTICK_SERIES_TYPE = 'candlestick';
|
|
22187
|
+
var CANDLESTICK_TOOLTIP_KEYS;
|
|
22188
|
+
(function (CANDLESTICK_TOOLTIP_KEYS) {
|
|
22189
|
+
CANDLESTICK_TOOLTIP_KEYS["OPEN"] = "open";
|
|
22190
|
+
CANDLESTICK_TOOLTIP_KEYS["HIGH"] = "high";
|
|
22191
|
+
CANDLESTICK_TOOLTIP_KEYS["LOW"] = "low";
|
|
22192
|
+
CANDLESTICK_TOOLTIP_KEYS["CLOSE"] = "close";
|
|
22193
|
+
CANDLESTICK_TOOLTIP_KEYS["SERIES_FIELD"] = "seriesField";
|
|
22194
|
+
})(CANDLESTICK_TOOLTIP_KEYS || (CANDLESTICK_TOOLTIP_KEYS = {}));
|
|
22195
|
+
var CandlestickMarkNameEnum;
|
|
22196
|
+
(function (CandlestickMarkNameEnum) {
|
|
22197
|
+
CandlestickMarkNameEnum["candlestick"] = "candlestick";
|
|
22198
|
+
})(CandlestickMarkNameEnum || (CandlestickMarkNameEnum = {}));
|
|
22199
|
+
const CandlestickSeriesMark = Object.assign(Object.assign({}, vchart.baseSeriesMark), { ["candlestick"]: { name: "candlestick", type: 'candlestick' } });
|
|
22200
|
+
|
|
22201
|
+
class CandlestickSeriesTooltipHelper extends vchart.BaseSeriesTooltipHelper {
|
|
22202
|
+
constructor() {
|
|
22203
|
+
super(...arguments);
|
|
22204
|
+
this.getContentKey = (contentType) => (datum) => {
|
|
22205
|
+
switch (contentType) {
|
|
22206
|
+
case CANDLESTICK_TOOLTIP_KEYS.OPEN: {
|
|
22207
|
+
const openField = this.series.getOpenField();
|
|
22208
|
+
return openField;
|
|
22209
|
+
}
|
|
22210
|
+
case CANDLESTICK_TOOLTIP_KEYS.HIGH: {
|
|
22211
|
+
const highField = this.series.getHighField();
|
|
22212
|
+
return highField;
|
|
22213
|
+
}
|
|
22214
|
+
case CANDLESTICK_TOOLTIP_KEYS.LOW: {
|
|
22215
|
+
const lowField = this.series.getLowField();
|
|
22216
|
+
return lowField;
|
|
22217
|
+
}
|
|
22218
|
+
case CANDLESTICK_TOOLTIP_KEYS.CLOSE: {
|
|
22219
|
+
const closeField = this.series.getCloseField();
|
|
22220
|
+
return closeField;
|
|
22221
|
+
}
|
|
22222
|
+
case CANDLESTICK_TOOLTIP_KEYS.SERIES_FIELD: {
|
|
22223
|
+
const seriesField = this.series.getSeriesField();
|
|
22224
|
+
return seriesField;
|
|
22225
|
+
}
|
|
22226
|
+
}
|
|
22227
|
+
return null;
|
|
22228
|
+
};
|
|
22229
|
+
this.getContentValue = (contentType) => (datum) => {
|
|
22230
|
+
switch (contentType) {
|
|
22231
|
+
case CANDLESTICK_TOOLTIP_KEYS.OPEN: {
|
|
22232
|
+
const openField = this.series.getOpenField();
|
|
22233
|
+
return datum[openField];
|
|
22234
|
+
}
|
|
22235
|
+
case CANDLESTICK_TOOLTIP_KEYS.HIGH: {
|
|
22236
|
+
const highField = this.series.getHighField();
|
|
22237
|
+
return datum[highField];
|
|
22238
|
+
}
|
|
22239
|
+
case CANDLESTICK_TOOLTIP_KEYS.LOW: {
|
|
22240
|
+
const lowField = this.series.getLowField();
|
|
22241
|
+
return datum[lowField];
|
|
22242
|
+
}
|
|
22243
|
+
case CANDLESTICK_TOOLTIP_KEYS.CLOSE: {
|
|
22244
|
+
const closeField = this.series.getCloseField();
|
|
22245
|
+
return datum[closeField];
|
|
22246
|
+
}
|
|
22247
|
+
case CANDLESTICK_TOOLTIP_KEYS.SERIES_FIELD: {
|
|
22248
|
+
const seriesField = this.series.getSeriesField();
|
|
22249
|
+
return datum[seriesField];
|
|
22250
|
+
}
|
|
22251
|
+
}
|
|
22252
|
+
return null;
|
|
22253
|
+
};
|
|
22254
|
+
this.shapeColorCallback = (datum) => {
|
|
22255
|
+
return this.series.getMarkInName('candlestick').getAttribute('stroke', datum);
|
|
22256
|
+
};
|
|
22257
|
+
}
|
|
22258
|
+
getDefaultContentList(activeType) {
|
|
22259
|
+
return [
|
|
22260
|
+
{
|
|
22261
|
+
key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.OPEN),
|
|
22262
|
+
value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.OPEN)
|
|
22263
|
+
},
|
|
22264
|
+
{
|
|
22265
|
+
key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.HIGH),
|
|
22266
|
+
value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.HIGH)
|
|
22267
|
+
},
|
|
22268
|
+
{
|
|
22269
|
+
key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.LOW),
|
|
22270
|
+
value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.LOW)
|
|
22271
|
+
},
|
|
22272
|
+
{
|
|
22273
|
+
key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.CLOSE),
|
|
22274
|
+
value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.CLOSE)
|
|
22275
|
+
},
|
|
22276
|
+
{
|
|
22277
|
+
key: this.getContentKey(CANDLESTICK_TOOLTIP_KEYS.SERIES_FIELD),
|
|
22278
|
+
value: this.getContentValue(CANDLESTICK_TOOLTIP_KEYS.SERIES_FIELD)
|
|
22279
|
+
}
|
|
22280
|
+
];
|
|
22281
|
+
}
|
|
22282
|
+
}
|
|
22283
|
+
|
|
22284
|
+
const getCandlestickTheme = () => {
|
|
22285
|
+
const res = {
|
|
22286
|
+
rising: {
|
|
22287
|
+
style: {
|
|
22288
|
+
boxFill: '#FF0000',
|
|
22289
|
+
stroke: '#FF0000'
|
|
22290
|
+
}
|
|
22291
|
+
},
|
|
22292
|
+
falling: {
|
|
22293
|
+
style: {
|
|
22294
|
+
boxFill: '#00AA00',
|
|
22295
|
+
stroke: '#00AA00'
|
|
22296
|
+
}
|
|
22297
|
+
},
|
|
22298
|
+
doji: {
|
|
22299
|
+
style: {
|
|
22300
|
+
boxFill: '#000000',
|
|
22301
|
+
stroke: '#000000'
|
|
22302
|
+
}
|
|
22303
|
+
},
|
|
22304
|
+
candlestick: {
|
|
22305
|
+
style: {
|
|
22306
|
+
lineWidth: 1
|
|
22307
|
+
}
|
|
22308
|
+
}
|
|
22309
|
+
};
|
|
22310
|
+
return res;
|
|
22311
|
+
};
|
|
22312
|
+
const candlestick = getCandlestickTheme();
|
|
22313
|
+
|
|
22314
|
+
class CandlestickSeries extends vchart.CartesianSeries {
|
|
22315
|
+
constructor() {
|
|
22316
|
+
super(...arguments);
|
|
22317
|
+
this.type = CANDLESTICK_SERIES_TYPE;
|
|
22318
|
+
this._mergedStyles = {
|
|
22319
|
+
rising: {},
|
|
22320
|
+
falling: {},
|
|
22321
|
+
doji: {}
|
|
22322
|
+
};
|
|
22323
|
+
}
|
|
22324
|
+
getOpenField() {
|
|
22325
|
+
return this._openField;
|
|
22326
|
+
}
|
|
22327
|
+
getHighField() {
|
|
22328
|
+
return this._highField;
|
|
22329
|
+
}
|
|
22330
|
+
getLowField() {
|
|
22331
|
+
return this._lowField;
|
|
22332
|
+
}
|
|
22333
|
+
getCloseField() {
|
|
22334
|
+
return this._closeField;
|
|
22335
|
+
}
|
|
22336
|
+
getBoxFill() {
|
|
22337
|
+
return this._boxFill;
|
|
22338
|
+
}
|
|
22339
|
+
getStrokeColor() {
|
|
22340
|
+
return this._strokeColor;
|
|
22341
|
+
}
|
|
22342
|
+
setAttrFromSpec() {
|
|
22343
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
22344
|
+
super.setAttrFromSpec();
|
|
22345
|
+
const spec = this._spec;
|
|
22346
|
+
const CandlestickStyle = (_b = (_a = spec.candlestick) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {};
|
|
22347
|
+
this._openField = spec.openField;
|
|
22348
|
+
this._highField = spec.highField;
|
|
22349
|
+
this._lowField = spec.lowField;
|
|
22350
|
+
this._closeField = spec.closeField;
|
|
22351
|
+
this._boxWidth = CandlestickStyle.boxWidth;
|
|
22352
|
+
this._boxFill = CandlestickStyle.boxFill;
|
|
22353
|
+
this._strokeColor = CandlestickStyle.strokeColor;
|
|
22354
|
+
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 : {});
|
|
22355
|
+
}
|
|
22356
|
+
initMark() {
|
|
22357
|
+
this._candlestickMark = this._createMark(CandlestickSeries.mark.candlestick, {
|
|
22358
|
+
groupKey: this._seriesField,
|
|
22359
|
+
isSeriesMark: true
|
|
22360
|
+
});
|
|
22361
|
+
}
|
|
22362
|
+
initMarkStyle() {
|
|
22363
|
+
var _a;
|
|
22364
|
+
const candlestickMark = this._candlestickMark;
|
|
22365
|
+
if (candlestickMark) {
|
|
22366
|
+
const CandlestickStyles = {
|
|
22367
|
+
fill: (datum) => {
|
|
22368
|
+
const boxFill = this.mergeStyle(datum).boxFill;
|
|
22369
|
+
return boxFill;
|
|
22370
|
+
},
|
|
22371
|
+
stroke: (datum) => {
|
|
22372
|
+
const strokeColor = this.mergeStyle(datum).stroke;
|
|
22373
|
+
return strokeColor;
|
|
22374
|
+
},
|
|
22375
|
+
lineWidth: (datum) => {
|
|
22376
|
+
const lineWidth = this.mergeStyle(datum).lineWidth;
|
|
22377
|
+
return lineWidth;
|
|
22378
|
+
},
|
|
22379
|
+
boxWidth: (_a = this._boxWidth) !== null && _a !== void 0 ? _a : this._getMarkWidth.bind(this),
|
|
22380
|
+
x: this.dataToPositionX.bind(this)
|
|
22381
|
+
};
|
|
22382
|
+
candlestickMark.setGlyphConfig({});
|
|
22383
|
+
this.setMarkStyle(candlestickMark, CandlestickStyles, vchart.STATE_VALUE_ENUM.STATE_NORMAL, vchart.AttributeLevel.Series);
|
|
22384
|
+
}
|
|
22385
|
+
}
|
|
22386
|
+
initCandlestickMarkStyle() {
|
|
22387
|
+
var _a;
|
|
22388
|
+
const candlestickMark = this._candlestickMark;
|
|
22389
|
+
const axisHelper = this._yAxisHelper;
|
|
22390
|
+
if (candlestickMark && axisHelper) {
|
|
22391
|
+
const { dataToPosition } = axisHelper;
|
|
22392
|
+
const scale = (_a = axisHelper === null || axisHelper === void 0 ? void 0 : axisHelper.getScale) === null || _a === void 0 ? void 0 : _a.call(axisHelper, 0);
|
|
22393
|
+
this.setMarkStyle(candlestickMark, {
|
|
22394
|
+
open: (datum) => vchart.valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._openField), {
|
|
22395
|
+
bandPosition: this._bandPosition
|
|
22396
|
+
}), scale),
|
|
22397
|
+
high: (datum) => vchart.valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._highField), {
|
|
22398
|
+
bandPosition: this._bandPosition
|
|
22399
|
+
}), scale),
|
|
22400
|
+
low: (datum) => vchart.valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._lowField), {
|
|
22401
|
+
bandPosition: this._bandPosition
|
|
22402
|
+
}), scale),
|
|
22403
|
+
close: (datum) => vchart.valueInScaleRange(dataToPosition(this.getDatumPositionValues(datum, this._closeField), {
|
|
22404
|
+
bandPosition: this._bandPosition
|
|
22405
|
+
}), scale)
|
|
22406
|
+
}, vchart.STATE_VALUE_ENUM.STATE_NORMAL, vchart.AttributeLevel.Series);
|
|
22407
|
+
}
|
|
22408
|
+
}
|
|
22409
|
+
init(option) {
|
|
22410
|
+
super.init(option);
|
|
22411
|
+
this.initCandlestickMarkStyle();
|
|
22412
|
+
}
|
|
22413
|
+
_initAnimationSpec(config = {}) {
|
|
22414
|
+
const newConfig = merge({}, config);
|
|
22415
|
+
['appear', 'enter', 'update', 'exit', 'disappear'].forEach(state => {
|
|
22416
|
+
if (newConfig[state] && newConfig[state].type === 'scaleIn') {
|
|
22417
|
+
newConfig[state].type = 'candlestickScaleIn';
|
|
22418
|
+
}
|
|
22419
|
+
else if (newConfig[state] && newConfig[state].type === 'scaleOut') {
|
|
22420
|
+
newConfig[state].type = 'candlestickScaleOut';
|
|
22421
|
+
}
|
|
22422
|
+
});
|
|
22423
|
+
return newConfig;
|
|
22424
|
+
}
|
|
22425
|
+
initAnimation() {
|
|
22426
|
+
var _a;
|
|
22427
|
+
const animationParams = vchart.getGroupAnimationParams(this);
|
|
22428
|
+
if (this._candlestickMark) {
|
|
22429
|
+
const newDefaultConfig = this._initAnimationSpec((_a = vchart.Factory.getAnimationInKey('scaleInOut')) === null || _a === void 0 ? void 0 : _a());
|
|
22430
|
+
const newConfig = this._initAnimationSpec(vchart.userAnimationConfig(CANDLESTICK_SERIES_TYPE, this._spec, this._markAttributeContext));
|
|
22431
|
+
this._candlestickMark.setAnimationConfig(vchart.animationConfig(newDefaultConfig, newConfig, animationParams));
|
|
22432
|
+
}
|
|
22433
|
+
}
|
|
22434
|
+
initTooltip() {
|
|
22435
|
+
this._tooltipHelper = new CandlestickSeriesTooltipHelper(this);
|
|
22436
|
+
this._candlestickMark && this._tooltipHelper.activeTriggerSet.mark.add(this._candlestickMark);
|
|
22437
|
+
}
|
|
22438
|
+
_buildMergedStyles(baseStyle, risingStyle, fallingStyle, dojiStyle) {
|
|
22439
|
+
this._mergedStyles.rising = merge({}, baseStyle, risingStyle);
|
|
22440
|
+
this._mergedStyles.falling = merge({}, baseStyle, fallingStyle);
|
|
22441
|
+
this._mergedStyles.doji = merge({}, baseStyle, dojiStyle);
|
|
22442
|
+
}
|
|
22443
|
+
mergeStyle(datum) {
|
|
22444
|
+
const open = this.getDatumPositionValues(datum, this._openField)[0];
|
|
22445
|
+
const close = this.getDatumPositionValues(datum, this._closeField)[0];
|
|
22446
|
+
if (open < close) {
|
|
22447
|
+
return this._mergedStyles.rising;
|
|
22448
|
+
}
|
|
22449
|
+
else if (open > close) {
|
|
22450
|
+
return this._mergedStyles.falling;
|
|
22451
|
+
}
|
|
22452
|
+
else {
|
|
22453
|
+
return this._mergedStyles.doji;
|
|
22454
|
+
}
|
|
22455
|
+
}
|
|
22456
|
+
_getMarkWidth() {
|
|
22457
|
+
if (this._autoBoxWidth) {
|
|
22458
|
+
return this._autoBoxWidth;
|
|
22459
|
+
}
|
|
22460
|
+
const bandAxisHelper = this._xAxisHelper;
|
|
22461
|
+
const xField = this._fieldX;
|
|
22462
|
+
const innerBandWidth = bandAxisHelper.getBandwidth(xField.length - 1);
|
|
22463
|
+
const autoBoxWidth = innerBandWidth / xField.length;
|
|
22464
|
+
this._autoBoxWidth = autoBoxWidth;
|
|
22465
|
+
return this._autoBoxWidth;
|
|
22466
|
+
}
|
|
22467
|
+
onLayoutEnd() {
|
|
22468
|
+
super.onLayoutEnd();
|
|
22469
|
+
this._autoBoxWidth = null;
|
|
22470
|
+
}
|
|
22471
|
+
getActiveMarks() {
|
|
22472
|
+
return [this._candlestickMark];
|
|
22473
|
+
}
|
|
22474
|
+
}
|
|
22475
|
+
CandlestickSeries.type = CANDLESTICK_SERIES_TYPE;
|
|
22476
|
+
CandlestickSeries.builtInTheme = { candlestick };
|
|
22477
|
+
CandlestickSeries.mark = CandlestickSeriesMark;
|
|
22478
|
+
const registerCandlestickSeries = () => {
|
|
22479
|
+
registerCandlestickMark();
|
|
22480
|
+
vchart.registerSymbolMark();
|
|
22481
|
+
vchart.registerScaleInOutAnimation();
|
|
22482
|
+
vchart.registerCartesianBandAxis();
|
|
22483
|
+
vchart.registerCartesianLinearAxis();
|
|
22484
|
+
registerCandlestickScaleAnimation();
|
|
22485
|
+
vchart.Factory.registerSeries(CandlestickSeries.type, CandlestickSeries);
|
|
22486
|
+
};
|
|
22487
|
+
|
|
22488
|
+
class CandlestickChart extends vchart.BaseChart {
|
|
22489
|
+
_setModelOption() {
|
|
22490
|
+
this._modelOption.getDimensionInfo = vchart.getCartesianDimensionInfo;
|
|
22491
|
+
this._modelOption.getDimensionInfoByValue = vchart.getDimensionInfoByValue;
|
|
22492
|
+
this._modelOption.getRectByDimensionData = vchart.getCartesianCrosshairRect;
|
|
22493
|
+
}
|
|
22494
|
+
}
|
|
22495
|
+
CandlestickChart.type = CANDLESTICK_CHART_TYPE;
|
|
22496
|
+
CandlestickChart.seriesType = CANDLESTICK_SERIES_TYPE;
|
|
22497
|
+
CandlestickChart.transformerConstructor = CandlestickChartSpecTransformer;
|
|
22498
|
+
const registerCandlestickChart = () => {
|
|
22499
|
+
vchart.registerDimensionTooltipProcessor();
|
|
22500
|
+
vchart.registerMarkTooltipProcessor();
|
|
22501
|
+
vchart.registerDimensionEvents();
|
|
22502
|
+
vchart.registerDimensionHover();
|
|
22503
|
+
registerCandlestickSeries();
|
|
22504
|
+
vchart.Factory.registerChart(CandlestickChart.type, CandlestickChart);
|
|
22505
|
+
};
|
|
22506
|
+
|
|
21977
22507
|
const GROUP_ATTRIBUTES = ["x", "y", "dx", "dy", "scaleX", "scaleY", "angle", "anchor", "postMatrix", "visible", "clip", "pickable", "childrenPickable", "zIndex", "cursor"];
|
|
21978
22508
|
class AbstractComponent extends Group {
|
|
21979
22509
|
constructor(attributes, options) {
|
|
@@ -25044,6 +25574,8 @@
|
|
|
25044
25574
|
exports.Bar3dSeries = Bar3dSeries;
|
|
25045
25575
|
exports.Bar3dSeriesSpecTransformer = Bar3dSeriesSpecTransformer;
|
|
25046
25576
|
exports.BarLinkComponent = BarLinkComponent;
|
|
25577
|
+
exports.CandlestickChart = CandlestickChart;
|
|
25578
|
+
exports.CandlestickChartSpecTransformer = CandlestickChartSpecTransformer;
|
|
25047
25579
|
exports.ConversionFunnelChart = ConversionFunnelChart;
|
|
25048
25580
|
exports.ConversionFunnelSeries = ConversionFunnelSeries;
|
|
25049
25581
|
exports.DefaultBandWidth = DefaultBandWidth;
|
|
@@ -25088,6 +25620,7 @@
|
|
|
25088
25620
|
exports.registerBar3dChart = registerBar3dChart;
|
|
25089
25621
|
exports.registerBar3dSeries = registerBar3dSeries;
|
|
25090
25622
|
exports.registerBarLink = registerBarLink;
|
|
25623
|
+
exports.registerCandlestickChart = registerCandlestickChart;
|
|
25091
25624
|
exports.registerConversionFunnelChart = registerConversionFunnelChart;
|
|
25092
25625
|
exports.registerFunnel3dChart = registerFunnel3dChart;
|
|
25093
25626
|
exports.registerFunnel3dSeries = registerFunnel3dSeries;
|