-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
modify-existing-chart-styled.test.ts
108 lines (104 loc) · 3.12 KB
/
modify-existing-chart-styled.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import Automizer, { modify } from '../src/index';
import { ChartData } from '../src/types/chart-types';
test('create presentation, add slide with charts from template and modify existing chart.', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/pptx-templates`,
outputDir: `${__dirname}/pptx-output`,
});
const pres = automizer
.loadRoot(`RootTemplate.pptx`)
.load(`SlideWithCharts.pptx`, 'charts');
const result = await pres
.addSlide('charts', 2, (slide) => {
slide.modifyElement('ColumnChart', [
modify.setChartData(<ChartData>{
series: [
{
label: 'series 1',
// Style prop can be applied to series
style: {
color: {
type: 'schemeClr',
value: 'accent1',
},
// All labels of a series can be styled
label: {
color: {
type: 'schemeClr',
value: 'accent2',
},
isBold: false,
size: 2200,
},
},
},
{ label: 'series 2' },
{ label: 'series 3' },
],
categories: [
{
label: 'cat 2-1',
values: [50, 40, 20],
// Style prop can be applied to single values,
// array indices need to correspond (0: 50)
styles: [
{
color: {
type: 'srgbClr',
value: '333333',
},
},
],
},
{
label: 'cat 2-2',
values: [25, 10, 20],
// Style prop will be applied to second point in category ("10").
styles: [
null,
{
color: {
type: 'srgbClr',
value: 'efefef',
},
},
{
color: {
type: 'srgbClr',
value: 'eecc00',
},
},
],
},
{ label: 'cat 2-3', values: [15, 50, 20] },
{
label: 'cat 2-4',
values: [26, 50, 20],
// Style prop will be applied to third point in category ("20").
styles: [
null,
null,
{
color: {
type: 'srgbClr',
value: 'eeccff',
},
// All single datapoint label can have a different style
label: {
color: {
type: 'schemeClr',
value: 'accent2',
},
isBold: false,
size: 2200,
},
},
],
},
],
}),
]);
})
.write(`modify-existing-chart-styled.test.pptx`);
expect(result.charts).toBe(3);
});