mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-04 17:16:39 +08:00
解决图表显示问题
This commit is contained in:
parent
c1ba0be98b
commit
cca33ae16f
@ -1,7 +1,12 @@
|
|||||||
// "use client";
|
// "use client";
|
||||||
import { Grid, Col, Card, Text, AreaChart, Metric } from "@tremor/react";
|
import { Grid, Col, Card, Text, AreaChart, Metric } from "@tremor/react";
|
||||||
import UsageAnalysis from "./usage-analysis";
|
import UsageAnalysis from "./usage-analysis";
|
||||||
import EchartsComponent from "./testchart";
|
// import EchartsComponent from "./testchart";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
|
||||||
|
const UsageByModelChart = dynamic(() => import("./usage-by-model"), {
|
||||||
|
ssr: false,
|
||||||
|
});
|
||||||
|
|
||||||
export default function AdminPage() {
|
export default function AdminPage() {
|
||||||
return (
|
return (
|
||||||
@ -11,7 +16,7 @@ export default function AdminPage() {
|
|||||||
<UsageAnalysis />
|
<UsageAnalysis />
|
||||||
</Col>
|
</Col>
|
||||||
<Col numColSpan={1} numColSpanLg={2}>
|
<Col numColSpan={1} numColSpanLg={2}>
|
||||||
<EchartsComponent />
|
<UsageByModelChart />
|
||||||
</Col>
|
</Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</>
|
</>
|
||||||
|
@ -2,9 +2,14 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import * as echarts from "echarts"; // 导入 echarts
|
import * as echarts from "echarts"; // 导入 echarts
|
||||||
|
|
||||||
|
// const isBrowser = () => typeof window !== 'undefined'; //The approach recommended by Next.js
|
||||||
|
|
||||||
const EchartsComponent: React.FC = () => {
|
const EchartsComponent: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
var chartDom = document.getElementById("charts");
|
// 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 myChart = echarts.init(chartDom);
|
||||||
var option;
|
var option;
|
||||||
|
|
||||||
@ -47,7 +52,12 @@ const EchartsComponent: React.FC = () => {
|
|||||||
option && myChart.setOption(option);
|
option && myChart.setOption(option);
|
||||||
}, []); // 空数组作为第二个参数,表示仅在组件挂载和卸载时执行
|
}, []); // 空数组作为第二个参数,表示仅在组件挂载和卸载时执行
|
||||||
|
|
||||||
return <div id="charts" style={{ width: "100%", height: "400px" }}></div>;
|
return (
|
||||||
|
<div
|
||||||
|
id="usage-by-model-chart"
|
||||||
|
style={{ width: "100%", height: "400px" }}
|
||||||
|
></div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EchartsComponent;
|
export default EchartsComponent;
|
Loading…
Reference in New Issue
Block a user