图表缩放
This commit is contained in:
+3
-3
@@ -13,8 +13,8 @@ const geistMono = Geist_Mono({
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
title: "ESP32 微弱压力数据采集系统",
|
||||
description: "用于采集和分析微弱压力数据的系统,基于 ESP32 平台构建。",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
@@ -23,7 +23,7 @@ export default function RootLayout({
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<html lang="zh-CN">
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
|
||||
@@ -11,9 +11,10 @@ import {
|
||||
Tooltip,
|
||||
Legend,
|
||||
} from 'chart.js'
|
||||
import zoomPlugin from 'chartjs-plugin-zoom'
|
||||
import { Line, Bar, Scatter } from 'react-chartjs-2'
|
||||
|
||||
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, BarElement, Tooltip, Legend)
|
||||
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, BarElement, Tooltip, Legend, zoomPlugin)
|
||||
|
||||
type Detail = {
|
||||
id: string
|
||||
@@ -88,7 +89,6 @@ export default function Page({ params }: { params: Promise<{ id: string }> }) {
|
||||
const dataToUse = enableEma ? smoothedCode : (rec?.code || [])
|
||||
return buildHistogram(dataToUse, 30)
|
||||
}, [rec, enableEma, smoothedCode])
|
||||
const forceHistogram = useMemo(() => buildHistogram(forceSeries || [], 30), [forceSeries])
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-zinc-50 text-zinc-900 dark:bg-black dark:text-zinc-100">
|
||||
@@ -180,6 +180,7 @@ export default function Page({ params }: { params: Promise<{ id: string }> }) {
|
||||
<span className="w-12 text-right">{emaAlpha.toFixed(2)}</span>
|
||||
</label>
|
||||
)}
|
||||
<span className="hidden text-xs text-zinc-500 sm:inline">按 Ctrl+滚轮 缩放,拖拽平移</span>
|
||||
</div>
|
||||
</div>
|
||||
<Line
|
||||
@@ -215,7 +216,17 @@ export default function Page({ params }: { params: Promise<{ id: string }> }) {
|
||||
options={{
|
||||
responsive: true,
|
||||
interaction: { mode: 'index', intersect: false },
|
||||
plugins: { legend: { position: 'top' as const } },
|
||||
plugins: {
|
||||
legend: { position: 'top' as const },
|
||||
zoom: {
|
||||
pan: { enabled: true, mode: 'x' as const },
|
||||
zoom: {
|
||||
wheel: { enabled: true, modifierKey: 'ctrl' as const },
|
||||
pinch: { enabled: true },
|
||||
mode: 'x' as const,
|
||||
},
|
||||
},
|
||||
},
|
||||
scales: {
|
||||
x: { title: { display: true, text: '时间 (ms)' } },
|
||||
yCode: { type: 'linear' as const, position: 'left' as const, title: { display: true, text: '码值' } },
|
||||
@@ -240,7 +251,19 @@ export default function Page({ params }: { params: Promise<{ id: string }> }) {
|
||||
},
|
||||
],
|
||||
}}
|
||||
options={{ scales: { x: { title: { display: true, text: '码值' } }, y: { title: { display: true, text: '数量' } } } }}
|
||||
options={{
|
||||
plugins: {
|
||||
zoom: {
|
||||
pan: { enabled: true, mode: 'x' as const },
|
||||
zoom: {
|
||||
wheel: { enabled: true, modifierKey: 'ctrl' as const },
|
||||
pinch: { enabled: true },
|
||||
mode: 'x' as const,
|
||||
},
|
||||
},
|
||||
},
|
||||
scales: { x: { title: { display: true, text: '码值' } }, y: { title: { display: true, text: '数量' } } },
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="rounded-lg border p-4 dark:border-zinc-800">
|
||||
@@ -261,7 +284,17 @@ export default function Page({ params }: { params: Promise<{ id: string }> }) {
|
||||
x: { title: { display: true, text: '码值' } },
|
||||
y: { title: { display: true, text: '力值 (mN)' } },
|
||||
},
|
||||
plugins: { legend: { display: false } },
|
||||
plugins: {
|
||||
legend: { display: false },
|
||||
zoom: {
|
||||
pan: { enabled: true, mode: 'x' as const },
|
||||
zoom: {
|
||||
wheel: { enabled: true, modifierKey: 'ctrl' as const },
|
||||
pinch: { enabled: true },
|
||||
mode: 'x' as const,
|
||||
},
|
||||
},
|
||||
},
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user