forked from HoangLaoTa/gk_se_web_report
Compare commits
61 Commits
Author | SHA1 | Date |
---|---|---|
|
b1674a9ce9 | 2 months ago |
|
1fb26ff5a8 | 2 months ago |
|
1b1bfb83fc | 2 months ago |
|
8027fcaafc | 2 months ago |
|
5bb67fe957 | 2 months ago |
|
7643a94564 | 2 months ago |
|
df5c7b1d69 | 2 months ago |
|
0c99db8cb9 | 2 months ago |
|
dd7373eb8a | 2 months ago |
|
1ab9f80b98 | 2 months ago |
|
4d053c0ad9 | 3 months ago |
|
ee2b4c9e51 | 3 months ago |
|
844bf6e782 | 3 months ago |
|
4bdae89f43 | 3 months ago |
|
1704b78058 | 3 months ago |
|
4131312cff | 3 months ago |
|
1dc72d120b | 3 months ago |
|
7ee4e325cf | 3 months ago |
|
943e3facd5 | 3 months ago |
|
e092dc64b1 | 3 months ago |
|
4ccc74e332 | 3 months ago |
|
8c13a2c108 | 3 months ago |
|
86a9f2f437 | 3 months ago |
|
4606c42c7a | 3 months ago |
|
a88f014c12 | 3 months ago |
|
81205da08c | 3 months ago |
|
ca037c6267 | 3 months ago |
|
60d2c077b8 | 3 months ago |
|
3a1d7d4009 | 3 months ago |
|
239e0734b3 | 3 months ago |
|
d8cb4ae59b | 3 months ago |
|
c1d0b7ce41 | 3 months ago |
|
c4682bb61c | 3 months ago |
|
46dce555d5 | 3 months ago |
|
16d12050c7 | 3 months ago |
|
4af9ce6629 | 3 months ago |
|
90ff3c8dc5 | 3 months ago |
|
b30181e1e2 | 3 months ago |
|
62fac2ec8a | 3 months ago |
|
87b55b0e01 | 3 months ago |
|
daff2332c2 | 3 months ago |
|
a4d4169148 | 3 months ago |
|
b888e82d88 | 3 months ago |
|
48c6143610 | 3 months ago |
|
4c329ae25e | 3 months ago |
|
20d1e5c553 | 3 months ago |
|
4c0830abbf | 3 months ago |
|
2958cf1483 | 3 months ago |
|
53ca639f1b | 3 months ago |
|
4bcf807247 | 3 months ago |
|
505c4ef3eb | 3 months ago |
|
84e1502e89 | 3 months ago |
|
b1fbbb9124 | 3 months ago |
|
db60b90bc4 | 3 months ago |
|
768b2317bc | 3 months ago |
|
ec162f6e45 | 3 months ago |
|
d9bbcd2850 | 3 months ago |
|
f3aff8b648 | 3 months ago |
|
0f15dfe3ec | 3 months ago |
|
e2ecabf447 | 3 months ago |
|
7d0967a370 | 3 months ago |
33 changed files with 1742 additions and 452 deletions
@ -1,75 +1,139 @@ |
|||||||
import { Subtitles } from '@material-ui/icons' |
|
||||||
import { PRIMARY_COLOR } from '../../_constants/common' |
import { PRIMARY_COLOR } from '../../_constants/common' |
||||||
import RDoughnutChart from '../chart/RDoughnutChart' |
import RDoughnutChart from '../chart/RDoughnutChart' |
||||||
import './boxChart.scss' |
import './boxChart.scss' |
||||||
import { VerticalBarChart } from '../chart/VerticalBarChart' |
import { VerticalBarChart } from '../chart/VerticalBarChart' |
||||||
import { useState } from 'react' |
import { useEffect, useState } from 'react' |
||||||
import InputDate from '../Auth/InputDate' |
import InputDate from '../Auth/InputDate' |
||||||
|
import { renderIconButton, renderIconButtonLeft, renderIconDate } from '../renderIcon' |
||||||
|
|
||||||
export default function BoxDoughnutBarChart({dataDoughnut = [], dataBarChart = [], labelsBarChart = [], dateBarChat, onSetDateBarChart, titleDoughnut, subtitleDoughnut, titleLine, subTitleLine}) { |
const Btn = ({ icon, isDisabled = false, onClick }) => { |
||||||
|
return ( |
||||||
|
<div className='d-flex justify-content-center align-items-center'> |
||||||
|
<button className={`d-flex custom-button ${isDisabled ? "button-disable" : ""}`} onClick={onClick} disabled={isDisabled}> |
||||||
|
<div>{icon}</div> |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
export default function BoxDoughnutBarChart({ |
||||||
|
dataDoughnut = [],
|
||||||
|
dataBarChart = [],
|
||||||
|
labelsBarChart = [],
|
||||||
|
dateBarChat, |
||||||
|
onSetDateBarChart, |
||||||
|
titleDoughnut, |
||||||
|
subtitleDoughnut, |
||||||
|
titleLine, |
||||||
|
subTitleLine, |
||||||
|
}) { |
||||||
const [month, setMonth] = useState(dateBarChat) |
const [month, setMonth] = useState(dateBarChat) |
||||||
const [monthError, setMonthError] = useState('') |
const [monthError, setMonthError] = useState('') |
||||||
|
const [current, target] = dataDoughnut |
||||||
|
|
||||||
const changeMonth = (date) => { |
const handleMonthChange = (date) => { |
||||||
setMonth(date) |
setMonth(date) |
||||||
!!onSetDateBarChart && onSetDateBarChart(date) |
|
||||||
} |
} |
||||||
|
|
||||||
const _dataDoughnut = (dataDoughnut?.[0] / dataDoughnut?.[1] === 1 || dataDoughnut?.[0] > dataDoughnut?.[1]) ? [dataDoughnut?.[0]] : [dataDoughnut?.[0], dataDoughnut?.[1] - dataDoughnut?.[0]] |
const renderDoughnutSection = () => ( |
||||||
|
<div style={{borderBottom: '1px solid #c4c4c4', paddingBottom: '1.6rem', flex: 0.38, display: 'flex', flexDirection: 'column'}}> |
||||||
|
{titleDoughnut && <p className='box-chart-title'>{titleDoughnut}</p>} |
||||||
|
{subtitleDoughnut && <p className='box-chart-subtitle'>{subtitleDoughnut}</p>} |
||||||
|
<div className='d-flex flex-1'> |
||||||
|
<div className='doughnut-chart-content flex-1'> |
||||||
|
<RDoughnutChart data={dataDoughnut} /> |
||||||
|
</div> |
||||||
|
<div className='origin-vertical justify-content-center align-item-center flex-1' style={{cursor:'pointer'}}> |
||||||
|
<div className="tooltip"> |
||||||
|
<p
|
||||||
|
style={{color: PRIMARY_COLOR, fontSize: '2.2rem', fontWeight: 800}} |
||||||
|
> |
||||||
|
{current} |
||||||
|
<span className="tooltiptext" style={{color: PRIMARY_COLOR}}>Số lượng đã tham gia: {current}</span> |
||||||
|
</p> |
||||||
|
</div> |
||||||
|
<div className="tooltip">
|
||||||
|
<p
|
||||||
|
style={{color: '#01AEF0', fontSize: '2.2rem', fontWeight: 800}} |
||||||
|
> |
||||||
|
{target > 0 ? target : '...'} |
||||||
|
<span className="tooltiptext" style={{color: '#01AEF0'}}>Tổng số: {target > 0 ? target : '...'}</span> |
||||||
|
</p> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
) |
||||||
|
|
||||||
|
const renderBarSection = () => ( |
||||||
|
<div className='d-flex' style={{marginTop: '1.2rem', flexDirection: 'column', flex: 0.62}}> |
||||||
|
{titleLine && <p className='box-chart-title'>{titleLine}</p>} |
||||||
|
{subTitleLine && <p className='box-chart-subtitle'>{subTitleLine}</p>} |
||||||
|
{dataBarChart.length > 0 ? ( |
||||||
|
<div className='chart-container'> |
||||||
|
<div className='flex-1' style={{ padding: '1.6rem 0', height: '100%'}}> |
||||||
|
<VerticalBarChart data={dataBarChart} labels={labelsBarChart} /> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
) : ( |
||||||
|
<div className="d-flex justify-content-center align-items-center flex-1"> |
||||||
|
Không có dữ liệu để hiển thị |
||||||
|
</div> |
||||||
|
)} |
||||||
|
</div> |
||||||
|
) |
||||||
|
const handleClickNext = () => { |
||||||
|
const newMonth = month.getMonth() + 1; |
||||||
|
const newYear = month.getFullYear(); |
||||||
|
|
||||||
|
if (newMonth > 11) { |
||||||
|
setMonth(new Date(newYear + 1, 0, 1)); |
||||||
|
} else { |
||||||
|
setMonth(new Date(newYear, newMonth, 1)); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
const handleClickPrev = () => { |
||||||
|
const newMonth = month.getMonth() - 1; |
||||||
|
const newYear = month.getFullYear(); |
||||||
|
|
||||||
|
if (newMonth < 0) { |
||||||
|
setMonth(new Date(newYear - 1, 11, 1));
|
||||||
|
} else { |
||||||
|
setMonth(new Date(newYear, newMonth, 1)); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
onSetDateBarChart?.(month); |
||||||
|
}, [month]); |
||||||
|
|
||||||
const renderIconDate = () => { |
const isDisabledNext = new Date(month).getMonth() === new Date().getMonth() && new Date(month).getFullYear() === new Date().getFullYear(); |
||||||
return ( |
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 20 20"> |
|
||||||
<path
|
|
||||||
fill="#00bbb5"
|
|
||||||
d="M5.673 0a.7.7 0 0 1 .7.7v1.309h7.517v-1.3a.7.7 0 0 1 1.4 0v1.3H18a2 2 0 0 1 2 1.999v13.993A2 2 0 0 1 18 20H2a2 2 0 0 1-2-1.999V4.008a2 2 0 0 1 2-1.999h2.973V.699a.7.7 0 0 1 .7-.699M1.4 7.742v10.259a.6.6 0 0 0 .6.6h16a.6.6 0 0 0 .6-.6V7.756zm5.267 6.877v1.666H5v-1.666zm4.166 0v1.666H9.167v-1.666zm4.167 0v1.666h-1.667v-1.666zm-8.333-3.977v1.666H5v-1.666zm4.166 0v1.666H9.167v-1.666zm4.167 0v1.666h-1.667v-1.666zM4.973 3.408H2a.6.6 0 0 0-.6.6v2.335l17.2.014V4.008a.6.6 0 0 0-.6-.6h-2.71v.929a.7.7 0 0 1-1.4 0v-.929H6.373v.92a.7.7 0 0 1-1.4 0z" |
|
||||||
/> |
|
||||||
</svg> |
|
||||||
) |
|
||||||
} |
|
||||||
|
|
||||||
return ( |
return ( |
||||||
<div className="box-chart-container"> |
<div className="box-chart-container"> |
||||||
<div style={{borderBottom: '1px solid #c4c4c4', paddingBottom: '1.6rem', flex: 0.38, display: 'flex', flexDirection: 'column'}}> |
{renderDoughnutSection()} |
||||||
{!!titleDoughnut && <p className='box-chart-title'>{titleDoughnut}</p>} |
{renderBarSection()} |
||||||
{!!subtitleDoughnut && <p className='box-chart-subtitle'>{subtitleDoughnut}</p>} |
<div className='d-flex justify-content-center align-items-center' style={{marginTop:'1.2rem'}}> |
||||||
<div className='d-flex flex-1'> |
<Btn icon={renderIconButtonLeft()} isDisabled={false} onClick={handleClickPrev} /> |
||||||
<div className='doughnut-chart-content flex-1'> |
<div className='d-flex justify-content-center align-item-center' style={{width: 140, alignSelf: 'center'}}> |
||||||
<RDoughnutChart data={_dataDoughnut} /> |
<InputDate |
||||||
</div> |
maxDate={new Date()} |
||||||
<div className='origin-vertical justify-content-center align-item-center flex-1'> |
label={''} |
||||||
<p style={{fontSize: '1.8rem'}}>{dataDoughnut?.[0] + '/' + dataDoughnut?.[1]}</p> |
styleContainer={{flex: 1}} |
||||||
<p style={{color: PRIMARY_COLOR, fontSize: '2.2rem', fontWeight: 800}}>{Math.round(dataDoughnut?.[0]/dataDoughnut?.[1] * 100) + '%'}</p> |
value={month} |
||||||
</div> |
setValue={handleMonthChange} |
||||||
</div> |
name="month" |
||||||
</div> |
renderLabelIcon={renderIconDate} |
||||||
<div className='d-flex' style={{marginTop: '1.2rem', flexDirection: 'column', flex: 0.62}}> |
errorText={monthError} |
||||||
{!!titleLine && <p className='box-chart-title'>{titleLine}</p>} |
errorAbsolute={true} |
||||||
{!!subTitleLine && <p className='box-chart-subtitle'>{subTitleLine}</p>} |
popperPlacement='top' |
||||||
<div className='flex-1' style={{padding: '1.6rem 0'}}> |
typeErrText='underAbsolute' |
||||||
<VerticalBarChart data={dataBarChart} labels={labelsBarChart}/> |
isMonthPicker |
||||||
|
/> |
||||||
</div> |
</div> |
||||||
</div> |
<Btn icon={renderIconButton()} isDisabled={isDisabledNext} onClick={handleClickNext} /> |
||||||
<div className='d-flex justify-content-center align-item-center' style={{width: 140, alignSelf: 'center'}}> |
|
||||||
{/* {renderArrowLeft()} |
|
||||||
<span style={{padding: '0 2rem', fontSize: '1.8rem'}}>Tháng 11</span> |
|
||||||
{renderArrowRight()} */} |
|
||||||
<InputDate |
|
||||||
maxDate={new Date()} |
|
||||||
label={''} |
|
||||||
styleContainer={{flex: 1}} |
|
||||||
value={month} |
|
||||||
setValue={changeMonth} |
|
||||||
name="month" |
|
||||||
renderLabelIcon={renderIconDate} |
|
||||||
errorText={monthError} |
|
||||||
errorAbsolute={true} |
|
||||||
// placeholder={"Chọn ngày sinh"}
|
|
||||||
popperPlacement='top' |
|
||||||
typeErrText='underAbsolute' |
|
||||||
isMonthPicker |
|
||||||
/> |
|
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
) |
) |
||||||
|
@ -1,5 +1,5 @@ |
|||||||
export * from "./config"; |
export * from "./config"; |
||||||
export * from "./configConstants"; |
// export * from "./configConstants";
|
||||||
export * from "./path"; |
export * from "./path"; |
||||||
export * from "./alerts"; |
export * from "./alerts"; |
||||||
export * from "./user"; |
export * from "./user"; |
||||||
|
Loading…
Reference in new issue