import apiFetch from "@/lib/apiFetch"; import { Card, Divider, Flex, Stack, Text, Title } from "@mantine/core"; import { IconChartBar } from "@tabler/icons-react"; import type { EChartsOption } from "echarts"; import EChartsReact from "echarts-for-react"; import { useEffect, useState } from "react"; import useSWR from "swr"; export default function DashboardGrafik() { const [options, setOptions] = useState({}); const { data, mutate, isLoading } = useSWR( "grafik-dashboard", async () => { return apiFetch.api.dashboard.grafik.get().then(res => res.data); } ); const loadData = () => { if (!data) return; const option: EChartsOption = { darkMode: true, animation: true, legend: { textStyle: { color: "#fff" } }, tooltip: {}, dataset: { dimensions: data.dimensions, source: data.source }, xAxis: { type: "category", axisLabel: { color: "#fff" } }, yAxis: { type: "value", minInterval: 1, axisLabel: { color: "#fff" } }, color: ["#1abc9c", "#10816aff"], series: [ { type: "bar" }, { type: "bar" } ] }; setOptions(option); }; useEffect(() => { if (data) loadData(); }, [data]); return ( Grafik Pengaduan dan Pelayanan Surat 7 Hari Terakhir ) }