IO-1911 Round TTSB to 1 decimal.

This commit is contained in:
Patrick Fic
2022-06-13 08:58:33 -07:00
parent 17c3b24380
commit 77cb6a4acc
3 changed files with 25 additions and 9 deletions

View File

@@ -1,12 +1,10 @@
import { Card } from "antd"; import { Card } from "antd";
import React from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { import {
Bar, Bar,
CartesianGrid, CartesianGrid,
ComposedChart, ComposedChart,
LabelList,
Legend, Legend,
ReferenceLine, ReferenceLine,
ResponsiveContainer, ResponsiveContainer,
@@ -69,7 +67,7 @@ export function ScoreboardTicketsBar({ data, bodyshop }) {
// barSize={20} // barSize={20}
fill={data.colors[idx]} fill={data.colors[idx]}
> >
<LabelList position="top" /> {/* <LabelList position="top" /> */}
</Bar> </Bar>
))} ))}
</ComposedChart> </ComposedChart>

View File

@@ -216,7 +216,10 @@ export default function ScoreboardTimeTickets() {
ret2.push(r); ret2.push(r);
}); });
roundObject(ret);
roundObject(totals);
roundObject(ret2);
console.log(ret);
return { return {
fixed: ret, fixed: ret,
timeperiod: { timeperiod: {
@@ -299,3 +302,18 @@ function getColorArray(num) {
// } // }
// return result; // return result;
} }
function roundObject(inputObj) {
for (var key of Object.keys(inputObj)) {
if (typeof inputObj[key] === "number" && inputObj[key] !== 0) {
inputObj[key] =
inputObj[key] && inputObj[key].toFixed
? inputObj[key].toFixed(1)
: inputObj[key]; //Math.round(inputObj[key] * 100) / 100;
} else if (Array.isArray(inputObj[key])) {
inputObj[key].forEach((item) => roundObject(item));
} else if (typeof inputObj[key] === "object") {
roundObject(inputObj[key]);
}
}
}

View File

@@ -73,13 +73,13 @@ export function ScoreboardTicketsStats({ data, bodyshop }) {
<Col span={12}> <Col span={12}>
<Statistic <Statistic
title={t("scoreboard.labels.lastweek")} title={t("scoreboard.labels.lastweek")}
value={data.totalLastWeek.toFixed(1)} value={data.totalLastWeek}
/> />
</Col> </Col>
<Col span={12}> <Col span={12}>
<Statistic <Statistic
title={t("scoreboard.labels.lastmonth")} title={t("scoreboard.labels.lastmonth")}
value={data.totalLastMonth.toFixed(1)} value={data.totalLastMonth}
/> />
</Col> </Col>
</Row> </Row>
@@ -87,13 +87,13 @@ export function ScoreboardTicketsStats({ data, bodyshop }) {
<Col span={12}> <Col span={12}>
<Statistic <Statistic
title={t("scoreboard.labels.thisweek")} title={t("scoreboard.labels.thisweek")}
value={data.totalThisWeek.toFixed(1)} value={data.totalThisWeek}
/> />
</Col> </Col>
<Col span={12}> <Col span={12}>
<Statistic <Statistic
title={t("scoreboard.labels.thismonth")} title={t("scoreboard.labels.thismonth")}
value={data.totalThisMonth.toFixed(1)} value={data.totalThisMonth}
/> />
</Col> </Col>
</Row> </Row>
@@ -101,7 +101,7 @@ export function ScoreboardTicketsStats({ data, bodyshop }) {
<Col span={12}> <Col span={12}>
<Statistic <Statistic
title={t("scoreboard.labels.totaloverperiod")} title={t("scoreboard.labels.totaloverperiod")}
value={data.totalOverPeriod.toFixed(1)} value={data.totalOverPeriod}
/> />
</Col> </Col>
</Row> </Row>