Create progress donut chart
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
|||||||
CopyPlus,
|
CopyPlus,
|
||||||
CopyMinus,
|
CopyMinus,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import RunProgressChart from "./RunProgressChart";
|
import RunProgressDounut from "./RunPregressDonutChart";
|
||||||
import TestCaseSelector from "./TestCaseSelector";
|
import TestCaseSelector from "./TestCaseSelector";
|
||||||
import { testRunStatus } from "@/config/selection";
|
import { testRunStatus } from "@/config/selection";
|
||||||
import { RunType, RunCaseType, RunCaseInfoType } from "@/types/run";
|
import { RunType, RunCaseType, RunCaseInfoType } from "@/types/run";
|
||||||
@@ -230,59 +230,62 @@ export default function RunEditor({ projectId, runId }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="container mx-auto max-w-5xl pt-6 px-6 flex-grow">
|
<div className="container mx-auto max-w-5xl pt-6 px-6 flex-grow">
|
||||||
<h6>Basic</h6>
|
<div className="flex">
|
||||||
<Input
|
<div>
|
||||||
size="sm"
|
<RunProgressDounut />
|
||||||
type="text"
|
</div>
|
||||||
variant="bordered"
|
<div className="flex-grow">
|
||||||
label="Name"
|
<Input
|
||||||
value={testRun.name}
|
size="sm"
|
||||||
isInvalid={isNameInvalid}
|
type="text"
|
||||||
errorMessage={isNameInvalid ? "please enter name" : ""}
|
variant="bordered"
|
||||||
onChange={(e) => {
|
label="Name"
|
||||||
setTestRun({ ...testRun, name: e.target.value });
|
value={testRun.name}
|
||||||
}}
|
isInvalid={isNameInvalid}
|
||||||
className="mt-3"
|
errorMessage={isNameInvalid ? "please enter name" : ""}
|
||||||
/>
|
onChange={(e) => {
|
||||||
|
setTestRun({ ...testRun, name: e.target.value });
|
||||||
|
}}
|
||||||
|
className="mt-3"
|
||||||
|
/>
|
||||||
|
|
||||||
<Textarea
|
<Textarea
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
label="Description"
|
label="Description"
|
||||||
placeholder="Test run description"
|
placeholder="Test run description"
|
||||||
value={testRun.description}
|
value={testRun.description}
|
||||||
onValueChange={(changeValue) => {
|
onValueChange={(changeValue) => {
|
||||||
setTestRun({ ...testRun, description: changeValue });
|
setTestRun({ ...testRun, description: changeValue });
|
||||||
}}
|
}}
|
||||||
className="mt-3"
|
className="mt-3"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Select
|
<Select
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
selectedKeys={[testRunStatus[testRun.state].uid]}
|
selectedKeys={[testRunStatus[testRun.state].uid]}
|
||||||
onSelectionChange={(e) => {
|
onSelectionChange={(e) => {
|
||||||
const selectedUid = e.anchorKey;
|
const selectedUid = e.anchorKey;
|
||||||
const index = testRunStatus.findIndex(
|
const index = testRunStatus.findIndex(
|
||||||
(template) => template.uid === selectedUid
|
(template) => template.uid === selectedUid
|
||||||
);
|
);
|
||||||
setTestRun({ ...testRun, state: index });
|
setTestRun({ ...testRun, state: index });
|
||||||
}}
|
}}
|
||||||
label="status"
|
label="status"
|
||||||
className="mt-3 max-w-xs"
|
className="mt-3 max-w-xs"
|
||||||
>
|
>
|
||||||
{testRunStatus.map((state, index) => (
|
{testRunStatus.map((state, index) => (
|
||||||
<SelectItem key={state.uid} value={index}>
|
<SelectItem key={state.uid} value={index}>
|
||||||
{state.name}
|
{state.name}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Divider className="my-6" />
|
|
||||||
<RunProgressChart />
|
|
||||||
|
|
||||||
<Divider className="my-6" />
|
<Divider className="my-6" />
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h6 className="h-8">Select test cases</h6>
|
<h6 className="h-8">Select test cases</h6>
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
|
||||||
|
|
||||||
|
const testCases = [
|
||||||
|
{ name: "Passed", value: 12, color: "#17c964" },
|
||||||
|
{ name: "Failed", value: 3, color: "#f31260" },
|
||||||
|
{ name: "Skipped", value: 14, color: "#71717a" },
|
||||||
|
{ name: "Untested", value: 32, color: "#d4d4d8" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function RunProgressDounut() {
|
||||||
|
const [chartData, setChartData] = useState({
|
||||||
|
series: testCases.map((entry) => {
|
||||||
|
return entry.value;
|
||||||
|
}),
|
||||||
|
options: {
|
||||||
|
labels: testCases.map((entry) => {
|
||||||
|
return entry.name;
|
||||||
|
}),
|
||||||
|
colors: testCases.map((entry) => {
|
||||||
|
return entry.color;
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>Progress</h1>
|
||||||
|
<Chart
|
||||||
|
options={chartData.options}
|
||||||
|
series={chartData.series}
|
||||||
|
type="donut"
|
||||||
|
width={400}
|
||||||
|
height={400}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { useState } from "react";
|
|
||||||
import Chart from "react-apexcharts";
|
|
||||||
|
|
||||||
// type Props = {
|
|
||||||
// projectId: string;
|
|
||||||
// };
|
|
||||||
|
|
||||||
const testCases = [
|
|
||||||
{ name: "Passed", value: 12, color: "#17c964" },
|
|
||||||
{ name: "Failed", value: 3, color: "#f31260" },
|
|
||||||
{ name: "Skipped", value: 14, color: "#71717a" },
|
|
||||||
{ name: "Untested", value: 32, color: "#d4d4d8" },
|
|
||||||
];
|
|
||||||
|
|
||||||
// export default function RunProgressChart({ projectId }: Props) {
|
|
||||||
export default function RunProgressChart() {
|
|
||||||
const [chartData, setChartData] = useState({
|
|
||||||
series: testCases.map((entry) => {
|
|
||||||
return {
|
|
||||||
name: entry.name,
|
|
||||||
data: [entry.value],
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
options: {
|
|
||||||
chart: {
|
|
||||||
type: "bar",
|
|
||||||
height: 100,
|
|
||||||
stacked: true,
|
|
||||||
stackType: "100%",
|
|
||||||
toolbar: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plotOptions: {
|
|
||||||
bar: {
|
|
||||||
horizontal: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
colors: testCases.map((entry) => {
|
|
||||||
return entry.color;
|
|
||||||
}),
|
|
||||||
legend: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
yaxis: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
xaxis: {
|
|
||||||
labels: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
axisTicks: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
grid: {
|
|
||||||
show: false,
|
|
||||||
padding: {
|
|
||||||
top: -20,
|
|
||||||
bottom: -20,
|
|
||||||
left: -20,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
x: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1>Progress</h1>
|
|
||||||
<Chart
|
|
||||||
options={chartData.options}
|
|
||||||
series={chartData.series}
|
|
||||||
type="bar"
|
|
||||||
width={500}
|
|
||||||
height={80}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user