Skip to content

Commit 29d1394

Browse files
authored
correct calculation text extents (#89)
correct calculation text extents for (member anchor '(left center right)), to avoid allocating too much vertical space for very wide labels
1 parent c80324d commit 29d1394

File tree

6 files changed

+30
-1
lines changed

6 files changed

+30
-1
lines changed

plot-lib/plot/private/common/draw.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
(: dys (Listof Real))
3232
(define dys (case anchor
3333
[(top-left top top-right) (list (- dist) (- height dist))]
34-
[(left center right) (list (* -1/2 height) (* 1/2 width))]
34+
[(left center right) (list (* -1/2 height) (* 1/2 height))]
3535
[else (list (- dist height) dist)]))
3636

3737
(for*/list : (Listof (Vector Real Real)) ([dx (in-list dxs)] [dy (in-list dys)])

plot-test/plot/tests/PRs/89.rkt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#lang racket
2+
(require rackunit
3+
plot pict racket/runtime-path
4+
"../helpers.rkt")
5+
6+
; tests for PR#89, https://github.com/racket/plot/pull/89
7+
; "fix calculation of text-extends for anchor 'right center left"
8+
9+
(define (do-plot output-fn)
10+
(parameterize ([plot-x-label #f]
11+
[plot-y-label #f])
12+
(output-fn
13+
(polar (lambda (t) 1))
14+
#:x-min 4025584149602844706/10000000000000000000
15+
#:x-max 4025584149602844712/10000000000000000000
16+
#:y-min 6805367900508167/10000000000000000
17+
#:y-max 6805367900508171/10000000000000000)))
18+
19+
(define-runtime-path pr89 "./test-data/pr89.dat")
20+
21+
(define pr86-test-suite
22+
(test-suite
23+
"PR#89: text-extents"
24+
(test-case "PR89: text-extents"
25+
(check-draw-steps do-plot pr89))))
26+
27+
(module+ test
28+
(require rackunit/text-ui)
29+
(run-tests pr86-test-suite))
1.31 KB
Binary file not shown.
12.8 KB
Loading
2.04 KB
Binary file not shown.
-131 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)