From c5457e2e270c1abcf4eab9c48dc4e30a37a3d155 Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Tue, 23 Jun 2026 15:11:24 +0200 Subject: [PATCH] viewer: keep plot axis labels readable when compressed When the plot dock was short, Qt Charts dropped the axis labels first, making the plot hard to read. - Reclaim Qt Charts' outer graphics-layout padding and trim the inner margins (both chart views) so the plot and its labels get the available space. - Raise the chart minimum height (dataset-info 80 -> 140, per-image 120 -> 140) so the dock can't be squeezed below the point where the axis labels fit. Co-Authored-By: Claude Opus 4.8 --- viewer/JFJochViewerDatasetInfo.cpp | 2 +- viewer/charts/JFJochDatasetInfoChartView.cpp | 6 ++++++ viewer/charts/JFJochSimpleChartView.cpp | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/viewer/JFJochViewerDatasetInfo.cpp b/viewer/JFJochViewerDatasetInfo.cpp index bc0cb932..774ce884 100644 --- a/viewer/JFJochViewerDatasetInfo.cpp +++ b/viewer/JFJochViewerDatasetInfo.cpp @@ -52,7 +52,7 @@ JFJochViewerDatasetInfo::JFJochViewerDatasetInfo(QWidget *parent) : QWidget(pare stack = new QStackedWidget(this); chart_view = new JFJochDatasetInfoChartView(this); - chart_view->setMinimumHeight(80); // low floor so the bottom dock resizes freely (default is set via resizeDocks) + chart_view->setMinimumHeight(140); // keep enough room for the axis labels even when compressed grid_scan_image = new JFJochGridScanImage(this); image_chart = new JFJochViewerSidePanelChart(this); // per-image profiles, folded in from the side panel diff --git a/viewer/charts/JFJochDatasetInfoChartView.cpp b/viewer/charts/JFJochDatasetInfoChartView.cpp index 77806db2..46486046 100644 --- a/viewer/charts/JFJochDatasetInfoChartView.cpp +++ b/viewer/charts/JFJochDatasetInfoChartView.cpp @@ -6,12 +6,18 @@ #include #include #include +#include #include "JFJochDatasetInfoChartView.h" JFJochDatasetInfoChartView::JFJochDatasetInfoChartView(QWidget *parent) : QChartView(new QChart(), parent) { chart()->legend()->hide(); + // Reclaim Qt Charts' outer layout padding and trim the inner margins so the axis labels keep + // their room even when the dock is short (otherwise they are the first thing Qt drops). + chart()->layout()->setContentsMargins(0, 0, 0, 0); + chart()->setMargins(QMargins(2, 2, 6, 2)); + chart()->setBackgroundRoundness(0); setRenderHint(QPainter::Antialiasing); // setRubberBand(QChartView::RubberBand::RectangleRubberBand); setMouseTracking(true); diff --git a/viewer/charts/JFJochSimpleChartView.cpp b/viewer/charts/JFJochSimpleChartView.cpp index d8622dd1..35b582fa 100644 --- a/viewer/charts/JFJochSimpleChartView.cpp +++ b/viewer/charts/JFJochSimpleChartView.cpp @@ -8,11 +8,14 @@ #include #include #include +#include JFJochSimpleChartView::JFJochSimpleChartView(QWidget *parent) : QChartView(new QChart(), parent) { chart()->legend()->hide(); - setMinimumHeight(120); // soft floor: let the host dock/window decide the height + chart()->layout()->setContentsMargins(0, 0, 0, 0); // reclaim padding for the plot + labels + chart()->setMargins(QMargins(2, 2, 6, 2)); + setMinimumHeight(140); // soft floor: enough for the axis labels to stay readable setRenderHint(QPainter::Antialiasing); setMouseTracking(true); //setRubberBand(QChartView::RubberBand::HorizontalRubberBand);