Skip to content
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
6 changes: 6 additions & 0 deletions .trae/specs/add-interactInvertType-background/checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- [x] SmartInvertAttrs.interactInvertType 已包含 'background'
- [x] 相交且 'background' 时设置 label.stroke=false
- [x] 相交且 'background' 时设置 label.background=baseMark.fill(有填充时)
- [x] 其他类型(none/stroked/inside)行为无回归
- [x] 注释更新为“四种处理方式”并包含 background 描述
- [x] 示例验证通过(IText 与 IRichText 场景)
38 changes: 38 additions & 0 deletions .trae/specs/add-interactInvertType-background/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 标签相交背景模式 Spec

## Why
当前标签与 mark 相交时仅支持 none/stroked/inside 三种处理方式,无法满足关闭描边并以底层 mark 的填充色作为文字背景的视觉需求,导致相交场景下对比度与观感不可控。

## What Changes
- 在 SmartInvertAttrs.interactInvertType 中新增 'background' 选项
- 在相交场景下(label 与 mark 相交且不完全在内部),当 interactInvertType 为 'background':
- 将标签描边 stroke 设置为 false(禁用描边)
- 将标签背景 background 设置为关联 mark 的填充色
- 更新 SmartInvert 相关注释文档,将“三种处理方式”修改为“四种”,并补充 background 描述
- 默认行为不变(未配置时保持现状),无破坏性变更

## Impact
- Affected specs: 标签智能反色/相交处理能力
- Affected code:
- packages/vrender-components/src/label/type.ts(类型与注释)
- packages/vrender-components/src/label/base.ts(_smartInvert 相交分支逻辑)

## ADDED Requirements
### Requirement: 新增 interactInvertType 'background'
系统应在标签与 mark 相交且配置 interactInvertType 为 'background' 时:
- 将标签的 stroke 设为 false,关闭描边;
- 将标签的 background 颜色设置为关联 mark 的填充色(优先取 mark.attribute.fill;若缺省则不改动 background)。
- 保持标签 fill 不做变更。

#### Scenario: Success case
- WHEN 标签与 mark 相交,且 smartInvert.interactInvertType === 'background'
- THEN label.stroke === false,且 label.background === baseMark.fill(存在时)

## MODIFIED Requirements
### Requirement: 更新交互反色类型文档
将注释由“支持三种处理方式:none/stroked/inside”更新为“四种处理方式:none/stroked/inside/background”,其中:
- background:关闭描边,并以 mark 的填充色作为文本背景参与渲染。

## REMOVED Requirements

9 changes: 9 additions & 0 deletions .trae/specs/add-interactInvertType-background/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Tasks
- [x] 更新类型定义与注释:为 SmartInvertAttrs.interactInvertType 添加 'background',并改注释为“四种处理方式”
- [x] 修改 _smartInvert 相交分支:实现 'background' 行为(stroke=false;background=baseMark.fill;保持 fill 不变;跳过描边缺省早退)
- [x] 添加验证用例:构造 label 与 mark 相交示例,确认背景色与填充色一致且描边关闭(覆盖 IText 与 IRichText)
- [x] 自检与清理:校验边界(mark 无 fill、stroke 初始为数组/布尔的情况)、类型约束与代码风格

