Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/vchart/__tests__/unit/chart/bar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { GlobalScale } from '../../../src/scale/global-scale';
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import type { BarSeries, IChartSpec } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { ThemeManager } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { BarChart } from '../../../src';
import { DataSet } from '@visactor/vdataset';
import { createCanvas, removeDom } from '../../util/dom';
Expand Down Expand Up @@ -117,8 +115,7 @@ describe('Bar chart test', () => {
}
} as any;
},
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme()
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any)
} as any
);
chart.created();
Expand Down
5 changes: 1 addition & 4 deletions packages/vchart/__tests__/unit/chart/histogram.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import type { BarSeries } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { ThemeManager } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { HistogramChart } from '../../../src';
import { DataSet, DataView, csvParser, dataViewParser } from '@visactor/vdataset';
import { createCanvas, removeDom } from '../../util/dom';
Expand Down Expand Up @@ -63,8 +61,7 @@ describe('histogram chart test', () => {
container: null,
mode: 'desktop-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme()
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any)
} as any);
chart.created();
chart.init();
Expand Down
9 changes: 3 additions & 6 deletions packages/vchart/__tests__/unit/chart/line.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import type { ILineChartSpec } from '../../../src/chart/line/interface';
import { GlobalScale } from '../../../src/scale/global-scale';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import type { LineSeries } from '../../../src/series/line/line';
import { DataSet, DataView, csvParser } from '@visactor/vdataset';
import { LineChart } from '../../../src/chart/line/line';
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import { getTestCompiler } from '../../util/factory/compiler';
import { ThemeManager } from '../../../src';
import { initChartDataSet } from '../../util/context';
import VChart from '../../../src';

const VChartClass = VChart; // 确保引用 vchart 以确保注册所需的图表
const dataSet = new DataSet();
initChartDataSet(dataSet);
dataSet.registerParser('csv', csvParser);
Expand Down Expand Up @@ -48,7 +47,6 @@ describe('line chart test', () => {
mode: 'desktop-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme(),
onError: () => {}
} as any);
chart.created();
Expand Down Expand Up @@ -120,8 +118,7 @@ describe('line chart test', () => {
container: null,
mode: 'mobile-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme()
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any)
} as any
);
chart.created();
Expand Down
5 changes: 1 addition & 4 deletions packages/vchart/__tests__/unit/chart/linearProgress.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { DataSet, csvParser, dataViewParser } from '@visactor/vdataset';
import { DataSet, csvParser } from '@visactor/vdataset';
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import type { LinearProgressSeries } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { ThemeManager } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { LinearProgressChart } from '../../../src';
import { getTestCompiler } from '../../util/factory/compiler';
import { GlobalScale } from '../../../src/scale/global-scale';
Expand Down Expand Up @@ -52,7 +50,6 @@ describe('linearProgress chart test', () => {
mode: 'desktop-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme(),
animation: false
} as any);
chart.created();
Expand Down
5 changes: 2 additions & 3 deletions packages/vchart/__tests__/unit/chart/rangeColumn.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DataSet, DataView, csvParser, dataViewParser } from '@visactor/vdataset';
import { RangeColumnChart, ThemeManager } from '../../../src';
import { DataSet, DataView, csvParser } from '@visactor/vdataset';
import { RangeColumnChart } from '../../../src';
import type { RangeColumnSeries } from '../../../src/series/range-column/range-column';
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import { getTestCompiler } from '../../util/factory/compiler';
Expand Down Expand Up @@ -63,7 +63,6 @@ describe('rangeColumn chart test', () => {
mode: 'desktop-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme(),
animation: false
} as any);
chart.created();
Expand Down
5 changes: 2 additions & 3 deletions packages/vchart/__tests__/unit/chart/treemap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { GlobalScale } from '../../../src/scale/global-scale';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import { ThemeManager, default as VChart } from '../../../src';
import { DataSet, csvParser, dataViewParser } from '@visactor/vdataset';
import { default as VChart } from '../../../src';
import { DataSet, csvParser } from '@visactor/vdataset';
import { createCanvas, removeDom } from '../../util/dom';
import { getTestCompiler } from '../../util/factory/compiler';
import { disk } from '../../data/disk';
Expand Down Expand Up @@ -66,7 +66,6 @@ describe('treemap chart test', () => {
mode: 'desktop-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme(),
onError: () => {}
} as any);
chart.created();
Expand Down
7 changes: 3 additions & 4 deletions packages/vchart/__tests__/unit/chart/word-cloud.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { GlobalScale } from '../../../src/scale/global-scale';
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import type { IWordCloudChartSpec } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { ThemeManager, default as VChart } from '../../../src';
import { DataSet, csvParser, dataViewParser } from '@visactor/vdataset';
import { default as VChart } from '../../../src';
import { DataSet, csvParser } from '@visactor/vdataset';
import { WordCloudChart } from '../../../src/chart/word-cloud/word-cloud';
import type { WordCloudSeries } from '../../../src/series/word-cloud/word-cloud';
import { dataWordCloud } from '../../data/data-wordcloud';
Expand Down Expand Up @@ -73,8 +73,7 @@ describe('wordCloud chart test', () => {
container: null,
mode: 'desktop-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme()
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any)
} as any);
chart.created();
chart.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { GlobalScale } from '../../../../../src/scale/global-scale';
import type { IEventDispatcher } from '../../../../../src/event/interface';
/* eslint-disable no-lone-blocks */
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { DataSet, csvParser, dataViewParser } from '@visactor/vdataset';
import { DataSet, csvParser } from '@visactor/vdataset';
import { dimensionStatistics } from '../../../../../src/data/transforms/dimension-statistics';
import type { CartesianLinearAxis } from '../../../../../src/index';
// eslint-disable-next-line no-duplicate-imports
import { CartesianAxis } from '../../../../../src/index';
import type { IComponent, IComponentOption } from '../../../../../src/component/interface';
import { EventDispatcher } from '../../../../../src/event/event-dispatcher';
import { lightTheme } from '../../../../../src/theme/builtin/light';
import { getTestCompiler } from '../../../../util/factory/compiler';
import { initChartDataSet } from '../../../../util/context';

