From 81a10f8c9b36694facd856c9ae8318679941f790 Mon Sep 17 00:00:00 2001 From: Jason Xie Date: Sun, 26 Nov 2023 21:42:42 -0500 Subject: [PATCH] Fix ci issues (#5839) * fix: undefined tooltip element (#5835) * fix: ci failed linting * fix: ci failed test chart show and hide * fix: ci failed test allow sufficient animation time * fix: ci increase setTimeout duration for animate test * Revert "fix: ci failed test chart show and hide" This reverts commit d8c52d17211c6792ff5b39d5dfe0e04f28fc1cf5. * fix: override chart show and hide method --- src/chart/chart.ts | 10 ++++++++++ src/chart/controller/tooltip.ts | 4 ++-- src/chart/view.ts | 4 ++-- src/facet/facet.ts | 8 +++----- src/util/scale.ts | 3 ++- tests/bugs/pie-update-spec.ts | 4 ++-- tests/unit/animate/index-spec.ts | 4 ++-- 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/chart/chart.ts b/src/chart/chart.ts index fe9b03dfa1..51ecf1ecbb 100644 --- a/src/chart/chart.ts +++ b/src/chart/chart.ts @@ -138,6 +138,16 @@ export default class Chart extends View { this.wrapperElement = null; } + public show() { + this.visible = true; + this.changeVisible(true); + } + + public hide() { + this.visible = false; + this.changeVisible(false); + } + /** * 显示或隐藏图表 * @param visible 是否可见,true 表示显示,false 表示隐藏 diff --git a/src/chart/controller/tooltip.ts b/src/chart/controller/tooltip.ts index f073cc479b..60ca28dee9 100644 --- a/src/chart/controller/tooltip.ts +++ b/src/chart/controller/tooltip.ts @@ -323,7 +323,7 @@ export default class Tooltip extends Controller { if (this.point) { this.showTooltip(this.point); } - + if (this.tooltip) { // #2279 修复resize之后tooltip越界的问题 // 确保tooltip已经创建的情况下 @@ -653,7 +653,7 @@ export default class Tooltip extends Controller { if (record) { const elementId = geometry.getElementId(record); const element = geometry.elementsMap[elementId]; - if (geometry.type === 'heatmap' || (element && element.visible)) { + if (geometry.type === 'heatmap' || (element && element.visible)) { // Heatmap 没有 Element // 如果图形元素隐藏了,怎不再 tooltip 上展示相关数据 const items = getTooltipItems(record, geometry, title); diff --git a/src/chart/view.ts b/src/chart/view.ts index a30d3e1355..6d30d9104f 100644 --- a/src/chart/view.ts +++ b/src/chart/view.ts @@ -984,7 +984,7 @@ export class View extends Base { * @returns 维度字段的 Attribute 数组 */ public getLegendAttributes(): Attribute[] { - return (flatten(this.geometries.map((g: Geometry) => g.getGroupAttributes())) as unknown) as Attribute[]; + return flatten(this.geometries.map((g: Geometry) => g.getGroupAttributes())) as unknown as Attribute[]; } /** @@ -1002,7 +1002,7 @@ export class View extends Base { * @returns G.Canvas 画布实例。 */ public getCanvas(): ICanvas { - return ((this.getRootView() as unknown) as Chart).canvas; + return (this.getRootView() as unknown as Chart).canvas; } /** diff --git a/src/facet/facet.ts b/src/facet/facet.ts index ed683e4e16..8015e465e8 100644 --- a/src/facet/facet.ts +++ b/src/facet/facet.ts @@ -153,11 +153,9 @@ export abstract class Facet = FacetCfg, */ private createFacetViews(): View[] { // 使用分面数据 创建分面 view - return this.facets.map( - (facet): View => { - return this.facetToView(facet); - } - ); + return this.facets.map((facet): View => { + return this.facetToView(facet); + }); } /** diff --git a/src/util/scale.ts b/src/util/scale.ts index 3ee298f83d..69ef38dcad 100644 --- a/src/util/scale.ts +++ b/src/util/scale.ts @@ -2,7 +2,8 @@ import { firstValue, get, isEmpty, isNil, isNumber, isString, valuesOfKey } from import { getScale, Scale } from '../dependents'; import { LooseObject, ScaleOption } from '../interface'; -const dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]+)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/; +const dateRegex = + /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]+)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/; /** * 获取字段对应数据的类型 diff --git a/tests/bugs/pie-update-spec.ts b/tests/bugs/pie-update-spec.ts index a3fd6c6e8e..5db443d4cc 100644 --- a/tests/bugs/pie-update-spec.ts +++ b/tests/bugs/pie-update-spec.ts @@ -43,7 +43,7 @@ describe('Pie update animation', () => { }); expect(commands).toEqual(['M', 'L', 'A', 'L', 'Z']); done(); - }, 600); + }, 1000); }); it('recheck', () => { @@ -162,6 +162,6 @@ describe('Pie update animation', () => { expect(labelContainer.getCount()).toBe(1); done(); - }, 500); + }, 1000); }); }); diff --git a/tests/unit/animate/index-spec.ts b/tests/unit/animate/index-spec.ts index 97ec72d110..e6ec877300 100644 --- a/tests/unit/animate/index-spec.ts +++ b/tests/unit/animate/index-spec.ts @@ -154,7 +154,7 @@ describe('Animate', () => { expect(isNumberEqual(rect.attr('width'), 150)).toBeTruthy(); expect(isNumberEqual(rect.attr('height'), 150)).toBeTruthy(); done(); - }, 450); + }, 1000); }); it('doGroupAppearAnimate', (done) => { @@ -183,7 +183,7 @@ describe('Animate', () => { setTimeout(() => { expect(group.attr('matrix')).toEqual([1, 0, 0, 0, 1, 0, 0, 0, 1]); done(); - }, 550); + }, 1000); }); afterEach(() => {