chart with external script - jsreport
vinithios opened this issue · 2 comments
Im getting the below error,
{"message":"Error during rendering report: Timeout when executing in phantom","stack":"Error: Timeout when executing in phantom\n at Timeout._onTimeout (/home/ionixx/jsReports/node_modules/phantom-html-to-pdf/lib/dedicatedProcessStrategy.js:81:26)\n at ontimeout (timers.js:488:11)\n at Timer.unrefdHandle (timers.js:599:5)"}
when i am adding external script to the chart in html.I don't know why this error occurs.It might be the script taking more time than,when we add script inside the html.
Is there any fix for this issue??
my code:
html:
<script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.min.js'></script>{{country}}
Download <script src="../../public/js/chart-pdf.js"></script>script file:
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['2011', '2012', '2013', '2014', '2015', '2016'],
datasets: [{
label: 'Pay slip',
data: [24000, 24000, 27000, 34000, 30000, 35000],
steppedLine: true,
backgroundColor: "rgba(220,143,143,0.4)",
borderColor: ""
},
{
label: 'Bank statement',
data: [23000, 28000, 27000, 36000, 33000, 29000],
steppedLine: true,
backgroundColor: "rgba(182,152,212,0.4)",
borderColor: ""
},
{
label: '26AS',
data: [27000, 29000, 35000, 36000, 32000, 35000],
steppedLine: true,
backgroundColor: "rgba(178,178,178,0.4)",
borderColor: ""
}
]
},
options: {
animation: {
onComplete: function () {
window.JSREPORT_READY_TO_START = true
}
},
elements: {
line: {
tension: 0
}
}
}
});
node file:
exports.report_full = function(req, res, next)
{
var url = req.query.file;
templatePath = templatePath+url;
var data = {
template: {
content: fs.readFileSync(path.join(rootPath, templatePath), 'utf8'),
recipe: 'phantom-pdf',
engine: 'handlebars',
phantom: {
"waitForJS": true
}
},
options: {
preview: true
}
};
var options = {
uri: 'http://localhost:8001/api/report',
method: 'POST',
json: data
};
var stream = request(options).pipe(res);
stream.on('finish', function (abc) {
//res.send(200);
});
}
it is really difficult to tell you what is happening without the full picture of your code, maybe there is some kind of javascript error in your page, try seeing the logs in the console. if you need more help you can also prepare a github repository with your problem and i can take a look quickly.
Closing because of inactivity. Feel free to reopen if you are able to demonstrate the issue.