-
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 pull request #37 from JJtan2002/main
Merge main into watchlist
- Loading branch information
Showing
3 changed files
with
91 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,37 @@ | ||
import React from "react"; | ||
import { useDash } from "../../contexts/DashBoardContext"; | ||
import { Bar } from "react-chartjs-2"; | ||
import React, { useContext } from 'react'; | ||
import { Bar } from 'react-chartjs-2'; | ||
import { useDash } from '../../contexts/DashBoardContext'; | ||
import { DashboardContextProvider } from '../../contexts/DashBoardContext'; | ||
|
||
const BarChart = () => { | ||
const { barData } = useDash(); | ||
const { barData, barDays, setBarDays } = useDash(DashboardContextProvider); | ||
|
||
const handleDaysChange = (event) => { | ||
setBarDays(parseInt(event.target.value, 10)); | ||
}; | ||
|
||
return ( | ||
<div className="w-full max-w-4xl mt-6"> | ||
<div className="w-full p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700"> | ||
<h2 className="mb-4 text-xl font-medium text-gray-900 dark:text-white">Daily Expenses</h2> | ||
<div className="flex justify-between items-center mb-4"> | ||
<h2 className="text-xl font-medium text-gray-900 dark:text-white">Daily Expenses</h2> | ||
<select | ||
value={barDays} | ||
onChange={handleDaysChange} | ||
className="p-2 border border-gray-300 rounded-lg dark:bg-gray-700 dark:text-white" | ||
> | ||
<option value={5}>Last 5 days</option> | ||
<option value={10}>Last 10 days</option> | ||
<option value={15}>Last 15 days</option> | ||
<option value={30}>Last 30 days</option> | ||
</select> | ||
</div> | ||
<div className="h-80"> {/* Adjust the height of the container */} | ||
<Bar data={barData} height={300} /> {/* Adjust the height of the chart */} | ||
</div> | ||
</div> | ||
</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 |
---|---|---|
@@ -1,21 +1,37 @@ | ||
import React from "react"; | ||
import { useDash } from "../../contexts/DashBoardContext"; | ||
import { Pie } from "react-chartjs-2"; | ||
import { useDash } from '../../contexts/DashBoardContext'; | ||
import { DashboardContextProvider } from '../../contexts/DashBoardContext'; | ||
|
||
const PieChart = () => { | ||
const { pieData } = useDash(); | ||
const { pieData, pieDays, setPieDays } = useDash(DashboardContextProvider); | ||
|
||
const handleDaysChange = (event) => { | ||
setPieDays(parseInt(event.target.value, 10)); | ||
}; | ||
|
||
return ( | ||
<div className="w-full max-w-4xl mt-6"> | ||
<div className="w-full p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700"> | ||
<h2 className="mb-4 text-xl font-medium text-gray-900 dark:text-white">Expense Distribution</h2> | ||
<div className="flex justify-between items-center mb-4"> | ||
<h2 className="text-xl font-medium text-gray-900 dark:text-white">Expense Distribution</h2> | ||
<select | ||
value={pieDays} | ||
onChange={handleDaysChange} | ||
className="p-2 border border-gray-300 rounded-lg dark:bg-gray-700 dark:text-white" | ||
> | ||
<option value={5}>Last 5 days</option> | ||
<option value={10}>Last 10 days</option> | ||
<option value={15}>Last 15 days</option> | ||
<option value={30}>Last 30 days</option> | ||
</select> | ||
</div> | ||
<div className="h-80"> {/* Adjust the height of the container */} | ||
<Pie data={pieData} height={300} /> {/* Adjust the height of the chart */} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
}; | ||
|
||
export default PieChart; |
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