@visactor/vchart 2.0.5-alpha.7 → 2.0.5-alpha.9
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/es5/index.js +1 -1
- package/build/index.es.js +147 -6
- package/build/index.js +147 -6
- package/build/index.min.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/component/axis/cartesian/axis.d.ts +6 -0
- package/cjs/component/axis/cartesian/axis.js +3 -0
- package/cjs/component/axis/cartesian/axis.js.map +1 -1
- package/cjs/component/crosshair/base.d.ts +7 -1
- package/cjs/component/crosshair/base.js +69 -9
- package/cjs/component/crosshair/base.js.map +1 -1
- package/cjs/component/crosshair/cartesian.js +15 -3
- package/cjs/component/crosshair/cartesian.js.map +1 -1
- package/cjs/core/expression-function.js +1 -1
- package/cjs/core/factory.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/instance-manager.js +1 -1
- package/cjs/core/interface.js +1 -1
- package/cjs/core/util.js +1 -1
- package/cjs/data/initialize.js +1 -1
- package/cjs/data/register.js +1 -1
- package/cjs/env/env.js +1 -1
- package/cjs/env/index.js +1 -1
- package/cjs/event/bubble.js +1 -1
- package/cjs/event/event-dispatcher.js +1 -1
- package/esm/component/axis/cartesian/axis.d.ts +6 -0
- package/esm/component/axis/cartesian/axis.js +3 -0
- package/esm/component/axis/cartesian/axis.js.map +1 -1
- package/esm/component/crosshair/base.d.ts +7 -1
- package/esm/component/crosshair/base.js +69 -9
- package/esm/component/crosshair/base.js.map +1 -1
- package/esm/component/crosshair/cartesian.js +15 -3
- package/esm/component/crosshair/cartesian.js.map +1 -1
- package/esm/core/expression-function.js +1 -1
- package/esm/core/factory.js +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/instance-manager.js +1 -1
- package/esm/core/interface.js +1 -1
- package/esm/core/util.js +1 -1
- package/esm/data/initialize.js +1 -1
- package/esm/data/register.js +1 -1
- package/esm/env/env.js +1 -1
- package/esm/env/index.js +1 -1
- package/esm/event/bubble.js +1 -1
- package/esm/event/event-dispatcher.js +1 -1
- package/package.json +5 -5
package/build/index.es.js
CHANGED
|
@@ -63124,6 +63124,9 @@ class CartesianAxis extends AxisComponent {
|
|
|
63124
63124
|
getScales() {
|
|
63125
63125
|
return this._scales;
|
|
63126
63126
|
}
|
|
63127
|
+
getInnerOffset() {
|
|
63128
|
+
return this._innerOffset;
|
|
63129
|
+
}
|
|
63127
63130
|
constructor(spec, options) {
|
|
63128
63131
|
super(spec, options);
|
|
63129
63132
|
this.type = ComponentTypeEnum.cartesianAxis;
|
|
@@ -91719,15 +91722,19 @@ class BaseCrossHair extends BaseComponent {
|
|
|
91719
91722
|
return;
|
|
91720
91723
|
}
|
|
91721
91724
|
}
|
|
91725
|
+
const prevComponentBounds = this._getNeedClearVRenderComponentBounds();
|
|
91722
91726
|
const { x, y } = this.calculateTriggerPoint(params);
|
|
91723
91727
|
this.showDefault = false;
|
|
91724
91728
|
this._layoutCrosshair(x, y, tooltipData, params.activeType);
|
|
91725
91729
|
const components = this._getNeedClearVRenderComponents();
|
|
91726
91730
|
this._hasActive = components.some(comp => comp && comp.attribute.visible !== false);
|
|
91731
|
+
this._renderNextFrame(prevComponentBounds);
|
|
91727
91732
|
};
|
|
91728
91733
|
this._handleTooltipHideOrRelease = () => {
|
|
91734
|
+
const prevComponentBounds = this._getNeedClearVRenderComponentBounds();
|
|
91729
91735
|
this.clearOutEvent();
|
|
91730
91736
|
this.hideCrosshair();
|
|
91737
|
+
this._renderNextFrame(prevComponentBounds);
|
|
91731
91738
|
};
|
|
91732
91739
|
this.enable = true;
|
|
91733
91740
|
this.showDefault = true;
|
|
@@ -91795,17 +91802,20 @@ class BaseCrossHair extends BaseComponent {
|
|
|
91795
91802
|
return this._limitBounds;
|
|
91796
91803
|
}
|
|
91797
91804
|
_showDefaultCrosshairBySpec() {
|
|
91805
|
+
let hasDefaultCrosshair = false;
|
|
91798
91806
|
Object.keys(this._stateByField).forEach(field => {
|
|
91799
91807
|
const fieldSpec = this._spec[field];
|
|
91800
91808
|
if (fieldSpec && fieldSpec.visible && fieldSpec.defaultSelect) {
|
|
91801
91809
|
const { axisIndex = 0, datum } = fieldSpec.defaultSelect;
|
|
91802
91810
|
const axis = this._option.getComponentsByKey('axes').find(c => c.getSpecIndex() === axisIndex);
|
|
91803
91811
|
if (axis) {
|
|
91812
|
+
hasDefaultCrosshair = true;
|
|
91804
91813
|
this._stateByField[field].currentValue.clear();
|
|
91805
91814
|
this._stateByField[field].currentValue.set(axisIndex, { axis, datum });
|
|
91806
91815
|
}
|
|
91807
91816
|
}
|
|
91808
91817
|
});
|
|
91818
|
+
return hasDefaultCrosshair;
|
|
91809
91819
|
}
|
|
91810
91820
|
_updateVisibleCrosshair() {
|
|
91811
91821
|
let hasVisible = false;
|
|
@@ -91824,8 +91834,8 @@ class BaseCrossHair extends BaseComponent {
|
|
|
91824
91834
|
}
|
|
91825
91835
|
_showDefaultCrosshair() {
|
|
91826
91836
|
if (this.showDefault) {
|
|
91827
|
-
this._showDefaultCrosshairBySpec();
|
|
91828
|
-
this.layoutByValue(false);
|
|
91837
|
+
const hasDefault = this._showDefaultCrosshairBySpec();
|
|
91838
|
+
hasDefault && this.layoutByValue(false);
|
|
91829
91839
|
}
|
|
91830
91840
|
else {
|
|
91831
91841
|
this._updateVisibleCrosshair();
|
|
@@ -91936,6 +91946,88 @@ class BaseCrossHair extends BaseComponent {
|
|
|
91936
91946
|
this.event.on(ChartEvent.tooltipShow, { source: Event_Source_Type.chart }, this._handleTooltipShow);
|
|
91937
91947
|
this.event.on(ChartEvent.tooltipRelease, { source: Event_Source_Type.chart }, this._handleTooltipHideOrRelease);
|
|
91938
91948
|
}
|
|
91949
|
+
_renderNextFrame(prevComponentBounds) {
|
|
91950
|
+
var _a;
|
|
91951
|
+
const stage = this._option.globalInstance.getStage();
|
|
91952
|
+
if (!stage) {
|
|
91953
|
+
return;
|
|
91954
|
+
}
|
|
91955
|
+
if (stage.state === 'rendering') {
|
|
91956
|
+
(_a = stage.renderNextFrame) === null || _a === void 0 ? void 0 : _a.call(stage);
|
|
91957
|
+
if (!this._pendingRenderAfterRendering) {
|
|
91958
|
+
this._pendingRenderAfterRendering = true;
|
|
91959
|
+
Promise.resolve().then(() => {
|
|
91960
|
+
var _a;
|
|
91961
|
+
this._pendingRenderAfterRendering = false;
|
|
91962
|
+
if (stage.releaseStatus === 'released') {
|
|
91963
|
+
return;
|
|
91964
|
+
}
|
|
91965
|
+
if (stage.state === 'rendering') {
|
|
91966
|
+
(_a = stage.renderNextFrame) === null || _a === void 0 ? void 0 : _a.call(stage);
|
|
91967
|
+
return;
|
|
91968
|
+
}
|
|
91969
|
+
this._renderStage(stage, prevComponentBounds);
|
|
91970
|
+
});
|
|
91971
|
+
}
|
|
91972
|
+
return;
|
|
91973
|
+
}
|
|
91974
|
+
this._renderStage(stage, prevComponentBounds);
|
|
91975
|
+
}
|
|
91976
|
+
_renderStage(stage, prevComponentBounds) {
|
|
91977
|
+
var _a;
|
|
91978
|
+
const shouldRenderExternalCanvas = this._isTransparentExternalCanvasStage(stage);
|
|
91979
|
+
const cleared = this._clearPreviousComponents(stage, prevComponentBounds);
|
|
91980
|
+
if ((shouldRenderExternalCanvas || cleared) && '_story_needRender' in stage) {
|
|
91981
|
+
stage._story_needRender = true;
|
|
91982
|
+
}
|
|
91983
|
+
if (stage.render) {
|
|
91984
|
+
stage.render();
|
|
91985
|
+
return;
|
|
91986
|
+
}
|
|
91987
|
+
(_a = stage.renderNextFrame) === null || _a === void 0 ? void 0 : _a.call(stage);
|
|
91988
|
+
}
|
|
91989
|
+
_isTransparentExternalCanvasStage(stage) {
|
|
91990
|
+
var _a;
|
|
91991
|
+
return (stage === null || stage === void 0 ? void 0 : stage.background) === false && ((_a = stage.params) === null || _a === void 0 ? void 0 : _a.canvasControled) === false;
|
|
91992
|
+
}
|
|
91993
|
+
_clearPreviousComponents(stage, prevComponentBounds) {
|
|
91994
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
91995
|
+
if (!(prevComponentBounds === null || prevComponentBounds === void 0 ? void 0 : prevComponentBounds.length) || !this._isTransparentExternalCanvasStage(stage)) {
|
|
91996
|
+
return false;
|
|
91997
|
+
}
|
|
91998
|
+
const context = (_b = (_a = stage.window) === null || _a === void 0 ? void 0 : _a.getContext) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
91999
|
+
const nativeContext = context === null || context === void 0 ? void 0 : context.nativeContext;
|
|
92000
|
+
const matrix = (_d = (_c = stage.window) === null || _c === void 0 ? void 0 : _c.getViewBoxTransform) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
92001
|
+
if (!nativeContext ||
|
|
92002
|
+
!matrix ||
|
|
92003
|
+
!nativeContext.save ||
|
|
92004
|
+
!nativeContext.setTransform ||
|
|
92005
|
+
!nativeContext.clearRect ||
|
|
92006
|
+
!nativeContext.restore) {
|
|
92007
|
+
return false;
|
|
92008
|
+
}
|
|
92009
|
+
const dpr = (_g = (_f = (_e = stage.window) === null || _e === void 0 ? void 0 : _e.dpr) !== null && _f !== void 0 ? _f : context.dpr) !== null && _g !== void 0 ? _g : 1;
|
|
92010
|
+
const transformPoint = (x, y) => ({
|
|
92011
|
+
x: matrix.a * x + matrix.c * y + matrix.e,
|
|
92012
|
+
y: matrix.b * x + matrix.d * y + matrix.f
|
|
92013
|
+
});
|
|
92014
|
+
const padding = 8;
|
|
92015
|
+
nativeContext.save();
|
|
92016
|
+
nativeContext.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
92017
|
+
prevComponentBounds.forEach(bounds => {
|
|
92018
|
+
const p1 = transformPoint(bounds.x1, bounds.y1);
|
|
92019
|
+
const p2 = transformPoint(bounds.x1, bounds.y2);
|
|
92020
|
+
const p3 = transformPoint(bounds.x2, bounds.y1);
|
|
92021
|
+
const p4 = transformPoint(bounds.x2, bounds.y2);
|
|
92022
|
+
const x1 = Math.min(p1.x, p2.x, p3.x, p4.x) - padding;
|
|
92023
|
+
const y1 = Math.min(p1.y, p2.y, p3.y, p4.y) - padding;
|
|
92024
|
+
const x2 = Math.max(p1.x, p2.x, p3.x, p4.x) + padding;
|
|
92025
|
+
const y2 = Math.max(p1.y, p2.y, p3.y, p4.y) + padding;
|
|
92026
|
+
nativeContext.clearRect(x1, y1, x2 - x1, y2 - y1);
|
|
92027
|
+
});
|
|
92028
|
+
nativeContext.restore();
|
|
92029
|
+
return true;
|
|
92030
|
+
}
|
|
91939
92031
|
_getAxisInfoByField(field) {
|
|
91940
92032
|
var _a, _b;
|
|
91941
92033
|
const axesComponents = (_b = (_a = this._option).getComponentsByKey) === null || _b === void 0 ? void 0 : _b.call(_a, 'axes');
|
|
@@ -91961,18 +92053,20 @@ class BaseCrossHair extends BaseComponent {
|
|
|
91961
92053
|
let y2 = -Infinity;
|
|
91962
92054
|
const { x: sx, y: sy } = this.getLayoutStartPoint();
|
|
91963
92055
|
bindingAxesIndex.forEach(idx => {
|
|
92056
|
+
var _a, _b;
|
|
91964
92057
|
(x1 = Infinity), (y1 = Infinity), (x2 = -Infinity), (y2 = -Infinity);
|
|
91965
92058
|
const axis = axesComponents.find(axis => axis.getSpecIndex() === idx);
|
|
91966
92059
|
if (!axis) {
|
|
91967
92060
|
return;
|
|
91968
92061
|
}
|
|
92062
|
+
const innerOffset = ((_b = (_a = axis).getInnerOffset) === null || _b === void 0 ? void 0 : _b.call(_a)) || { left: 0, right: 0, top: 0, bottom: 0 };
|
|
91969
92063
|
const regions = axis.getRegions();
|
|
91970
92064
|
regions.forEach(r => {
|
|
91971
92065
|
const { x: regionStartX, y: regionStartY } = r.getLayoutStartPoint();
|
|
91972
|
-
x1 = Math.min(x1, regionStartX - sx);
|
|
91973
|
-
y1 = Math.min(y1, regionStartY - sy);
|
|
91974
|
-
x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx);
|
|
91975
|
-
y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy);
|
|
92066
|
+
x1 = Math.min(x1, regionStartX - sx + innerOffset.left);
|
|
92067
|
+
y1 = Math.min(y1, regionStartY - sy + innerOffset.top);
|
|
92068
|
+
x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx - innerOffset.right);
|
|
92069
|
+
y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy - innerOffset.bottom);
|
|
91976
92070
|
});
|
|
91977
92071
|
map.set(idx, { x1, y1, x2, y2, axis: axis });
|
|
91978
92072
|
});
|
|
@@ -92164,6 +92258,27 @@ class BaseCrossHair extends BaseComponent {
|
|
|
92164
92258
|
return res;
|
|
92165
92259
|
}, []);
|
|
92166
92260
|
}
|
|
92261
|
+
_getNeedClearVRenderComponentBounds() {
|
|
92262
|
+
return this._getNeedClearVRenderComponents().reduce((bounds, component) => {
|
|
92263
|
+
if (!component || component.attribute.visible === false) {
|
|
92264
|
+
return bounds;
|
|
92265
|
+
}
|
|
92266
|
+
const componentBounds = component.globalAABBBounds;
|
|
92267
|
+
if (componentBounds &&
|
|
92268
|
+
Number.isFinite(componentBounds.x1) &&
|
|
92269
|
+
Number.isFinite(componentBounds.y1) &&
|
|
92270
|
+
Number.isFinite(componentBounds.x2) &&
|
|
92271
|
+
Number.isFinite(componentBounds.y2)) {
|
|
92272
|
+
bounds.push({
|
|
92273
|
+
x1: componentBounds.x1,
|
|
92274
|
+
y1: componentBounds.y1,
|
|
92275
|
+
x2: componentBounds.x2,
|
|
92276
|
+
y2: componentBounds.y2
|
|
92277
|
+
});
|
|
92278
|
+
}
|
|
92279
|
+
return bounds;
|
|
92280
|
+
}, []);
|
|
92281
|
+
}
|
|
92167
92282
|
}
|
|
92168
92283
|
BaseCrossHair.specKey = 'crosshair';
|
|
92169
92284
|
|
|
@@ -92285,9 +92400,27 @@ class CartesianCrossHair extends BaseCrossHair {
|
|
|
92285
92400
|
var _a;
|
|
92286
92401
|
let x = relativeX;
|
|
92287
92402
|
let y = relativeY;
|
|
92403
|
+
let tooltipAxisValue;
|
|
92404
|
+
const setTooltipAxisValue = () => {
|
|
92405
|
+
if (!tooltipAxisValue) {
|
|
92406
|
+
return;
|
|
92407
|
+
}
|
|
92408
|
+
const field = isXAxis(tooltipAxisValue.axis.getOrient()) ? 'xField' : 'yField';
|
|
92409
|
+
const { currentValue } = this._stateByField[field];
|
|
92410
|
+
if (!currentValue.has(tooltipAxisValue.axis.getSpecIndex())) {
|
|
92411
|
+
currentValue.clear();
|
|
92412
|
+
}
|
|
92413
|
+
this.setAxisValue(tooltipAxisValue.value, tooltipAxisValue.axis);
|
|
92414
|
+
};
|
|
92288
92415
|
if (tooltipData && tooltipData.length) {
|
|
92289
92416
|
if (activeType === 'dimension') {
|
|
92290
92417
|
const dimensionInfo = tooltipData[0];
|
|
92418
|
+
if ((dimensionInfo === null || dimensionInfo === void 0 ? void 0 : dimensionInfo.axis) && isValid$1(dimensionInfo.value)) {
|
|
92419
|
+
tooltipAxisValue = {
|
|
92420
|
+
axis: dimensionInfo.axis,
|
|
92421
|
+
value: dimensionInfo.value
|
|
92422
|
+
};
|
|
92423
|
+
}
|
|
92291
92424
|
const datumIndex = dimensionInfo.data.findIndex(dimData => dimData.datum.length > 0);
|
|
92292
92425
|
let pos;
|
|
92293
92426
|
if (datumIndex > -1) {
|
|
@@ -92314,6 +92447,11 @@ class CartesianCrossHair extends BaseCrossHair {
|
|
|
92314
92447
|
this.clearAxisValue();
|
|
92315
92448
|
const { xAxisMap, yAxisMap } = this._findAllAxisContains(x, y);
|
|
92316
92449
|
if ((xAxisMap && xAxisMap.size === 0) || (yAxisMap && yAxisMap.size === 0)) {
|
|
92450
|
+
if (tooltipAxisValue) {
|
|
92451
|
+
setTooltipAxisValue();
|
|
92452
|
+
this.layoutByValue(false);
|
|
92453
|
+
return;
|
|
92454
|
+
}
|
|
92317
92455
|
if (this.enableRemain) {
|
|
92318
92456
|
return;
|
|
92319
92457
|
}
|
|
@@ -92322,6 +92460,9 @@ class CartesianCrossHair extends BaseCrossHair {
|
|
|
92322
92460
|
}
|
|
92323
92461
|
xAxisMap && xAxisMap.size && this._setAllAxisValues(xAxisMap, { x, y }, 'xField');
|
|
92324
92462
|
yAxisMap && yAxisMap.size && this._setAllAxisValues(yAxisMap, { x, y }, 'yField');
|
|
92463
|
+
if (tooltipAxisValue) {
|
|
92464
|
+
setTooltipAxisValue();
|
|
92465
|
+
}
|
|
92325
92466
|
this.layoutByValue();
|
|
92326
92467
|
}
|
|
92327
92468
|
layoutByValue(enableRemain) {
|
package/build/index.js
CHANGED
|
@@ -63130,6 +63130,9 @@
|
|
|
63130
63130
|
getScales() {
|
|
63131
63131
|
return this._scales;
|
|
63132
63132
|
}
|
|
63133
|
+
getInnerOffset() {
|
|
63134
|
+
return this._innerOffset;
|
|
63135
|
+
}
|
|
63133
63136
|
constructor(spec, options) {
|
|
63134
63137
|
super(spec, options);
|
|
63135
63138
|
this.type = ComponentTypeEnum.cartesianAxis;
|
|
@@ -91725,15 +91728,19 @@
|
|
|
91725
91728
|
return;
|
|
91726
91729
|
}
|
|
91727
91730
|
}
|
|
91731
|
+
const prevComponentBounds = this._getNeedClearVRenderComponentBounds();
|
|
91728
91732
|
const { x, y } = this.calculateTriggerPoint(params);
|
|
91729
91733
|
this.showDefault = false;
|
|
91730
91734
|
this._layoutCrosshair(x, y, tooltipData, params.activeType);
|
|
91731
91735
|
const components = this._getNeedClearVRenderComponents();
|
|
91732
91736
|
this._hasActive = components.some(comp => comp && comp.attribute.visible !== false);
|
|
91737
|
+
this._renderNextFrame(prevComponentBounds);
|
|
91733
91738
|
};
|
|
91734
91739
|
this._handleTooltipHideOrRelease = () => {
|
|
91740
|
+
const prevComponentBounds = this._getNeedClearVRenderComponentBounds();
|
|
91735
91741
|
this.clearOutEvent();
|
|
91736
91742
|
this.hideCrosshair();
|
|
91743
|
+
this._renderNextFrame(prevComponentBounds);
|
|
91737
91744
|
};
|
|
91738
91745
|
this.enable = true;
|
|
91739
91746
|
this.showDefault = true;
|
|
@@ -91801,17 +91808,20 @@
|
|
|
91801
91808
|
return this._limitBounds;
|
|
91802
91809
|
}
|
|
91803
91810
|
_showDefaultCrosshairBySpec() {
|
|
91811
|
+
let hasDefaultCrosshair = false;
|
|
91804
91812
|
Object.keys(this._stateByField).forEach(field => {
|
|
91805
91813
|
const fieldSpec = this._spec[field];
|
|
91806
91814
|
if (fieldSpec && fieldSpec.visible && fieldSpec.defaultSelect) {
|
|
91807
91815
|
const { axisIndex = 0, datum } = fieldSpec.defaultSelect;
|
|
91808
91816
|
const axis = this._option.getComponentsByKey('axes').find(c => c.getSpecIndex() === axisIndex);
|
|
91809
91817
|
if (axis) {
|
|
91818
|
+
hasDefaultCrosshair = true;
|
|
91810
91819
|
this._stateByField[field].currentValue.clear();
|
|
91811
91820
|
this._stateByField[field].currentValue.set(axisIndex, { axis, datum });
|
|
91812
91821
|
}
|
|
91813
91822
|
}
|
|
91814
91823
|
});
|
|
91824
|
+
return hasDefaultCrosshair;
|
|
91815
91825
|
}
|
|
91816
91826
|
_updateVisibleCrosshair() {
|
|
91817
91827
|
let hasVisible = false;
|
|
@@ -91830,8 +91840,8 @@
|
|
|
91830
91840
|
}
|
|
91831
91841
|
_showDefaultCrosshair() {
|
|
91832
91842
|
if (this.showDefault) {
|
|
91833
|
-
this._showDefaultCrosshairBySpec();
|
|
91834
|
-
this.layoutByValue(false);
|
|
91843
|
+
const hasDefault = this._showDefaultCrosshairBySpec();
|
|
91844
|
+
hasDefault && this.layoutByValue(false);
|
|
91835
91845
|
}
|
|
91836
91846
|
else {
|
|
91837
91847
|
this._updateVisibleCrosshair();
|
|
@@ -91942,6 +91952,88 @@
|
|
|
91942
91952
|
this.event.on(exports.ChartEvent.tooltipShow, { source: Event_Source_Type.chart }, this._handleTooltipShow);
|
|
91943
91953
|
this.event.on(exports.ChartEvent.tooltipRelease, { source: Event_Source_Type.chart }, this._handleTooltipHideOrRelease);
|
|
91944
91954
|
}
|
|
91955
|
+
_renderNextFrame(prevComponentBounds) {
|
|
91956
|
+
var _a;
|
|
91957
|
+
const stage = this._option.globalInstance.getStage();
|
|
91958
|
+
if (!stage) {
|
|
91959
|
+
return;
|
|
91960
|
+
}
|
|
91961
|
+
if (stage.state === 'rendering') {
|
|
91962
|
+
(_a = stage.renderNextFrame) === null || _a === void 0 ? void 0 : _a.call(stage);
|
|
91963
|
+
if (!this._pendingRenderAfterRendering) {
|
|
91964
|
+
this._pendingRenderAfterRendering = true;
|
|
91965
|
+
Promise.resolve().then(() => {
|
|
91966
|
+
var _a;
|
|
91967
|
+
this._pendingRenderAfterRendering = false;
|
|
91968
|
+
if (stage.releaseStatus === 'released') {
|
|
91969
|
+
return;
|
|
91970
|
+
}
|
|
91971
|
+
if (stage.state === 'rendering') {
|
|
91972
|
+
(_a = stage.renderNextFrame) === null || _a === void 0 ? void 0 : _a.call(stage);
|
|
91973
|
+
return;
|
|
91974
|
+
}
|
|
91975
|
+
this._renderStage(stage, prevComponentBounds);
|
|
91976
|
+
});
|
|
91977
|
+
}
|
|
91978
|
+
return;
|
|
91979
|
+
}
|
|
91980
|
+
this._renderStage(stage, prevComponentBounds);
|
|
91981
|
+
}
|
|
91982
|
+
_renderStage(stage, prevComponentBounds) {
|
|
91983
|
+
var _a;
|
|
91984
|
+
const shouldRenderExternalCanvas = this._isTransparentExternalCanvasStage(stage);
|
|
91985
|
+
const cleared = this._clearPreviousComponents(stage, prevComponentBounds);
|
|
91986
|
+
if ((shouldRenderExternalCanvas || cleared) && '_story_needRender' in stage) {
|
|
91987
|
+
stage._story_needRender = true;
|
|
91988
|
+
}
|
|
91989
|
+
if (stage.render) {
|
|
91990
|
+
stage.render();
|
|
91991
|
+
return;
|
|
91992
|
+
}
|
|
91993
|
+
(_a = stage.renderNextFrame) === null || _a === void 0 ? void 0 : _a.call(stage);
|
|
91994
|
+
}
|
|
91995
|
+
_isTransparentExternalCanvasStage(stage) {
|
|
91996
|
+
var _a;
|
|
91997
|
+
return (stage === null || stage === void 0 ? void 0 : stage.background) === false && ((_a = stage.params) === null || _a === void 0 ? void 0 : _a.canvasControled) === false;
|
|
91998
|
+
}
|
|
91999
|
+
_clearPreviousComponents(stage, prevComponentBounds) {
|
|
92000
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
92001
|
+
if (!(prevComponentBounds === null || prevComponentBounds === void 0 ? void 0 : prevComponentBounds.length) || !this._isTransparentExternalCanvasStage(stage)) {
|
|
92002
|
+
return false;
|
|
92003
|
+
}
|
|
92004
|
+
const context = (_b = (_a = stage.window) === null || _a === void 0 ? void 0 : _a.getContext) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
92005
|
+
const nativeContext = context === null || context === void 0 ? void 0 : context.nativeContext;
|
|
92006
|
+
const matrix = (_d = (_c = stage.window) === null || _c === void 0 ? void 0 : _c.getViewBoxTransform) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
92007
|
+
if (!nativeContext ||
|
|
92008
|
+
!matrix ||
|
|
92009
|
+
!nativeContext.save ||
|
|
92010
|
+
!nativeContext.setTransform ||
|
|
92011
|
+
!nativeContext.clearRect ||
|
|
92012
|
+
!nativeContext.restore) {
|
|
92013
|
+
return false;
|
|
92014
|
+
}
|
|
92015
|
+
const dpr = (_g = (_f = (_e = stage.window) === null || _e === void 0 ? void 0 : _e.dpr) !== null && _f !== void 0 ? _f : context.dpr) !== null && _g !== void 0 ? _g : 1;
|
|
92016
|
+
const transformPoint = (x, y) => ({
|
|
92017
|
+
x: matrix.a * x + matrix.c * y + matrix.e,
|
|
92018
|
+
y: matrix.b * x + matrix.d * y + matrix.f
|
|
92019
|
+
});
|
|
92020
|
+
const padding = 8;
|
|
92021
|
+
nativeContext.save();
|
|
92022
|
+
nativeContext.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
92023
|
+
prevComponentBounds.forEach(bounds => {
|
|
92024
|
+
const p1 = transformPoint(bounds.x1, bounds.y1);
|
|
92025
|
+
const p2 = transformPoint(bounds.x1, bounds.y2);
|
|
92026
|
+
const p3 = transformPoint(bounds.x2, bounds.y1);
|
|
92027
|
+
const p4 = transformPoint(bounds.x2, bounds.y2);
|
|
92028
|
+
const x1 = Math.min(p1.x, p2.x, p3.x, p4.x) - padding;
|
|
92029
|
+
const y1 = Math.min(p1.y, p2.y, p3.y, p4.y) - padding;
|
|
92030
|
+
const x2 = Math.max(p1.x, p2.x, p3.x, p4.x) + padding;
|
|
92031
|
+
const y2 = Math.max(p1.y, p2.y, p3.y, p4.y) + padding;
|
|
92032
|
+
nativeContext.clearRect(x1, y1, x2 - x1, y2 - y1);
|
|
92033
|
+
});
|
|
92034
|
+
nativeContext.restore();
|
|
92035
|
+
return true;
|
|
92036
|
+
}
|
|
91945
92037
|
_getAxisInfoByField(field) {
|
|
91946
92038
|
var _a, _b;
|
|
91947
92039
|
const axesComponents = (_b = (_a = this._option).getComponentsByKey) === null || _b === void 0 ? void 0 : _b.call(_a, 'axes');
|
|
@@ -91967,18 +92059,20 @@
|
|
|
91967
92059
|
let y2 = -Infinity;
|
|
91968
92060
|
const { x: sx, y: sy } = this.getLayoutStartPoint();
|
|
91969
92061
|
bindingAxesIndex.forEach(idx => {
|
|
92062
|
+
var _a, _b;
|
|
91970
92063
|
(x1 = Infinity), (y1 = Infinity), (x2 = -Infinity), (y2 = -Infinity);
|
|
91971
92064
|
const axis = axesComponents.find(axis => axis.getSpecIndex() === idx);
|
|
91972
92065
|
if (!axis) {
|
|
91973
92066
|
return;
|
|
91974
92067
|
}
|
|
92068
|
+
const innerOffset = ((_b = (_a = axis).getInnerOffset) === null || _b === void 0 ? void 0 : _b.call(_a)) || { left: 0, right: 0, top: 0, bottom: 0 };
|
|
91975
92069
|
const regions = axis.getRegions();
|
|
91976
92070
|
regions.forEach(r => {
|
|
91977
92071
|
const { x: regionStartX, y: regionStartY } = r.getLayoutStartPoint();
|
|
91978
|
-
x1 = Math.min(x1, regionStartX - sx);
|
|
91979
|
-
y1 = Math.min(y1, regionStartY - sy);
|
|
91980
|
-
x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx);
|
|
91981
|
-
y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy);
|
|
92072
|
+
x1 = Math.min(x1, regionStartX - sx + innerOffset.left);
|
|
92073
|
+
y1 = Math.min(y1, regionStartY - sy + innerOffset.top);
|
|
92074
|
+
x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx - innerOffset.right);
|
|
92075
|
+
y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy - innerOffset.bottom);
|
|
91982
92076
|
});
|
|
91983
92077
|
map.set(idx, { x1, y1, x2, y2, axis: axis });
|
|
91984
92078
|
});
|
|
@@ -92170,6 +92264,27 @@
|
|
|
92170
92264
|
return res;
|
|
92171
92265
|
}, []);
|
|
92172
92266
|
}
|
|
92267
|
+
_getNeedClearVRenderComponentBounds() {
|
|
92268
|
+
return this._getNeedClearVRenderComponents().reduce((bounds, component) => {
|
|
92269
|
+
if (!component || component.attribute.visible === false) {
|
|
92270
|
+
return bounds;
|
|
92271
|
+
}
|
|
92272
|
+
const componentBounds = component.globalAABBBounds;
|
|
92273
|
+
if (componentBounds &&
|
|
92274
|
+
Number.isFinite(componentBounds.x1) &&
|
|
92275
|
+
Number.isFinite(componentBounds.y1) &&
|
|
92276
|
+
Number.isFinite(componentBounds.x2) &&
|
|
92277
|
+
Number.isFinite(componentBounds.y2)) {
|
|
92278
|
+
bounds.push({
|
|
92279
|
+
x1: componentBounds.x1,
|
|
92280
|
+
y1: componentBounds.y1,
|
|
92281
|
+
x2: componentBounds.x2,
|
|
92282
|
+
y2: componentBounds.y2
|
|
92283
|
+
});
|
|
92284
|
+
}
|
|
92285
|
+
return bounds;
|
|
92286
|
+
}, []);
|
|
92287
|
+
}
|
|
92173
92288
|
}
|
|
92174
92289
|
BaseCrossHair.specKey = 'crosshair';
|
|
92175
92290
|
|
|
@@ -92291,9 +92406,27 @@
|
|
|
92291
92406
|
var _a;
|
|
92292
92407
|
let x = relativeX;
|
|
92293
92408
|
let y = relativeY;
|
|
92409
|
+
let tooltipAxisValue;
|
|
92410
|
+
const setTooltipAxisValue = () => {
|
|
92411
|
+
if (!tooltipAxisValue) {
|
|
92412
|
+
return;
|
|
92413
|
+
}
|
|
92414
|
+
const field = isXAxis(tooltipAxisValue.axis.getOrient()) ? 'xField' : 'yField';
|
|
92415
|
+
const { currentValue } = this._stateByField[field];
|
|
92416
|
+
if (!currentValue.has(tooltipAxisValue.axis.getSpecIndex())) {
|
|
92417
|
+
currentValue.clear();
|
|
92418
|
+
}
|
|
92419
|
+
this.setAxisValue(tooltipAxisValue.value, tooltipAxisValue.axis);
|
|
92420
|
+
};
|
|
92294
92421
|
if (tooltipData && tooltipData.length) {
|
|
92295
92422
|
if (activeType === 'dimension') {
|
|
92296
92423
|
const dimensionInfo = tooltipData[0];
|
|
92424
|
+
if ((dimensionInfo === null || dimensionInfo === void 0 ? void 0 : dimensionInfo.axis) && isValid$1(dimensionInfo.value)) {
|
|
92425
|
+
tooltipAxisValue = {
|
|
92426
|
+
axis: dimensionInfo.axis,
|
|
92427
|
+
value: dimensionInfo.value
|
|
92428
|
+
};
|
|
92429
|
+
}
|
|
92297
92430
|
const datumIndex = dimensionInfo.data.findIndex(dimData => dimData.datum.length > 0);
|
|
92298
92431
|
let pos;
|
|
92299
92432
|
if (datumIndex > -1) {
|
|
@@ -92320,6 +92453,11 @@
|
|
|
92320
92453
|
this.clearAxisValue();
|
|
92321
92454
|
const { xAxisMap, yAxisMap } = this._findAllAxisContains(x, y);
|
|
92322
92455
|
if ((xAxisMap && xAxisMap.size === 0) || (yAxisMap && yAxisMap.size === 0)) {
|
|
92456
|
+
if (tooltipAxisValue) {
|
|
92457
|
+
setTooltipAxisValue();
|
|
92458
|
+
this.layoutByValue(false);
|
|
92459
|
+
return;
|
|
92460
|
+
}
|
|
92323
92461
|
if (this.enableRemain) {
|
|
92324
92462
|
return;
|
|
92325
92463
|
}
|
|
@@ -92328,6 +92466,9 @@
|
|
|
92328
92466
|
}
|
|
92329
92467
|
xAxisMap && xAxisMap.size && this._setAllAxisValues(xAxisMap, { x, y }, 'xField');
|
|
92330
92468
|
yAxisMap && yAxisMap.size && this._setAllAxisValues(yAxisMap, { x, y }, 'yField');
|
|
92469
|
+
if (tooltipAxisValue) {
|
|
92470
|
+
setTooltipAxisValue();
|
|
92471
|
+
}
|
|
92331
92472
|
this.layoutByValue();
|
|
92332
92473
|
}
|
|
92333
92474
|
layoutByValue(enableRemain) {
|