Skip to content

Commit 51df106

Browse files
authored
Merge pull request #4643 from VisActor/feat/upgrade-vrender-to-optimiaz-pie
Feat/upgrade vrender to optimiaz pie
2 parents 94ca022 + 5805011 commit 51df106

11 files changed

Lines changed: 455 additions & 367 deletions

File tree

common/config/rush/pnpm-lock.yaml

Lines changed: 336 additions & 334 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"@visactor/vchart-theme": "~1.6.6",
2020
"@visactor/vmind": "1.2.4-alpha.5",
2121
"@visactor/vutils": "~1.0.23",
22-
"@visactor/vrender": "~1.1.8-alpha.0",
23-
"@visactor/vrender-kits": "~1.1.8-alpha.0",
22+
"@visactor/vrender": "1.1.8",
23+
"@visactor/vrender-kits": "1.1.8",
2424
"@visactor/vtable": "1.19.0-alpha.0",
2525
"@visactor/vtable-editors": "1.19.0-alpha.0",
2626
"@visactor/vtable-gantt": "1.19.0-alpha.0",

packages/openinula-vchart/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"dependencies": {
3131
"@visactor/vchart": "workspace:2.1.5",
3232
"@visactor/vutils": "~1.0.23",
33-
"@visactor/vrender-core": "~1.1.8-alpha.0",
34-
"@visactor/vrender-kits": "~1.1.8-alpha.0",
33+
"@visactor/vrender-core": "1.1.8",
34+
"@visactor/vrender-kits": "1.1.8",
3535
"react-is": "^18.2.0"
3636
},
3737
"devDependencies": {

packages/react-vchart/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"@visactor/vchart": "workspace:2.1.5",
3737
"@visactor/vchart-extension": "workspace:2.1.5",
3838
"@visactor/vutils": "~1.0.23",
39-
"@visactor/vrender-core": "~1.1.8-alpha.0",
40-
"@visactor/vrender-kits": "~1.1.8-alpha.0",
39+
"@visactor/vrender-core": "1.1.8",
40+
"@visactor/vrender-kits": "1.1.8",
4141
"react-is": "^18.2.0"
4242
},
4343
"devDependencies": {

packages/vchart-extension/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
"start": "ts-node __tests__/runtime/browser/scripts/initVite.ts && vite serve __tests__/runtime/browser"
2727
},
2828
"dependencies": {
29-
"@visactor/vrender-core": "~1.1.8-alpha.0",
30-
"@visactor/vrender-kits": "~1.1.8-alpha.0",
31-
"@visactor/vrender-components": "~1.1.8-alpha.0",
32-
"@visactor/vrender-animate": "~1.1.8-alpha.0",
29+
"@visactor/vrender-core": "1.1.8",
30+
"@visactor/vrender-kits": "1.1.8",
31+
"@visactor/vrender-components": "1.1.8",
32+
"@visactor/vrender-animate": "1.1.8",
3333
"@visactor/vchart": "workspace:2.1.5",
3434
"@visactor/vutils": "~1.0.23",
3535
"@visactor/vdataset": "~1.0.23",

packages/vchart/__tests__/runtime/browser/index.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@
6363
<!-- 添加新的控制脚本 -->
6464
<script type="module">
6565
const params = new URLSearchParams(window.location.search);
66-
const currentView = params.get('view') === 'dashboard' ? 'dashboard' : 'default';
66+
const currentView =
67+
params.get('view') === 'dashboard'
68+
? 'dashboard'
69+
: params.get('view') === 'pie-performance'
70+
? 'pie-performance'
71+
: 'default';
6772
const button = document.getElementById('toggleScriptBtn');
6873

6974
let scriptSrc;
@@ -74,10 +79,14 @@
7479
scriptSrc = './index.page.dashboard.ts';
7580
nextViewUrl = './index.html'; // 切换回默认视图
7681
buttonText = '切换到默认视图 (单图)';
82+
} else if (currentView === 'pie-performance') {
83+
scriptSrc = './test-page/performance-pie-small.ts';
84+
nextViewUrl = './index.html';
85+
buttonText = '切换到默认视图 (单图)';
7786
} else {
7887
scriptSrc = './index.page.ts'; // 默认加载这个脚本
79-
nextViewUrl = './index.html?view=dashboard'; // 切换到仪表盘视图
80-
buttonText = '切换到仪表盘视图 (6图)';
88+
nextViewUrl = './index.html?view=pie-performance';
89+
buttonText = '切换到饼图性能页';
8190
}
8291

