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

feat: support overflow of mark #578

Merged
merged 2 commits into from
Nov 20, 2024
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,11 @@
{
"changes": [
{
"comment": "feat: support overflow of mark\n\n",
"type": "none",
"packageName": "@visactor/vgrammar-core"
}
],
"packageName": "@visactor/vgrammar-core",
"email": "[email protected]"
}
1 change: 1 addition & 0 deletions packages/vgrammar-core/src/types/mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export interface IMarkConfig {
* set graphic name
*/
graphicName?: string | ((element: IElement) => string);
overflow?: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';
}

/**
Expand Down
14 changes: 12 additions & 2 deletions packages/vgrammar-core/src/view/mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ export class Mark extends GrammarBase implements IMark {
'skipTheme',
'enableSegments',
'stateSort',
'graphicName'
'graphicName',
'overflow'
];
if (config === null) {
keys.forEach(key => {
Expand Down Expand Up @@ -637,7 +638,8 @@ export class Mark extends GrammarBase implements IMark {
if (!this.graphicItem) {
const graphicItem = createGraphicItem(this, GrammarMarkType.group, {
pickable: false,
zIndex: this.spec.zIndex ?? 0
zIndex: this.spec.zIndex ?? 0,
overflow: this.spec.overflow
}) as IGroup;
if (this.spec.support3d || (Mark3DType as string[]).includes(this.markType)) {
graphicItem.setMode('3d');
Expand All @@ -651,6 +653,10 @@ export class Mark extends GrammarBase implements IMark {
}
} else {
this.graphicParent = groupGraphicItem;

this.graphicParent.setAttributes({
overflow: this.spec.overflow
});
}
this.graphicIndex = markIndex;
}
Expand Down Expand Up @@ -684,6 +690,10 @@ export class Mark extends GrammarBase implements IMark {
}
}

if (!isNil(spec.overflow)) {
this.graphicItem.setAttribute('overflow', spec.overflow);
}

// only update interactive
this.elementMap.forEach(element => {
element.updateGraphicItem();
Expand Down
Loading