diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 77b7b99d7..6c7e0ea79 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -14,8 +14,8 @@ importers: '@types/react-dom': ^18.0.0 '@visactor/vchart': 1.3.0 '@visactor/vgrammar': ~0.5.7 - '@visactor/vrender': workspace:0.20.4 - '@visactor/vutils': ~0.18.15 + '@visactor/vrender': workspace:0.20.5 + '@visactor/vutils': ~0.18.16 '@vitejs/plugin-react': 3.1.0 axios: ^1.4.0 chalk: ^3.0.0 @@ -38,7 +38,7 @@ importers: '@visactor/vchart': 1.3.0 '@visactor/vgrammar': 0.5.7 '@visactor/vrender': link:../packages/vrender - '@visactor/vutils': 0.18.15 + '@visactor/vutils': 0.18.16 axios: 1.7.4 highlight.js: 11.10.0 lodash: 4.17.21 @@ -71,8 +71,8 @@ importers: '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 '@types/react-reconciler': ^0.28.2 - '@visactor/vrender': workspace:0.20.4 - '@visactor/vutils': ~0.18.15 + '@visactor/vrender': workspace:0.20.5 + '@visactor/vutils': ~0.18.16 '@vitejs/plugin-react': 3.1.0 cross-env: ^7.0.3 eslint: ~8.18.0 @@ -84,7 +84,7 @@ importers: vite: 3.2.6 dependencies: '@visactor/vrender': link:../vrender - '@visactor/vutils': 0.18.15 + '@visactor/vutils': 0.18.16 react-reconciler: 0.29.2_react@18.3.1 tslib: 2.6.3 devDependencies: @@ -111,9 +111,9 @@ importers: '@rushstack/eslint-patch': ~1.1.4 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/react-vrender': workspace:0.20.4 - '@visactor/vrender': workspace:0.20.4 - '@visactor/vutils': ~0.18.15 + '@visactor/react-vrender': workspace:0.20.5 + '@visactor/vrender': workspace:0.20.5 + '@visactor/vutils': ~0.18.16 '@vitejs/plugin-react': 3.1.0 cross-env: ^7.0.3 eslint: ~8.18.0 @@ -126,7 +126,7 @@ importers: dependencies: '@visactor/react-vrender': link:../react-vrender '@visactor/vrender': link:../vrender - '@visactor/vutils': 0.18.15 + '@visactor/vutils': 0.18.16 react-reconciler: 0.29.2_react@18.3.1 tslib: 2.6.3 devDependencies: @@ -153,9 +153,9 @@ importers: '@types/jest': ^26.0.0 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/vrender-core': workspace:0.20.4 - '@visactor/vrender-kits': workspace:0.20.4 - '@visactor/vutils': ~0.18.15 + '@visactor/vrender-core': workspace:0.20.5 + '@visactor/vrender-kits': workspace:0.20.5 + '@visactor/vutils': ~0.18.16 '@vitejs/plugin-react': 3.1.0 canvas: 2.11.2 cross-env: ^7.0.3 @@ -179,7 +179,7 @@ importers: '@types/jest': 26.0.24 '@types/react': 18.3.3 '@types/react-dom': 18.3.0 - '@visactor/vutils': 0.18.15 + '@visactor/vutils': 0.18.16 '@vitejs/plugin-react': 3.1.0_vite@3.2.6 canvas: 2.11.2 cross-env: 7.0.3 @@ -200,10 +200,10 @@ importers: '@internal/ts-config': workspace:* '@rushstack/eslint-patch': ~1.1.4 '@types/jest': ^26.0.0 - '@visactor/vrender-core': workspace:0.20.4 - '@visactor/vrender-kits': workspace:0.20.4 - '@visactor/vscale': ~0.18.15 - '@visactor/vutils': ~0.18.15 + '@visactor/vrender-core': workspace:0.20.5 + '@visactor/vrender-kits': workspace:0.20.5 + '@visactor/vscale': ~0.18.16 + '@visactor/vutils': ~0.18.16 cross-env: ^7.0.3 eslint: ~8.18.0 jest: ^26.0.0 @@ -215,8 +215,8 @@ importers: dependencies: '@visactor/vrender-core': link:../vrender-core '@visactor/vrender-kits': link:../vrender-kits - '@visactor/vscale': 0.18.15 - '@visactor/vutils': 0.18.15 + '@visactor/vscale': 0.18.16 + '@visactor/vutils': 0.18.16 devDependencies: '@internal/bundler': link:../../tools/bundler '@internal/eslint-config': link:../../share/eslint-config @@ -241,7 +241,7 @@ importers: '@types/jest': ^26.0.0 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/vutils': ~0.18.15 + '@visactor/vutils': ~0.18.16 '@vitejs/plugin-react': 3.1.0 color-convert: 2.0.1 cross-env: ^7.0.3 @@ -255,7 +255,7 @@ importers: typescript: 4.9.5 vite: 3.2.6 dependencies: - '@visactor/vutils': 0.18.15 + '@visactor/vutils': 0.18.16 color-convert: 2.0.1 devDependencies: '@internal/bundler': link:../../tools/bundler @@ -287,8 +287,8 @@ importers: '@types/node-fetch': 2.6.4 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/vrender-core': workspace:0.20.4 - '@visactor/vutils': ~0.18.15 + '@visactor/vrender-core': workspace:0.20.5 + '@visactor/vutils': ~0.18.16 '@vitejs/plugin-react': 3.1.0 canvas: 2.11.2 cross-env: ^7.0.3 @@ -302,7 +302,7 @@ importers: dependencies: '@resvg/resvg-js': 2.4.1 '@visactor/vrender-core': link:../vrender-core - '@visactor/vutils': 0.18.15 + '@visactor/vutils': 0.18.16 roughjs: 4.5.2 devDependencies: '@internal/bundler': link:../../tools/bundler @@ -369,10 +369,10 @@ importers: '@rushstack/eslint-patch': ~1.1.4 '@types/node': '*' '@types/node-fetch': 2.6.4 - '@visactor/vrender': workspace:0.20.4 - '@visactor/vrender-components': workspace:0.20.4 - '@visactor/vrender-core': workspace:0.20.4 - '@visactor/vrender-kits': workspace:0.20.4 + '@visactor/vrender': workspace:0.20.5 + '@visactor/vrender-components': workspace:0.20.5 + '@visactor/vrender-core': workspace:0.20.5 + '@visactor/vrender-kits': workspace:0.20.5 cross-env: ^7.0.3 eslint: ~8.18.0 form-data: ~4.0.0 @@ -3422,10 +3422,10 @@ packages: '@visactor/vutils': 0.15.14 dev: false - /@visactor/vscale/0.18.15: - resolution: {integrity: sha512-09dDWc6muJbOMxzp4odCsyLjqAF6u3BOx9kAJJ0tEpKE1AuHL4BTejNe697mJAnXqAo2ynAA+dn+cgWYiW1WQg==} + /@visactor/vscale/0.18.16: + resolution: {integrity: sha512-iOMo7dHoImlRntHdSLVbx4dgyGQ7SCSeOHoA5Re7rDmC23h8Tsb9n5sP8l6DRYq/Xzuq0yAbR80iizmNZnnlWw==} dependencies: - '@visactor/vutils': 0.18.15 + '@visactor/vutils': 0.18.16 dev: false /@visactor/vutils/0.13.3: @@ -3444,8 +3444,8 @@ packages: eventemitter3: 4.0.7 dev: false - /@visactor/vutils/0.18.15: - resolution: {integrity: sha512-gTw8n14SU4avmqZ6VwpHwqoDfOCq044M2QA43rViNaHBnOQ/ePOPRZHl0heSfGQoMIJSZUD7SowLnn5NJjVXYw==} + /@visactor/vutils/0.18.16: + resolution: {integrity: sha512-F2QZVtnc47L1jXyz9o5bEeadIwgdPfoQy6gxE+n6bPJfKZHq3YKp0B5ase9+m2sKNBCrHYc2q9k5lRtp8h/TAQ==} dependencies: '@turf/helpers': 6.5.0 '@turf/invariant': 6.5.0 @@ -6205,7 +6205,7 @@ packages: resolution: {integrity: sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==} engines: {node: '>= 4.0'} os: [darwin] - deprecated: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2 + deprecated: Upgrade to fsevents v2 to mitigate potential security issues requiresBuild: true dependencies: bindings: 1.5.0 diff --git a/common/config/rush/version-policies.json b/common/config/rush/version-policies.json index eba2c500b..4eb52d350 100644 --- a/common/config/rush/version-policies.json +++ b/common/config/rush/version-policies.json @@ -1 +1 @@ -[{"definitionName":"lockStepVersion","policyName":"vrenderMain","version":"0.20.4","nextBump":"patch"}] +[{"definitionName":"lockStepVersion","policyName":"vrenderMain","version":"0.20.5","nextBump":"patch"}] diff --git a/docs/assets/changelog/en/changelog.md b/docs/assets/changelog/en/changelog.md index b3530ac5e..a3148708c 100644 --- a/docs/assets/changelog/en/changelog.md +++ b/docs/assets/changelog/en/changelog.md @@ -1,3 +1,21 @@ +# v0.20.4 + +2024-09-12 + + +**🆕 New feature** + +- **@visactor/vrender-core**: pauseRender support pass count + +**🐛 Bug fix** + +- **@visactor/vrender-components**: fix the issue where labels are not drawn when the linelabel animation is enabled. +- **@visactor/vrender-core**: add updateHoverIconState in richtext + + + +[more detail about v0.20.4](https://github.com/VisActor/VRender/releases/tag/v0.20.4) + # v0.20.3 2024-09-09 diff --git a/docs/assets/changelog/zh/changelog.md b/docs/assets/changelog/zh/changelog.md index 2bb2143bb..f03b1306e 100644 --- a/docs/assets/changelog/zh/changelog.md +++ b/docs/assets/changelog/zh/changelog.md @@ -1,3 +1,21 @@ +# v0.20.4 + +2024-09-12 + + +**🆕 新增功能** + +- **@visactor/vrender-core**: pauseRender support pass count + +**🐛 功能修复** + +- **@visactor/vrender-components**: fix the issue where labels are not drawn when the linelabel animation is enabled. +- **@visactor/vrender-core**: add updateHoverIconState in richtext + + + +[更多详情请查看 v0.20.4](https://github.com/VisActor/VRender/releases/tag/v0.20.4) + # v0.20.3 2024-09-09 diff --git a/docs/demos/package.json b/docs/demos/package.json index caba6c946..dc9e44eae 100644 --- a/docs/demos/package.json +++ b/docs/demos/package.json @@ -12,7 +12,7 @@ "@internal/eslint-config": "workspace:*", "@internal/ts-config": "workspace:*", "@visactor/vrender-kits": "workspace:0.14.8", - "@visactor/vutils": "~0.18.15", + "@visactor/vutils": "~0.18.16", "d3-scale-chromatic": "^3.0.0", "lodash": "4.17.21", "dat.gui": "^0.7.9", diff --git a/docs/package.json b/docs/package.json index b4fdf49d9..a202b8e35 100644 --- a/docs/package.json +++ b/docs/package.json @@ -11,9 +11,9 @@ "dependencies": { "@arco-design/web-react": "2.46.1", "@visactor/vchart": "1.3.0", - "@visactor/vutils": "~0.18.15", + "@visactor/vutils": "~0.18.16", "@visactor/vgrammar": "~0.5.7", - "@visactor/vrender": "workspace:0.20.4", + "@visactor/vrender": "workspace:0.20.5", "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 6408810f9..cd485cded 100644 --- a/packages/react-vrender-utils/CHANGELOG.json +++ b/packages/react-vrender-utils/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@visactor/react-vrender-utils", "entries": [ + { + "version": "0.20.5", + "tag": "@visactor/react-vrender-utils_v0.20.5", + "date": "Fri, 20 Sep 2024 06:37:57 GMT", + "comments": { + "none": [ + { + "comment": "fix: fix path string of arc, fix #1434\n\n" + } + ] + } + }, { "version": "0.20.4", "tag": "@visactor/react-vrender-utils_v0.20.4", diff --git a/packages/react-vrender-utils/CHANGELOG.md b/packages/react-vrender-utils/CHANGELOG.md index f5099019f..530a1b144 100644 --- a/packages/react-vrender-utils/CHANGELOG.md +++ b/packages/react-vrender-utils/CHANGELOG.md @@ -1,6 +1,15 @@ # Change Log - @visactor/react-vrender-utils -This log was last generated on Thu, 12 Sep 2024 07:33:20 GMT and should not be manually modified. +This log was last generated on Fri, 20 Sep 2024 06:37:57 GMT and should not be manually modified. + +## 0.20.5 +Fri, 20 Sep 2024 06:37:57 GMT + +### Updates + +- fix: fix path string of arc, fix #1434 + + ## 0.20.4 Thu, 12 Sep 2024 07:33:20 GMT diff --git a/packages/react-vrender-utils/package.json b/packages/react-vrender-utils/package.json index 1408c3fd5..d9cc637ca 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.4", + "version": "0.20.5", "description": "", "sideEffects": false, "main": "cjs/index.js", @@ -24,9 +24,9 @@ "react-dom": "^18.2.0" }, "dependencies": { - "@visactor/vrender": "workspace:0.20.4", - "@visactor/react-vrender": "workspace:0.20.4", - "@visactor/vutils": "~0.18.15", + "@visactor/vrender": "workspace:0.20.5", + "@visactor/react-vrender": "workspace:0.20.5", + "@visactor/vutils": "~0.18.16", "react-reconciler": "^0.29.0", "tslib": "^2.3.1" }, diff --git a/packages/react-vrender/CHANGELOG.json b/packages/react-vrender/CHANGELOG.json index 99cfc0c85..71469b48f 100644 --- a/packages/react-vrender/CHANGELOG.json +++ b/packages/react-vrender/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@visactor/react-vrender", "entries": [ + { + "version": "0.20.5", + "tag": "@visactor/react-vrender_v0.20.5", + "date": "Fri, 20 Sep 2024 06:37:57 GMT", + "comments": { + "none": [ + { + "comment": "fix: fix path string of arc, fix #1434\n\n" + } + ] + } + }, { "version": "0.20.4", "tag": "@visactor/react-vrender_v0.20.4", diff --git a/packages/react-vrender/CHANGELOG.md b/packages/react-vrender/CHANGELOG.md index bc64b15c0..efe1ad0a9 100644 --- a/packages/react-vrender/CHANGELOG.md +++ b/packages/react-vrender/CHANGELOG.md @@ -1,6 +1,15 @@ # Change Log - @visactor/react-vrender -This log was last generated on Thu, 12 Sep 2024 07:33:20 GMT and should not be manually modified. +This log was last generated on Fri, 20 Sep 2024 06:37:57 GMT and should not be manually modified. + +## 0.20.5 +Fri, 20 Sep 2024 06:37:57 GMT + +### Updates + +- fix: fix path string of arc, fix #1434 + + ## 0.20.4 Thu, 12 Sep 2024 07:33:20 GMT diff --git a/packages/react-vrender/package.json b/packages/react-vrender/package.json index 8d22a2b7b..144409191 100644 --- a/packages/react-vrender/package.json +++ b/packages/react-vrender/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/react-vrender", - "version": "0.20.4", + "version": "0.20.5", "description": "", "sideEffects": false, "main": "cjs/index.js", @@ -23,8 +23,8 @@ "react": "^18.2.0" }, "dependencies": { - "@visactor/vrender": "workspace:0.20.4", - "@visactor/vutils": "~0.18.15", + "@visactor/vrender": "workspace:0.20.5", + "@visactor/vutils": "~0.18.16", "react-reconciler": "^0.29.0", "tslib": "^2.3.1" }, diff --git a/packages/vrender-components/CHANGELOG.json b/packages/vrender-components/CHANGELOG.json index 421bde038..6512b3ba1 100644 --- a/packages/vrender-components/CHANGELOG.json +++ b/packages/vrender-components/CHANGELOG.json @@ -1,6 +1,30 @@ { "name": "@visactor/vrender-components", "entries": [ + { + "version": "0.20.5", + "tag": "@visactor/vrender-components_v0.20.5", + "date": "Fri, 20 Sep 2024 06:37:57 GMT", + "comments": { + "none": [ + { + "comment": "fix: update parameters" + }, + { + "comment": "fix: fix maxLineWidth of arc label\n\n" + }, + { + "comment": "fix: fix path string of arc, fix #1434\n\n" + }, + { + "comment": "fix: fix `textStyle` of data-zoom\n\n" + }, + { + "comment": "fix: fix error of morphing animation in `multiToOneMorph`, fix #1439\n\n" + } + ] + } + }, { "version": "0.20.4", "tag": "@visactor/vrender-components_v0.20.4", diff --git a/packages/vrender-components/CHANGELOG.md b/packages/vrender-components/CHANGELOG.md index bc62af835..d3ca06ff8 100644 --- a/packages/vrender-components/CHANGELOG.md +++ b/packages/vrender-components/CHANGELOG.md @@ -1,6 +1,25 @@ # Change Log - @visactor/vrender-components -This log was last generated on Thu, 12 Sep 2024 07:33:20 GMT and should not be manually modified. +This log was last generated on Fri, 20 Sep 2024 06:37:57 GMT and should not be manually modified. + +## 0.20.5 +Fri, 20 Sep 2024 06:37:57 GMT + +### Updates + +- fix: update parameters +- fix: fix maxLineWidth of arc label + + +- fix: fix path string of arc, fix #1434 + + +- fix: fix `textStyle` of data-zoom + + +- fix: fix error of morphing animation in `multiToOneMorph`, fix #1439 + + ## 0.20.4 Thu, 12 Sep 2024 07:33:20 GMT diff --git a/packages/vrender-components/__tests__/browser/examples/checkbox.ts b/packages/vrender-components/__tests__/browser/examples/checkbox.ts index 74d8bad8f..2f6c39907 100644 --- a/packages/vrender-components/__tests__/browser/examples/checkbox.ts +++ b/packages/vrender-components/__tests__/browser/examples/checkbox.ts @@ -14,7 +14,10 @@ export function run() { text: 'checkbox' }, checked: false, - disabled: true + disabled: true, + box: { + disableFill: 'red' + } }) ); diff --git a/packages/vrender-components/__tests__/unit/axis/circle.test.ts b/packages/vrender-components/__tests__/unit/axis/circle.test.ts index ba6d7b19f..7ca2016e1 100644 --- a/packages/vrender-components/__tests__/unit/axis/circle.test.ts +++ b/packages/vrender-components/__tests__/unit/axis/circle.test.ts @@ -76,10 +76,10 @@ describe('Circle Axis', () => { // label const axisLabels = axis.getElementsByName(`${AXIS_ELEMENT_NAME.labelContainer}-layer-0`)[0] as unknown as Group; expect(axisLabels.childrenCount).toBe(8); - expect((axisLabels.children[1] as unknown as Text).attribute.textAlign).toBe('center'); - expect((axisLabels.children[1] as unknown as Text).attribute.textBaseline).toBe('middle'); - expect((axisLabels.children[5] as unknown as Text).attribute.textAlign).toBe('center'); - expect((axisLabels.children[5] as unknown as Text).attribute.textBaseline).toBe('middle'); + expect((axisLabels.children[1] as unknown as Text).attribute.textAlign).toBe('left'); + expect((axisLabels.children[1] as unknown as Text).attribute.textBaseline).toBe('bottom'); + expect((axisLabels.children[5] as unknown as Text).attribute.textAlign).toBe('right'); + expect((axisLabels.children[5] as unknown as Text).attribute.textBaseline).toBe('top'); // tick & subTick const tickLineGroup = axis.getElementsByName(AXIS_ELEMENT_NAME.tickContainer)[0] as unknown as Group; diff --git a/packages/vrender-components/package.json b/packages/vrender-components/package.json index 4f812f9d8..219314acb 100644 --- a/packages/vrender-components/package.json +++ b/packages/vrender-components/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vrender-components", - "version": "0.20.4", + "version": "0.20.5", "description": "components library for dp visualization", "sideEffects": false, "main": "cjs/index.js", @@ -24,17 +24,17 @@ "analysis-core": "cross-env DEBUG='Bundler*' bundle -f umd -a -i core.ts" }, "dependencies": { - "@visactor/vutils": "~0.18.15", - "@visactor/vscale": "~0.18.15", - "@visactor/vrender-core": "workspace:0.20.4", - "@visactor/vrender-kits": "workspace:0.20.4" + "@visactor/vutils": "~0.18.16", + "@visactor/vscale": "~0.18.16", + "@visactor/vrender-core": "workspace:0.20.5", + "@visactor/vrender-kits": "workspace:0.20.5" }, "devDependencies": { "@internal/bundler": "workspace:*", "@internal/eslint-config": "workspace:*", "@internal/ts-config": "workspace:*", "@rushstack/eslint-patch": "~1.1.4", - "@visactor/vscale": "~0.18.15", + "@visactor/vscale": "~0.18.16", "@types/jest": "^26.0.0", "jest": "^26.0.0", "jest-electron": "^0.1.12", diff --git a/packages/vrender-components/src/axis/base.ts b/packages/vrender-components/src/axis/base.ts index a8c802c2f..9fc851f29 100644 --- a/packages/vrender-components/src/axis/base.ts +++ b/packages/vrender-components/src/axis/base.ts @@ -17,7 +17,7 @@ import type { import { graphicCreator } from '@visactor/vrender-core'; import type { Dict } from '@visactor/vutils'; // eslint-disable-next-line no-duplicate-imports -import { abs, cloneDeep, get, isEmpty, isFunction, isNumberClose, merge, pi } from '@visactor/vutils'; +import { abs, cloneDeep, get, isEmpty, isFunction, merge, pi } from '@visactor/vutils'; import { AbstractComponent } from '../core/base'; import type { Point } from '../core/type'; import type { TagAttributes } from '../tag'; @@ -32,7 +32,8 @@ import type { TickAttributes, TransformedAxisItem, SubTickAttributes, - TickLineItem + TickLineItem, + callbackFunc } from './type'; import { Tag } from '../tag/tag'; import { getElMap, getVerticalCoord } from './util'; @@ -79,7 +80,6 @@ export abstract class AxisBase extends AbstractCom abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number]; abstract getRelativeVector(point?: Point): [number, number]; protected abstract getTitleAttribute(): TagAttributes; - protected abstract getTextBaseline(vector: [number, number], inside?: boolean): TextBaselineType; protected abstract beforeLabelsOverlap( labelShapes: IText[], labelData: AxisItem[], @@ -361,27 +361,6 @@ export abstract class AxisBase extends AbstractCom return getVerticalCoord(point, this.getVerticalVector(offset, inside, point)); } - protected getTextAlign(vector: number[]): TextAlignType { - let align: TextAlignType = 'center'; - - if (isNumberClose(vector[0], 0)) { - if (isNumberClose(vector[1], 0)) { - if (Object.is(vector[1], -0)) { - align = 'start'; - } else if (Object.is(vector[0], -0)) { - align = 'end'; - } - } else { - align = 'center'; - } - } else if (vector[0] > 0) { - align = 'start'; - } else if (vector[0] < 0) { - align = 'end'; - } - return align; - } - protected getTickLineItems() { const { tick } = this.attribute; const data = this.data; @@ -524,7 +503,11 @@ export abstract class AxisBase extends AbstractCom : tickDatum.label; let { style: textStyle } = this.attribute.label as LabelAttributes; textStyle = isFunction(textStyle) - ? merge({}, DEFAULT_AXIS_THEME.label.style, textStyle(tickDatum, index, tickData, layer)) + ? merge( + {}, + DEFAULT_AXIS_THEME.label.style, + (textStyle as callbackFunc | undefined>)(tickDatum, index, tickData, layer) + ) : textStyle; const labelAlign = this.getLabelAlign(vector, inside, (textStyle as ITextGraphicAttribute).angle); diff --git a/packages/vrender-components/src/axis/circle.ts b/packages/vrender-components/src/axis/circle.ts index 9ba6e9cad..4f2944558 100644 --- a/packages/vrender-components/src/axis/circle.ts +++ b/packages/vrender-components/src/axis/circle.ts @@ -13,7 +13,7 @@ import type { import { graphicCreator } from '@visactor/vrender-core'; // eslint-disable-next-line no-duplicate-imports import type { Point } from '@visactor/vutils'; -import { isNil, get, merge, isNumberClose, isEmpty, mixin, isValidNumber } from '@visactor/vutils'; +import { isNil, get, merge, isNumberClose, isEmpty, mixin, isValidNumber, isFunction } from '@visactor/vutils'; import { POLAR_END_ANGLE, POLAR_START_ANGLE } from '../constant'; import type { CircleAxisAttributes, TitleAttributes, SubTickAttributes, TickLineItem, AxisItem } from './type'; import { AxisBase } from './base'; @@ -23,6 +23,8 @@ import { CircleAxisMixin } from './mixin/circle'; import { getCircleLabelPosition, getCirclePoints, getPolygonPath } from './util'; import type { ComponentOptions } from '../interface'; import { loadCircleAxisComponent } from './register'; +import { autoHide as autoHideFunc } from './overlap/auto-hide'; +import { circleAutoLimit } from './overlap/circle-auto-limit'; loadCircleAxisComponent(); export interface CircleAxis @@ -194,19 +196,6 @@ export class CircleAxis extends AxisBase { return subTickLineItems; } - - protected getTextBaseline(vector: number[]): TextBaselineType { - let base: TextBaselineType = 'middle'; - if (isNumberClose(vector[1], 0)) { - base = 'middle'; - } else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) { - base = 'top'; - } else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) { - base = 'bottom'; - } - return base; - } - protected beforeLabelsOverlap( labelShapes: IText[], labelData: AxisItem[], @@ -223,8 +212,44 @@ export class CircleAxis extends AxisBase { layer: number, layerCount: number ): void { - // 暂不支持 - return; + if (isEmpty(labelShapes)) { + return; + } + + const { inside, radius, center, width, height, 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 { layoutFunc, autoLimit, limitEllipsis, autoHide, autoHideMethod, autoHideSeparation, autoWrap } = label; + + if (isFunction(layoutFunc)) { + // 自定义布局 + layoutFunc(labelShapes, labelData, layer, this); + } else { + // autoWrap has computed width & height limit + if (autoLimit || autoWrap) { + circleAutoLimit(labelShapes, { inside, autoWrap, bounds, ellipsis: limitEllipsis, center }); + } + if (autoHide) { + autoHideFunc(labelShapes, { + orient, + method: autoHideMethod, + separation: autoHideSeparation + }); + } + } } protected afterLabelsOverlap( labelShapes: IText[], @@ -236,11 +261,40 @@ export class CircleAxis extends AxisBase { return; } + protected getTextBaseline(vector: [number, number]) { + if (Math.abs(vector[1] / vector[0]) < 0.3) { + return 'middle'; + } else if (vector[1] < 0) { + return 'bottom'; + } else if (vector[1] > 0) { + return 'top'; + } + + return 'middle'; + } + protected getLabelAlign( vector: [number, number], inside?: boolean, angle?: number ): { textAlign: TextAlignType; textBaseline: TextBaselineType } { + if (isNumberClose(vector[0], 0)) { + return { + textAlign: 'center', + textBaseline: vector[1] > 0 ? 'top' : 'bottom' + }; + } else if (vector[0] < 0) { + return { + textAlign: 'right', + textBaseline: this.getTextBaseline(vector) + }; + } else if (vector[0] > 0) { + return { + textAlign: 'left', + textBaseline: this.getTextBaseline(vector) + }; + } + return { textAlign: 'center', //'left', textBaseline: 'middle' //'top' @@ -253,7 +307,7 @@ export class CircleAxis extends AxisBase { text: string | number, style: Partial ) { - return getCircleLabelPosition(point, vector, text, style); + return point; } } diff --git a/packages/vrender-components/src/axis/line.ts b/packages/vrender-components/src/axis/line.ts index 19f58d7ad..280845e0e 100644 --- a/packages/vrender-components/src/axis/line.ts +++ b/packages/vrender-components/src/axis/line.ts @@ -168,6 +168,27 @@ export class LineAxis extends AxisBase { container.add(axisLineGroup as unknown as INode); } + protected getTextAlign(vector: number[]): TextAlignType { + let align: TextAlignType = 'center'; + + if (isNumberClose(vector[0], 0)) { + if (isNumberClose(vector[1], 0)) { + if (Object.is(vector[1], -0)) { + align = 'start'; + } else if (Object.is(vector[0], -0)) { + align = 'end'; + } + } else { + align = 'center'; + } + } else if (vector[0] > 0) { + align = 'start'; + } else if (vector[0] < 0) { + align = 'end'; + } + return align; + } + // TODO: 太 hack 了,需要静心优化 protected getTitleAttribute() { const { diff --git a/packages/vrender-components/src/axis/overlap/circle-auto-limit.ts b/packages/vrender-components/src/axis/overlap/circle-auto-limit.ts new file mode 100644 index 000000000..96c2691af --- /dev/null +++ b/packages/vrender-components/src/axis/overlap/circle-auto-limit.ts @@ -0,0 +1,108 @@ +import type { IText } from '@visactor/vrender-core'; +import { isNumberClose } from '@visactor/vutils'; +import type { Point } from '../../core/type'; + +type WrapConfig = { + center: Point; + inside?: boolean; + ellipsis?: string; + bounds: { x1: number; x2: number; y1: number; y2: number }; + autoWrap?: boolean; +}; + +function findSiblingLabels(labels: IText[], selfIndex: number) { + const len = labels.length; + const prevLabel = selfIndex >= 1 ? labels[selfIndex - 1] : labels[len - 1]; + const nextLabel = selfIndex < len - 1 ? labels[selfIndex + 1] : labels[0]; + + return { prevLabel, nextLabel }; +} + +function adjustMaxLineWidth(label: IText, maxLineWidth: number, ellipsis: string) { + label.setAttributes({ + maxLineWidth, + ellipsis: label.attribute.ellipsis ?? ellipsis + }); +} + +function adjustMaxHeight( + labels: IText[], + selfIndex: number, + bounds: { x1: number; x2: number; y1: number; y2: number } +) { + const siblings = []; + if (labels.length >= 3) { + const { prevLabel, nextLabel } = findSiblingLabels(labels, selfIndex); + + siblings.push(prevLabel, nextLabel); + } else if (labels.length === 2) { + siblings.push(labels[selfIndex === 0 ? 1 : 0]); + } + const label = labels[selfIndex]; + + let heightLimit = Math.min(Math.abs(label.attribute.y - bounds.y1), Math.abs(label.attribute.y - bounds.y2)); + + siblings.forEach(sibling => { + heightLimit = Math.min(heightLimit, Math.abs(sibling.attribute.y - label.attribute.y)); + }); + + if (heightLimit > 0) { + label.setAttributes({ whiteSpace: 'normal', heightLimit }); + } +} +/** + * 基于所有的标签初始化未知已经布局在圆的边缘 + * @param labels + * @param labelPoints + * @param config + */ +export function circleAutoLimit(labels: IText[], config: WrapConfig) { + const { ellipsis, inside, bounds, autoWrap, center } = config; + + if (!inside) { + // TODO inside label暂不处理,现在应该没有类似的需求 + labels.forEach((label, index) => { + const { x, y } = label.attribute; + const b = label.AABBBounds; + + if (isNumberClose(x, center.x)) { + if (y > bounds.y2 || y < bounds.y1) { + adjustMaxLineWidth(label, 0, ellipsis); + return; + } + + const boxWidth = bounds.x2 - bounds.x1; + // 12点和6点钟方向对应的label + if (labels.length >= 3) { + // 这里其实有一个前提:所有的label都是按照顺时针或者逆时针排序好的 + const { prevLabel, nextLabel } = findSiblingLabels(labels, index); + let leftX = prevLabel.attribute.x; + let rightX = nextLabel.attribute.x; + + if (leftX > rightX) { + leftX = nextLabel.attribute.x; + rightX = prevLabel.attribute.x; + } + + const maxWidth = + leftX === rightX + ? boxWidth + : x >= leftX && x <= rightX + ? rightX - leftX + : Math.min(Math.abs(leftX - x), Math.abs(rightX - x)); + if (label.AABBBounds.width() > maxWidth) { + adjustMaxLineWidth(label, maxWidth, ellipsis); + } + } else if (label.AABBBounds.width() > boxWidth) { + adjustMaxLineWidth(label, boxWidth, ellipsis); + } + } else if (x > center.x && b.x2 > bounds.x2) { + adjustMaxLineWidth(label, bounds.x2 - x, ellipsis); + autoWrap && adjustMaxHeight(labels, index, bounds); + } else if (x < center.x && b.x1 < bounds.x1) { + adjustMaxLineWidth(label, x - bounds.x1, ellipsis); + autoWrap && adjustMaxHeight(labels, index, bounds); + } + }); + } +} diff --git a/packages/vrender-components/src/axis/tick-data/discrete/polar-angle.ts b/packages/vrender-components/src/axis/tick-data/discrete/polar-angle.ts index 696797683..8180b1184 100644 --- a/packages/vrender-components/src/axis/tick-data/discrete/polar-angle.ts +++ b/packages/vrender-components/src/axis/tick-data/discrete/polar-angle.ts @@ -1,6 +1,6 @@ import type { BandScale, IBaseScale } from '@visactor/vscale'; -import { isFunction, isValid, maxInArray, minInArray } from '@visactor/vutils'; -import type { IPolarTickDataOpt, ITickData } from '../../type'; +import { isFunction, isValid, maxInArray, minInArray, isNumberClose } from '@visactor/vutils'; +import type { IPolarTickDataOpt, ITickCallbackOption, ITickData } from '../../type'; import { MIN_TICK_GAP, convertDomainToTickData, labelOverlap } from '../util'; import { AABBBounds } from '@visactor/vutils'; import { initTextMeasure } from '../../../util/text'; @@ -22,16 +22,34 @@ export const getPolarAngleLabelBounds = (scale: IBaseScale, domain: any[], op: I // 估算文本位置 const angle = scale.scale(v); + const center = { x: 0, y: 0 }; let textX = 0; let textY = 0; const orient = { - align: labelStyle.textAlign ?? 'center', - baseline: labelStyle.textBaseline ?? 'middle' + align: labelStyle.textAlign, + baseline: labelStyle.textBaseline }; - const { x, y } = getPolarAngleLabelPosition(angle, { x: 0, y: 0 }, radius, labelOffset, inside, str, labelStyle); - textX = x + (orient.align === 'right' ? -textWidth : orient.align === 'center' ? -textWidth / 2 : 0); - textY = y + (orient.baseline === 'bottom' ? -textHeight : orient.baseline === 'middle' ? -textHeight / 2 : 0); + const { x, y } = getPolarAngleLabelPosition(angle, center, radius, labelOffset, inside); + + if (!orient.align) { + if (isNumberClose(x, center.x)) { + if (!orient.baseline) { + if (y > center.y) { + orient.baseline = 'top'; + } else { + orient.baseline = 'bottom'; + } + } + } else if (x > center.x) { + orient.align = 'left'; + } else if (x < center.x) { + orient.align = 'right'; + } + } + + textX = x + (orient.align === 'right' ? -textWidth : orient.align === 'left' ? 0 : -textWidth / 2); + textY = y + (orient.baseline === 'bottom' ? -textHeight : orient.baseline === 'top' ? 0 : -textHeight / 2); // 计算 label 包围盒 const bounds = new AABBBounds() @@ -67,7 +85,9 @@ export const polarAngleAxisDiscreteTicks = (scale: BandScale, op: IPolarTickData } else if (isValid(tickCount)) { const range = scale.range(); const rangeSize = Math.abs(range[range.length - 1] - range[0]); - const count = isFunction(tickCount) ? tickCount({ axisLength: rangeSize, labelStyle }) : tickCount; + const count = isFunction(tickCount) + ? (tickCount as (option: ITickCallbackOption) => number)({ axisLength: rangeSize, labelStyle }) + : tickCount; scaleTicks = scale.ticks(count); } else if (op.sampling) { const domain = scale.domain(); diff --git a/packages/vrender-components/src/axis/type.ts b/packages/vrender-components/src/axis/type.ts index f999dd7e6..7bcb84711 100644 --- a/packages/vrender-components/src/axis/type.ts +++ b/packages/vrender-components/src/axis/type.ts @@ -567,7 +567,7 @@ export interface ITickData { // label: string; } -type ITickCallbackOption = { +export type ITickCallbackOption = { /** * 坐标轴占据的画布大小。 * 直角坐标系中为轴的宽度或高度。 diff --git a/packages/vrender-components/src/axis/util.ts b/packages/vrender-components/src/axis/util.ts index 7017993fd..2ce44e743 100644 --- a/packages/vrender-components/src/axis/util.ts +++ b/packages/vrender-components/src/axis/util.ts @@ -1,4 +1,3 @@ -import { getTextBounds } from '@visactor/vrender-core'; // eslint-disable-next-line no-duplicate-imports import type { IGraphic, IGroup, ITextGraphicAttribute, TextAlignType, TextBaselineType } from '@visactor/vrender-core'; import type { Dict } from '@visactor/vutils'; @@ -31,52 +30,11 @@ export function isInRange(a: number, min: number, max: number) { return !isLess(a, min, 0, 1e-6) && !isGreater(a, max, 0, 1e-6); } -export function getCircleLabelPosition( - tickPosition: Point, - tickVector: [number, number], - text: string | number, - style: Partial -) { - const labelBounds = getTextBounds({ - text, - ...style - }); - const width = labelBounds.width(); - const height = labelBounds.height(); - const angle = clampRadian(Math.atan2(tickVector[1], tickVector[0])) - Math.PI; - - const PI_3_4 = (Math.PI * 3) / 4; - const PI_1_4 = Math.PI / 4; - const PI_1_2 = Math.PI / 2; - - // x - const baseX = tickPosition.x; - let dx = 0; - if (isInRange(angle, -PI_3_4, -PI_1_4)) { - dx = ((angle + PI_3_4) / PI_1_2 - 0.5) * width; - } else if (isInRange(angle, PI_1_4, PI_3_4)) { - dx = (0.5 - (angle - PI_1_4) / PI_1_2) * width; - } else if (Math.cos(angle) >= 0) { - dx = width * 0.5; - } else { - dx = -width * 0.5; - } - const x = baseX - dx; - - const baseY = tickPosition.y; - let dy = 0; - if (isInRange(angle, -PI_3_4, -PI_1_4)) { - dy = -height * 0.5; - } else if (isInRange(angle, PI_1_4, PI_3_4)) { - dy = height * 0.5; - } else if (Math.cos(angle) >= 0) { - dy = (0.5 - (PI_1_4 - angle) / PI_1_2) * height; - } else { - dy = (0.5 - clampRadian(angle - PI_3_4) / PI_1_2) * height; - } - const y = baseY - dy; - - return { x, y }; +export function getCircleLabelPosition(tickPosition: Point, tickVector: [number, number]) { + return { + x: tickPosition.x + tickVector[0], + y: tickPosition.y + tickVector[1] + }; } export function getAxisBreakSymbolAttrs(props: BreakSymbol = {}) { @@ -156,14 +114,12 @@ export function getPolarAngleLabelPosition( center: { x: number; y: number }, radius: number, labelOffset: number, - inside: boolean, - text: string | number, - style: Partial + inside: boolean ) { const point = polarToCartesian({ x: 0, y: 0 }, radius, angle); const labelPoint = getVerticalCoord(point, getCircleVerticalVector(labelOffset, point, center, inside)); const vector = getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside); - return getCircleLabelPosition(labelPoint, vector, text, style); + return getCircleLabelPosition(labelPoint, vector); } export function getCirclePoints(center: Point, count: number, radius: number, startAngle: number, endAngle: number) { diff --git a/packages/vrender-components/src/checkbox/checkbox.ts b/packages/vrender-components/src/checkbox/checkbox.ts index 2260ee16b..c9346059e 100644 --- a/packages/vrender-components/src/checkbox/checkbox.ts +++ b/packages/vrender-components/src/checkbox/checkbox.ts @@ -96,6 +96,11 @@ export class CheckBox extends AbstractComponent> { fill: this.attribute.box.checkedFill, stroke: this.attribute.box.checkedStroke }); + } else if (this.attribute.disabled) { + this._box.setAttributes({ + fill: this.attribute.box.disableFill + // stroke: this.attribute.box.disableFill + }); } this.appendChild(this._box); } diff --git a/packages/vrender-components/src/data-zoom/data-zoom.ts b/packages/vrender-components/src/data-zoom/data-zoom.ts index 3c28aceff..946d30464 100644 --- a/packages/vrender-components/src/data-zoom/data-zoom.ts +++ b/packages/vrender-components/src/data-zoom/data-zoom.ts @@ -523,11 +523,11 @@ export class DataZoom extends AbstractComponent> { }; startTextAlignStyle = { textAlign: this.isTextOverflow(componentBoundsLike, startTextBounds, 'start') ? 'left' : 'right', - textBaseline: 'middle' + textBaseline: restStartTextStyle?.textStyle?.textBaseline ?? 'middle' }; endTextAlignStyle = { textAlign: this.isTextOverflow(componentBoundsLike, endTextBounds, 'end') ? 'right' : 'left', - textBaseline: 'middle' + textBaseline: restEndTextStyle?.textStyle?.textBaseline ?? 'middle' }; } else { startTextPosition = { @@ -539,11 +539,11 @@ export class DataZoom extends AbstractComponent> { y: position.y + end * height }; startTextAlignStyle = { - textAlign: 'center', + textAlign: restStartTextStyle?.textStyle?.textAlign ?? 'center', textBaseline: this.isTextOverflow(componentBoundsLike, startTextBounds, 'start') ? 'top' : 'bottom' }; endTextAlignStyle = { - textAlign: 'center', + textAlign: restEndTextStyle?.textStyle?.textAlign ?? 'center', textBaseline: this.isTextOverflow(componentBoundsLike, endTextBounds, 'end') ? 'bottom' : 'top' }; } diff --git a/packages/vrender-components/src/interface.ts b/packages/vrender-components/src/interface.ts index 551d182bd..5daa44740 100644 --- a/packages/vrender-components/src/interface.ts +++ b/packages/vrender-components/src/interface.ts @@ -1,9 +1,10 @@ import type { ICustomPath2D, IGraphicAttribute, + IGroup, IRectGraphicAttribute, - IRichTextAttribute, - ITextGraphicAttribute + IRichText, + IText } from '@visactor/vrender-core'; import type { TextContent } from './core/type'; @@ -20,11 +21,7 @@ export type BackgroundAttributes = { * 自定义路径 * @since 0.19.19 */ - customShape?: ( - text: ITextGraphicAttribute | IRichTextAttribute, - attrs: Partial, - path: ICustomPath2D - ) => ICustomPath2D; + customShape?: (container: IGroup, attrs: Partial, path: ICustomPath2D) => ICustomPath2D; } & Partial; export type IDelayType = 'debounce' | 'throttle'; diff --git a/packages/vrender-components/src/label/arc.ts b/packages/vrender-components/src/label/arc.ts index e52d545d4..666d120bc 100644 --- a/packages/vrender-components/src/label/arc.ts +++ b/packages/vrender-components/src/label/arc.ts @@ -11,7 +11,7 @@ import { } from '@visactor/vutils'; import { LabelBase } from './base'; import type { ArcLabelAttrs, IPoint, Quadrant, BaseLabelAttrs, LabelItem, IArcLabelLineSpec } from './type'; -import type { IArc, IRichTextAttribute } from '@visactor/vrender-core'; +import type { IArc, IRichTextAttribute, ITextAttribute } from '@visactor/vrender-core'; // eslint-disable-next-line no-duplicate-imports import { type IRichText, type IText, type IArcGraphicAttribute, type IGraphic } from '@visactor/vrender-core'; import { @@ -82,7 +82,6 @@ export class ArcInfo { this.outerRadius = outerRadius; this.circleCenter = circleCenter; this.labelVisible = true; - this.labelLimit = 0; } getLabelBounds(): IBoundsLike { @@ -170,7 +169,9 @@ export class ArcLabel extends LabelBase { } const labels = super._layout(texts); - const textBoundsArray = labels.map(label => this.getGraphicBounds(label as any)); + const textBoundsArray = labels.map(label => { + return this.getGraphicBounds(label as any); + }); const ellipsisLabelAttribute = { ...this.attribute.textStyle, text: '…' @@ -220,16 +221,21 @@ export class ArcLabel extends LabelBase { x: basedArc.labelPosition.x, y: basedArc.labelPosition.y, angle: basedArc.angle, - maxLineWidth: basedArc.labelLimit, points: basedArc.pointA && basedArc.pointB && basedArc.pointC ? [basedArc.pointA, basedArc.pointB, basedArc.pointC] : undefined, line: basedArc.labelLine }; + if (labels[i].type === 'richtext') { - (labelAttribute as unknown as IRichTextAttribute).width = basedArc.labelLimit; + (labelAttribute as unknown as IRichTextAttribute).width = + basedArc.labelLimit ?? (labels[i].attribute as IRichTextAttribute).width; + } else { + (labelAttribute as unknown as ITextAttribute).maxLineWidth = + basedArc.labelLimit ?? (labels[i].attribute as ITextAttribute).maxLineWidth; } + labels[i].setAttributes(labelAttribute); } } @@ -526,12 +532,18 @@ export class ArcLabel extends LabelBase { break; } labelWidth = Math.max(this._ellipsisWidth, labelWidth); - arc.labelLimit = labelWidth; + const needAdjustLimit = labelWidth < arc.labelSize.width - 1; + + if (needAdjustLimit) { + arc.labelLimit = labelWidth; + } else { + arc.labelLimit = null; + } + arc.pointC = { x: cx, y: labelPosition.y }; const align = this._computeAlign(arc, attribute); - const targetCenterOffset = - getAlignOffset(align) * (arc.labelLimit < arc.labelSize.width ? arc.labelLimit : arc.labelSize.width); + const targetCenterOffset = getAlignOffset(align) * (needAdjustLimit ? labelWidth : arc.labelSize.width); if (labelLayoutAlign === 'edge') { // edge 模式下的多行文本对齐方向与其他模式相反 diff --git a/packages/vrender-components/src/label/base.ts b/packages/vrender-components/src/label/base.ts index d2e07daa8..f3cc0e0a9 100644 --- a/packages/vrender-components/src/label/base.ts +++ b/packages/vrender-components/src/label/base.ts @@ -142,7 +142,14 @@ export class LabelBase extends AbstractComponent { if (line.customShape) { const customShape = line.customShape; lineGraphic.pathProxy = (attrs: Partial) => { - return customShape(text.attribute, attrs, new CustomPath2D()); + return customShape( + { + text, + baseMark: baseMark + }, + attrs, + new CustomPath2D() + ); }; } diff --git a/packages/vrender-components/src/label/type.ts b/packages/vrender-components/src/label/type.ts index 76df325d1..a0449e4bb 100644 --- a/packages/vrender-components/src/label/type.ts +++ b/packages/vrender-components/src/label/type.ts @@ -12,7 +12,8 @@ import type { IRichText, ILine, ICustomPath2D, - IArc + IArc, + IGroup } from '@visactor/vrender-core'; import type { BoundsAnchorType, IPointLike, InsideBoundsAnchorType } from '@visactor/vutils'; @@ -427,11 +428,7 @@ export interface ILabelLineSpec { * 自定义路径 * @since 0.19.21 */ - customShape?: ( - text: ITextGraphicAttribute, - attrs: Partial, - path: ICustomPath2D - ) => ICustomPath2D; + customShape?: (container: IGroup, attrs: Partial, path: ICustomPath2D) => ICustomPath2D; /** * 引导线样式 */ diff --git a/packages/vrender-components/src/radio/radio.ts b/packages/vrender-components/src/radio/radio.ts index cb5d6c69f..2c4f1e563 100644 --- a/packages/vrender-components/src/radio/radio.ts +++ b/packages/vrender-components/src/radio/radio.ts @@ -81,6 +81,11 @@ export class Radio extends AbstractComponent> { fill: this.attribute.circle.checkedFill, stroke: this.attribute.circle.checkedStroke }); + } else if (this.attribute.disabled) { + this._circle.setAttributes({ + fill: this.attribute.circle.disableFill + // stroke: this.attribute.circle.disableFill + }); } this.appendChild(this._circle); } diff --git a/packages/vrender-components/src/tag/tag.ts b/packages/vrender-components/src/tag/tag.ts index 046e4c1cc..902b5aaed 100644 --- a/packages/vrender-components/src/tag/tag.ts +++ b/packages/vrender-components/src/tag/tag.ts @@ -83,6 +83,8 @@ export class Tag extends AbstractComponent> { const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup; let symbol; + let tagX = -parsedPadding[3]; + let tagY = -parsedPadding[0]; let tagWidth = parsedPadding[1] + parsedPadding[3]; let tagHeight = parsedPadding[0] + parsedPadding[2]; let textX = 0; @@ -128,33 +130,10 @@ export class Tag extends AbstractComponent> { y: 0 }; textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext') as IRichText; - - // 绘制背景层 - const { visible: bgVisible, ...backgroundStyle } = panel; - if (visible && isBoolean(bgVisible)) { - const bgRect = this.createOrUpdateChild( - 'tag-panel', - { - ...backgroundStyle, - visible: bgVisible && !!text, - x: textShape.AABBBounds.x1 - parsedPadding[1], - y: textShape.AABBBounds.y1 - parsedPadding[0], - width: textShape.AABBBounds.width() + (parsedPadding[1] + parsedPadding[3]), - height: textShape.AABBBounds.height() + (parsedPadding[0] + parsedPadding[2]) - }, - 'rect' - ) as IRect; - if (!isEmpty(state?.panel)) { - bgRect.states = state.panel; - } - if (backgroundStyle.customShape) { - const customShape = backgroundStyle.customShape; - bgRect.pathProxy = (attrs: Partial) => { - return customShape(textShape.attribute, attrs, new CustomPath2D()); - }; - } - this._bgRect = bgRect; - } + tagWidth += textShape.AABBBounds.width(); + tagHeight += textShape.AABBBounds.height(); + tagX += textShape.AABBBounds.x1; + tagY += textShape.AABBBounds.y1; } else { const textAttrs = { text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text, @@ -193,8 +172,8 @@ export class Tag extends AbstractComponent> { } } - let x = 0; - let y = 0; + tagX = 0; + tagY = 0; let flag = 0; if (textAlign === 'left' || textAlign === 'start') { flag = 1; @@ -204,14 +183,14 @@ export class Tag extends AbstractComponent> { flag = 0; } if (!flag) { - x -= tagWidth / 2; + tagX -= tagWidth / 2; if (symbol) { symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2); } group.setAttribute('x', -symbolPlaceWidth / 2); } else if (flag < 0) { - x -= tagWidth; + tagX -= tagWidth; if (symbol) { symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth); } @@ -287,12 +266,12 @@ export class Tag extends AbstractComponent> { } if (textBaseline === 'middle') { - y -= tagHeight / 2; + tagY -= tagHeight / 2; if (symbol) { symbol.setAttribute('y', 0); } } else if (textBaseline === 'bottom') { - y -= tagHeight; + tagY -= tagHeight; if (symbol) { symbol.setAttribute('y', -textHeight / 2); } @@ -304,33 +283,32 @@ export class Tag extends AbstractComponent> { symbol.setAttribute('y', textHeight / 2); } } - - // 绘制背景层 - const { visible: bgVisible, ...backgroundStyle } = panel; - if (visible && isBoolean(bgVisible)) { - const bgRect = this.createOrUpdateChild( - 'tag-panel', - { - ...backgroundStyle, - visible: bgVisible && !!text, - x, - y, - width: tagWidth, - height: tagHeight - }, - 'rect' - ) as IRect; - if (!isEmpty(state?.panel)) { - bgRect.states = state.panel; - } - if (backgroundStyle.customShape) { - const customShape = backgroundStyle.customShape; - bgRect.pathProxy = (attrs: Partial) => { - return customShape(textShape.attribute, attrs, new CustomPath2D()); - }; - } - this._bgRect = bgRect; + } + // 绘制背景层 + const { visible: bgVisible, ...backgroundStyle } = panel; + if (visible && isBoolean(bgVisible)) { + const bgRect = this.createOrUpdateChild( + 'tag-panel', + { + ...backgroundStyle, + visible: bgVisible && !!text, + width: tagWidth, + height: tagHeight, + x: tagX, + y: tagY + }, + 'rect' + ) as IRect; + if (!isEmpty(state?.panel)) { + bgRect.states = state.panel; + } + if (backgroundStyle.customShape) { + const customShape = backgroundStyle.customShape; + bgRect.pathProxy = (attrs: Partial) => { + return customShape(this, attrs, new CustomPath2D()); + }; } + this._bgRect = bgRect; } this._textShape = textShape; this._symbol = symbol; diff --git a/packages/vrender-components/src/util/text.ts b/packages/vrender-components/src/util/text.ts index 00dd819e7..3c62d511b 100644 --- a/packages/vrender-components/src/util/text.ts +++ b/packages/vrender-components/src/util/text.ts @@ -9,7 +9,7 @@ import type { import { getTextBounds, graphicCreator } from '@visactor/vrender-core'; import type { ITextMeasureOption } from '@visactor/vutils'; // eslint-disable-next-line no-duplicate-imports -import { TextMeasure, isObject } from '@visactor/vutils'; +import { TextMeasure, isObject, isValid } from '@visactor/vutils'; import { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant'; import type { HTMLTextContent, ReactTextContent, TextContent } from '../core/type'; @@ -75,9 +75,13 @@ export function getTextType(attributes: TextContent, typeKey = 'type') { } export function richTextAttributeTransform(attributes: ITextGraphicAttribute & IRichTextAttribute & TextContent) { + if (isValid(attributes.maxLineWidth)) { + attributes.maxWidth = attributes.maxLineWidth; + delete attributes.maxLineWidth; + } + attributes.width = attributes.width ?? 0; attributes.height = attributes.height ?? 0; - attributes.maxWidth = attributes.maxLineWidth; attributes.textConfig = (attributes.text as unknown as any).text || attributes.text; return attributes; } diff --git a/packages/vrender-core/CHANGELOG.json b/packages/vrender-core/CHANGELOG.json index 42e201b97..ac17d76bc 100644 --- a/packages/vrender-core/CHANGELOG.json +++ b/packages/vrender-core/CHANGELOG.json @@ -1,6 +1,33 @@ { "name": "@visactor/vrender-core", "entries": [ + { + "version": "0.20.5", + "tag": "@visactor/vrender-core_v0.20.5", + "date": "Fri, 20 Sep 2024 06:37:57 GMT", + "comments": { + "none": [ + { + "comment": "feat: poptip suppport multiline text, closed #1444" + }, + { + "comment": "feat: fix issue with richtext width on disableAutoWrapLine mode, support clip attr" + }, + { + "comment": "fix: fix error of `bounds-contex` when use `arcTo` in customShape" + }, + { + "comment": "fix: fix maxLineWidth of arc label\n\n" + }, + { + "comment": "fix: fix path string of arc, fix #1434\n\n" + }, + { + "comment": "fix: fix error of morphing animation in `multiToOneMorph`, fix #1439\n\n" + } + ] + } + }, { "version": "0.20.4", "tag": "@visactor/vrender-core_v0.20.4", diff --git a/packages/vrender-core/CHANGELOG.md b/packages/vrender-core/CHANGELOG.md index 0d7cfb266..6a1234e31 100644 --- a/packages/vrender-core/CHANGELOG.md +++ b/packages/vrender-core/CHANGELOG.md @@ -1,6 +1,24 @@ # Change Log - @visactor/vrender-core -This log was last generated on Thu, 12 Sep 2024 07:33:20 GMT and should not be manually modified. +This log was last generated on Fri, 20 Sep 2024 06:37:57 GMT and should not be manually modified. + +## 0.20.5 +Fri, 20 Sep 2024 06:37:57 GMT + +### Updates + +- feat: poptip suppport multiline text, closed #1444 +- feat: fix issue with richtext width on disableAutoWrapLine mode, support clip attr +- fix: fix error of `bounds-contex` when use `arcTo` in customShape +- fix: fix maxLineWidth of arc label + + +- fix: fix path string of arc, fix #1434 + + +- fix: fix error of morphing animation in `multiToOneMorph`, fix #1439 + + ## 0.20.4 Thu, 12 Sep 2024 07:33:20 GMT diff --git a/packages/vrender-core/package.json b/packages/vrender-core/package.json index 0d74603d8..004aaab06 100644 --- a/packages/vrender-core/package.json +++ b/packages/vrender-core/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vrender-core", - "version": "0.20.4", + "version": "0.20.5", "description": "", "sideEffects": [ "./src/modules.ts", @@ -29,7 +29,7 @@ }, "dependencies": { "color-convert": "2.0.1", - "@visactor/vutils": "~0.18.15" + "@visactor/vutils": "~0.18.16" }, "devDependencies": { "@internal/bundler": "workspace:*", diff --git a/packages/vrender-core/src/common/bounds-context.ts b/packages/vrender-core/src/common/bounds-context.ts index f2df6c4a7..9297dcd10 100644 --- a/packages/vrender-core/src/common/bounds-context.ts +++ b/packages/vrender-core/src/common/bounds-context.ts @@ -118,7 +118,9 @@ export class BoundsContext implements IPath2D { } // @ts-ignore arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void { - throw new Error('不支持arcTo'); + // 主要用于绘制圆角的场景,暂时只算第一个控制点 + this.bounds.add(x1, y1); + // this.bounds.add(x2, y2); } // @ts-ignore bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void { diff --git a/packages/vrender-core/src/common/shape/arc.ts b/packages/vrender-core/src/common/shape/arc.ts index 6fc003e22..2c6d36924 100644 --- a/packages/vrender-core/src/common/shape/arc.ts +++ b/packages/vrender-core/src/common/shape/arc.ts @@ -184,30 +184,37 @@ export const addArcToBezierPath = ( ) => { // https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%A9zier-curves const delta = Math.abs(endAngle - startAngle); - const len = (Math.tan(delta / 4) * 4) / 3; - const dir = endAngle < startAngle ? -1 : 1; - - const c1 = Math.cos(startAngle); - const s1 = Math.sin(startAngle); - const c2 = Math.cos(endAngle); - const s2 = Math.sin(endAngle); - - const x1 = c1 * rx + cx; - const y1 = s1 * ry + cy; - - const x4 = c2 * rx + cx; - const y4 = s2 * ry + cy; - - const hx = rx * len * dir; - const hy = ry * len * dir; - - bezierPath.push( - // Move control points on tangent. - x1 - hx * s1, - y1 + hy * c1, - x4 + hx * s2, - y4 - hy * c2, - x4, - y4 - ); + const count = delta > 0.5 * Math.PI ? Math.ceil((2 * delta) / Math.PI) : 1; + const stepAngle = (endAngle - startAngle) / count; + + for (let i = 0; i < count; i++) { + const sa = startAngle + stepAngle * i; + const ea = startAngle + stepAngle * (i + 1); + const len = (Math.tan(Math.abs(stepAngle) / 4) * 4) / 3; + const dir = ea < sa ? -1 : 1; + + const c1 = Math.cos(sa); + const s1 = Math.sin(sa); + const c2 = Math.cos(ea); + const s2 = Math.sin(ea); + + const x1 = c1 * rx + cx; + const y1 = s1 * ry + cy; + + const x4 = c2 * rx + cx; + const y4 = s2 * ry + cy; + + const hx = rx * len * dir; + const hy = ry * len * dir; + + bezierPath.push( + // Move control points on tangent. + x1 - hx * s1, + y1 + hy * c1, + x4 + hx * s2, + y4 - hy * c2, + x4, + y4 + ); + } }; diff --git a/packages/vrender-core/src/graphic/graphic-service/graphic-service.ts b/packages/vrender-core/src/graphic/graphic-service/graphic-service.ts index 30dabda04..186d5535e 100644 --- a/packages/vrender-core/src/graphic/graphic-service/graphic-service.ts +++ b/packages/vrender-core/src/graphic/graphic-service/graphic-service.ts @@ -362,9 +362,9 @@ export class DefaultGraphicService implements IGraphicService { return true; } - // if (graphic.shadowRoot) { - // return true; - // } + if (graphic.shadowRoot) { + return true; + } if (!graphic.valid) { aabbBounds.clear(); diff --git a/packages/vrender-core/src/graphic/richtext.ts b/packages/vrender-core/src/graphic/richtext.ts index bd1bd4ec0..a2e94ebd1 100644 --- a/packages/vrender-core/src/graphic/richtext.ts +++ b/packages/vrender-core/src/graphic/richtext.ts @@ -263,6 +263,27 @@ export class RichText extends Graphic implements IRic } return this._frameCache; } + + get cliped() { + const frameCache = this.getFrameCache(); + if (frameCache.actualHeight > frameCache.height) { + return true; + } + const { disableAutoWrapLine } = this.attribute; + if (disableAutoWrapLine) { + for (let i = 0; i < frameCache.lines.length; i++) { + const l = frameCache.lines[i]; + for (let j = 0; j < l.paragraphs.length; j++) { + const p = l.paragraphs[j]; + if ((p as any).overflow && (p as any).text !== '') { + return true; + } + } + } + } + return false; + // if (height < this.attribute.height || ) + } combinedStyleToCharacter(config: IRichTextImageCharacter | IRichTextParagraphCharacter) { const { fill, diff --git a/packages/vrender-core/src/graphic/richtext/line.ts b/packages/vrender-core/src/graphic/richtext/line.ts index b7b891c6d..74f499e72 100644 --- a/packages/vrender-core/src/graphic/richtext/line.ts +++ b/packages/vrender-core/src/graphic/richtext/line.ts @@ -142,41 +142,61 @@ export default class Line { drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void ) { if (drawEllipsis && (lastLine || this.paragraphs.some(p => (p as Paragraph).overflow))) { - // 处理省略号 - let otherParagraphWidth = 0; + // 检测是否需要省略号,因为会有多行同时省略的情况 + let emptyOverflow = true; + let skipEllipsis = false; for (let i = this.paragraphs.length - 1; i >= 0; i--) { const paragraph = this.paragraphs[i]; if ((paragraph as Paragraph).overflow) { - continue; - } - if (paragraph instanceof RichTextIcon) { - break; // todo: 处理最后为图标,显示省略号的情况 - } - if (this.direction === 'vertical' && paragraph.direction !== 'vertical') { - paragraph.verticalEllipsis = true; - break; - } - const ellipsis = drawEllipsis === true ? '...' : drawEllipsis || ''; - paragraph.ellipsisStr = ellipsis; - // const { width } = measureText('...', paragraph.style); - const { width } = measureTextCanvas(ellipsis, paragraph.character); - const ellipsisWidth = width || 0; - if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) { - // 省略号可以直接接在后面paragraph - lastLine && (paragraph.ellipsis = 'add'); - - break; - } else if (ellipsisWidth <= this.blankWidth + otherParagraphWidth + paragraph.width) { - // 省略号需要替换paragraph中的字符 - paragraph.ellipsis = 'replace'; - paragraph.ellipsisWidth = ellipsisWidth; - paragraph.ellipsisOtherParagraphWidth = this.blankWidth + otherParagraphWidth; - - break; + emptyOverflow = emptyOverflow && (paragraph as Paragraph).text === ''; } else { - // 省略号需要的width大于paragraph的width,隐藏paragraph,向前搜索 - paragraph.ellipsis = 'hide'; - otherParagraphWidth += paragraph.width; + if (emptyOverflow) { + skipEllipsis = true; + break; + } + } + } + + // 处理省略号 + let otherParagraphWidth = 0; + if (!skipEllipsis) { + for (let i = this.paragraphs.length - 1; i >= 0; i--) { + const paragraph = this.paragraphs[i]; + if ((paragraph as Paragraph).overflow) { + if ((paragraph as Paragraph).text === '') { + break; + } + continue; + } + if (paragraph instanceof RichTextIcon) { + break; // todo: 处理最后为图标,显示省略号的情况 + } + if (this.direction === 'vertical' && paragraph.direction !== 'vertical') { + paragraph.verticalEllipsis = true; + break; + } + const ellipsis = drawEllipsis === true ? '...' : drawEllipsis || ''; + paragraph.ellipsisStr = ellipsis; + // const { width } = measureText('...', paragraph.style); + const { width } = measureTextCanvas(ellipsis, paragraph.character); + const ellipsisWidth = width || 0; + if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) { + // 省略号可以直接接在后面paragraph + lastLine && (paragraph.ellipsis = 'add'); + + break; + } else if (ellipsisWidth <= this.blankWidth + otherParagraphWidth + paragraph.width) { + // 省略号需要替换paragraph中的字符 + paragraph.ellipsis = 'replace'; + paragraph.ellipsisWidth = ellipsisWidth; + paragraph.ellipsisOtherParagraphWidth = this.blankWidth + otherParagraphWidth; + + break; + } else { + // 省略号需要的width大于paragraph的width,隐藏paragraph,向前搜索 + paragraph.ellipsis = 'hide'; + otherParagraphWidth += paragraph.width; + } } } } diff --git a/packages/vrender-core/src/graphic/text.ts b/packages/vrender-core/src/graphic/text.ts index f06b90f25..489c9aeeb 100644 --- a/packages/vrender-core/src/graphic/text.ts +++ b/packages/vrender-core/src/graphic/text.ts @@ -78,14 +78,20 @@ export class Text extends Graphic implements IText { get cliped(): boolean | undefined { const textTheme = this.getGraphicTheme(); const attribute = this.attribute; - if (this.isMultiLine) { - return undefined; - } - const { maxLineWidth = textTheme.maxLineWidth } = attribute; + const { maxLineWidth = textTheme.maxLineWidth, text, whiteSpace = textTheme.whiteSpace } = attribute; if (!Number.isFinite(maxLineWidth)) { return false; } this.tryUpdateAABBBounds(); + if (this.cache?.layoutData?.lines) { + let mergedText = ''; + this.cache.layoutData.lines.forEach(item => { + mergedText += item.str; + }); + const originText = Array.isArray(text) ? text.join('') : text; + + return originText !== mergedText; + } if (attribute.direction === 'vertical' && this.cache.verticalList && this.cache.verticalList[0]) { return this.cache.verticalList[0].map(item => item.text).join('') !== attribute.text.toString(); } diff --git a/packages/vrender-core/src/interface/graphic/richText.ts b/packages/vrender-core/src/interface/graphic/richText.ts index 7d9f5d1fe..01d788a52 100644 --- a/packages/vrender-core/src/interface/graphic/richText.ts +++ b/packages/vrender-core/src/interface/graphic/richText.ts @@ -219,6 +219,7 @@ export interface IRichTextFrame { export interface IRichText extends IGraphic { getFrameCache: () => IRichTextFrame; + cliped?: boolean; } export interface IRichTextIcon extends IImage { diff --git a/packages/vrender-kits/CHANGELOG.json b/packages/vrender-kits/CHANGELOG.json index 74dff8332..c0f9fa671 100644 --- a/packages/vrender-kits/CHANGELOG.json +++ b/packages/vrender-kits/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@visactor/vrender-kits", "entries": [ + { + "version": "0.20.5", + "tag": "@visactor/vrender-kits_v0.20.5", + "date": "Fri, 20 Sep 2024 06:37:57 GMT", + "comments": { + "none": [ + { + "comment": "fix: fix path string of arc, fix #1434\n\n" + } + ] + } + }, { "version": "0.20.4", "tag": "@visactor/vrender-kits_v0.20.4", diff --git a/packages/vrender-kits/CHANGELOG.md b/packages/vrender-kits/CHANGELOG.md index da5baf269..d09658354 100644 --- a/packages/vrender-kits/CHANGELOG.md +++ b/packages/vrender-kits/CHANGELOG.md @@ -1,6 +1,15 @@ # Change Log - @visactor/vrender-kits -This log was last generated on Thu, 12 Sep 2024 07:33:20 GMT and should not be manually modified. +This log was last generated on Fri, 20 Sep 2024 06:37:57 GMT and should not be manually modified. + +## 0.20.5 +Fri, 20 Sep 2024 06:37:57 GMT + +### Updates + +- fix: fix path string of arc, fix #1434 + + ## 0.20.4 Thu, 12 Sep 2024 07:33:20 GMT diff --git a/packages/vrender-kits/package.json b/packages/vrender-kits/package.json index 6ae97f4dc..abe6a0ad6 100644 --- a/packages/vrender-kits/package.json +++ b/packages/vrender-kits/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vrender-kits", - "version": "0.20.4", + "version": "0.20.5", "description": "", "sideEffects": false, "main": "cjs/index.js", @@ -20,8 +20,8 @@ "test": "" }, "dependencies": { - "@visactor/vutils": "~0.18.15", - "@visactor/vrender-core": "workspace:0.20.4", + "@visactor/vutils": "~0.18.16", + "@visactor/vrender-core": "workspace:0.20.5", "@resvg/resvg-js": "2.4.1", "roughjs": "4.5.2" }, diff --git a/packages/vrender/CHANGELOG.json b/packages/vrender/CHANGELOG.json index 960c7ccc1..e7ba03bf8 100644 --- a/packages/vrender/CHANGELOG.json +++ b/packages/vrender/CHANGELOG.json @@ -1,6 +1,27 @@ { "name": "@visactor/vrender", "entries": [ + { + "version": "0.20.5", + "tag": "@visactor/vrender_v0.20.5", + "date": "Fri, 20 Sep 2024 06:37:57 GMT", + "comments": { + "none": [ + { + "comment": "fix: fix maxLineWidth of arc label\n\n" + }, + { + "comment": "fix: add disableFill box color in checkbox and radio #1437" + }, + { + "comment": "fix: fix path string of arc, fix #1434\n\n" + }, + { + "comment": "fix: fix error of morphing animation in `multiToOneMorph`, fix #1439\n\n" + } + ] + } + }, { "version": "0.20.4", "tag": "@visactor/vrender_v0.20.4", diff --git a/packages/vrender/CHANGELOG.md b/packages/vrender/CHANGELOG.md index 34d0039a4..0e9b3e2a9 100644 --- a/packages/vrender/CHANGELOG.md +++ b/packages/vrender/CHANGELOG.md @@ -1,6 +1,22 @@ # Change Log - @visactor/vrender -This log was last generated on Thu, 12 Sep 2024 07:33:20 GMT and should not be manually modified. +This log was last generated on Fri, 20 Sep 2024 06:37:57 GMT and should not be manually modified. + +## 0.20.5 +Fri, 20 Sep 2024 06:37:57 GMT + +### Updates + +- fix: fix maxLineWidth of arc label + + +- fix: add disableFill box color in checkbox and radio #1437 +- fix: fix path string of arc, fix #1434 + + +- fix: fix error of morphing animation in `multiToOneMorph`, fix #1439 + + ## 0.20.4 Thu, 12 Sep 2024 07:33:20 GMT diff --git a/packages/vrender/__tests__/browser/src/pages/morphing.ts b/packages/vrender/__tests__/browser/src/pages/morphing.ts index a9d0212d5..93502018e 100644 --- a/packages/vrender/__tests__/browser/src/pages/morphing.ts +++ b/packages/vrender/__tests__/browser/src/pages/morphing.ts @@ -184,7 +184,7 @@ export const page = () => { const symbols = createSymbol({ x: Math.random() * 500, y: Math.random() * 500, - symbolType: 'triangleLeft', + symbolType: 'arrow', size: 10, fill: colorPools[2], // angle: Math.PI / 4, @@ -194,9 +194,9 @@ export const page = () => { stage.defaultLayer.appendChild(symbols); } - stage.defaultLayer.appendChild(arc); + // stage.defaultLayer.appendChild(arc); - oneToMultiMorph(arc, symbolList, { duration: 2000, splitPath: 'clone', easing: 'quadIn' }); + // oneToMultiMorph(arc, symbolList, { duration: 2000, easing: 'quadIn' }); const fromSymbolList = []; for (let i = 0; i < 23; i++) { diff --git a/packages/vrender/__tests__/browser/src/pages/richtext.ts b/packages/vrender/__tests__/browser/src/pages/richtext.ts index b43e3b6d3..ad3c22cae 100644 --- a/packages/vrender/__tests__/browser/src/pages/richtext.ts +++ b/packages/vrender/__tests__/browser/src/pages/richtext.ts @@ -961,6 +961,52 @@ export const page = () => { }) ); + const rt = createRichText({ + fontSize: 14, + fill: '#FFC400', + fontFamily: + 'PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol', + textAlign: 'center', + textBaseline: 'middle', + boundsPadding: [10, 0, 10, 0], + fontWeight: 'normal', + fillOpacity: 1, + ellipsis: true, + pickable: true, + lineJoin: 'bevel', + stroke: '#ffffff', + _debug_bounds: true, + zIndex: -1, + // maxLineWidth: 200, + disableAutoWrapLine: true, + x: 100, + y: 100, + angle: 0, + // lineWidth: 0, + textConfig: [ + { + text: '空值0\n', + fontSize: 12, + textAlign: 'left', + fill: '#1F2329' + }, + { + text: '8%', + fontSize: 12, + textAlign: 'left', + fill: '#646A73' + } + ], + z: 0, + // width: 30, + width: 31, + // width: 0, + height: 80 + // maxWidth: 200 + }); + + console.log(rt); + const stage = createStage({ canvas: 'main', width: 1200, @@ -986,50 +1032,52 @@ export const page = () => { shapes.length = 0; - shapes.push( - createRichText({ - fontSize: 14, - fill: '#FF8A00', - fontFamily: - 'PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol', - textAlign: 'center', - textBaseline: 'middle', - boundsPadding: [-1, 0, -1, 0], - visible: true, - fontWeight: 'normal', - fillOpacity: 1, - pickable: false, - lineJoin: 'bevel', - stroke: '#ffffff', - width: 50, - height: 40, - ellipsis: true, - disableAutoWrapLine: true, - x: 446.334013251786, - y: 198.39408125844088, - angle: 0, - lineWidth: 0, - textConfig: [ - { - text: 'aluminum1111111111111\n', - fontSize: 14, - fontWeight: 'bold', - fill: 'red' - }, - { - text: '1.13%', - fontSize: 14, - lineThrough: true, - underline: true, - fill: 'green' - } - ], - z: 0, - id: 'vrender-component-arc-label-2', - opacity: 1, - strokeOpacity: 1 - }) - ); + shapes.push(rt); + + // shapes.push( + // createRichText({ + // fontSize: 14, + // fill: '#FF8A00', + // fontFamily: + // 'PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol', + // textAlign: 'center', + // textBaseline: 'middle', + // boundsPadding: [-1, 0, -1, 0], + // visible: true, + // fontWeight: 'normal', + // fillOpacity: 1, + // pickable: false, + // lineJoin: 'bevel', + // stroke: '#ffffff', + // width: 50, + // height: 40, + // ellipsis: true, + // disableAutoWrapLine: true, + // x: 446.334013251786, + // y: 198.39408125844088, + // angle: 0, + // lineWidth: 0, + // textConfig: [ + // { + // text: 'aluminum1111111111111\n', + // fontSize: 14, + // fontWeight: 'bold', + // fill: 'red' + // }, + // { + // text: '1.13%', + // fontSize: 14, + // lineThrough: true, + // underline: true, + // fill: 'green' + // } + // ], + // z: 0, + // id: 'vrender-component-arc-label-2', + // opacity: 1, + // strokeOpacity: 1 + // }) + // ); addShapesToStage(stage, shapes as any, true); stage.render(); diff --git a/packages/vrender/__tests__/browser/src/pages/text.ts b/packages/vrender/__tests__/browser/src/pages/text.ts index 76b0d93a4..9f175f2c5 100644 --- a/packages/vrender/__tests__/browser/src/pages/text.ts +++ b/packages/vrender/__tests__/browser/src/pages/text.ts @@ -126,12 +126,15 @@ export const page = () => { // }, // background: 'red', // backgroundCornerRadius: 10, - text: '这是一行文字', + text: ['这是一行文字', '这是第二哈那个'], fill: 'red', + maxLineWidth: 100, + whiteSpace: 'normal', fontSize: 36, textBaseline: 'top' }) ); + console.log('aaa', graphics[graphics.length - 1]); graphics.push( createLine({ x: 300, diff --git a/packages/vrender/package.json b/packages/vrender/package.json index 159670431..6bd2e22a9 100644 --- a/packages/vrender/package.json +++ b/packages/vrender/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vrender", - "version": "0.20.4", + "version": "0.20.5", "description": "", "sideEffects": true, "main": "cjs/index.js", @@ -24,15 +24,15 @@ "test-watch": "cross-env DEBUG_MODE=1 jest --watch" }, "dependencies": { - "@visactor/vrender-core": "workspace:0.20.4", - "@visactor/vrender-kits": "workspace:0.20.4" + "@visactor/vrender-core": "workspace:0.20.5", + "@visactor/vrender-kits": "workspace:0.20.5" }, "devDependencies": { "@internal/bundler": "workspace:*", "@internal/eslint-config": "workspace:*", "@internal/ts-config": "workspace:*", "@rushstack/eslint-patch": "~1.1.4", - "@visactor/vutils": "~0.18.15", + "@visactor/vutils": "~0.18.16", "canvas": "2.11.2", "react": "^18.0.0", "react-dom": "^18.0.0", diff --git a/tools/bugserver-trigger/package.json b/tools/bugserver-trigger/package.json index 4ddc3c94c..cdcf9fd10 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.4", - "@visactor/vrender-core": "workspace:0.20.4", - "@visactor/vrender-kits": "workspace:0.20.4", - "@visactor/vrender-components": "workspace:0.20.4" + "@visactor/vrender": "workspace:0.20.5", + "@visactor/vrender-core": "workspace:0.20.5", + "@visactor/vrender-kits": "workspace:0.20.5", + "@visactor/vrender-components": "workspace:0.20.5" }, "devDependencies": { "@rushstack/eslint-patch": "~1.1.4",