This repository has been archived by the owner on Sep 29, 2024. It is now read-only.
generated from caffeine-addictt/waku
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/feedback
- Loading branch information
Showing
16 changed files
with
919 additions
and
54 deletions.
There are no files selected for viewing
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,54 @@ | ||
import React from 'react'; | ||
import { Line } from 'react-chartjs-2'; | ||
import { | ||
Chart, | ||
CategoryScale, | ||
LinearScale, | ||
PointElement, | ||
LineElement, | ||
Title, | ||
Tooltip, | ||
Legend, | ||
} from 'chart.js'; | ||
|
||
// Register the components | ||
Chart.register( | ||
CategoryScale, | ||
LinearScale, | ||
PointElement, | ||
LineElement, | ||
Title, | ||
Tooltip, | ||
Legend, | ||
); | ||
|
||
interface Sale { | ||
date: string; | ||
amount: number; | ||
} | ||
|
||
interface GraphProps { | ||
salesData: Sale[]; | ||
} | ||
|
||
const Graph: React.FC<GraphProps> = ({ salesData }) => { | ||
const chartData = { | ||
labels: salesData.map((sale) => sale.date), | ||
datasets: [ | ||
{ | ||
label: 'Sales Amount', | ||
data: salesData.map((sale) => sale.amount), | ||
borderColor: 'rgba(75, 192, 192, 1)', | ||
backgroundColor: 'rgba(75, 192, 192, 0.2)', | ||
}, | ||
], | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Line data={chartData} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Graph; |
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,63 @@ | ||
import React from 'react'; | ||
import { Pie } from 'react-chartjs-2'; | ||
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js'; | ||
import { TooltipItem } from 'chart.js'; | ||
|
||
ChartJS.register(ArcElement, Tooltip, Legend); | ||
|
||
interface SustainabilityPieChartProps { | ||
data: { | ||
label: string; | ||
value: number; | ||
}[]; | ||
} | ||
|
||
const SustainabilityPieChart: React.FC<SustainabilityPieChartProps> = ({ | ||
data, | ||
}) => { | ||
// Prepare data for the chart | ||
const chartData = { | ||
labels: data.map((item) => item.label), | ||
datasets: [ | ||
{ | ||
data: data.map((item) => item.value), | ||
backgroundColor: [ | ||
'#FF6384', | ||
'#36A2EB', | ||
'#FFCE56', | ||
'#FF5733', | ||
'#C70039', | ||
], | ||
borderColor: '#fff', | ||
borderWidth: 1, | ||
}, | ||
], | ||
}; | ||
|
||
// Options for the pie chart | ||
const options = { | ||
responsive: true, | ||
plugins: { | ||
legend: { | ||
position: 'top' as const, | ||
}, | ||
tooltip: { | ||
callbacks: { | ||
label: (tooltipItem: TooltipItem<'pie'>) => { | ||
return `${tooltipItem.label}: ${tooltipItem.raw}`; | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<div className="flex size-full items-center justify-center p-6"> | ||
<div className="size-80"> | ||
<Pie data={chartData} options={options} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SustainabilityPieChart; |
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
Oops, something went wrong.