diff --git a/src/App.jsx b/src/App.jsx
index 6f3a265..d105d5e 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -6,6 +6,7 @@ import ChartContainer from './components/ChartContainer';
import { ComparisonControls } from './components/ComparisonControls';
import { Header } from './components/Header';
import { FileConfigModal } from './components/FileConfigModal';
+import { PanelLeftClose, PanelLeftOpen } from 'lucide-react';
function App() {
const [uploadedFiles, setUploadedFiles] = useState([]);
@@ -37,6 +38,7 @@ function App() {
const [, setDragCounter] = useState(0);
const [xRange, setXRange] = useState({ min: undefined, max: undefined });
const [maxStep, setMaxStep] = useState(0);
+ const [sidebarVisible, setSidebarVisible] = useState(true);
const handleFilesUploaded = useCallback((files) => {
const filesWithDefaults = files.map(file => ({
@@ -188,7 +190,7 @@ function App() {
{/* 全页面拖拽覆盖层 */}
{globalDragOver && (
-
)}
+ {!sidebarVisible && (
+
+ )}
+
-
-
-
+
+
+ )}
-
diff --git a/src/components/ChartContainer.jsx b/src/components/ChartContainer.jsx
index 495c99f..aa316e3 100644
--- a/src/components/ChartContainer.jsx
+++ b/src/components/ChartContainer.jsx
@@ -214,6 +214,30 @@ export default function ChartContainer({
return result;
};
+ const calculateYRange = useCallback((dataArray) => {
+ let min = Infinity;
+ let max = -Infinity;
+ dataArray.forEach(item => {
+ item.data.forEach(point => {
+ const inRange =
+ (xRange.min === undefined || point.x >= xRange.min) &&
+ (xRange.max === undefined || point.x <= xRange.max);
+ if (inRange) {
+ if (point.y < min) min = point.y;
+ if (point.y > max) max = point.y;
+ }
+ });
+ });
+ if (min === Infinity || max === -Infinity) {
+ return { min: 0, max: 1 };
+ }
+ if (min === max) {
+ return { min: min - 1, max: max + 1 };
+ }
+ const pad = (max - min) * 0.05;
+ return { min: min - pad, max: max + pad };
+ }, [xRange]);
+
const chartOptions = useMemo(() => ({
responsive: true,
maintainAspectRatio: false,
@@ -326,7 +350,6 @@ export default function ChartContainer({
display: true,
title: { display: true, text: 'Value' },
bounds: 'data',
- grace: '20%',
ticks: {
callback: function (value) {
return Number(value.toPrecision(2));
@@ -429,6 +452,15 @@ export default function ChartContainer({
const dataArray = metricDataArrays[key] || [];
const showComparison = dataArray.length === 2;
+ const yRange = calculateYRange(dataArray);
+ const options = {
+ ...chartOptions,
+ scales: {
+ ...chartOptions.scales,
+ y: { ...chartOptions.scales.y, min: yRange.min, max: yRange.max }
+ }
+ };
+
let stats = null;
if (showComparison) {
const normalDiff = getComparisonData(dataArray[0].data, dataArray[1].data, 'normal');
@@ -442,6 +474,30 @@ export default function ChartContainer({
};
}
+ let comparisonChart = null;
+ if (showComparison) {
+ const compData = createComparisonChartData(dataArray[0], dataArray[1], key);
+ const compRange = calculateYRange(compData.datasets);
+ const compOptions = {
+ ...chartOptions,
+ scales: {
+ ...chartOptions.scales,
+ y: { ...chartOptions.scales.y, min: compRange.min, max: compRange.max }
+ }
+ };
+ comparisonChart = (
+
+
+
+ );
+ }
+
return (
@@ -450,20 +506,10 @@ export default function ChartContainer({
onRegisterChart={registerChart}
onSyncHover={syncHoverToAllCharts}
data={createChartData(dataArray)}
- options={chartOptions}
+ options={options}
/>
- {showComparison && (
-
-
-
- )}
+ {comparisonChart}
{stats && (
{key} 差值统计