1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
@Section
@Title { Labels }
@Tag { pie_labe }
@Begin
@PP
labels. @RawIndex { labels }
labels.in.pie @SubIndex { in pie graphs }
piegraphs. @RawIndex { pie graphs }
piegraphs.labels @SubIndex { labels }
Labels are short messages printed inside the slices,
identifying them. We've already seen the @Code label
option, in which we place the label, which can be an
arbitrary Lout object. In this section we'll show how
to change the format and position of these labels.
@PP
For changing the format of a label there are four options:
@ID -1px @Break @OneRow @Code @Verbatim {
@Slice
labelfont { -2p }
labelbreak { clines }
labelmargin { 0.2f }
labelformat { @Body }
}
This shows the default values of these options.
@PP
The @Code labelfont option determines the font in which the
labelfont. @RawIndex { @Code "labelfont" options }
labelfont.in.pie @SubIndex { in pie graphs }
piegraphs. @RawIndex { pie graphs }
piegraphs.labelfont @SubIndex { @Code "labelfont" option }
label will be printed. The default value shown above calls
for the current font to be used, two points smaller than it
otherwise would have been. Any value acceptable to the
@Code "@Font" symbol from Section {@NumberOf fonts} is
acceptable here, including changing the family and face.
@PP
The @Code labelbreak option determines how paragraph breaking
labelbreak. @RawIndex { @Code "labelbreak" options }
labelbreak.in.pie @SubIndex { in pie graphs }
piegraphs. @RawIndex { pie graphs }
piegraphs.labelbreak @SubIndex { @Code "labelbreak" option }
within the label will be carried out. Any value acceptable to
the @Code "@Break" symbol from Section {@NumberOf paras} is
acceptable here. The default value shown above causes each
line of the label to be one line of the result, with each
line centred with respect to the longest line.
@PP
The @Code labelmargin option places a margin around the
labelmargin. @RawIndex { @Code "labelmargin" options }
labelmargin.in.pie @SubIndex { in pie graphs }
piegraphs. @RawIndex { pie graphs }
piegraphs.labelmargin @SubIndex { @Code "labelmargin" option }
label. The default value shown makes a margin of width
0.2 times the current font size. This margin has no effect
on the appearance or position of the label (in particular,
it is drawn outside @Code "labelformat" below, not inside).
It is only needed for adjusting the appearance of fingers,
as described as the end of this section.
@PP
The @Code labelformat option allows more radical changes
labelformat. @RawIndex { @Code "labelformat" options }
labelformat.in.pie @SubIndex { in pie graphs }
piegraphs. @RawIndex { pie graphs }
piegraphs.labelformat @SubIndex { @Code "labelformat" option }
to the label format. Its value may be an arbitrary
object. Within it, the symbol @Code "@Body" stands for
the value of the @Code "label" option:
@ID -1px @Break @OneRow @Code @Verbatim {
@Slice
labelformat { @ShadowBox @Body }
}
will cause the text of the label to appear within a
shadow box. Of course, we could get this effect by
placing these symbols in the label itself, like this:
@ID -1px @Break @OneRow @Code @Verbatim {
@Slice
label { @ShadowBox { Admin (20%) } }
}
However, like all @Code "@Slice" options, @Code labelformat
may be given to @Code "@Pie" as well, like this:
@ID -1px @Break @OneRow @Code @Verbatim {
@Pie
labelformat { @ShadowBox @Body }
}
and there it affects every label in the pie graph:
@CD @Pie
labelformat { @ShadowBox @Body }
{
@Slice
weight { 20 }
label { Admin (20%) }
@Slice
weight { 40 }
label { Research (40%) }
@Slice
weight { 40 }
label { Teaching (40%) }
}
When the labels all have the same format, this is much faster
and less error-prone than formatting each label independently,
especially when experimenting with different formats.
@PP
Two options are available for changing the positions of
labels:
@ID -1px @Break @OneRow @Code @Verbatim {
@Slice
labelradius { internal }
labeladjust { 0c 0c }
}
Each label occupies a rectangular area, and these options
determine the position of the centre of the rectangle.
@PP
The @Code labelradius option determines how far the
labelradius.pie @Index { @Code "labelradius" option (pie graphs) }
piegraphs. @RawIndex { pie graphs }
piegraphs.labelradius @SubIndex { @Code "labelradius" option }
centre of the label is from the point of the slice
(usually the same as the centre of the pie graph,
but not when the slice is detached). The default value
of {@Code labelradius} shown above, {@Code internal},
is a synonym for 0.6, so it causes the centre of the label
to appear 60% of the way from the point of the slice to
its outside boundary. The angular position of the label
centre will be halfway around the arc of the slice. No
attempt is made to fit the label into the interior of
the slice; it lands where these rules say irrespective
of what might be overstruck when it does. It is printed
after its slice's outline and paint, so it can't be
hidden by them; but if it strays into the next slice it
will be buried under any paint in that slice.
@PP
For fine adjustments, the @Code labeladjust option
labeladjust. @RawIndex { @Code "labeladjust" options }
labeladjust.in.pie @SubIndex { in pie graphs }
piegraphs. @RawIndex { pie graphs }
piegraphs.labeladjust @SubIndex { @Code "labeladjust" option }
may be used to move the label centre any distance in
the x and y directions. For example,
@ID -1px @Break @OneRow @Code @Verbatim {
@Slice
labeladjust { 0.2c -0.1c }
}
will move the label centre 0.2 centimetres further to
the right and 0.1 centimetres down from where it would
otherwise have appeared.
@PP
The recommended procedure for getting internal labels
to look good is to first try them without any adjustment.
Next, consider rearranging the label layout. Our running
example has poorly positioned labels, but they can be
improved just by breaking each label over two lines:
@CD @Pie
# abovecaption { Ideal breakdown of academic workload }
aboveextra { 1f }
{
@Slice
detach { yes }
weight { 20 }
label { Admin @LLP (20%) }
@Slice
weight { 40 }
paint { green }
label { Research @LLP (40%) }
@Slice
weight { 40 }
paint { lightred }
label { Teaching @LLP (40%) }
}
Finally, the @Code labeladjust option is there as a last resort.
@PP
To get a label outside its slice, use
externallabels.pie @Index { external labels in pie graphs }
piegraphs. @RawIndex { pie graphs }
piegraphs.externallabels @SubIndex { external labels }
@ID -1px @Break @OneRow @Code @Verbatim {
@Slice
labelradius { external }
}
Again, @Code external is just a synonym for the number
1.4, meaning that the label centre is to be placed 140%
of the pie chart's radius away from the point of the
slice. It can be replaced by any number.
@PP
Two issues arise when labels are placed externally.
The first issue is that Lout does not know where these labels
are being printed and so cannot leave space for them.
Section {@NumberOf pie_over} has already explained how to
handle this problem using the {@Code leftextra},
{@Code rightextra}, {@Code aboveextra}, and {@Code belowextra}
options of {@Code "@Pie"}. Our running example, converted
to external labels, might be entered like this:
@ID -1px @Break @OneRow @Code @Verbatim {
@Pie
abovecaption { Ideal breakdown of academic workload }
labelradius { external }
aboveextra { 0.7c }
belowextra { 1.3c }
{
@Slice
detach { yes }
weight { 20 }
label { Admin @LLP (20%) }
@Slice
weight { 40 }
paint { green }
label { Research @LLP (40%) }
@Slice
weight { 40 }
paint { lightred }
label { Teaching @LLP (40%) }
}
}
which produces this:
@CD @Pie
abovecaption { Ideal breakdown of academic workload }
labelradius { external }
aboveextra { 0.7c }
belowextra { 1.3c }
{
@Slice
detach { yes }
weight { 20 }
label { Admin @LLP (20%) }
@Slice
weight { 40 }
paint { green }
label { Research @LLP (40%) }
@Slice
weight { 40 }
paint { lightred }
label { Teaching @LLP (40%) }
}
The amount of extra space to add has to be worked out by
experiment. It can help to temporarily remove all
captions and enclose the @Code "@Pie" symbol in a box
with zero margin:
@ID -1px @Break @Code @Verbatim { @Box margin { 0i } @Pie ... }
to show clearly how much space the @Code extra options
are covering.
@PP
The second issue raised by external labels is how to
visually connect each label with its slice, when this
fingers.pie @Index { fingers in pie graphs }
piegraphs. @RawIndex { pie graphs }
piegraphs.fingers @SubIndex { fingers }
seems necessary. @Code "@Pie" can do this with short
line segments that we will call {@I fingers}:
@CD @Pie
abovecaption { Ideal breakdown of academic workload }
labelradius { external }
aboveextra { 1.3f }
belowextra { 3f }
finger { yes }
{
@Slice
detach { yes }
weight { 20 }
label { Admin @LLP (20%) }
@Slice
weight { 40 }
paint { green }
label { Research @LLP (40%) }
@Slice
weight { 40 }
paint { lightred }
label { Teaching @LLP (40%) }
}
These were made by adding @Code "finger { yes }" as
another option to the @Code "@Pie" symbol.
@PP
Each slice has several options which control the
appearance of its own finger. Here is the full set,
showing their default values:
@ID -1px @Break @OneRow @Code @Verbatim {
@Slice
finger { no }
fingerstyle { solid }
fingerdashlength { 0.2f }
fingerwidth { thin }
fingerradius { 0.7 }
fingeradjust { 0c 0c }
}
The @Code "finger" option may be @Code "no" or @Code "yes"
finger.pie @Index { @Code "finger" option (pie graphs) }
piegraphs. @RawIndex { pie graphs }
piegraphs.finger @SubIndex { @Code "finger" option }
and determines whether a finger will be drawn or not.
@PP
The {@Code fingerstyle}, {@Code fingerdashlength}, and
{@Code fingerwidth} options are exactly analogous to
fingerstyle.pie @Index { @Code "fingerstyle" option (pie graphs) }
piegraphs. @RawIndex { pie graphs }
piegraphs.fingerstyle @SubIndex { @Code "fingerstyle" option }
fingerdashlength.pie @Index { @Code "fingerdashlength" option (pie graphs) }
piegraphs. @RawIndex { pie graphs }
piegraphs.fingerdashlength @SubIndex { @Code "fingerdashlength" option }
fingerwidth.pie @Index { @Code "fingerwidth" option (pie graphs) }
piegraphs. @RawIndex { pie graphs }
piegraphs.fingerwidth @SubIndex { @Code "fingerwidth" option }
the {@Code outlinestyle}, {@Code outlinedashlength}, and
{@Code outlinewidth} options. They take the same range
of values, and determine the style of the line segment
drawn to make the finger (solid, dashed, etc.).
@PP
The {@Code fingerradius} and {@Code fingeradjust} options
are exactly analogous to the {@Code labelradius} and
{@Code labeladjust} options, except that instead of
determining the position of the centre of the label they
determine the position of the inner endpoint of the
finger. The default values place it 70% of the way
from the point of the slice to its outer edge. The
@I outer endpoint of the finger always terminates on
the bounding box of the label, with the line pointing
through the centre of the label, and this cannot be
changed, although the @Code labelmargin option
(see the start of this section) may be used to decrease
or increase the margin around the label, thus causing
the finger to terminate closer to the label or further away.
@PP
Fingers may have arrowheads on their inner ends:
@ID @OneRow @Code @Verbatim {
@Pie
labelradius { 1.6 }
aboveextra { 2f }
belowextra { 4f }
finger { yes }
fingerarrow { yes }
fingerradius { 1 }
{
@Slice
detach { yes }
weight { 20 }
label { Admin @LLP (20%) }
@Slice
weight { 40 }
paint { green }
label { Research @LLP (40%) }
@Slice
weight { 40 }
paint { lightred }
label { Teaching @LLP (40%) }
}
}
produces
@CD @Pie
labelradius { 1.6 }
aboveextra { 2f }
belowextra { 4f }
finger { yes }
fingerarrow { yes }
fingerradius { 1 }
{
@Slice
detach { yes }
weight { 20 }
label { Admin @LLP (20%) }
@Slice
weight { 40 }
paint { green }
label { Research @LLP (40%) }
@Slice
weight { 40 }
paint { lightred }
label { Teaching @LLP (40%) }
}
The point of the arrowhead coincides with the inner
endpoint of the finger, so @Code "fingerradius" would
usually be set to @Code 1 when arrowheads are used.
@PP
Although @Code "@Pie" does not offer the elegant selection
of arrowhead styles of {@Code "@Diag"}, it is possible
to change the length and width of the arrowheads
with these options:
@ID @OneRow @Code @Verbatim {
@Slice
fingerarrowlength { 0.6f }
fingerarrowwidth { 0.45f }
}
This example shows the default values of these options.
These options may of course be given to @Code "@Pie" and
also in the setup file as usual.
@End @Section
|