我的解决方案非常简单,我需要分配表是什么类型的元素。所以我的问题是:
createTable(chart){
var table = document.createElement("TABLE") as HTMLTableElement;
var row,header,cell1, cell2;
var data = chart.options.data;
table.style.border = "1px solid #000";
header = table.createTHead();
row = header.insertRow(0);
cell1 = row.insertCell(0);
cell2 = row.insertCell(1);
cell1.style.border = "1px solid #000";
cell2.style.border = "1px solid #000";
cell1.innerHTML = "<b>X-Value</b>";
cell2.innerHTML = "<b>Y-Value</b>";
for(var i = 0; i < data.length; i++){
for(var j = 0; j< data[i].dataPoints.length; j++){
row = table.insertRow(1);
cell1 = row.insertCell(0);
cell2 = row.insertCell(1);
cell1.style.border = "1px solid #000";
cell2.style.border = "1px solid #000";
cell1.innerHTML = data[i].dataPoints[j].x;
cell2.innerHTML = data[i].dataPoints[j].y;
}
}
document.getElementById("chartContainer").appendChild(table);
}
所以我添加了htmltableelement,这是解决我问题的方法。