@visactor/vchart 2.0.5-alpha.8 → 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 +106 -5
- package/build/index.js +106 -5
- package/build/index.min.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/component/crosshair/base.d.ts +5 -0
- package/cjs/component/crosshair/base.js +49 -6
- package/cjs/component/crosshair/base.js.map +1 -1
- package/esm/component/crosshair/base.d.ts +5 -0
- package/esm/component/crosshair/base.js +49 -6
- package/esm/component/crosshair/base.js.map +1 -1
- package/package.json +3 -3
package/build/index.es.js
CHANGED
|
@@ -91722,17 +91722,19 @@ class BaseCrossHair extends BaseComponent {
|
|
|
91722
91722
|
return;
|
|
91723
91723
|
}
|
|
91724
91724
|
}
|
|
91725
|
+
const prevComponentBounds = this._getNeedClearVRenderComponentBounds();
|
|
91725
91726
|
const { x, y } = this.calculateTriggerPoint(params);
|
|
91726
91727
|
this.showDefault = false;
|
|
91727
91728
|
this._layoutCrosshair(x, y, tooltipData, params.activeType);
|
|
91728
91729
|
const components = this._getNeedClearVRenderComponents();
|
|
91729
91730
|
this._hasActive = components.some(comp => comp && comp.attribute.visible !== false);
|
|
91730
|
-
this._renderNextFrame();
|
|
91731
|
+
this._renderNextFrame(prevComponentBounds);
|
|
91731
91732
|
};
|
|
91732
91733
|
this._handleTooltipHideOrRelease = () => {
|
|
91734
|
+
const prevComponentBounds = this._getNeedClearVRenderComponentBounds();
|
|
91733
91735
|
this.clearOutEvent();
|
|
91734
91736
|
this.hideCrosshair();
|
|
91735
|
-
this._renderNextFrame();
|
|
91737
|
+
this._renderNextFrame(prevComponentBounds);
|
|
91736
91738
|
};
|
|
91737
91739
|
this.enable = true;
|
|
91738
91740
|
this.showDefault = true;
|
|
@@ -91944,9 +91946,87 @@ class BaseCrossHair extends BaseComponent {
|
|
|
91944
91946
|
this.event.on(ChartEvent.tooltipShow, { source: Event_Source_Type.chart }, this._handleTooltipShow);
|
|
91945
91947
|
this.event.on(ChartEvent.tooltipRelease, { source: Event_Source_Type.chart }, this._handleTooltipHideOrRelease);
|
|
91946
91948
|
}
|
|
91947
|
-
_renderNextFrame() {
|
|
91948
|
-
var _a
|
|
91949
|
-
|
|
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;
|
|
91950
92030
|
}
|
|
91951
92031
|
_getAxisInfoByField(field) {
|
|
91952
92032
|
var _a, _b;
|
|
@@ -92178,6 +92258,27 @@ class BaseCrossHair extends BaseComponent {
|
|
|
92178
92258
|
return res;
|
|
92179
92259
|
}, []);
|
|
92180
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
|
+
}
|
|
92181
92282
|
}
|
|
92182
92283
|
BaseCrossHair.specKey = 'crosshair';
|
|
92183
92284
|
|
package/build/index.js
CHANGED
|
@@ -91728,17 +91728,19 @@
|
|
|
91728
91728
|
return;
|
|
91729
91729
|
}
|
|
91730
91730
|
}
|
|
91731
|
+
const prevComponentBounds = this._getNeedClearVRenderComponentBounds();
|
|
91731
91732
|
const { x, y } = this.calculateTriggerPoint(params);
|
|
91732
91733
|
this.showDefault = false;
|
|
91733
91734
|
this._layoutCrosshair(x, y, tooltipData, params.activeType);
|
|
91734
91735
|
const components = this._getNeedClearVRenderComponents();
|
|
91735
91736
|
this._hasActive = components.some(comp => comp && comp.attribute.visible !== false);
|
|
91736
|
-
this._renderNextFrame();
|
|
91737
|
+
this._renderNextFrame(prevComponentBounds);
|
|
91737
91738
|
};
|
|
91738
91739
|
this._handleTooltipHideOrRelease = () => {
|
|
91740
|
+
const prevComponentBounds = this._getNeedClearVRenderComponentBounds();
|
|
91739
91741
|
this.clearOutEvent();
|
|
91740
91742
|
this.hideCrosshair();
|
|
91741
|
-
this._renderNextFrame();
|
|
91743
|
+
this._renderNextFrame(prevComponentBounds);
|
|
91742
91744
|
};
|
|
91743
91745
|
this.enable = true;
|
|
91744
91746
|
this.showDefault = true;
|
|
@@ -91950,9 +91952,87 @@
|
|
|
91950
91952
|
this.event.on(exports.ChartEvent.tooltipShow, { source: Event_Source_Type.chart }, this._handleTooltipShow);
|
|
91951
91953
|
this.event.on(exports.ChartEvent.tooltipRelease, { source: Event_Source_Type.chart }, this._handleTooltipHideOrRelease);
|
|
91952
91954
|
}
|
|
91953
|
-
_renderNextFrame() {
|
|
91954
|
-
var _a
|
|
91955
|
-
|
|
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;
|
|
91956
92036
|
}
|
|
91957
92037
|
_getAxisInfoByField(field) {
|
|
91958
92038
|
var _a, _b;
|
|
@@ -92184,6 +92264,27 @@
|
|
|
92184
92264
|
return res;
|
|
92185
92265
|
}, []);
|
|
92186
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
|
+
}
|
|
92187
92288
|
}
|
|
92188
92289
|
BaseCrossHair.specKey = 'crosshair';
|
|
92189
92290
|
|