From 846fe2d235a6f9ced19253ae8aabd5a25c0578b9 Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Tue, 14 Jul 2026 19:27:40 +0200 Subject: [PATCH] Fix sqrt minor ticks: crowd toward low end via squared position --- k8s/deployment.yaml | 2 +- web/app.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 8d0d2eb..294976b 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: m1730-generator - image: git.baumann.gr/adebaumann/m1730-generator:0.78 + image: git.baumann.gr/adebaumann/m1730-generator:0.79 imagePullPolicy: Always ports: - containerPort: 5000 diff --git a/web/app.py b/web/app.py index 8748f67..1ed0a00 100644 --- a/web/app.py +++ b/web/app.py @@ -8,7 +8,7 @@ from fontTools.pens.svgPathPen import SVGPathPen app = Flask(__name__) -VERSION = "0.78" +VERSION = "0.79" _LOGO_PATH = pathlib.Path(__file__).parent / 'static' / 'logo.png' _LOGO_B64 = base64.b64encode(_LOGO_PATH.read_bytes()).decode() @@ -444,14 +444,23 @@ def generate_svg(unit, min_val, max_val, range_label, big_ticks, small_ticks, la f' style="stroke:#1a1a1a;stroke-width:0.555;stroke-linecap:butt" />' ) - # Minor ticks — evenly spaced in value, then positioned by the scale mapping. - # On a linear scale this is uniform; on a log scale they crowd toward the high end. + # Minor ticks — placement depends on scale type: + # linear: uniform physical spacing (= uniform value spacing) + # log: linear value interpolation between geometric major values + # (crowds toward high end of each interval) + # sqrt: sqrt of fractional position within each interval, giving + # consistent high-end crowding across all intervals; using + # value interpolation instead would concentrate the crowding + # only near zero (where sqrt is steepest) and look linear elsewhere. if small_ticks > 0: sub = small_ticks + 1 for i in range(big_ticks): for j in range(1, small_ticks + 1): - v = big_vals[i] + j * (big_vals[i + 1] - big_vals[i]) / sub - x = value_to_x(v) + if scale_type == 'sqrt': + x = big_xs[i] + (j / sub) ** 2 * (big_xs[i + 1] - big_xs[i]) + else: + v = big_vals[i] + j * (big_vals[i + 1] - big_vals[i]) / sub + x = value_to_x(v) parts.append( f' '