Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(treemap): add custom cursor properties for treemap #20113

Merged
merged 6 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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
adaelixir marked this conversation as resolved.
Show resolved Hide resolved
}

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)
adaelixir marked this conversation as resolved.
Show resolved Hide resolved
};

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
193 changes: 193 additions & 0 deletions test/treemap-cursor.html

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