-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
modify-chart-datalabels.test.ts
60 lines (55 loc) · 1.68 KB
/
modify-chart-datalabels.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Automizer, { LabelPosition, modify } from '../src/index';
import { ChartSeriesDataLabelAttributes } from '../src/types/chart-types';
test('modify chart data label.', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/pptx-templates`,
outputDir: `${__dirname}/pptx-output`,
});
const pres = automizer
.loadRoot(`RootTemplate.pptx`)
.load(`ChartBarsStackedLabels.pptx`, 'charts')
.load(`ChartLinesVertical.pptx`, 'chartLines');
const DataLabelAttributes: ChartSeriesDataLabelAttributes = {
dLblPos: LabelPosition.Top,
showLegendKey: false,
showVal: false,
showCatName: true,
showSerName: false,
showPercent: false,
showBubbleSize: false,
showLeaderLines: false,
};
const result = await pres
.addSlide('charts', 1, (slide) => {
slide.modifyElement('BarsStacked', [
modify.setDataLabelAttributes(DataLabelAttributes),
]);
})
.addSlide('charts', 1, (slide) => {
slide.modifyElement('BarsStacked', [
modify.setDataLabelAttributes({
applyToSeries: 1,
dLblPos: LabelPosition.InsideBase,
showVal: true,
showSerName: true,
showPercent: true,
}),
]);
})
.addSlide('chartLines', 1, (slide) => {
slide.modifyElement('DotMatrix', [
modify.setDataLabelAttributes({
dLblPos: LabelPosition.Top,
showLegendKey: true,
showCatName: true,
showSerName: true,
solidFill: {
type: 'srgbClr',
value: '#FF00CC',
},
}),
]);
})
.write(`modify-chart-datalabels.test.pptx`);
expect(result.charts).toBe(6);
});