Expand Down Expand Up @@ -90,7 +89,6 @@ const ctx: IComponentOption = {
getChartViewRect: () => {
return { width: 500, height: 500 } as any;
},
getTheme: () => lightTheme,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getComponentByUserId: function (user_id: string | number): IComponent | undefined {
throw new Error('Function not implemented.');
Expand Down
9 changes: 3 additions & 6 deletions packages/vchart/__tests__/unit/data/fields.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { LineChart } from '../../../src/chart/line/line';
import { DataSet, dataViewParser } from '@visactor/vdataset';
import { DataSet } from '@visactor/vdataset';
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import * as bt from '../../../src/vchart-all';
import { getTestCompiler } from '../../util/factory/compiler';
import { GlobalScale } from '../../../src/scale/global-scale';
import { ThemeManager } from '../../../src';
import { initChartDataSet } from '../../util/context';
bt;

Expand Down Expand Up @@ -68,8 +67,7 @@ describe('data fields test', () => {
container: null,
mode: 'desktop-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme()
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any)
} as any
);
chart.created();
Expand Down Expand Up @@ -143,8 +141,7 @@ describe('data fields test', () => {
container: null,
mode: 'desktop-browser',
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
getTheme: () => ThemeManager.getCurrentTheme()
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any)
} as any
);
chart.created();
Expand Down
7 changes: 2 additions & 5 deletions packages/vchart/__tests__/unit/morph/morph.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BarChart, CommonChart, ThemeManager } from '../../../src';
import { DataSet, dataViewParser, DataView, csvParser } from '@visactor/vdataset';
import { BarChart, CommonChart } from '../../../src';
import { DataSet, DataView, csvParser } from '@visactor/vdataset';
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import { createCanvas, removeDom } from '../../util/dom';
import { getTestCompiler } from '../../util/factory/compiler';
Expand Down Expand Up @@ -126,7 +126,6 @@ describe('Bar chart test', () => {
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
animation: true,
getTheme: () => ThemeManager.getCurrentTheme(),
onError: () => {}
} as any);
scatterChart.created();
Expand All @@ -147,7 +146,6 @@ describe('Bar chart test', () => {
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
animation: true,
getTheme: () => ThemeManager.getCurrentTheme(),
onError: () => {}
} as any);
barChart.created();
Expand Down Expand Up @@ -184,7 +182,6 @@ describe('Bar chart test', () => {
getCompiler: getTestCompiler,
globalScale: new GlobalScale([], { getAllSeries: () => [] as any[] } as any),
animation: true,
getTheme: () => ThemeManager.getCurrentTheme(),
onError: () => {}
} as any
);
Expand Down
11 changes: 4 additions & 7 deletions packages/vchart/__tests__/unit/scale/global-scale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import { CommonChart } from '../../../src/chart/common/common';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import { EventDispatcher } from '../../../src/event/event-dispatcher';
import type { IChartSpec, ScatterSeries } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { ThemeManager } from '../../../src';
import { VChart, type IChartSpec, type ScatterSeries } from '../../../src';
// eslint-disable-next-line no-duplicate-imports
import { DataSet, dataViewParser, DataView } from '@visactor/vdataset';
import { createCanvas, removeDom } from '../../util/dom';
import type { IAttrs, VisualScaleType } from '../../../src/mark/interface';
import { dimensionStatistics } from '../../../src/data/transforms/dimension-statistics';