8392
// 设置按钮文本
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { default as VChart, type ISpec } from '../../../../src/index';
2+
3+
const WIDTH = 640;
4+
const HEIGHT = 360;
5+
const DATA_COUNT = 1000;
6+
7+
const values = Array.from({ length: DATA_COUNT }, (_, index) => {
8+
const itemIndex = index + 1;
9+
const category = `R${itemIndex.toString().padStart(5, '0')}`;
10+
11+
return {
12+
category: itemIndex % 17 === 0 ? `${category}-resize-label-long-text` : category,
13+
value: (itemIndex * 37 + 1) % 997,
14+
value2: (itemIndex * 53 + 18) % 991,
15+
word: `word-${itemIndex.toString().padStart(5, '0')}`
16+
};
17+
});
18+
19+
const spec: ISpec = {
20+
type: 'pie',
21+
width: WIDTH,
22+
height: HEIGHT,
23+
autoFit: false,
24+
animation: false,
25+
background: '#ffffff',
26+
color: ['#3370ff', '#00b8d9', '#34c724', '#ff7d00', '#7b67ee', '#f54a45'],
27+
padding: { top: 24, right: 24, bottom: 52, left: 60 },
28+
data: [{ id: 'main', values }],
29+
tooltip: { visible: true },
30+
categoryField: 'category',
31+
valueField: 'value',
32+
outerRadius: 0.82,
33+
label: { visible: true, style: { fontSize: 10 }, position: 'outside' },
34+
legends: { visible: true, orient: 'right' }
35+
};
36+
37+
const chartContainer = document.getElementById('chartContainer') as HTMLElement;
38+
const chartDom = document.getElementById('chart') as HTMLElement;
39+
const controlPanel = document.getElementById('controlPanel') as HTMLElement;
40+
41+
chartContainer.style.flexGrow = '0';
42+
chartContainer.style.width = `${WIDTH}px`;
43+
chartContainer.style.height = `${HEIGHT}px`;
44+
chartContainer.style.margin = '12px auto 0';
45+
chartDom.style.width = '100%';
46+
chartDom.style.height = '100%';
47+
48+
const renderButton = document.createElement('button');
49+
renderButton.type = 'button';
50+
renderButton.textContent = '渲染 pie.small.100';
51+
52+
const resetButton = document.createElement('button');
53+
resetButton.type = 'button';
54+
resetButton.textContent = '释放并重置';
55+
56+
const status = document.createElement('span');
57+
status.style.marginLeft = '8px';
58+
status.textContent = '100 个数据点,等待录制后点击渲染';
59+
60+
let chart: VChart | undefined;
61+
62+
const reset = () => {
63+
chart?.release();
64+
chart = undefined;
65+
chartDom.replaceChildren();
66+
renderButton.disabled = false;
67+
status.textContent = '已重置,可开始下一次录制';
68+
};
69+
70+
renderButton.addEventListener('click', () => {
71+
reset();
72+
performance.mark('vchart-pie-small:create-start');
73+
chart = new VChart(spec, { dom: chartDom, mode: 'desktop-browser', animation: false });
74+
performance.mark('vchart-pie-small:render-start');
75+
chart.renderSync();
76+
performance.mark('vchart-pie-small:render-end');
77+
renderButton.disabled = true;
78+
window['vchart'] = chart;
79+
status.textContent = '已渲染;使用“释放并重置”后可进行下一次录制';
80+
});
81+
82+
resetButton.addEventListener('click', reset);
83+
controlPanel.append(renderButton, resetButton, status);

