-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
572f7d0
commit c9a4b28
Showing
6 changed files
with
192 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react'; | ||
import { Bar } from 'react-chartjs-2'; | ||
|
||
function BarChart({ orderData }) { | ||
|
||
const saleByMonth = [] | ||
if (orderData) { | ||
for (let od of orderData) { | ||
saleByMonth.push(od.numOfOrder) | ||
} | ||
} | ||
|
||
|
||
const data = { | ||
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], | ||
datasets: [ | ||
{ | ||
label: '# of Sales by Months', | ||
data: saleByMonth, | ||
backgroundColor: [ | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
'rgba(0,158,96, 0.2)', | ||
|
||
], | ||
|
||
borderColor: [ | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
'rgba(0,158,96, 0.8)', | ||
], | ||
|
||
borderWidth: 1, | ||
}, | ||
], | ||
}; | ||
|
||
const options = { | ||
scales: { | ||
yAxes: [ | ||
{ | ||
ticks: { | ||
beginAtZero: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
return ( | ||
<div> | ||
<Bar data={data} options={options} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default BarChart |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import { Line } from 'react-chartjs-2'; | ||
|
||
function LineChart({ orderData }) { | ||
const saleByMonth=[] | ||
if (orderData) { | ||
for (let od of orderData) { | ||
saleByMonth.push(od.numOfOrder) | ||
} | ||
} | ||
const data = { | ||
|
||
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], | ||
datasets: [ | ||
{ | ||
label: '# of Sales By Month', | ||
data: saleByMonth, | ||
fill: false, | ||
pointRadius:5, | ||
backgroundColor: 'rgb(0,158,96)', | ||
borderColor: 'rgba(0,158,96, 0.2)', | ||
}, | ||
], | ||
}; | ||
|
||
|
||
const options = { | ||
scales: { | ||
yAxes: [ | ||
{ | ||
ticks: { | ||
beginAtZero: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Line data={data} options={options} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default LineChart |
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
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