diff --git a/app/app/(admin)/admin/page.tsx b/app/app/(admin)/admin/page.tsx
index bef4e9350..e653a425b 100644
--- a/app/app/(admin)/admin/page.tsx
+++ b/app/app/(admin)/admin/page.tsx
@@ -1,12 +1,7 @@
// "use client";
import { Grid, Col, Card, Text, AreaChart, Metric } from "@tremor/react";
import UsageAnalysis from "./usage-analysis";
-// import EchartsComponent from "./testchart";
-import dynamic from "next/dynamic";
-
-const UsageByModelChart = dynamic(() => import("./usage-by-model"), {
- ssr: false,
-});
+import UsageByModel from "./usage-by-model";
export default function AdminPage() {
return (
@@ -16,7 +11,7 @@ export default function AdminPage() {
-
+
>
diff --git a/app/app/(admin)/admin/usage-by-model-chart.tsx b/app/app/(admin)/admin/usage-by-model-chart.tsx
new file mode 100644
index 000000000..b327d2dbb
--- /dev/null
+++ b/app/app/(admin)/admin/usage-by-model-chart.tsx
@@ -0,0 +1,30 @@
+"use client";
+import React, { useEffect, useState } from "react";
+import * as echarts from "echarts"; // 导入 echarts
+
+export default function UsageByModelChart({
+ option,
+}: {
+ option: echarts.EChartsOption;
+}) {
+ // const EchartsComponent: React.FC = ({ data: any }) => {
+ // const [option, setOption] = useState({});
+ console.log("======", option);
+
+ useEffect(() => {
+ var chartDom = document.getElementById("usage-by-model-chart");
+ // if (chartDom) echarts.dispose(chartDom);
+ var myChart = echarts.init(chartDom);
+ // console.log('=======[option]', option)
+ option && myChart.setOption(option);
+ }, []); // 空数组作为第二个参数,表示仅在组件挂载和卸载时执行
+
+ return (
+
+ );
+}
+
+// export default EchartsComponent;
diff --git a/app/app/(admin)/admin/usage-by-model.tsx b/app/app/(admin)/admin/usage-by-model.tsx
index a6c84ea02..ea432fec5 100644
--- a/app/app/(admin)/admin/usage-by-model.tsx
+++ b/app/app/(admin)/admin/usage-by-model.tsx
@@ -1,63 +1,50 @@
-"use client";
-import React, { useEffect } from "react";
-import * as echarts from "echarts"; // 导入 echarts
+import * as echarts from "echarts";
+import { EChartsOption } from "echarts";
+import dynamic from "next/dynamic";
-// const isBrowser = () => typeof window !== 'undefined'; //The approach recommended by Next.js
+const UsageByModelChart = dynamic(() => import("./usage-by-model-chart"), {
+ ssr: false,
+});
-const EchartsComponent: React.FC = () => {
- useEffect(() => {
- // if (!isBrowser()) return;
- var chartDom = document.getElementById("usage-by-model-chart");
- // if (!chartDiv.current) return;
- // var myChart = echarts.init(chartDiv.current)
- var myChart = echarts.init(chartDom);
- var option;
-
- option = {
- title: {
- text: "Referer of a Website",
- subtext: "Fake Data",
- left: "center",
- },
- tooltip: {
- trigger: "item",
- },
- legend: {
- orient: "vertical",
- left: "left",
- },
- series: [
- {
- name: "Access From",
- type: "pie",
- radius: "50%",
- data: [
- { value: 1048, name: "Search Engine" },
- { value: 735, name: "Direct" },
- { value: 580, name: "Email" },
- { value: 484, name: "Union Ads" },
- { value: 300, name: "Video Ads" },
- ],
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: "rgba(0, 0, 0, 0.5)",
- },
+export default function UsageByModel() {
+ const usageByModelOption: EChartsOption = {
+ title: {
+ text: "Referer of a Website",
+ subtext: "Fake Data",
+ left: "center",
+ },
+ tooltip: {
+ trigger: "item",
+ },
+ legend: {
+ orient: "vertical",
+ left: "left",
+ },
+ series: [
+ {
+ name: "Access From",
+ type: "pie",
+ radius: "50%",
+ data: [
+ { value: 1048, name: "Search Engine" },
+ { value: 735, name: "Direct" },
+ { value: 580, name: "Email" },
+ { value: 484, name: "Union Ads" },
+ { value: 300, name: "Video Ads" },
+ ],
+ emphasis: {
+ itemStyle: {
+ shadowBlur: 10,
+ shadowOffsetX: 0,
+ shadowColor: "rgba(0, 0, 0, 0.5)",
},
},
- ],
- };
-
- option && myChart.setOption(option);
- }, []); // 空数组作为第二个参数,表示仅在组件挂载和卸载时执行
-
+ },
+ ],
+ };
return (
-
+ <>
+
+ >
);
-};
-
-export default EchartsComponent;
+}