export const timeDataOptionToContent = (opt) => {
|
|
const headerList = [opt.xAxis[0]].concat(opt.yAxis).map((item) => `<td>${item.name}</td>`).join('');
|
const title = opt.title?.[0]?.text ?? '';
|
let table = '<div style="border:1px solid black"><h3>'+title+'</h3><table style="width:100%;text-align:center"><tbody><tr>' + headerList + '</tr>';
|
const timeData = new Set();
|
const dataMap = opt.series.map((item) => {
|
for (const subItem of item.data) {
|
timeData.add(subItem[0]);
|
}
|
return new Map(item.data);
|
});
|
const bodyList = Array.from(timeData)
|
.toSorted((a, b) => {
|
return (a as any).localeCompare(b);
|
})
|
.map((item) => {
|
|
return `<tr><td>${item}</td>${dataMap.map((itemMap) => `<td>${itemMap.get(item) ?? ''}</td>`)}</tr>`;
|
}).join('');
|
table += bodyList;
|
|
table += '</tbody></table></div>';
|
return table;
|
};
|