Skip to content

Commit

Permalink
feat(treemap): add scaleLimit to limit the zooming. close apache#14599
Browse files Browse the repository at this point in the history
  • Loading branch information
p_tastyliu committed Apr 11, 2023
1 parent 57b8c97 commit 8921fec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
14 changes: 6 additions & 8 deletions src/chart/treemap/TreemapSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import SeriesData from '../../data/SeriesData';
import { normalizeToArray } from '../../util/model';
import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup';
import enableAriaDecalForTree from '../helper/enableAriaDecalForTree';
import View from '../../coord/View';

// Only support numeric value.
type TreemapSeriesDataValue = number | number[];
Expand Down Expand Up @@ -218,8 +217,6 @@ export interface TreemapSeriesOption

class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {

coordinateSystem: View;

static type = 'series.treemap';
type = TreemapSeriesModel.type;

Expand All @@ -235,6 +232,11 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
private _idIndexMap: zrUtil.HashMap<number>;
private _idIndexMapCount: number;

zoomLimit: {
max?: number;
min?: number;
};

static defaultOption: TreemapSeriesOption = {
coordinateSystem: 'view',
// Disable progressive rendering
Expand All @@ -255,7 +257,7 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {

zoomToNodeRatio: 0.32 * 0.32,

zoom: 1,
scaleLimit: null,

roam: true,
nodeClick: 'zoomToNode',
Expand Down Expand Up @@ -511,10 +513,6 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
enableAriaDecal() {
enableAriaDecalForTree(this);
}

setZoom(zoom: number) {
this.option.zoom = zoom;
}
}

/**
Expand Down
3 changes: 0 additions & 3 deletions src/chart/treemap/TreemapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,7 @@ class TreemapView extends ChartView {
controllerHost = this._controllerHost = {
target: this.group
} as RoamControllerHost;
this.seriesModel.setZoom(this.seriesModel.get('zoom'));
this.seriesModel.coordinateSystem.zoomLimit = this.seriesModel.get('scaleLimit');
controllerHost.zoomLimit = this.seriesModel.get('scaleLimit');
controllerHost.zoom = this.seriesModel.coordinateSystem.getZoom();
}

const rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight());
Expand Down

1 comment on commit 8921fec

@dannishushu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问最后这个commit被merge到echarts的rc分支了么?

Please sign in to comment.