Created
May 12, 2019 21:16
-
-
Save gpDA/15a00ac0b7e2f53ac5f1b61ec18fd0e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const Chart = ({data}) => { | |
| // data ==> filteredData | |
| // console.log('chart.js ?',data) | |
| // get bytes_ts | |
| const bytes_ts = Array.from(data.map(datum => datum.map(ele => {return ele.bytes_ts}))) | |
| // get the length of data... | |
| const len_data = data.map(ele => {return ele.length}); | |
| // get bytes_fs | |
| const bytes_fs = (data.map(datum => datum.map(ele => {return ele.bytes_fs}))) | |
| // console.log('bytes_ts',bytes_fs) | |
| // to populate x axes | |
| const num_data = [...Array(len_data[0]).keys()] | |
| const chart_data = { | |
| labels: num_data, | |
| datasets: [{ | |
| label: "bytes_ts", | |
| lineTension: 0.1, | |
| fill: false, | |
| pointHoverBackgroundColor: "yellow", | |
| borderColor: "purple", | |
| pointRadius: 4, | |
| pointHitRadius: 10, | |
| data: bytes_ts[0], | |
| },{ | |
| label: "bytes_fs", | |
| lineTension: 0.1, | |
| fill: false, | |
| pointHoverBackgroundColor: "brown", | |
| borderColor: "green", | |
| pointRadius: 4, | |
| pointHitRadius: 10, | |
| data: bytes_fs[0] | |
| } | |
| ] | |
| } | |
| const options = { | |
| title: { | |
| display: true, | |
| text: 'chart.js line Chart' | |
| } | |
| } | |
| return ( | |
| // chartjs {Line} data && options | |
| <Line data={chart_data} options={options} /> | |
| ) | |
| }; | |
| export default Chart; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment