Skip to content

Commit

Permalink
feature(treemap): add custom cursor properties for treemap
Browse files Browse the repository at this point in the history
  • Loading branch information
adaelixir committed Jul 4, 2024
1 parent 369cb03 commit 01df4b0
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/chart/treemap/TreemapSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ import {
SeriesLabelOption,
DefaultEmphasisFocus,
AriaOptionMixin,
BlurScope
BlurScope,
OptionDataItemObject,
OptionDataValueNumeric,
} from '../../util/types';
import GlobalModel from '../../model/Global';
import { LayoutRect } from '../../util/layout';
Expand Down Expand Up @@ -133,8 +135,11 @@ export interface TreemapSeriesLevelOption extends TreemapSeriesVisualOption,
decal?: DecalObject[] | 'none'
}

export interface TreemapSeriesNodeItemOption extends TreemapSeriesVisualOption,
TreemapStateOption, StatesOptionMixin<TreemapStateOption, ExtraStateOption> {
export interface TreemapSeriesNodeItemOption extends
TreemapSeriesVisualOption,
TreemapStateOption,
OptionDataItemObject<OptionDataValueNumeric>,
StatesOptionMixin<TreemapStateOption, ExtraStateOption> {
id?: OptionId
name?: OptionName

Expand All @@ -144,7 +149,9 @@ export interface TreemapSeriesNodeItemOption extends TreemapSeriesVisualOption,

color?: ColorString[] | 'none'

decal?: DecalObject[] | 'none'
decal?: DecalObject[] | 'none',

cursor?:string
}

export interface TreemapSeriesOption
Expand Down Expand Up @@ -212,7 +219,7 @@ export interface TreemapSeriesOption

levels?: TreemapSeriesLevelOption[]

data?: TreemapSeriesNodeItemOption[]
data?: (OptionDataValueNumeric | OptionDataValueNumeric[] | TreemapSeriesNodeItemOption)[]
}

class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
Expand Down Expand Up @@ -362,7 +369,7 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
// Create a virtual root.
const root: TreemapSeriesNodeItemOption = {
name: option.name,
children: option.data
children: option.data.map(item => item as TreemapSeriesNodeItemOption)
};

completeTreeValue(root);
Expand Down
5 changes: 4 additions & 1 deletion src/chart/treemap/TreemapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ class TreemapView extends ChartView {
? this._rootToNode({node: node})
: this._zoomToNode({node: node});
}
});
});
}

/**
Expand Down Expand Up @@ -877,6 +877,9 @@ function renderNode(
// Only for enabling highlight/downplay.
data.setItemGraphicEl(thisNode.dataIndex, group);

const cursorStyle = nodeModel.getShallow('cursor');
cursorStyle && content.attr('cursor', cursorStyle);

enableHoverFocus(group, focusOrIndices, blurScope);
}

Expand Down
195 changes: 195 additions & 0 deletions test/treemap-cursor.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 01df4b0

Please sign in to comment.