Created
December 4, 2017 02:14
-
-
Save dance2die/415c53ec7475ebb066373983c93ccc1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import shortid from "shortid"; | |
const TableView = ({ data }) => { | |
const { labels, datasets } = data; | |
const headers = datasets.map(set => ( | |
<th key={shortid.generate()}>{set.title}</th> | |
)); | |
const rows = labels.map((label, i) => { | |
return ( | |
<tr key={shortid.generate()}> | |
<td key={shortid.generate()}>{label}</td> | |
{datasets.map(set => <td key={shortid.generate()}>{set.values[i]}</td>)} | |
</tr> | |
); | |
}); | |
return ( | |
<table> | |
<thead> | |
<tr> | |
<th key={shortid.generate()}>Labels</th> | |
{headers} | |
</tr> | |
</thead> | |
<tbody>{rows}</tbody> | |
</table> | |
); | |
}; | |
export default TableView; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment