This commit is contained in:
YasinShaikh123
2024-10-17 18:00:47 +05:30
2 changed files with 5 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ import {
} from "@chakra-ui/react";
import { TbArrowBadgeRightFilled } from "react-icons/tb";
function ChartsTabs({ selectedValue, setSelectedValue }) {
function ChartsTabs({ selectedValue, setSelectedValue, days }) {
const { colorMode } = useColorMode();
// This function represents the RadioCard part
@@ -49,7 +49,7 @@ function ChartsTabs({ selectedValue, setSelectedValue }) {
}
// Setting defaultValue to '24 DayusHrs'
const options = ["24 Hrs", "30 Days", "12 Months"];
const options = ["24 Hrs", `${days} Days`, "12 Months"];
const { getRootProps, getRadioProps } = useRadioGroup({
name: "framework",

View File

@@ -27,7 +27,7 @@ ChartJS.register(
const LineChart = () => {
const { colorMode } = useColorMode();
const [selectedValue, setSelectedValue] = useState("Daily");
const [selectedValue, setSelectedValue] = useState("24 Hrs");
const [labels, setLabels] = useState([]);
const [dataset, setDataset] = useState([]);
@@ -41,7 +41,7 @@ const LineChart = () => {
Math.floor(Math.random() * 5000 + 1000)
);
setDataset(dailyData);
} else if (selectedValue === "30 Days") {
} else if (selectedValue === `${dayjs().daysInMonth()} Days`) {
// Create labels for the current month (days)
const daysInMonth = dayjs().daysInMonth();
const days = Array.from(
@@ -167,6 +167,7 @@ const LineChart = () => {
<ChartsTabs
setSelectedValue={setSelectedValue}
selectedValue={selectedValue}
days={dayjs().daysInMonth()}
/>
</Box>
<Line data={data} options={options} />