1# The `fit` attribute 2 3The "`fit`" attribute causes an object to automatically adjust its 4"`width`", "`height`", and/or "`radius`" so that it will enclose its 5text annotations with a reasonable margin. 6 7~~~ pikchr toggle 8box "with" "\"fit\"" fit 9move 10box "without" "\"fit\"" 11~~~ 12 13The "`fit`" attribute only works with text annotations that occur 14earlier in the object definition. In other words, the "`fit`" keyword 15should come after all text annotations have been defined. 16 17## Pikchr guesses at the size of text 18 19Pikchr does not have access to the SVG rendering engine. Therefore, 20it cannot know the precise dimensions of text annotations. It has to 21guess. Usually Pikchr does a reasonable job, but sometimes it can be 22a little off, especially with unusual characters. If "`fit`" causes the 23object to be too narrow, you can try adding spaces at the beginning and 24end of the longest text annotation. You can also adjust the width 25and height by a percentage after running "`fit`": 26 27 * `width 110%` 28 * `height 90%` 29 * `radius 120%` 30 31And so forth. Substitute percentage increases and decreases, as 32appropriate, to make the text fit like you want. 33 34## Auto-fit 35 36If at the end of an objection definition the requested width or height of the 37object is less then or equal to zero, then that dimension is adjusted 38upwards to enclose the text annotations. Thus, by setting variables 39like: 40 41~~~ 42 boxwid = 0 43 boxht = 0 44~~~ 45 46You can cause all boxes to scale to enclose their text annotations. 47(Caution: boxes without any text annotations go to zero height and width 48and thus disappear when auto-fit.) 49