我正在使用React開發Web應用程序。我想將圖表和數據導出到單個PDF頁面。試圖做到這一點,我得到以下錯誤未捕獲錯誤:不支持的編號:00940155.184155.1840040
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)
是什麼原因呢?
代碼如下
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");
});
});
});
有線105是chart.export.toPDF,我使用this例如開發這個代碼。
這裏是jsfiddle
請提供更多信息[更多信息](https://stackoverflow.com/help/how-to-ask) –
您必須共享代碼/數據,以便能夠理解此問題的來源。 – Styx
告訴我們你的代碼?並從我得到你想要分配'00940155.184155.1840040'到一個不可能的數字,因爲它有2位小數 – mrid