откат 2 графиков
This commit is contained in:
parent
a6a6bda089
commit
1e2b320f79
@ -112,30 +112,48 @@ const GeneralItemTimeConv = ({
|
|||||||
numberType,
|
numberType,
|
||||||
calculateTime = false,
|
calculateTime = false,
|
||||||
conversionValue,
|
conversionValue,
|
||||||
day,
|
|
||||||
}: GeneralItemsProps) => {
|
}: GeneralItemsProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(700));
|
const isMobile = useMediaQuery(theme.breakpoints.down(700));
|
||||||
|
|
||||||
const data = Object.entries(general).sort(
|
const data = Object.entries(general)
|
||||||
([nextValue], [currentValue]) => Number(nextValue) - Number(currentValue),
|
.sort((a, b) => a[0] - b[0]);
|
||||||
);
|
|
||||||
const days = data.map(([value]) => value);
|
|
||||||
const time = data.map(([_, value]) => value);
|
|
||||||
|
|
||||||
const numberValue = calculateTime
|
const days = [...data].map(e => e[0])
|
||||||
? time.reduce((total, value) => total + value, 0) / days.length
|
|
||||||
: conversionValue;
|
let buffer = 0
|
||||||
|
|
||||||
|
const time = [...data].map(e => {
|
||||||
|
if (e[1] > 0) {
|
||||||
|
buffer = e[1]
|
||||||
|
}
|
||||||
|
return buffer
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
console.log("data", data)
|
||||||
|
console.log("time", time.reduce((a, b) => (Number(a) + Number(b)), 0))
|
||||||
|
console.log("time", getCalculatedTime(time.reduce((a, b) => (Number(a) + Number(b)), 0)))
|
||||||
|
console.log("days", days.length)
|
||||||
|
const numberValue = calculateTime ?
|
||||||
|
(
|
||||||
|
(time.reduce((a, b) => (Number(a) + Number(b)), 0))
|
||||||
|
/
|
||||||
|
(days.length)
|
||||||
|
) || 0
|
||||||
|
:
|
||||||
|
conversionValue
|
||||||
|
|
||||||
if (
|
if (
|
||||||
Object.keys(general).length === 0 ||
|
Object.keys(general).length === 0 ||
|
||||||
Object.values(general).every((item) => item === 0)
|
Object.values(general).every((x) => x === 0)
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<Typography textAlign="center">{`${title} - нет данных`}</Typography>
|
<Typography textAlign="center">{`${title} - нет данных`}</Typography>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
sx={{
|
sx={{
|
||||||
@ -146,25 +164,24 @@ const GeneralItemTimeConv = ({
|
|||||||
>
|
>
|
||||||
<Typography sx={{ margin: "20px 20px 0" }}>{title}</Typography>
|
<Typography sx={{ margin: "20px 20px 0" }}>{title}</Typography>
|
||||||
<Typography sx={{ margin: "10px 20px 0", fontWeight: "bold" }}>
|
<Typography sx={{ margin: "10px 20px 0", fontWeight: "bold" }}>
|
||||||
{calculateTime
|
{calculateTime ? `${getCalculatedTime(numberValue)} с` : `${numberValue.toFixed(2)}%`}
|
||||||
? `${getCalculatedTime(numberValue ?? 0)} с`
|
|
||||||
: `${numberValue?.toFixed(2) ?? 0}%`}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
<LineChart
|
<LineChart
|
||||||
xAxis={[
|
xAxis={[
|
||||||
{
|
{
|
||||||
data: days,
|
data: days,
|
||||||
valueFormatter: (value) =>
|
valueFormatter: (value) =>
|
||||||
moment.unix(Number(value)).format("DD/MM/YYYY HH") + "ч",
|
moment.utc(Number(value) * 1000).format("DD/MM/YYYY"),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
series={[
|
series={[
|
||||||
{
|
{
|
||||||
data: Object.values(time),
|
data: Object.values(time),
|
||||||
valueFormatter: (value) =>
|
valueFormatter: (value) => {
|
||||||
calculateTime
|
console.log("log", value)
|
||||||
? getCalculatedTime(value)
|
return calculateTime ? getCalculatedTime(value) : String((value*100).toFixed(2)) + "%"
|
||||||
: String((value * 100).toFixed(2)) + "%",
|
}
|
||||||
|
,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
// dataset={Object.entries(general).map(([, v]) => moment.unix(v).format("ss:mm:HH")).reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {})}
|
// dataset={Object.entries(general).map(([, v]) => moment.unix(v).format("ss:mm:HH")).reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {})}
|
||||||
@ -179,6 +196,7 @@ const GeneralItemTimeConv = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const General: FC<GeneralProps> = ({ data, day }) => {
|
export const General: FC<GeneralProps> = ({ data, day }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
||||||
|
Loading…
Reference in New Issue
Block a user