Fix sqrt minor ticks: crowd toward low end via squared position
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
+14
-5
@@ -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' <line x1="{x:.5f}" y1="{BAR_Y}" x2="{x:.5f}" y2="{BAR_Y - SMALL_H:.5f}"'
|
||||
f' style="stroke:#1a1a1a;stroke-width:0.302;stroke-linecap:butt" />'
|
||||
|
||||
Reference in New Issue
Block a user