-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart-example.js
40 lines (36 loc) · 1.27 KB
/
chart-example.js
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
const fs = require('fs');
const { Page, Image, Container } = require('../src/components/index.js');
const { Alignment, PageSize } = require('../src/components/enums/index.js');
const { Offset } = require('../src/components/models/index.js');
const ReplyPDF = require('../src/reply-pdf.js');
module.exports = {
generate: () => {
const template = new Page({
size: PageSize.A4,
margin: new Offset(50),
children: [
new Container({
children: [
new Image({
verticalAlignment: Alignment.start,
horizontalAlignment: Alignment.middle,
binding: 'chart',
width: 300,
height: 100
}),
],
}),
],
});
const data = {
chart: 'https://image-charts.com/chart?chco=3072F3%2Cff0000%2C00aaaa&chd=t%3A10%2C20%2C40%2C80%2C90%2C95%2C99%7C20%2C30%2C40%2C50%2C60%2C70%2C80%7C-1%7C5%2C10%2C22%2C35%2C85&chdl=Ponies%7CUnicorns&chdlp=t&chls=2%2C4%2C1&chm=s%2C000000%2C0%2C-1%2C5%7Cs%2C000000%2C1%2C-1%2C5&chs=700x200&cht=lxy',
};
let doc = ReplyPDF.generateDocument({
data: data,
template: template,
debug: false,
});
doc.pipe(fs.createWriteStream('examples/outputs/output-chart-example.pdf'));
doc.end();
}
}