diff --git a/pages/search/[id].vue b/pages/search/[id].vue index cc6fd54ab08fc0666ed25446f22df509098a34e1..004cdde89976ce5ac46fc66b871da2a5116bb7dd 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -191,12 +191,24 @@ function handleFormatWebSource (source) { return sources } function handleFormatReports (content) { - let start = '::ProseLineChart' + let chartStart = '::ProseLineChart' + // todo + let tableStart = '::ProseDataTable' let result = '' + // ::ProseLineChart{title='xxx' :labels='[]' :data='[]'} content.forEach(item => { - const { title, data, columns } = item - let toStr = JSON.stringify({ title, data, columns }) - result += `${start}{:data=${toStr}}` + const { title, data, format } = item + if (format === 'timeline') { + const labels = [] + const datas = [] + data.forEach(child => { + labels.push(child.date) + datas.push(child.stargazers) + }) + result += `${chartStart}{title=${title} :labels=${JSON.stringify(labels)} :data=${JSON.stringify(datas)}}` + } else if ( format === 'table' ) { + result += `${tableStart}{:data=${JSON.stringify(data)}}` + } }) return result }