Skip to content

Commit

Permalink
fix: axis size align with vrender-component #1784
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed May 24, 2024
1 parent 80c1976 commit e772cfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix: axis size align with vrender-component #1784",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray, merge } from '@visactor/vutils';
import { isArray, isString, merge } from '@visactor/vutils';
import type { BaseTableAPI } from '../../ts-types/base-table';
import type { ICellAxisOption } from '../../ts-types/component/axis';
import { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE, commonAxis } from './get-axis-attributes';
Expand Down Expand Up @@ -69,7 +69,8 @@ export function computeAxisComponentWidth(config: ICellAxisOption, table: BaseTa

// title
let titleWidth = 0;
if (attribute.title.visible && attribute.title.text) {
// align with vrender-component, use isString()
if (attribute.title.visible && isString(attribute.title.text)) {
const { width, height } = table.measureText(attribute.title.text, {
fontSize: attribute.title?.style?.fontSize ?? DEFAULT_TEXT_FONT_SIZE,
fontWeight: attribute.title?.style?.fontWeight ?? 'normal',
Expand Down

0 comments on commit e772cfb

Please sign in to comment.