фикс выводов графиков (что пришло то и вывелось)
This commit is contained in:
parent
c785b9eb95
commit
3df3eb2432
@ -42,16 +42,9 @@ const GeneralItem = ({
|
||||
([nextValue], [currentValue]) => Number(nextValue) - Number(currentValue),
|
||||
);
|
||||
const days = data.map(([value]) => value);
|
||||
const { time } = data.reduce(
|
||||
(total, [_, value]) => ({
|
||||
defaultValue: value > 0 ? value : total.defaultValue,
|
||||
time: [...total.time, value > 0 ? value : total.defaultValue],
|
||||
}),
|
||||
{ defaultValue: 0, time: [] as number[] },
|
||||
);
|
||||
|
||||
const numberValue = calculateTime
|
||||
? time.reduce((total, value) => total + value, 0) / days.length
|
||||
? Object.values(general).reduce((total, value) => total + value, 0) / Object.values(general).length
|
||||
: conversionValue
|
||||
? conversionValue
|
||||
: Object.values(general).reduce((total, item) => total + item, 0);
|
||||
@ -82,17 +75,17 @@ const GeneralItem = ({
|
||||
<LineChart
|
||||
xAxis={[
|
||||
{
|
||||
data: statiscticsResult ? days : Object.keys(general),
|
||||
data: Object.keys(general),
|
||||
valueFormatter: (value) => {
|
||||
const timestamp = Number(value);
|
||||
if (isNaN(timestamp)) return 'Invalid Date';
|
||||
return moment.unix(timestamp).format(statiscticsResult ? "DD/MM/YYYY" : "DD/MM/YYYY HH") + (statiscticsResult ? "" : "ч");
|
||||
return moment.unix(timestamp).format("DD/MM/YYYY");
|
||||
},
|
||||
},
|
||||
]}
|
||||
series={[
|
||||
{
|
||||
data: Object.values(statiscticsResult ? time : general),
|
||||
data: Object.values(general),
|
||||
valueFormatter: (value) =>
|
||||
calculateTime
|
||||
? getCalculatedTime(value)
|
||||
|
Loading…
Reference in New Issue
Block a user