Skip to content

Commit

Permalink
report: audit wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloarocha committed Jan 9, 2024
1 parent c46e390 commit bfe7be2
Show file tree
Hide file tree
Showing 22 changed files with 1,343 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/features/admin/Memory/Reports/Reports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function MemoryReports() {
id: "INTERVENTION",
value: "Intervenções",
},
{
id: "PRESCRIPTION_AUDIT",
value: "Auditoria",
},
],
optionsType: "key-value",
style: { width: "100%" },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from "react";

import { EChartBase } from "components/EChartBase";

export default function ChartAuditDay({ reportData, isLoading }) {
const chartOptions = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
label: {
backgroundColor: "#6a7985",
},
},
},
legend: {
data: ["Checagem", "Deschecagem"],
},
toolbox: {
feature: {
saveAsImage: { title: "Salvar como imagem" },
},
},
grid: {
left: "2%",
right: "3%",
bottom: "3%",
containLabel: true,
},
xAxis: [
{
type: "category",
boundaryGap: false,
data: reportData?.days || [],
},
],
yAxis: [
{
type: "value",
},
],
series: [
{
name: "Checagem",
type: "line",
color: "#90BF71",
emphasis: {
focus: "series",
},
data: reportData?.auditPlotSeries
? reportData.auditPlotSeries.map(({ check }) => check)
: [],
},
{
name: "Deschecagem",
type: "line",
color: "#E6744E",
emphasis: {
focus: "series",
},
data: reportData?.auditPlotSeries
? reportData.auditPlotSeries.map(({ uncheck }) => uncheck)
: [],
},
],
};

return (
<EChartBase
option={chartOptions}
style={{ height: "40vh", minHeight: "500px" }}
loading={isLoading}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from "react";

import { EChartBase } from "components/EChartBase";

export default function ChartDepartments({ reportData, isLoading }) {
const chartOptions = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
},
legend: {},
grid: {
left: "3%",
right: "3%",
bottom: "2%",
containLabel: true,
},
xAxis: {
type: "value",
boundaryGap: [0, 0.01],
},
yAxis: {
type: "category",
data: reportData?.departmentSummary
? reportData?.departmentSummary.map((i) => i.name)
: [],
},
toolbox: {
feature: {
saveAsImage: { title: "Salvar como imagem" },
},
},
series: [
{
name: "Deschecagem",
type: "bar",
color: "#E6744E",
stack: "total",
data: reportData?.departmentSummary
? reportData?.departmentSummary.map((i) => i.totals["uncheck"])
: [],
},
{
name: "Checagem",
type: "bar",
color: "#90BF71",
stack: "total",
data: reportData?.departmentSummary
? reportData?.departmentSummary.map((i) => ({
value: i.totals["check"],
total: i.totals["all"],
}))
: [],
label: {
show: true,
position: "right",
valueAnimation: true,
formatter: (params) => {
return params.data.total;
},
},
},
],
};

return (
<EChartBase
option={chartOptions}
style={{ height: "60vh", minHeight: "700px" }}
loading={isLoading}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React from "react";
import { convertRange } from "utils/report";

import { EChartBase } from "components/EChartBase";

export default function ChartEventScatter({ reportData, isLoading }) {
const days = [
"Domingo",
"Segunda",
"Terça",
"Quarta",
"Quinta",
"Sexta",
"Sábado",
];
const hours = [];
for (let h = 0; h < 24; h++) {
hours.push(
h.toLocaleString("en-US", {
minimumIntegerDigits: 2,
useGrouping: false,
})
);
}

let maxValue = 0;
const title = [];
const singleAxis = [];
const series = [];

if (reportData.eventScatter) {
reportData.eventScatter.forEach(function (i) {
if (i[2] > maxValue) {
maxValue = i[2];
}
});
}

days.forEach(function (day, idx) {
title.push({
textBaseline: "middle",
top: ((idx + 0.5) * 100) / 7 + "%",
text: day,
});
singleAxis.push({
left: 150,
type: "category",
boundaryGap: false,
data: hours,
top: (idx * 100) / 7 + 5 + "%",
height: 100 / 7 - 10 + "%",
axisLabel: {
interval: 2,
},
});
series.push({
singleAxisIndex: idx,
coordinateSystem: "singleAxis",
type: "scatter",
data: [],
symbolSize: function (dataItem) {
return dataItem[1] === 0
? 0
: convertRange(dataItem[1], [0, maxValue], [10, 100]);
},
});
});
if (reportData.eventScatter) {
reportData.eventScatter.forEach(function (dataItem) {
series[dataItem[0]].data.push([dataItem[1], dataItem[2]]);
});
}

const chartOptions = {
tooltip: {
position: "top",
},
title: title,
singleAxis: singleAxis,
series: series,
};

return (
<EChartBase
option={chartOptions}
style={{ height: "50vh", minHeight: "700px" }}
loading={isLoading}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from "react";

import { EChartBase } from "components/EChartBase";

export default function ChartResponsibles({ reportData, isLoading }) {
const chartOptions = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
},
legend: {},
grid: {
left: "3%",
right: "3%",
bottom: "2%",
containLabel: true,
},
xAxis: {
type: "value",
boundaryGap: [0, 0.01],
},
yAxis: {
type: "category",
data: reportData?.responsibleSummary
? reportData?.responsibleSummary.map((i) => i.name)
: [],
},
toolbox: {
feature: {
saveAsImage: { title: "Salvar como imagem" },
},
},
series: [
{
name: "Deschecagem",
type: "bar",
color: "#E6744E",
stack: "total",
data: reportData?.responsibleSummary
? reportData?.responsibleSummary.map((i) => i.totals["uncheck"])
: [],
},
{
name: "Checagem",
type: "bar",
color: "#90BF71",
stack: "total",
data: reportData?.responsibleSummary
? reportData?.responsibleSummary.map((i) => ({
value: i.totals["check"],
total: i.totals["all"],
}))
: [],
label: {
show: true,
position: "right",
valueAnimation: true,
formatter: (params) => {
return params.data.total;
},
},
},
],
};

return (
<EChartBase
option={chartOptions}
style={{ height: "60vh", minHeight: "700px" }}
loading={isLoading}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from "react";

import { EChartBase } from "components/EChartBase";

export default function ChartSegments({ reportData, isLoading }) {
const chartOptions = {
tooltip: {
trigger: "item",
},
legend: {
top: "0",
left: "center",
},
toolbox: {
feature: {
saveAsImage: { title: "Salvar como imagem" },
},
},
series: [
{
type: "pie",
radius: ["20%", "70%"],
avoidLabelOverlap: true,
itemStyle: {
borderRadius: 10,
borderColor: "#fff",
borderWidth: 2,
},
label: {
show: true,
},
labelLine: {
show: true,
},
data: reportData?.segments ? reportData.segments : [],
color: ["#9789D9", "#F78B52", "#67DBDD", "#B8B4E8", "#EAD76F"],
},
],
};

return (
<EChartBase
option={chartOptions}
style={{ height: "40vh", minHeight: "600px" }}
loading={isLoading}
/>
);
}
Loading

0 comments on commit bfe7be2

Please sign in to comment.