-
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
99a4276
commit 83fb6f2
Showing
9 changed files
with
201 additions
and
22 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,30 @@ | ||
import React from 'react'; | ||
import { CSVLink } from 'react-csv'; | ||
|
||
function CSVReportGeneration({ data }) { | ||
|
||
const csv_data = data | ||
const headers = [ | ||
{ label: "Date", key: "date" }, | ||
{ label: "Product ID", key: "product_id" }, | ||
{ label: "Product Name", key: "product_name" }, | ||
{ label: "Price/Per unit", key: "product_price" }, | ||
{ label: "Quantity", key: "product_qty" }, | ||
{ label: "Total", key: "total" }, | ||
] | ||
|
||
const csvReport = { | ||
filename: 'SalesReport.csv', | ||
headers, | ||
data:csv_data | ||
} | ||
|
||
|
||
return ( | ||
<div style={{ marginTop: '2rem', textAlign: 'center', fontSize: '1.7rem', marginBottom: '5rem', fontFamily: 'Poppins' }} > | ||
<CSVLink {...csvReport} >Export to CSV</CSVLink> | ||
</div> | ||
) | ||
} | ||
|
||
export default CSVReportGeneration |
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,88 @@ | ||
import React from 'react'; | ||
import { Pie } from 'react-chartjs-2'; | ||
|
||
function SalesPieChart({ pie_data }) { | ||
|
||
|
||
const dataLabel = [] | ||
const dataValues = [] | ||
|
||
for (let pd of pie_data) { | ||
const val = parseInt(pd.value) | ||
dataLabel.push(pd.name) | ||
dataValues.push(val) | ||
} | ||
|
||
const bgColPalette = [ | ||
'rgba(255, 99, 132, 0.2)', //Red | ||
'rgba(54, 162, 235, 0.2)', //Blue | ||
'rgba(255, 206, 86, 0.2)', // Yellow | ||
'rgba(75, 192, 192, 0.2)', // Green | ||
'rgba(153, 102, 255, 0.2)', // Purple | ||
'rgba(255, 159, 64, 0.2)', // Orange | ||
'rgba(255, 99, 132, 0.8)', //Red | ||
'rgba(54, 162, 235, 0.8)', //Blue | ||
'rgba(255, 206, 86, 0.8)', // Yellow | ||
'rgba(75, 192, 192, 0.8)', // Green | ||
'rgba(153, 102, 255, 0.8)', // Purple | ||
'rgba(255, 159, 64, 0.8)', // Orange | ||
'rgba(255, 99, 132,1)', //Red | ||
'rgba(54, 162, 235, 1)', //Blue | ||
'rgba(255, 206, 86, 1)', // Yellow | ||
'rgba(75, 192, 192, 1)', // Green | ||
'rgba(153, 102, 255, 1)', // Purple | ||
'rgba(255, 159, 64, 1)', // Orange | ||
] | ||
const borderColPalette = [ | ||
'rgba(255, 99, 132, 1)', | ||
'rgba(54, 162, 235, 1)', | ||
'rgba(255, 206, 86, 1)', | ||
'rgba(75, 192, 192, 1)', | ||
'rgba(153, 102, 255, 1)', | ||
'rgba(255, 159, 64, 1)', | ||
'rgba(255, 99, 132, 1)', | ||
'rgba(54, 162, 235, 1)', | ||
'rgba(255, 206, 86, 1)', | ||
'rgba(75, 192, 192, 1)', | ||
'rgba(153, 102, 255, 1)', | ||
'rgba(255, 159, 64, 1)', | ||
'rgba(255, 99, 132, 1)', | ||
'rgba(54, 162, 235, 1)', | ||
'rgba(255, 206, 86, 1)', | ||
'rgba(75, 192, 192, 1)', | ||
'rgba(153, 102, 255, 1)', | ||
'rgba(255, 159, 64, 1)', | ||
] | ||
|
||
|
||
const background = [] | ||
const border = [] | ||
|
||
for (let i = 0; i < pie_data.length; i++){ | ||
background[i] = bgColPalette[i] | ||
border[i] = borderColPalette[i] | ||
} | ||
|
||
const data = { | ||
labels: dataLabel, | ||
datasets: [ | ||
{ | ||
label: 'Contribution of each product', | ||
data: dataValues, | ||
backgroundColor:background , | ||
borderColor:border, | ||
borderWidth: 1, | ||
}, | ||
], | ||
|
||
}; | ||
|
||
return ( | ||
|
||
<div style={{ width: '50%', margin: 'auto' }}> | ||
<Pie data={data} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default SalesPieChart |
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
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
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