Skip to content

Commit

Permalink
add scaleLimit to treemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Hur Wang committed Sep 1, 2022
1 parent 7f3b2ba commit 5905ecf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/chart/treemap/TreemapSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
// to align specialized icon. ▷▶❒❐▼✚

zoomToNodeRatio: 0.32 * 0.32,
scaleLimit: null,

roam: true,
nodeClick: 'zoomToNode',
Expand Down
8 changes: 8 additions & 0 deletions src/chart/treemap/TreemapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class TreemapView extends ChartView {

private _storage = createStorage() as RenderElementStorage;

private _zoom = 1;;

seriesModel: TreemapSeriesModel;
api: ExtensionAPI;
ecModel: GlobalModel;
Expand Down Expand Up @@ -528,6 +530,12 @@ class TreemapView extends ChartView {
let mouseY = e.originY;

if (this._state !== 'animating') {
let newZoom = this._zoom * e.scale;
const scaleLimit = this.seriesModel.get('scaleLimit');
if (newZoom > scaleLimit.max || newZoom < scaleLimit.min) {
return;
}
this._zoom = newZoom;
// These param must not be cached.
const root = this.seriesModel.getData().tree.root;

Expand Down

0 comments on commit 5905ecf

Please sign in to comment.