Skip to content

Commit

Permalink
hot fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Renatavl committed Nov 2, 2024
1 parent 9dd4f94 commit 28db1e0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
import React, { useMemo } from 'react'
import { Bar } from 'react-chartjs-2'
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend
} from 'chart.js'
import { Box } from '@mui/material'
import useBreakpoints from '~/hooks/use-breakpoints'
import palette from '~/styles/app-theme/app.pallete'

ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend)

const data = {
export const data = {
labels: [
'JAN',
'FEB',
Expand All @@ -42,7 +27,7 @@ const data = {
]
}

const options = {
export const options = {
responsive: true,
maintainAspectRatio: false,
plugins: {
Expand Down Expand Up @@ -75,22 +60,3 @@ const options = {
}
}
}

const QuantityLessonsChart = () => {
const { isMobile } = useBreakpoints()

const dataResponsive = useMemo(() => {
const obj = data
obj.datasets[0].barThickness = isMobile ? 20 : 28

return obj
}, [isMobile])

return (
<Box height={'181px'} key={+isMobile}>
<Bar data={dataResponsive} options={options} />
</Box>
)
}

export default QuantityLessonsChart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { useMemo } from 'react'
import { Bar } from 'react-chartjs-2'
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend
} from 'chart.js'
import { Box } from '@mui/material'
import useBreakpoints from '~/hooks/use-breakpoints'
import { data, options } from './QuantityLessonsChart.constants'

ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend)

const QuantityLessonsChart = () => {
const { isMobile } = useBreakpoints()

const dataResponsive = useMemo(() => {
const obj = data
obj.datasets[0].barThickness = isMobile ? 20 : 28

return obj
}, [isMobile])

return (
<Box height='181px' key={+isMobile}>
<Bar data={dataResponsive} options={options} />
</Box>
)
}

export default QuantityLessonsChart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, Button, MenuItem, Select, Typography } from '@mui/material'
import { styles } from './QuantityLessonsCard.styles'
import SchoolIcon from '@mui/icons-material/School'
import EventIcon from '@mui/icons-material/Event'
import QuantityLessonsChart from './QuantityLessonsChart'
import QuantityLessonsChart from './QuantityLessonChart/QuantityLessonsChart'
import { useTranslation } from 'react-i18next'
import { categories, subjects, years } from './QuantityLessons.constants'

Expand Down

0 comments on commit 28db1e0

Please sign in to comment.