IO-1053 Added Job Total to graph
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
import Dinero from "dinero.js";
|
||||||
|
|
||||||
|
const CustomTooltip = ({ active, payload, label }) => {
|
||||||
|
if (active && payload && payload.length) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: "white",
|
||||||
|
border: "1px solid gray",
|
||||||
|
padding: "0.5rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p style={{ margin: "0" }}>{label}</p>
|
||||||
|
{payload.map((data, index) => {
|
||||||
|
if (data.dataKey === "sales")
|
||||||
|
return (
|
||||||
|
<p
|
||||||
|
style={{ margin: "10px 0", color: data.color }}
|
||||||
|
key={index}
|
||||||
|
>{`${data.name} : ${Dinero({
|
||||||
|
amount: data.value,
|
||||||
|
}).toFormat()}`}</p>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<p
|
||||||
|
style={{ margin: "10px 0", color: data.color }}
|
||||||
|
key={index}
|
||||||
|
>{`${data.name} : ${data.value}`}</p>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CustomTooltip;
|
||||||
@@ -18,6 +18,7 @@ import { createStructuredSelector } from "reselect";
|
|||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import * as Utils from "../scoreboard-targets-table/scoreboard-targets-table.util";
|
import * as Utils from "../scoreboard-targets-table/scoreboard-targets-table.util";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import CustomTooltip from "./chart-custom-tooltip";
|
||||||
|
|
||||||
const graphProps = {
|
const graphProps = {
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
@@ -55,6 +56,14 @@ export function ScoreboardChart({ sbEntriesByDate, bodyshop }) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const yesterdaySales = acc.length > 0 && acc[acc.length - 1].sales;
|
||||||
|
const sales =
|
||||||
|
sbEntriesByDate[val]?.reduce((acc, sb) => {
|
||||||
|
return acc + sb.job.job_totals.totals.subtotal.amount;
|
||||||
|
}, 0) || 0;
|
||||||
|
|
||||||
|
const accSales = yesterdaySales + sales;
|
||||||
|
|
||||||
const theValue = {
|
const theValue = {
|
||||||
date: moment(val).format("D ddd"),
|
date: moment(val).format("D ddd"),
|
||||||
paintHrs: _.round(dayhrs.painthrs, 1),
|
paintHrs: _.round(dayhrs.painthrs, 1),
|
||||||
@@ -73,6 +82,7 @@ export function ScoreboardChart({ sbEntriesByDate, bodyshop }) {
|
|||||||
: dayhrs.painthrs + dayhrs.bodyhrs,
|
: dayhrs.painthrs + dayhrs.bodyhrs,
|
||||||
1
|
1
|
||||||
),
|
),
|
||||||
|
sales: accSales,
|
||||||
};
|
};
|
||||||
|
|
||||||
return [...acc, theValue];
|
return [...acc, theValue];
|
||||||
@@ -87,8 +97,15 @@ export function ScoreboardChart({ sbEntriesByDate, bodyshop }) {
|
|||||||
>
|
>
|
||||||
<CartesianGrid stroke="#f5f5f5" />
|
<CartesianGrid stroke="#f5f5f5" />
|
||||||
<XAxis dataKey="date" strokeWidth={graphProps.strokeWidth} />
|
<XAxis dataKey="date" strokeWidth={graphProps.strokeWidth} />
|
||||||
<YAxis strokeWidth={graphProps.strokeWidth} />
|
<YAxis
|
||||||
<Tooltip />
|
strokeWidth={graphProps.strokeWidth}
|
||||||
|
allowDataOverflow
|
||||||
|
dataKey="sales"
|
||||||
|
yAxisId="right"
|
||||||
|
orientation="right"
|
||||||
|
/>
|
||||||
|
<YAxis yAxisId="left" strokeWidth={graphProps.strokeWidth} />
|
||||||
|
<Tooltip content={<CustomTooltip />} />
|
||||||
<Legend />
|
<Legend />
|
||||||
<Area
|
<Area
|
||||||
type="monotone"
|
type="monotone"
|
||||||
@@ -96,6 +113,7 @@ export function ScoreboardChart({ sbEntriesByDate, bodyshop }) {
|
|||||||
dataKey="accHrs"
|
dataKey="accHrs"
|
||||||
fill="lightgreen"
|
fill="lightgreen"
|
||||||
stroke="green"
|
stroke="green"
|
||||||
|
yAxisId="left"
|
||||||
/>
|
/>
|
||||||
<Bar
|
<Bar
|
||||||
name="Body Hours"
|
name="Body Hours"
|
||||||
@@ -103,6 +121,7 @@ export function ScoreboardChart({ sbEntriesByDate, bodyshop }) {
|
|||||||
stackId="day"
|
stackId="day"
|
||||||
barSize={20}
|
barSize={20}
|
||||||
fill="darkblue"
|
fill="darkblue"
|
||||||
|
yAxisId="left"
|
||||||
/>
|
/>
|
||||||
<Bar
|
<Bar
|
||||||
name="Paint Hours"
|
name="Paint Hours"
|
||||||
@@ -110,12 +129,23 @@ export function ScoreboardChart({ sbEntriesByDate, bodyshop }) {
|
|||||||
stackId="day"
|
stackId="day"
|
||||||
barSize={20}
|
barSize={20}
|
||||||
fill="darkred"
|
fill="darkred"
|
||||||
|
yAxisId="left"
|
||||||
/>
|
/>
|
||||||
<Line
|
<Line
|
||||||
name="Target Hours"
|
name="Target Hours"
|
||||||
type="monotone"
|
type="monotone"
|
||||||
dataKey="accTargetHrs"
|
dataKey="accTargetHrs"
|
||||||
stroke="#ff7300"
|
stroke="#ff7300"
|
||||||
|
yAxisId="left"
|
||||||
|
strokeWidth={graphProps.strokeWidth}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Line
|
||||||
|
name="Sales"
|
||||||
|
type="monotone"
|
||||||
|
dataKey="sales"
|
||||||
|
stroke="#8F00FF"
|
||||||
|
yAxisId="right"
|
||||||
strokeWidth={graphProps.strokeWidth}
|
strokeWidth={graphProps.strokeWidth}
|
||||||
/>
|
/>
|
||||||
</ComposedChart>
|
</ComposedChart>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export const QUERY_SCOREBOARD = gql`
|
|||||||
v_make_desc
|
v_make_desc
|
||||||
v_model_desc
|
v_model_desc
|
||||||
v_model_yr
|
v_model_yr
|
||||||
|
job_totals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user