const VChartClass = VChart; // 确保引用 vchart 以确保注册所需的图表
// 保证引入执行 Build-in
let dataSet: DataSet;
const data = [
Expand Down Expand Up @@ -315,8 +314,7 @@ describe('global-scale test', () => {
};
}
} as any;
},
getTheme: () => ThemeManager.getCurrentTheme()
}
} as any
);
chart.created();
Expand Down Expand Up @@ -470,8 +468,7 @@ describe('global-scale test', () => {
};
}
} as any;
},
getTheme: () => ThemeManager.getCurrentTheme()
}
} as any
);
chart.created();
Expand Down
6 changes: 2 additions & 4 deletions packages/vchart/__tests__/unit/theme/line.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataSet, DataView, csvParser, dataViewParser } from '@visactor/vdataset';
import { DataSet, DataView, csvParser } from '@visactor/vdataset';
import { VChart } from '../../../src/vchart-all';
import type { ITheme } from '../../../src/theme';
// eslint-disable-next-line no-duplicate-imports
Expand Down Expand Up @@ -137,8 +137,7 @@ describe('theme switch test', () => {
await vchart.renderAsync();
// await vchart.setCurrentTheme('light');
// sepc
expect(vchart.getCurrentTheme().background).toBe('red');
expect(vchart.getCurrentThemeName()).toBe('newTheme');
expect(vchart.getCompiler().getVGrammarView().background()).toBe('red');
});

it('set theme in spec and theme is an object', async () => {
Expand Down Expand Up @@ -179,7 +178,6 @@ describe('theme switch test', () => {

await vchart.renderAsync();
// spec
expect(vchart.getCurrentTheme().background).toBe('red');
expect(vchart.getCompiler().getVGrammarView().background()).toBe('red');
expect(vchart.getCurrentThemeName()).toBe('light');
});
Expand Down
2 changes: 0 additions & 2 deletions packages/vchart/__tests__/util/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function modelOption(opt: Partial<IModelOption> = {}, chart?: TestChart):
export function seriesOption(opt: Partial<IModelOption> = {}, chart?: TestChart): ISeriesOption {
const option = modelOption(opt) as ISeriesOption;
option.globalScale = new GlobalScale([], chart as any);
option.getTheme = () => ThemeManager.getCurrentTheme();
option.region = (chart?.getAllRegions?.()?.[0] ?? new TestRegion({})) as IRegion;
option.onError = msg => {
console.log(msg);
Expand All @@ -65,7 +64,6 @@ export function seriesOption(opt: Partial<IModelOption> = {}, chart?: TestChart)

export function componentOption(opt: Partial<IModelOption> = {}, chart: TestChart): IComponentOption {
const option = modelOption(opt) as IComponentOption;
option.getTheme = () => ThemeManager.getCurrentTheme();
// 区域
option.getRegionsInIndex = chart.getRegionsInIndex.bind(chart);
option.getRegionsInIds = chart.getRegionsInIds.bind(chart);
Expand Down
Loading