From 05e585410731b6b87799a63efde3d0dc4039447a Mon Sep 17 00:00:00 2001
From: Martin Marmsoler <martin.marmsoler@gmail.com>
Date: Tue, 28 Dec 2021 18:03:35 +0100
Subject: [PATCH] do not change format and scale if only start and end are
 passed

---
 src/backend/lib/Range.h                                 | 7 +++++--
 src/backend/worksheet/plots/cartesian/CartesianPlot.cpp | 8 ++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/backend/lib/Range.h b/src/backend/lib/Range.h
index a866a5704a..6b57d424b1 100644
--- a/src/backend/lib/Range.h
+++ b/src/backend/lib/Range.h
@@ -92,13 +92,16 @@ public:
 
 	void setStart(T start) { m_start = start; }
 	void setEnd(T end) { m_end = end; }
-	void setRange(T start, T end, Format format = Format::Numeric,
-		      Scale scale = Scale::Linear) {
+	void setRange(T start, T end, Format format, Scale scale) {
 		m_start = start;
 		m_end = end;
 		m_format = format;
 		m_scale = scale;
 	}
+	void setRange(T start, T end) {
+		m_start = start;
+		m_end = end;
+	}
 	void setFormat(Format format) { m_format = format; }
 	void setScale(Scale scale) { m_scale = scale; }
 	void setDateTimeFormat(QString format) { m_dateTimeFormat = format; }
diff --git a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
index 2ae68bbf87..f40e7ec0d1 100644
--- a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
+++ b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
@@ -243,8 +243,8 @@ void CartesianPlot::setType(Type type) {
 			break;
 		}
 	case Type::TwoAxesCentered: {
-			d->xRanges[0].range.setRange(-0.5, 0.5);
-			d->yRanges[0].range.setRange(-0.5, 0.5);
+			d->xRanges[0].range.setRange(-0.5, 0.5, RangeT::Format::Numeric, RangeT::Scale::Linear);
+			d->yRanges[0].range.setRange(-0.5, 0.5, RangeT::Format::Numeric, RangeT::Scale::Linear);
 
 			d->horizontalPadding = Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Centimeter);
 			d->verticalPadding = Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Centimeter);
@@ -282,8 +282,8 @@ void CartesianPlot::setType(Type type) {
 			break;
 		}
 	case Type::TwoAxesCenteredZero: {
-			d->xRanges[0].range.setRange(-0.5, 0.5);
-			d->yRanges[0].range.setRange(-0.5, 0.5);
+			d->xRanges[0].range.setRange(-0.5, 0.5, RangeT::Format::Numeric, RangeT::Scale::Linear);
+			d->yRanges[0].range.setRange(-0.5, 0.5, RangeT::Format::Numeric, RangeT::Scale::Linear);
 
 			d->horizontalPadding = Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Centimeter);
 			d->verticalPadding = Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Centimeter);
-- 
GitLab