diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 06038dc61..1fd5fdf99 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -14,7 +14,7 @@ importers: '@types/react-dom': ^18.0.0 '@visactor/vchart': 1.3.0 '@visactor/vgrammar': ~0.5.7 - '@visactor/vrender': workspace:0.20.10 + '@visactor/vrender': workspace:0.20.11 '@visactor/vutils': ~0.18.17 '@vitejs/plugin-react': 3.1.0 axios: ^1.4.0 @@ -71,7 +71,7 @@ importers: '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 '@types/react-reconciler': ^0.28.2 - '@visactor/vrender': workspace:0.20.10 + '@visactor/vrender': workspace:0.20.11 '@visactor/vutils': ~0.18.17 '@vitejs/plugin-react': 3.1.0 cross-env: ^7.0.3 @@ -111,8 +111,8 @@ importers: '@rushstack/eslint-patch': ~1.1.4 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/react-vrender': workspace:0.20.10 - '@visactor/vrender': workspace:0.20.10 + '@visactor/react-vrender': workspace:0.20.11 + '@visactor/vrender': workspace:0.20.11 '@visactor/vutils': ~0.18.17 '@vitejs/plugin-react': 3.1.0 cross-env: ^7.0.3 @@ -153,8 +153,8 @@ importers: '@types/jest': ^26.0.0 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/vrender-core': workspace:0.20.10 - '@visactor/vrender-kits': workspace:0.20.10 + '@visactor/vrender-core': workspace:0.20.11 + '@visactor/vrender-kits': workspace:0.20.11 '@visactor/vutils': ~0.18.17 '@vitejs/plugin-react': 3.1.0 canvas: 2.11.2 @@ -200,8 +200,8 @@ importers: '@internal/ts-config': workspace:* '@rushstack/eslint-patch': ~1.1.4 '@types/jest': ^26.0.0 - '@visactor/vrender-core': workspace:0.20.10 - '@visactor/vrender-kits': workspace:0.20.10 + '@visactor/vrender-core': workspace:0.20.11 + '@visactor/vrender-kits': workspace:0.20.11 '@visactor/vscale': ~0.18.17 '@visactor/vutils': ~0.18.17 cross-env: ^7.0.3 @@ -287,7 +287,7 @@ importers: '@types/node-fetch': 2.6.4 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/vrender-core': workspace:0.20.10 + '@visactor/vrender-core': workspace:0.20.11 '@visactor/vutils': ~0.18.17 '@vitejs/plugin-react': 3.1.0 canvas: 2.11.2 @@ -369,10 +369,10 @@ importers: '@rushstack/eslint-patch': ~1.1.4 '@types/node': '*' '@types/node-fetch': 2.6.4 - '@visactor/vrender': workspace:0.20.10 - '@visactor/vrender-components': workspace:0.20.10 - '@visactor/vrender-core': workspace:0.20.10 - '@visactor/vrender-kits': workspace:0.20.10 + '@visactor/vrender': workspace:0.20.11 + '@visactor/vrender-components': workspace:0.20.11 + '@visactor/vrender-core': workspace:0.20.11 + '@visactor/vrender-kits': workspace:0.20.11 cross-env: ^7.0.3 eslint: ~8.18.0 form-data: ~4.0.0 diff --git a/common/config/rush/version-policies.json b/common/config/rush/version-policies.json index d5b6d4a32..0223edc10 100644 --- a/common/config/rush/version-policies.json +++ b/common/config/rush/version-policies.json @@ -1 +1 @@ -[{"definitionName":"lockStepVersion","policyName":"vrenderMain","version":"0.20.10","nextBump":"patch"}] +[{"definitionName":"lockStepVersion","policyName":"vrenderMain","version":"0.20.11","nextBump":"patch"}] diff --git a/docs/assets/changelog/en/changelog.md b/docs/assets/changelog/en/changelog.md index 830f86df4..80551945f 100644 --- a/docs/assets/changelog/en/changelog.md +++ b/docs/assets/changelog/en/changelog.md @@ -1,3 +1,21 @@ +# v0.20.10 + +2024-10-25 + + +**🆕 New feature** + +- **@visactor/vrender-core**: support fillStrokeOrder, closed [#1505](https://github.com/VisActor/VRender/issues/1505) + +**🐛 Bug fix** + +- **@visactor/vrender-core**: fix issue with parse m where multi pos follow, closed [#1490](https://github.com/VisActor/VRender/issues/1490) +- **@visactor/vrender-core**: fix the accuracy issue of number matching, closed [#1488](https://github.com/VisActor/VRender/issues/1488) + + + +[more detail about v0.20.10](https://github.com/VisActor/VRender/releases/tag/v0.20.10) + # v0.20.9 2024-10-15 diff --git a/docs/assets/changelog/zh/changelog.md b/docs/assets/changelog/zh/changelog.md index 628510c06..8119575d7 100644 --- a/docs/assets/changelog/zh/changelog.md +++ b/docs/assets/changelog/zh/changelog.md @@ -1,3 +1,21 @@ +# v0.20.10 + +2024-10-25 + + +**🆕 新增功能** + +- **@visactor/vrender-core**: support fillStrokeOrder, closed [#1505](https://github.com/VisActor/VRender/issues/1505) + +**🐛 功能修复** + +- **@visactor/vrender-core**: fix issue with parse m where multi pos follow, closed [#1490](https://github.com/VisActor/VRender/issues/1490) +- **@visactor/vrender-core**: fix the accuracy issue of number matching, closed [#1488](https://github.com/VisActor/VRender/issues/1488) + + + +[更多详情请查看 v0.20.10](https://github.com/VisActor/VRender/releases/tag/v0.20.10) + # v0.20.9 2024-10-15 diff --git a/docs/package.json b/docs/package.json index 0409ac301..5988d5651 100644 --- a/docs/package.json +++ b/docs/package.json @@ -13,7 +13,7 @@ "@visactor/vchart": "1.3.0", "@visactor/vutils": "~0.18.17", "@visactor/vgrammar": "~0.5.7", - "@visactor/vrender": "workspace:0.20.10", + "@visactor/vrender": "workspace:0.20.11", "markdown-it": "^13.0.0", "highlight.js": "^11.8.0", "axios": "^1.4.0", diff --git a/packages/react-vrender-utils/CHANGELOG.json b/packages/react-vrender-utils/CHANGELOG.json index c354be9ae..a180c9b29 100644 --- a/packages/react-vrender-utils/CHANGELOG.json +++ b/packages/react-vrender-utils/CHANGELOG.json @@ -1,6 +1,12 @@ { "name": "@visactor/react-vrender-utils", "entries": [ + { + "version": "0.20.11", + "tag": "@visactor/react-vrender-utils_v0.20.11", + "date": "Wed, 30 Oct 2024 13:10:03 GMT", + "comments": {} + }, { "version": "0.20.10", "tag": "@visactor/react-vrender-utils_v0.20.10", diff --git a/packages/react-vrender-utils/CHANGELOG.md b/packages/react-vrender-utils/CHANGELOG.md index ec5e36bf0..f46f81eec 100644 --- a/packages/react-vrender-utils/CHANGELOG.md +++ b/packages/react-vrender-utils/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @visactor/react-vrender-utils -This log was last generated on Wed, 23 Oct 2024 08:37:33 GMT and should not be manually modified. +This log was last generated on Wed, 30 Oct 2024 13:10:03 GMT and should not be manually modified. + +## 0.20.11 +Wed, 30 Oct 2024 13:10:03 GMT + +_Version update only_ ## 0.20.10 Wed, 23 Oct 2024 08:37:33 GMT diff --git a/packages/react-vrender-utils/package.json b/packages/react-vrender-utils/package.json index cb94cf187..c9f365c34 100644 --- a/packages/react-vrender-utils/package.json +++ b/packages/react-vrender-utils/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/react-vrender-utils", - "version": "0.20.10", + "version": "0.20.11", "description": "", "sideEffects": false, "main": "cjs/index.js", @@ -24,8 +24,8 @@ "react-dom": "^18.2.0" }, "dependencies": { - "@visactor/vrender": "workspace:0.20.10", - "@visactor/react-vrender": "workspace:0.20.10", + "@visactor/vrender": "workspace:0.20.11", + "@visactor/react-vrender": "workspace:0.20.11", "@visactor/vutils": "~0.18.17", "react-reconciler": "^0.29.0", "tslib": "^2.3.1" diff --git a/packages/react-vrender/CHANGELOG.json b/packages/react-vrender/CHANGELOG.json index f7ecfed18..4b3a0d8a5 100644 --- a/packages/react-vrender/CHANGELOG.json +++ b/packages/react-vrender/CHANGELOG.json @@ -1,6 +1,12 @@ { "name": "@visactor/react-vrender", "entries": [ + { + "version": "0.20.11", + "tag": "@visactor/react-vrender_v0.20.11", + "date": "Wed, 30 Oct 2024 13:10:03 GMT", + "comments": {} + }, { "version": "0.20.10", "tag": "@visactor/react-vrender_v0.20.10", diff --git a/packages/react-vrender/CHANGELOG.md b/packages/react-vrender/CHANGELOG.md index 9448844bb..f9bc4a83d 100644 --- a/packages/react-vrender/CHANGELOG.md +++ b/packages/react-vrender/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @visactor/react-vrender -This log was last generated on Wed, 23 Oct 2024 08:37:33 GMT and should not be manually modified. +This log was last generated on Wed, 30 Oct 2024 13:10:03 GMT and should not be manually modified. + +## 0.20.11 +Wed, 30 Oct 2024 13:10:03 GMT + +_Version update only_ ## 0.20.10 Wed, 23 Oct 2024 08:37:33 GMT diff --git a/packages/react-vrender/package.json b/packages/react-vrender/package.json index 3b90ce5e1..543f41591 100644 --- a/packages/react-vrender/package.json +++ b/packages/react-vrender/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/react-vrender", - "version": "0.20.10", + "version": "0.20.11", "description": "", "sideEffects": false, "main": "cjs/index.js", @@ -23,7 +23,7 @@ "react": "^18.2.0" }, "dependencies": { - "@visactor/vrender": "workspace:0.20.10", + "@visactor/vrender": "workspace:0.20.11", "@visactor/vutils": "~0.18.17", "react-reconciler": "^0.29.0", "tslib": "^2.3.1" diff --git a/packages/vrender-components/CHANGELOG.json b/packages/vrender-components/CHANGELOG.json index c723e26e6..46d80b719 100644 --- a/packages/vrender-components/CHANGELOG.json +++ b/packages/vrender-components/CHANGELOG.json @@ -1,6 +1,24 @@ { "name": "@visactor/vrender-components", "entries": [ + { + "version": "0.20.11", + "tag": "@visactor/vrender-components_v0.20.11", + "date": "Wed, 30 Oct 2024 13:10:03 GMT", + "comments": { + "none": [ + { + "comment": "fix: optimize limit length calculation for line axis label autoWrap" + }, + { + "comment": "fix: fix bounds of circle axis\n\n" + }, + { + "comment": "fix: last page is empty in legend. fix@VisActor/VChart#3344" + } + ] + } + }, { "version": "0.20.10", "tag": "@visactor/vrender-components_v0.20.10", diff --git a/packages/vrender-components/CHANGELOG.md b/packages/vrender-components/CHANGELOG.md index 3dd5e99a2..d0e3e202b 100644 --- a/packages/vrender-components/CHANGELOG.md +++ b/packages/vrender-components/CHANGELOG.md @@ -1,6 +1,17 @@ # Change Log - @visactor/vrender-components -This log was last generated on Wed, 23 Oct 2024 08:37:33 GMT and should not be manually modified. +This log was last generated on Wed, 30 Oct 2024 13:10:03 GMT and should not be manually modified. + +## 0.20.11 +Wed, 30 Oct 2024 13:10:03 GMT + +### Updates + +- fix: optimize limit length calculation for line axis label autoWrap +- fix: fix bounds of circle axis + + +- fix: last page is empty in legend. fix@VisActor/VChart#3344 ## 0.20.10 Wed, 23 Oct 2024 08:37:33 GMT diff --git a/packages/vrender-components/package.json b/packages/vrender-components/package.json index 0fbba3785..6c4650cf6 100644 --- a/packages/vrender-components/package.json +++ b/packages/vrender-components/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vrender-components", - "version": "0.20.10", + "version": "0.20.11", "description": "components library for dp visualization", "sideEffects": false, "main": "cjs/index.js", @@ -26,8 +26,8 @@ "dependencies": { "@visactor/vutils": "~0.18.17", "@visactor/vscale": "~0.18.17", - "@visactor/vrender-core": "workspace:0.20.10", - "@visactor/vrender-kits": "workspace:0.20.10" + "@visactor/vrender-core": "workspace:0.20.11", + "@visactor/vrender-kits": "workspace:0.20.11" }, "devDependencies": { "@internal/bundler": "workspace:*", diff --git a/packages/vrender-components/src/axis/circle.ts b/packages/vrender-components/src/axis/circle.ts index 4f2944558..d6e7d5e72 100644 --- a/packages/vrender-components/src/axis/circle.ts +++ b/packages/vrender-components/src/axis/circle.ts @@ -20,7 +20,7 @@ import { AxisBase } from './base'; import { DEFAULT_AXIS_THEME } from './config'; import { AXIS_ELEMENT_NAME, DEFAULT_STATES } from './constant'; import { CircleAxisMixin } from './mixin/circle'; -import { getCircleLabelPosition, getCirclePoints, getPolygonPath } from './util'; +import { getCirclePoints, getPolygonPath } from './util'; import type { ComponentOptions } from '../interface'; import { loadCircleAxisComponent } from './register'; import { autoHide as autoHideFunc } from './overlap/auto-hide'; @@ -216,22 +216,21 @@ export class CircleAxis extends AxisBase { return; } - const { inside, radius, center, width, height, label, orient } = this.attribute; + const { inside, radius, center, size, label, orient } = this.attribute; // 宽高为0的异常情况,还是以圆心进行布局 - const bounds = - width && height - ? { - x1: 0, - y1: 0, - x2: width, - y2: height - } - : { - x1: center.x - radius, - y1: center.y - radius, - x2: center.x + radius, - y2: center.y + radius - }; + const bounds = size + ? { + x1: 0, + y1: 0, + x2: size.width, + y2: size.height + } + : { + x1: center.x - radius, + y1: center.y - radius, + x2: center.x + radius, + y2: center.y + radius + }; const { layoutFunc, autoLimit, limitEllipsis, autoHide, autoHideMethod, autoHideSeparation, autoWrap } = label; if (isFunction(layoutFunc)) { diff --git a/packages/vrender-components/src/axis/overlap/auto-limit.ts b/packages/vrender-components/src/axis/overlap/auto-limit.ts index 8796a4bc7..ff1b4d00d 100644 --- a/packages/vrender-components/src/axis/overlap/auto-limit.ts +++ b/packages/vrender-components/src/axis/overlap/auto-limit.ts @@ -39,21 +39,28 @@ export function autoLimit(labels: IText[], config: LimitConfig) { if (isEmpty(labels) || !isValidNumber(limitLength)) { return; } - const DELTA = Math.sin(Math.PI / 10); - const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength); + // 注意:自动隐藏算法暂时只考虑所有标签角度都一致的情况 + const firstLabel = labels[0]; + const angle = firstLabel.attribute.angle; + const hasAngle = !isNil(angle); + const cos = hasAngle ? Math.cos(angle) : 1; + const sin = hasAngle ? Math.sin(angle) : 0; + const isHorizontal = isAngleHorizontal(angle); + const isVertical = isAngleVertical(angle); + const isX = orient === 'top' || orient === 'bottom'; + const direction = firstLabel.attribute.direction; + // 判断有长度差异的阀值 + const THRESHOLD = 2; + const checkBox = + !isHorizontal && + !isVertical && + isX && + (labels.length < 2 || + labels.some(label => Math.abs(label.AABBBounds.width() - firstLabel.AABBBounds.width()) >= THRESHOLD)) && + firstLabel.AABBBounds.width() > Math.abs(limitLength / sin); labels.forEach(label => { - const angle = label.attribute.angle; - - const hasAngle = !isNil(angle); - const cos = hasAngle ? Math.cos(angle) : 1; - const sin = hasAngle ? Math.sin(angle) : 0; - const isHorizontal = isAngleHorizontal(angle); - const isVertical = isAngleVertical(angle); - - const isX = orient === 'top' || orient === 'bottom'; - if (isX) { if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) { return; @@ -63,7 +70,6 @@ export function autoLimit(labels: IText[], config: LimitConfig) { } } - const direction = label.attribute.direction; if (!isX) { if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) { return; @@ -87,13 +93,24 @@ export function autoLimit(labels: IText[], config: LimitConfig) { const { x1, x2 } = label.AABBBounds; const tan = sin / cos; const verticalSizeLimit = Math.abs(limitLength / sin); - if (tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength) { + + if ( + checkBox && + tan > 0 && + x1 <= axisLength + overflowLimitLength.right && + limitLength / tan + x1 > axisLength + overflowLimitLength.right + ) { // 以 x1 近似为锚点,文字在 x1 右侧 - const lengthLimit = (axisLength - x1) / Math.abs(cos) + overflowLimitLength.right; + const lengthLimit = (axisLength - x1 + overflowLimitLength.right) / Math.abs(cos); limitLabelLength = Math.min(lengthLimit, verticalSizeLimit); - } else if (tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0) { + } else if ( + checkBox && + tan < 0 && + x2 >= -overflowLimitLength.left && + limitLength / tan + x2 < -overflowLimitLength.left + ) { // 以 x2 近似为锚点,文字在 x2 左侧 - const lengthLimit = x2 / Math.abs(cos) + overflowLimitLength.left; + const lengthLimit = (x2 + overflowLimitLength.left) / Math.abs(cos); limitLabelLength = Math.min(lengthLimit, verticalSizeLimit); } else { limitLabelLength = verticalSizeLimit; diff --git a/packages/vrender-components/src/axis/overlap/auto-wrap.ts b/packages/vrender-components/src/axis/overlap/auto-wrap.ts index 48efeb193..85a6bad77 100644 --- a/packages/vrender-components/src/axis/overlap/auto-wrap.ts +++ b/packages/vrender-components/src/axis/overlap/auto-wrap.ts @@ -1,5 +1,5 @@ import type { IText } from '@visactor/vrender-core'; -import { isEmpty, isValidNumber } from '@visactor/vutils'; +import { isEmpty, isValidNumber, min } from '@visactor/vutils'; import { isAngleHorizontal, isAngleVertical } from './util'; type WrapConfig = { @@ -15,25 +15,38 @@ export function autoWrap(labels: IText[], config: WrapConfig) { return; } - const verticalLimitLength = axisLength / labels.length; + // 注意:自动换行算法暂时只考虑所有标签角度都一致的情况 + const firstLabel = labels[0]; + const angle = firstLabel.attribute.angle; + const isHorizontal = isAngleHorizontal(angle); + const isVertical = isAngleVertical(angle); + const isX = orient === 'top' || orient === 'bottom'; - labels.forEach(label => { - const angle = label.attribute.angle; - - const isHorizontal = isAngleHorizontal(angle); - const isVertical = isAngleVertical(angle); - const isX = orient === 'top' || orient === 'bottom'; + let verticalLimitLength = axisLength / labels.length; + labels.forEach((label, index) => { if (isX) { if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) { return; } - if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) { - return; + if (isHorizontal) { + const curLabelX = label.attribute.x; + const nextLabelX = labels[index + 1]?.attribute.x; + const lastLabelX = labels[index - 1]?.attribute.x; + const minGap = getLabelMinGap(curLabelX, nextLabelX, lastLabelX); + if (isValidNumber(minGap)) { + verticalLimitLength = min(verticalLimitLength, minGap); + } } } else { - if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) { - return; + if (isVertical) { + const curLabelY = label.attribute.y; + const nextLabelY = labels[index + 1]?.attribute.y; + const lastLabelY = labels[index - 1]?.attribute.y; + const minGap = getLabelMinGap(curLabelY, nextLabelY, lastLabelY); + if (isValidNumber(minGap)) { + verticalLimitLength = min(verticalLimitLength, minGap); + } } if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) { return; @@ -60,7 +73,6 @@ export function autoWrap(labels: IText[], config: WrapConfig) { heightLimit = verticalLimitLength; } } - label.setAttributes({ maxLineWidth: limitLabelLength, ellipsis: label.attribute.ellipsis ?? ellipsis, @@ -69,3 +81,20 @@ export function autoWrap(labels: IText[], config: WrapConfig) { }); }); } + +function getLabelMinGap(current: number, next?: number, prev?: number) { + let minGap; + if (isValidNumber(next)) { + minGap = Math.abs(next - current); + } + + if (isValidNumber(prev)) { + if (isValidNumber(minGap)) { + minGap = Math.min(Math.abs(current - prev), minGap); + } else { + minGap = Math.abs(current - prev); + } + } + + return minGap; +} diff --git a/packages/vrender-components/src/axis/type.ts b/packages/vrender-components/src/axis/type.ts index e1b76a294..a9c46a44f 100644 --- a/packages/vrender-components/src/axis/type.ts +++ b/packages/vrender-components/src/axis/type.ts @@ -226,6 +226,11 @@ export interface LineAxisAttributes extends Omit { } export interface CircleAxisAttributes extends AxisBaseAttributes { + /** + * 坐标轴可用布局区域的大小,之前是通过width,height传入,会影响组件的Bounds大小,影响拾取 + * @since 0.20.11 + */ + size?: { width: number; height: number }; /** * 当配置了 innerRadius 时,可以通过设置 inside: true,将坐标轴战士在内圆半径上。 * @default false diff --git a/packages/vrender-components/src/legend/discrete/discrete.ts b/packages/vrender-components/src/legend/discrete/discrete.ts index d5ee1400b..540577849 100644 --- a/packages/vrender-components/src/legend/discrete/discrete.ts +++ b/packages/vrender-components/src/legend/discrete/discrete.ts @@ -1047,13 +1047,37 @@ export class DiscreteLegend extends LegendBase { } // 重新进行布局 - - (itemsContainer.getChildren() as unknown as IGroup[]).forEach((item, index) => { - const { height } = item.attribute; - - pages = Math.floor((startY + height) / contentHeight) + 1; - startY += spaceRow + (height as number); - }); + // 边界场景: 最后一项item的文字内容在倒数第二页, 但由于bounds比文字本身大一点, 触发分页, 导致最后一页是空白 + // 关联issue: https://github.com/VisActor/VChart/issues/3344 + // 解决方式: + // - 所有的item 高度一致的时候: 按照 (itemHeight + space) * 倍数 布局 + // - item高度不一致的情况: 最后一项的的高度分到最后一页的高度 >= 1/3 才分页 + const items = itemsContainer.getChildren() as IGroup[]; + const itemsHeightArr = items.map((item: IGroup) => item.attribute.height); + if (itemsHeightArr.length === 1 || itemsHeightArr.every(entry => entry === itemsHeightArr[0])) { + const itemHeight = itemsHeightArr[0]; + const maxContentHeight = contentHeight; + const pageItemsCount = Math.floor(maxContentHeight / (spaceRow + itemHeight)); + contentHeight = pageItemsCount * (spaceRow + itemHeight); + pages = Math.ceil(items.length / pageItemsCount); + } else { + items.forEach((item, index) => { + const { height } = item.attribute; + + const prePages = pages; + const preStartY = startY; + pages = Math.floor((startY + height) / contentHeight) + 1; + startY += spaceRow + (height as number); + if ( + prePages !== pages && // 触发分页 + index === itemsContainer.getChildren().length - 1 && // + startY - contentHeight >= (1 / 3) * height + ) { + contentHeight = preStartY + height; // 保证刚好完全展示最后一项 + pages -= 1; // 不分页 + } + }); + } this._itemContext.totalPage = pages; this._itemContext.pages = pages; diff --git a/packages/vrender-core/CHANGELOG.json b/packages/vrender-core/CHANGELOG.json index 9ddc2e2a6..4b6069a46 100644 --- a/packages/vrender-core/CHANGELOG.json +++ b/packages/vrender-core/CHANGELOG.json @@ -1,6 +1,21 @@ { "name": "@visactor/vrender-core", "entries": [ + { + "version": "0.20.11", + "tag": "@visactor/vrender-core_v0.20.11", + "date": "Wed, 30 Oct 2024 13:10:03 GMT", + "comments": { + "none": [ + { + "comment": "fix: fix group fill gradient #1518" + }, + { + "comment": "fix: annotate the Ramer Douglas Peucker algorithm in point optimization" + } + ] + } + }, { "version": "0.20.10", "tag": "@visactor/vrender-core_v0.20.10", diff --git a/packages/vrender-core/CHANGELOG.md b/packages/vrender-core/CHANGELOG.md index 9b75a753d..a83401208 100644 --- a/packages/vrender-core/CHANGELOG.md +++ b/packages/vrender-core/CHANGELOG.md @@ -1,6 +1,14 @@ # Change Log - @visactor/vrender-core -This log was last generated on Wed, 23 Oct 2024 08:37:33 GMT and should not be manually modified. +This log was last generated on Wed, 30 Oct 2024 13:10:03 GMT and should not be manually modified. + +## 0.20.11 +Wed, 30 Oct 2024 13:10:03 GMT + +### Updates + +- fix: fix group fill gradient #1518 +- fix: annotate the Ramer Douglas Peucker algorithm in point optimization ## 0.20.10 Wed, 23 Oct 2024 08:37:33 GMT diff --git a/packages/vrender-core/package.json b/packages/vrender-core/package.json index 7534136dc..a71e5b7f5 100644 --- a/packages/vrender-core/package.json +++ b/packages/vrender-core/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vrender-core", - "version": "0.20.10", + "version": "0.20.11", "description": "", "sideEffects": [ "./src/modules.ts", diff --git a/packages/vrender-core/src/common/simplify.ts b/packages/vrender-core/src/common/simplify.ts index 479b808eb..81fd35457 100644 --- a/packages/vrender-core/src/common/simplify.ts +++ b/packages/vrender-core/src/common/simplify.ts @@ -62,13 +62,14 @@ function simplifyDPStep( nextIdx = i; } } + if (maxSqDist > sqTolerance) { if (nextIdx - startIdx > 2) { simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified); } simplified.push(points[nextIdx], points[nextIdx + 1]); if (endIdx - nextIdx > 2) { - simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified); + simplifyDPStep(points, nextIdx + 1, endIdx, sqTolerance, simplified); } } } @@ -88,6 +89,7 @@ export function flatten_simplify(points: IPointLike[], tolerance: number, highes } const sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; points = highestQuality ? points : simplifyRadialDist(points, sqTolerance); - points = simplifyDouglasPeucker(points, sqTolerance); + // 暂时屏蔽 Douglas-Peucker 算法, 因为在极端情况下不会有点被删除, 导致性能问题 + // points = simplifyDouglasPeucker(points, sqTolerance); return points; } diff --git a/packages/vrender-core/src/render/contributions/render/group-render.ts b/packages/vrender-core/src/render/contributions/render/group-render.ts index b63ce2491..eb6655eb2 100644 --- a/packages/vrender-core/src/render/contributions/render/group-render.ts +++ b/packages/vrender-core/src/render/contributions/render/group-render.ts @@ -73,7 +73,10 @@ export class DefaultCanvasGroupRender implements IGraphicRender { path = groupAttribute.path, lineWidth = groupAttribute.lineWidth, visible = groupAttribute.visible, - fillStrokeOrder = groupAttribute.fillStrokeOrder + fillStrokeOrder = groupAttribute.fillStrokeOrder, + + x: originX = groupAttribute.x, + y: originY = groupAttribute.y } = group.attribute; // 不绘制或者透明 @@ -166,7 +169,7 @@ export class DefaultCanvasGroupRender implements IGraphicRender { if (fillCb) { fillCb(context, group.attribute, groupAttribute); } else if (fVisible) { - context.setCommonStyle(group, group.attribute, x, y, groupAttribute); + context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute); context.fill(); } } @@ -177,7 +180,7 @@ export class DefaultCanvasGroupRender implements IGraphicRender { if (strokeCb) { strokeCb(context, group.attribute, groupAttribute); } else if (sVisible) { - context.setStrokeStyle(group, group.attribute, x, y, groupAttribute); + context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute); context.stroke(); } } diff --git a/packages/vrender-kits/CHANGELOG.json b/packages/vrender-kits/CHANGELOG.json index 9d6bd8a31..6d967f89e 100644 --- a/packages/vrender-kits/CHANGELOG.json +++ b/packages/vrender-kits/CHANGELOG.json @@ -1,6 +1,12 @@ { "name": "@visactor/vrender-kits", "entries": [ + { + "version": "0.20.11", + "tag": "@visactor/vrender-kits_v0.20.11", + "date": "Wed, 30 Oct 2024 13:10:03 GMT", + "comments": {} + }, { "version": "0.20.10", "tag": "@visactor/vrender-kits_v0.20.10", diff --git a/packages/vrender-kits/CHANGELOG.md b/packages/vrender-kits/CHANGELOG.md index 09bb362b0..03ad1fa7c 100644 --- a/packages/vrender-kits/CHANGELOG.md +++ b/packages/vrender-kits/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @visactor/vrender-kits -This log was last generated on Wed, 23 Oct 2024 08:37:33 GMT and should not be manually modified. +This log was last generated on Wed, 30 Oct 2024 13:10:03 GMT and should not be manually modified. + +## 0.20.11 +Wed, 30 Oct 2024 13:10:03 GMT + +_Version update only_ ## 0.20.10 Wed, 23 Oct 2024 08:37:33 GMT diff --git a/packages/vrender-kits/package.json b/packages/vrender-kits/package.json index 4dc2af2f8..71a8f11a7 100644 --- a/packages/vrender-kits/package.json +++ b/packages/vrender-kits/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vrender-kits", - "version": "0.20.10", + "version": "0.20.11", "description": "", "sideEffects": false, "main": "cjs/index.js", @@ -21,7 +21,7 @@ }, "dependencies": { "@visactor/vutils": "~0.18.17", - "@visactor/vrender-core": "workspace:0.20.10", + "@visactor/vrender-core": "workspace:0.20.11", "@resvg/resvg-js": "2.4.1", "roughjs": "4.5.2" }, diff --git a/packages/vrender/CHANGELOG.json b/packages/vrender/CHANGELOG.json index 5176ad52d..e65c292f1 100644 --- a/packages/vrender/CHANGELOG.json +++ b/packages/vrender/CHANGELOG.json @@ -1,6 +1,12 @@ { "name": "@visactor/vrender", "entries": [ + { + "version": "0.20.11", + "tag": "@visactor/vrender_v0.20.11", + "date": "Wed, 30 Oct 2024 13:10:03 GMT", + "comments": {} + }, { "version": "0.20.10", "tag": "@visactor/vrender_v0.20.10", diff --git a/packages/vrender/CHANGELOG.md b/packages/vrender/CHANGELOG.md index 041d27e94..6567893c9 100644 --- a/packages/vrender/CHANGELOG.md +++ b/packages/vrender/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @visactor/vrender -This log was last generated on Wed, 23 Oct 2024 08:37:33 GMT and should not be manually modified. +This log was last generated on Wed, 30 Oct 2024 13:10:03 GMT and should not be manually modified. + +## 0.20.11 +Wed, 30 Oct 2024 13:10:03 GMT + +_Version update only_ ## 0.20.10 Wed, 23 Oct 2024 08:37:33 GMT diff --git a/packages/vrender/package.json b/packages/vrender/package.json index 9718256b6..7f749a36c 100644 --- a/packages/vrender/package.json +++ b/packages/vrender/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vrender", - "version": "0.20.10", + "version": "0.20.11", "description": "", "sideEffects": true, "main": "cjs/index.js", @@ -24,8 +24,8 @@ "test-watch": "cross-env DEBUG_MODE=1 jest --watch" }, "dependencies": { - "@visactor/vrender-core": "workspace:0.20.10", - "@visactor/vrender-kits": "workspace:0.20.10" + "@visactor/vrender-core": "workspace:0.20.11", + "@visactor/vrender-kits": "workspace:0.20.11" }, "devDependencies": { "@internal/bundler": "workspace:*", diff --git a/tools/bugserver-trigger/package.json b/tools/bugserver-trigger/package.json index ce6bab629..fa99100b3 100644 --- a/tools/bugserver-trigger/package.json +++ b/tools/bugserver-trigger/package.json @@ -8,10 +8,10 @@ "ci": "ts-node --transpileOnly --skipProject ./scripts/trigger-test.ts" }, "dependencies": { - "@visactor/vrender": "workspace:0.20.10", - "@visactor/vrender-core": "workspace:0.20.10", - "@visactor/vrender-kits": "workspace:0.20.10", - "@visactor/vrender-components": "workspace:0.20.10" + "@visactor/vrender": "workspace:0.20.11", + "@visactor/vrender-core": "workspace:0.20.11", + "@visactor/vrender-kits": "workspace:0.20.11", + "@visactor/vrender-components": "workspace:0.20.11" }, "devDependencies": { "@rushstack/eslint-patch": "~1.1.4",