Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "feat: scrollbar support auto visible. close #3972",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
minInArray,
maxInArray,
abs,
last
last,
throttle
} from '@visactor/vutils';
// eslint-disable-next-line no-duplicate-imports
import type { IFilterMode } from './interface';
Expand Down Expand Up @@ -64,6 +65,8 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
protected _orient: IOrientType = 'left';
protected _isHorizontal: boolean;

protected _throttledHide: () => void;

// 是否为自动模式
protected _auto?: boolean;
protected _fixedBandSize?: number;
Expand Down Expand Up @@ -448,25 +451,25 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
s.coordinate === 'cartesian'
? (s as ICartesianSeries).getXAxisHelper()
: s.coordinate === 'polar'
? (s as IPolarSeries).angleAxisHelper
: null;
? (s as IPolarSeries).angleAxisHelper
: null;
const yAxisHelper =
s.coordinate === 'cartesian'
? (s as ICartesianSeries).getYAxisHelper()
: s.coordinate === 'polar'
? (s as IPolarSeries).radiusAxisHelper
: null;
? (s as IPolarSeries).radiusAxisHelper
: null;
if (!xAxisHelper || !yAxisHelper) {
return;
}
const stateAxisHelper =
xAxisHelper.getAxisId() === this._relatedAxisComponent.id
? xAxisHelper
: yAxisHelper.getAxisId() === this._relatedAxisComponent.id
? yAxisHelper
: this._isHorizontal
? xAxisHelper
: yAxisHelper;
? yAxisHelper
: this._isHorizontal
? xAxisHelper
: yAxisHelper;
const valueAxisHelper = stateAxisHelper === xAxisHelper ? yAxisHelper : xAxisHelper;

dataCollection.push(s.getRawData());
Expand Down Expand Up @@ -642,8 +645,8 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
start = this._spec.start
? this._spec.start
: this._spec.startValue
? this.dataToStatePoint(this._spec.startValue)
: 0;
? this.dataToStatePoint(this._spec.startValue)
: 0;
end = this._spec.end ? this._spec.end : this._spec.endValue ? this.dataToStatePoint(this._spec.endValue) : 1;
}
this._startValue = this.statePointToData(start);
Expand Down Expand Up @@ -862,6 +865,9 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
if (!this._activeRoam || (this._dragAttr.filter && !this._dragAttr.filter(delta, e))) {
return;
}
if ((this._spec.roamDrag as IRoamDragSpec)?.autoVisible) {
this.show();
}
const [dx, dy] = delta;
let value = this._isHorizontal ? dx : dy;
if (this._dragAttr.reverse) {
Expand All @@ -886,7 +892,7 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec

protected _initCommonEvent() {
const delayType: IDelayType = this._spec?.delayType ?? 'throttle';
const delayTime = isValid(this._spec?.delayType) ? this._spec?.delayTime ?? 30 : 0;
const delayTime = isValid(this._spec?.delayType) ? (this._spec?.delayTime ?? 30) : 0;
const realTime = this._spec?.realTime ?? true;
const option = { delayType, delayTime, realTime, allowComponentZoom: true };
if (this._zoomAttr.enable) {
Expand All @@ -898,6 +904,13 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
if (this._dragAttr.enable) {
(this as unknown as IZoomable).initDragEventOfRegions(this._regions, null, this._handleChartDrag, option);
}
if ((this._spec.roamDrag as IRoamDragSpec)?.autoVisible) {
const dragEnd = 'panend';
this._throttledHide = throttle(() => this.hide(), 300);
this.event.on(dragEnd, () => {
this._throttledHide();
});
}
}

updateLayoutAttribute(): void {
Expand Down Expand Up @@ -1038,6 +1051,10 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
protected _getNeedClearVRenderComponents(): IGraphic[] {
return [this._component] as unknown as IGroup[];
}

clear(): void {
this._throttledHide = null;
}
}

mixin(DataFilterBaseComponent, Zoomable);
5 changes: 5 additions & 0 deletions packages/vchart/src/component/data-zoom/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ export interface IRoamDragSpec extends IRoamSpec {
* @returns
*/
filter?: (delta: [number, number], e?: BaseEventParams['event']) => boolean;
/**
* 仅在画布交互展示组件
* @since 2.0.3
*/
autoVisible?: boolean;
}

export interface IRoamScrollSpec extends IRoamSpec {
Expand Down
Loading