packages/vchart/__tests__/unit/component/legend/discrete-legend.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,7 @@ describe('Discrete legend getLegendAttributes layout callbacks', () => {
108108
});
109109

110110
test('should keep a static `pager.layout` unchanged', () => {
111-
const attrs = getLegendAttributes(
112-
{ type: 'discrete', pager: { layout: 'horizontal' } } as any,
113-
rect as any
114-
);
111+
const attrs = getLegendAttributes({ type: 'discrete', pager: { layout: 'horizontal' } } as any, rect as any);
115112

116113
expect(attrs.pager.layout).toBe('horizontal');
117114
});
@@ -144,10 +141,7 @@ describe('Discrete legend getLegendAttributes layout callbacks', () => {
144141
});
145142

146143
test('should keep a static `pager.position` unchanged', () => {
147-
const attrs = getLegendAttributes(
148-
{ type: 'discrete', pager: { position: 'middle' } } as any,
149-
rect as any
150-
);
144+
const attrs = getLegendAttributes({ type: 'discrete', pager: { position: 'middle' } } as any, rect as any);
151145

152146
expect(attrs.pager.position).toBe('middle');
153147
});

packages/vchart/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@
128128
"@visactor/vdataset": "~1.0.23",
129129
"@visactor/vscale": "~1.0.23",
130130
"@visactor/vlayouts": "~1.0.23",
131-
"@visactor/vrender": "~1.1.8-alpha.0",
132-
"@visactor/vrender-core": "~1.1.8-alpha.0",
133-
"@visactor/vrender-kits": "~1.1.8-alpha.0",
134-
"@visactor/vrender-components": "~1.1.8-alpha.0",
135-
"@visactor/vrender-animate": "~1.1.8-alpha.0",
131+
"@visactor/vrender": "1.1.8",
132+
"@visactor/vrender-core": "1.1.8",
133+
"@visactor/vrender-kits": "1.1.8",
134+
"@visactor/vrender-components": "1.1.8",
135+
"@visactor/vrender-animate": "1.1.8",
136136
"@visactor/vutils-extension": "workspace:2.1.5"
137137
},
138138
"publishConfig": {

packages/vchart/src/core/vchart.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export class VChart implements IVChart {
467467
// 设置全局字体
468468
this._setFontFamilyTheme(this.getTheme('fontFamily') as string);
469469
this._initDataSet(this._option.dataSet);
470-
this._autoSize = isTrueBrowseEnv ? (spec.autoFit ?? this._option.autoFit ?? true) : false;
470+
this._autoSize = isTrueBrowseEnv ? spec.autoFit ?? this._option.autoFit ?? true : false;
471471
this._bindResizeEvent();
472472
this._bindViewEvent();
473473
this._initChartPlugin();
@@ -1526,8 +1526,8 @@ export class VChart implements IVChart {
15261526
isObject(specTheme) && specTheme.type
15271527
? specTheme.type
15281528
: isObject(optionTheme) && optionTheme.type
1529-
? optionTheme.type
1530-
: this._currentThemeName
1529+
? optionTheme.type
1530+
: this._currentThemeName
15311531
),
15321532
getThemeObject(optionTheme),
15331533
getThemeObject(specTheme)
@@ -1561,7 +1561,7 @@ export class VChart implements IVChart {
15611561
}
15621562

15631563
const lasAutoSize = this._autoSize;
1564-
this._autoSize = isTrueBrowser(this._option.mode) ? (this._spec.autoFit ?? this._option.autoFit ?? true) : false;
1564+
this._autoSize = isTrueBrowser(this._option.mode) ? this._spec.autoFit ?? this._option.autoFit ?? true : false;
15651565
if (this._autoSize !== lasAutoSize) {
15661566
resize = true;
15671567
}

0 commit comments

Comments
 (0)