yazid138 3 жил өмнө
parent
commit
19d3222e4a

+ 14 - 6
components/Riwayat/ChartDataBar.js

@@ -14,7 +14,7 @@ class ChartDataBar extends React.Component {
 			series: [
 				{
 					data: [44, 55, 41, 64, 22, 43, 21, 44, 42, 67, 43, 86, 42, 99, 131, 313],
-					name: 'jumlah laporan',
+					name: "jumlah laporan",
 				},
 			],
 			options: {
@@ -39,7 +39,7 @@ class ChartDataBar extends React.Component {
 					},
 				},
 
-				colors: ['#B2B0D2'],
+				colors: ["#B2B0D2"],
 				dataLabels: {
 					enabled: true,
 					offsetX: -6,
@@ -63,9 +63,8 @@ class ChartDataBar extends React.Component {
 					// name: ["LLDikti I", "LLDikti II", "LLDikti III", "LLDikti IV", "LLDikti V", "LLDikti VI", "LLDikti VII", "LLDikti VIII", "LLDikti IX", "LLDikti X", "LLDikti XI", "LLDikti XII", "LLDikti XIII", "LLDikti XIV", "LLDikti XV", "LLDikti XVI"]
 				},
 				fill: {
-					colors: ['#B2B0D2'],
-				}
-
+					colors: ["#B2B0D2"],
+				},
 			},
 		};
 	}
@@ -73,7 +72,16 @@ class ChartDataBar extends React.Component {
 	async componentDidMount() {
 		const { token } = this.props;
 		const data = await jumlahLaporan(token);
-		console.log(data.data);
+		this.setState((prevState) => ({
+			...prevState,
+			series: [{ data: data.data.map((e) => e.jumlah_laporan), name: "jumlah laporan" }],
+			options: {
+				...prevState.options,
+				xaxis: {
+					categories: data.data.map((e) => e._id),
+				},
+			},
+		}));
 	}
 
 	render() {