diff --git a/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list-2.ts b/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list-2.ts index 0ab9b79e3..ee0827146 100644 --- a/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list-2.ts +++ b/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list-2.ts @@ -1,7 +1,5 @@ import { registerRankingList } from '../../../../src'; import { VChart } from '@visactor/vchart'; -import { defaultSpec } from '../../../../src/charts/ranking-list/constant'; -import { merge } from '@visactor/vutils'; import { GUI } from 'lil-gui'; const guiObject = { @@ -196,7 +194,7 @@ const spec = { const run = () => { registerRankingList(); - const cs = new VChart(merge(defaultSpec, spec), { + const cs = new VChart(spec, { dom: document.getElementById('chart') as HTMLElement, //theme: 'dark', onError: err => { diff --git a/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list-3.ts b/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list-3.ts index 85d432543..939e24d71 100644 --- a/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list-3.ts +++ b/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list-3.ts @@ -1,7 +1,5 @@ import { registerRankingList } from '../../../../src'; import { VChart } from '@visactor/vchart'; -import { defaultSpec } from '../../../../src/charts/ranking-list/constant'; -import { merge } from '@visactor/vutils'; import { GUI } from 'lil-gui'; const guiObject = { @@ -245,7 +243,7 @@ const spec = { const run = () => { registerRankingList(); - const cs = new VChart(merge(defaultSpec, spec), { + const cs = new VChart(spec, { dom: document.getElementById('chart') as HTMLElement, //theme: 'dark', onError: err => { diff --git a/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list.ts b/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list.ts index 2bcd2154d..cadcc4a33 100644 --- a/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list.ts +++ b/packages/vchart-extension/__tests__/runtime/browser/test-page/ranking-list.ts @@ -1,7 +1,5 @@ import { registerRankingList } from '../../../../src'; import { VChart } from '@visactor/vchart'; -import { defaultSpec } from '../../../../src/charts/ranking-list/constant'; -import { merge } from '@visactor/vutils'; import { GUI } from 'lil-gui'; const guiObject = { @@ -176,7 +174,7 @@ const spec = { const run = () => { registerRankingList(); - const cs = new VChart(merge(defaultSpec, spec), { + const cs = new VChart(spec, { dom: document.getElementById('chart') as HTMLElement, //theme: 'dark', onError: err => { diff --git a/packages/vchart-extension/src/charts/ranking-list/utils.ts b/packages/vchart-extension/src/charts/ranking-list/utils.ts index ddbe55f9c..94a417b44 100644 --- a/packages/vchart-extension/src/charts/ranking-list/utils.ts +++ b/packages/vchart-extension/src/charts/ranking-list/utils.ts @@ -1,6 +1,6 @@ import { Datum } from '@visactor/vchart/src/typings'; -export const applyVisible = (spec, keyList: string[]) => { +export const applyVisible = (spec: any, keyList: string[]) => { keyList.forEach(key => { spec[key] = { ...spec[key], @@ -12,15 +12,15 @@ export const applyVisible = (spec, keyList: string[]) => { }); }; -export const mergeObjects = (objA, objB) => { - function recursiveMerge(target, source) { +export const mergeObjects = (objA: any, objB: any) => { + function recursiveMerge(target: any, source: any) { for (const key in source) { if (typeof source[key] === 'object' && source[key] !== null) { - if (!target[key]) { + if (!target.hasOwnProperty(key)) { target[key] = Array.isArray(source[key]) ? [] : {}; } recursiveMerge(target[key], source[key]); - } else if (!target.hasOwnProperty(key)) { + } else if (!target.hasOwnProperty(key) && typeof target === 'object') { target[key] = source[key]; } }