# Task Dependencies
- [修改 _smartInvert 相交分支] 依赖于 [更新类型定义与注释]
- [添加验证用例] 依赖于 [修改 _smartInvert 相交分支]
36 changes: 18 additions & 18 deletions common/config/rush/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion common/config/rush/version-policies.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"definitionName":"lockStepVersion","policyName":"vrenderMain","version":"1.0.41","nextBump":"patch"}]
[{"definitionName":"lockStepVersion","policyName":"vrenderMain","version":"1.0.42","nextBump":"patch"}]
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@visactor/vchart": "1.3.0",
"@visactor/vutils": "~1.0.12",
"@visactor/vgrammar": "~0.5.7",
"@visactor/vrender": "workspace:1.0.41",
"@visactor/vrender": "workspace:1.0.42",
"markdown-it": "^13.0.0",
"highlight.js": "^11.8.0",
"axios": "^1.4.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/react-vrender-utils/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "@visactor/react-vrender-utils",
"entries": [
{
"version": "1.0.42",
"tag": "@visactor/react-vrender-utils_v1.0.42",
"date": "Mon, 23 Mar 2026 08:08:45 GMT",
"comments": {}
},
{
"version": "1.0.41",
"tag": "@visactor/react-vrender-utils_v1.0.41",
Expand Down
7 changes: 6 additions & 1 deletion packages/react-vrender-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log - @visactor/react-vrender-utils

This log was last generated on Tue, 03 Mar 2026 11:54:26 GMT and should not be manually modified.
This log was last generated on Mon, 23 Mar 2026 08:08:45 GMT and should not be manually modified.

## 1.0.42
Mon, 23 Mar 2026 08:08:45 GMT

_Version update only_

## 1.0.41
Tue, 03 Mar 2026 11:54:26 GMT
Expand Down
6 changes: 3 additions & 3 deletions packages/react-vrender-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/react-vrender-utils",
"version": "1.0.41",
"version": "1.0.42",
"description": "",
"sideEffects": false,
"main": "cjs/index.js",
Expand All @@ -24,8 +24,8 @@
"react-dom": "^18.2.0"
},
"dependencies": {
"@visactor/vrender": "workspace:1.0.41",
"@visactor/react-vrender": "workspace:1.0.41",
"@visactor/vrender": "workspace:1.0.42",
"@visactor/react-vrender": "workspace:1.0.42",
"@visactor/vutils": "~1.0.12",
"react-reconciler": "^0.29.0",
"tslib": "^2.3.1"
Expand Down
6 changes: 6 additions & 0 deletions packages/react-vrender/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "@visactor/react-vrender",
"entries": [
{
"version": "1.0.42",
"tag": "@visactor/react-vrender_v1.0.42",
"date": "Mon, 23 Mar 2026 08:08:45 GMT",
"comments": {}
},
{
"version": "1.0.41",
"tag": "@visactor/react-vrender_v1.0.41",
Expand Down
7 changes: 6 additions & 1 deletion packages/react-vrender/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log - @visactor/react-vrender

This log was last generated on Tue, 03 Mar 2026 11:54:26 GMT and should not be manually modified.
This log was last generated on Mon, 23 Mar 2026 08:08:45 GMT and should not be manually modified.

## 1.0.42
Mon, 23 Mar 2026 08:08:45 GMT

_Version update only_

## 1.0.41
Tue, 03 Mar 2026 11:54:26 GMT
Expand Down
4 changes: 2 additions & 2 deletions packages/react-vrender/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/react-vrender",
"version": "1.0.41",
"version": "1.0.42",
"description": "",
"sideEffects": false,
"main": "cjs/index.js",
Expand All @@ -23,7 +23,7 @@
"react": "^18.2.0"
},
"dependencies": {
"@visactor/vrender": "workspace:1.0.41",
"@visactor/vrender": "workspace:1.0.42",
"@visactor/vutils": "~1.0.12",
"react-reconciler": "^0.29.0",
"tslib": "^2.3.1"
Expand Down
6 changes: 6 additions & 0 deletions packages/vrender-animate/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "@visactor/vrender-animate",
"entries": [
{
"version": "1.0.42",
"tag": "@visactor/vrender-animate_v1.0.42",
"date": "Mon, 23 Mar 2026 08:08:45 GMT",
"comments": {}
},
{
"version": "1.0.41",
"tag": "@visactor/vrender-animate_v1.0.41",
Expand Down
7 changes: 6 additions & 1 deletion packages/vrender-animate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log - @visactor/vrender-animate

This log was last generated on Tue, 03 Mar 2026 11:54:26 GMT and should not be manually modified.
This log was last generated on Mon, 23 Mar 2026 08:08:45 GMT and should not be manually modified.

## 1.0.42
Mon, 23 Mar 2026 08:08:45 GMT

_Version update only_

## 1.0.41
Tue, 03 Mar 2026 11:54:26 GMT
Expand Down
4 changes: 2 additions & 2 deletions packages/vrender-animate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/vrender-animate",
"version": "1.0.41",
"version": "1.0.42",
"description": "",
"sideEffects": false,
"main": "cjs/index.js",
Expand All @@ -21,7 +21,7 @@
},
"dependencies": {
"@visactor/vutils": "~1.0.12",
"@visactor/vrender-core": "workspace:1.0.41"
"@visactor/vrender-core": "workspace:1.0.42"
},
"devDependencies": {
"@internal/bundler": "workspace:*",
Expand Down
6 changes: 6 additions & 0 deletions packages/vrender-components/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "@visactor/vrender-components",
"entries": [
{
"version": "1.0.42",
"tag": "@visactor/vrender-components_v1.0.42",
"date": "Mon, 23 Mar 2026 08:08:45 GMT",
"comments": {}
},
{
"version": "1.0.41",
"tag": "@visactor/vrender-components_v1.0.41",
Expand Down
7 changes: 6 additions & 1 deletion packages/vrender-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log - @visactor/vrender-components

This log was last generated on Tue, 03 Mar 2026 11:54:26 GMT and should not be manually modified.
This log was last generated on Mon, 23 Mar 2026 08:08:45 GMT and should not be manually modified.

## 1.0.42
Mon, 23 Mar 2026 08:08:45 GMT

_Version update only_

## 1.0.41
Tue, 03 Mar 2026 11:54:26 GMT
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import '@visactor/vrender';
import { createRect } from '@visactor/vrender';
import { createRenderer } from '../../util/render';
import { RectLabel } from '../../../src';

export const run = () => {
const stage = createRenderer('main');

const rect = createRect({
x: 180,
y: 180,
width: 160,
height: 100,
fill: '#2E62F1'
});
stage.defaultLayer.add(rect);

const label = new RectLabel({
data: [{ text: 'Intersect Background' }],
// 放置在图形边缘附近以制造相交(根据文本尺寸可能略有不同)
position: 'top',
offset: -10,
textStyle: {
fill: '#000',
stroke: '#fff',
lineWidth: 1
},
smartInvert: {
interactInvertType: 'background'
}
});

// 关联 label 到 rect
// @ts-ignore
label.setRelatedGraphic(rect);
stage.defaultLayer.add(label);

stage.render();

// 输出验证信息
// eslint-disable-next-line no-console
console.log('label.stroke:', label.attribute?.stroke);
// eslint-disable-next-line no-console
console.log('label.background:', label.attribute?.background);
};
4 changes: 4 additions & 0 deletions packages/vrender-components/__tests__/browser/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ const specs = [
path: 'label-smart-inverse',
name: '标签智能反色'
},
{
path: 'label-smart-inverse-background',
name: '标签相交背景模式'
},
{
path: 'scrollbar',
name: '滚动条'
Expand Down
Loading
Loading