admin管理员组文章数量:1434934
I'm developing a web application using React. I want to export a chart and data to a single PDF page. Trying to do this, I'm getting the following error
pdfmake.js:29058 Uncaught Error: unsupported number: 00940155.184155.1840040
at t.number (pdfmake.js:29058)
at r.lineTo (pdfmake.js:37584)
at d (pdfmake.js:2733)
at f (pdfmake.js:2601)
at r.createPdfKitDocument (pdfmake.js:2392)
at i._createDoc (pdfmake.js:104)
at i.getBuffer (pdfmake.js:242)
at i.getDataUrl (pdfmake.js:222)
at Object.toPDF (export.min.js:1)
at Object.<anonymous> (TestLineChart.jsx:105)
what is reason for that?
Code is below
TestLineChart.jsx
chart.export.capture({}, function () {
this.toJPG({}, function (data) {
let chartHeder = document.getElementById('chartHeder').innerText;
images.push({
"text": chartHeder,
"fontSize": 15
});
images.push({
'image': data,
"fit": [523.28, 769.89]
});
images.push({
"text": '\n\n',
"fontSize": 15
});
images.push({
"table": {
"headerRows": 1,
"widths": columnStyleArray,
"body": [ //chart.dataProvider
["DATE VARIANCE", "CURRENT YEAR VARIANCE", "LAST YEAR VARIANCE"],
["5000", "4500", "5100"],
["5000", "4500", "5100"],
["5000", "4500", "5100"],
]
}
});
chart.export.toPDF({
content: images
}, function (data) {
let fileName = chartHeder.split(' /')[0] + '_' + chart.dataProvider[0].date + ' - ' + chart.dataProvider[chart.dataProvider.length - 1].date;
this.download(data, "application/pdf", fileName + ".pdf");
});
});
});
there are line 105 is chart.export.toPDF, I use this example to develop this code.
Here is the jsfiddle
I'm developing a web application using React. I want to export a chart and data to a single PDF page. Trying to do this, I'm getting the following error
pdfmake.js:29058 Uncaught Error: unsupported number: 00940155.184155.1840040
at t.number (pdfmake.js:29058)
at r.lineTo (pdfmake.js:37584)
at d (pdfmake.js:2733)
at f (pdfmake.js:2601)
at r.createPdfKitDocument (pdfmake.js:2392)
at i._createDoc (pdfmake.js:104)
at i.getBuffer (pdfmake.js:242)
at i.getDataUrl (pdfmake.js:222)
at Object.toPDF (export.min.js:1)
at Object.<anonymous> (TestLineChart.jsx:105)
what is reason for that?
Code is below
TestLineChart.jsx
chart.export.capture({}, function () {
this.toJPG({}, function (data) {
let chartHeder = document.getElementById('chartHeder').innerText;
images.push({
"text": chartHeder,
"fontSize": 15
});
images.push({
'image': data,
"fit": [523.28, 769.89]
});
images.push({
"text": '\n\n',
"fontSize": 15
});
images.push({
"table": {
"headerRows": 1,
"widths": columnStyleArray,
"body": [ //chart.dataProvider
["DATE VARIANCE", "CURRENT YEAR VARIANCE", "LAST YEAR VARIANCE"],
["5000", "4500", "5100"],
["5000", "4500", "5100"],
["5000", "4500", "5100"],
]
}
});
chart.export.toPDF({
content: images
}, function (data) {
let fileName = chartHeder.split(' /')[0] + '_' + chart.dataProvider[0].date + ' - ' + chart.dataProvider[chart.dataProvider.length - 1].date;
this.download(data, "application/pdf", fileName + ".pdf");
});
});
});
there are line 105 is chart.export.toPDF, I use this example to develop this code.
Here is the jsfiddle
Share Improve this question edited Aug 14, 2017 at 3:43 Thilina Sampath asked Aug 11, 2017 at 5:42 Thilina SampathThilina Sampath 3,7737 gold badges42 silver badges66 bronze badges 6- Please provide more information.more info – Jude Niroshan Commented Aug 11, 2017 at 5:50
- 1 You have to share the code/data so it would be possible to understand the source of this issue. – Styx Commented Aug 11, 2017 at 5:50
-
show us your code ? and from what I get you are trying to assign
00940155.184155.1840040
to a number which is not possible since it has 2 decimals – mrid Commented Aug 11, 2017 at 5:52 - I updated qustion. please check – Thilina Sampath Commented Aug 11, 2017 at 6:11
-
Please, add an example of
data
value that causes this error. – Styx Commented Aug 11, 2017 at 7:32
2 Answers
Reset to default 5Looking at your jsfiddle, It's funny but your only problem is, In your table your first width
value is missing %
so change it to "40%"
Here I updated your jsfiddle
notice I only changed the table's width property
from "widths": ["40", "30%", "30%"]
to "widths": ["40%", "30%", "30%"]
adding %
to the first value.
Another solution in case you want to give exact width (like I wanted when I got similar error) is to pass a number, not a string.
I.e: "widths": [40, "30%", "30%"]
本文标签: javascriptUncaught Error unsupported number 009401551841551840040Stack Overflow
版权声明:本文标题:javascript - Uncaught Error: unsupported number: 00940155.184155.1840040 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745629261a2667169.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论