mirror of
https://github.com/bakhirev/assayo.git
synced 2025-09-02 02:29:48 +00:00
update
This commit is contained in:
parent
760781bc8c
commit
c80bceabef
5 changed files with 33 additions and 6 deletions
|
@ -1,10 +1,21 @@
|
||||||
import React from 'react';
|
import React, { useLayoutEffect, useState, useRef } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { IOptions, ISubLine } from 'ts/components/LineChart/interfaces';
|
import { IOptions, ISubLine } from 'ts/components/LineChart/interfaces';
|
||||||
|
import isMobile from 'ts/helpers/isMobile';
|
||||||
|
|
||||||
import style from '../index.module.scss';
|
import style from '../index.module.scss';
|
||||||
|
|
||||||
|
function getColumnCount(parts: ISubLine[], element?: HTMLElement | null) {
|
||||||
|
if (!element || isMobile || parts.length <= 7) return 1;
|
||||||
|
// @ts-ignore
|
||||||
|
const width = element?.parentNode?.getBoundingClientRect()?.width || 0;
|
||||||
|
const countByWidth = Math.floor(width / 300) || 1;
|
||||||
|
const countByLength = Math.round(parts.length / 8);
|
||||||
|
console.log(countByWidth, countByLength);
|
||||||
|
return Math.min(countByLength, countByWidth);
|
||||||
|
}
|
||||||
|
|
||||||
interface ILegendProps {
|
interface ILegendProps {
|
||||||
parts: ISubLine[];
|
parts: ISubLine[];
|
||||||
options: IOptions;
|
options: IOptions;
|
||||||
|
@ -15,6 +26,12 @@ function Legend({
|
||||||
options,
|
options,
|
||||||
}: ILegendProps): React.ReactElement | null {
|
}: ILegendProps): React.ReactElement | null {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const ref = useRef() as React.MutableRefObject<HTMLDivElement>;
|
||||||
|
const [columnCount, setColumnCount] = useState<number>(1);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
setColumnCount(getColumnCount(parts, ref?.current));
|
||||||
|
}, [ref, ref.current]);
|
||||||
|
|
||||||
const lines = parts.map((item: ISubLine) => {
|
const lines = parts.map((item: ISubLine) => {
|
||||||
return (
|
return (
|
||||||
|
@ -37,7 +54,11 @@ function Legend({
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.pie_chart_legend}>
|
<div
|
||||||
|
ref={ref}
|
||||||
|
className={style.pie_chart_legend}
|
||||||
|
style={{ columnCount }}
|
||||||
|
>
|
||||||
{lines}
|
{lines}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -67,6 +67,8 @@
|
||||||
|
|
||||||
&_text {
|
&_text {
|
||||||
max-width: calc(100% - 40px);
|
max-width: calc(100% - 40px);
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
.ui_kit_select {
|
.ui_kit_select {
|
||||||
padding: 0 var(--space-xs) 0 var(--space-l);
|
padding: 0 var(--space-xs) 0 var(--space-l);
|
||||||
|
|
||||||
|
&_value {
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui_kit_select_with_buttons {
|
.ui_kit_select_with_buttons {
|
||||||
|
|
|
@ -48,7 +48,7 @@ const Department = observer(({
|
||||||
to="response"
|
to="response"
|
||||||
loader={getFakeLoader(content, mode)}
|
loader={getFakeLoader(content, mode)}
|
||||||
>
|
>
|
||||||
<Departments />
|
<Departments mode={mode} />
|
||||||
<Pagination />
|
<Pagination />
|
||||||
</DataLoader>
|
</DataLoader>
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ const Department = observer(({
|
||||||
loader={getFakeLoader(byMonths[taskCode], mode)}
|
loader={getFakeLoader(byMonths[taskCode], mode)}
|
||||||
watch={taskCode}
|
watch={taskCode}
|
||||||
>
|
>
|
||||||
<Months/>
|
<Months mode={mode} />
|
||||||
<Pagination />
|
<Pagination />
|
||||||
</DataLoader>
|
</DataLoader>
|
||||||
<Description text={t('page.team.department.months.description')} />
|
<Description text={t('page.team.department.months.description')} />
|
||||||
|
|
|
@ -152,8 +152,7 @@ const Refactor = observer(({
|
||||||
to="response"
|
to="response"
|
||||||
loader={getFakeLoader(content, mode)}
|
loader={getFakeLoader(content, mode)}
|
||||||
>
|
>
|
||||||
<View />
|
<View mode={mode} />
|
||||||
<Pagination />
|
|
||||||
</DataLoader>
|
</DataLoader>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue