-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
modify-chart-scatter.test.ts
53 lines (48 loc) · 1.61 KB
/
modify-chart-scatter.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
import Automizer, { modify } from '../src/index';
import {ChartData} from '../dist';
test('create presentation, add and modify a scatter chart.', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/pptx-templates`,
outputDir: `${__dirname}/pptx-output`
});
const pres = automizer
.loadRoot(`RootTemplate.pptx`)
.load(`ChartScatter.pptx`, 'charts');
const dataScatter = <ChartData><unknown>{
series: [
{label: 'series s1'},
{label: 'series s2'},
{label: 'series s3'}
],
categories: [
{label: 'r1', values: [{x: 10, y: 20}, {x: 9, y: 30}, {x: 19, y: 40}]},
{label: 'r2', values: [{x: 21, y: 11}, {x: 8, y: 31}, {x: 18, y: 41}]},
{label: 'r3', values: [{x: 22, y: 28}, {x: 7, y: 26}, {x: 17, y: 36}]},
{label: 'r4', values: [{x: 13, y: 13}, {x: 16, y: 28}, {x: 26, y: 38}]},
{label: 'r5', values: [{x: 18, y: 24}, {x: 15, y: 24}, {x: 25, y: 34}]},
{label: 'r6', values: [{x: 28, y: 34}, {x: 25, y: 34}, {x: 35, y: 44}]},
],
}
const result = await pres
.addSlide('charts', 1, (slide) => {
slide.modifyElement('Scatter', [
modify.setChartScatter(dataScatter),
]);
})
.addSlide('charts', 2, (slide) => {
// Set color of a single datapoint
dataScatter.categories[0].styles = [
{
color: {
type: 'srgbClr',
value: 'cccccc'
}
}
]
slide.modifyElement('ScatterPoint', [
modify.setChartScatter(dataScatter),
]);
})
.write(`modify-chart-scatter.test.pptx`)
expect(result.charts).toBe(4);
});