Home
piechartmp.
Contents
1. documentclass article begin document label TeXTextC this is textbf bold text origin The external file based on this METAPOST code will look like this verbatimtex 8 latex documentclassf article begin document etex btex this is textbf bold text etex As you can see this corresponds with the code where btex etex are used in the label command Now it is possible to concatenate the text from multiple strings since the text including the TeX commands is for METAPOST only a simple string But it has a disadvantage it is very slow 3 3 3 piechartMP Text Setup Not all chart labels need advanced typesetting features Therefore piechartMP supports in general two ways of typesetting labels the first mentioned string based and the last mentioned external way SetupText Mode TeXFormat TeXSettings Mode Type numeric this parameter sets which way of typesetting piechartMP uti lizes 0 string based typesetting default 1 external TeX based typesetting a verbatimtex etex block is written using TeXFormat and TeXSettings 2 the same as 1 but documentclass minimal and begin document are written in the external file auto matically 3 the same as 2 but TeXFormat defaults to latex see sec tion 3 3 1 for a list of systems supporting this format setup this the current value ATTENTION using TX based text modes can damage data since in these modes an external file with name lt jobname gt pct will be created He
2. 1 MyChart i endfor 31 6 Tips for Presentations end the first segment a green label the first segment a green label the third segment the first segment a green label the first segment a green label the second segment the fifth segment the fifth segment the third segment the third segment the first segment a green label the second segment the fifth segment the third segment the fourth segment a red label The figures are scaled by factor 0 5 6 3 Presentations not segment by segment Not all presentations need a segment by segment order The following example presents Germany s most important trade partners The first slide should only show the pie chart and the names of the countries The second chart adds the percent values Then in the following slides every country should be discussed Therefore the segment of the country will be emphasize by a radial displacement PiechartBBox 1 input piechartmp SetupNumbers 1 this SetupPercent this Segment 11 1 France 6blue Segment 10 6 USA 4 5 0 Segment 8 4 Great Britain 7 7 0 Segment 7 4 Italy 6 4 0 Segment 6 2 Netherlands 7green Segment 5 1 Austria 6red Segment 51 2 others 5white FigCounter 0 The first part declares the segments and defines the figure counter Next the META POST commands DoIf and ResetSe
3. fifth for i 2 upto 5 SegmentState i invisible this endfor beginfig 1 PieChart 2cm 0 15 60 0 0 Label auto 0 name outwards 0 endfig SegmentState 3 normal this 26 5 Special Features beginfig 2 PieChart 2cm 0 15 60 0 0 Label auto 0 name outwards 0 endfig SegmentState 4 normal this beginfig 3 PieChart 2cm 0 15 60 0 0 Label auto 0 name outwards 0 endfig SegmentState 2 normal this beginfig 4 PieChart 2cm 0 15 60 0 0 Label auto 0 name outwards 0 endfig SegmentState 3 this 0 3 SegmentState 5 normal this beginfig 5 PieChart 2cm 0 15 60 0 0 Label auto 0 name outwards 0 endfig end The resulting figures you can see below On the left side is the figure for the case when PiechartBBox was not specified first first first first 27 5 Special Features first first third third r fourth r fourth first first second second third fourth fourth first first second second fifth fifth third fourth third fourth 5 2 Enhanced Graphics with MetaFun If you look on a real round 3D object you will see that the round outside is not a solid color With the help of some other packages piechartMP is able to draw the segment outsides as gradients in order to give the cha
4. METAPOST colors these can be used multiplied with a factor 0 4 red in order to get dark red R G B adirect color specification in Red Green Blue color space PatternColor Type color the color used to draw the pattern foreground 23 4 Fill Patterns auto piechartMP calculates the color for you the method used here is different compared to the FillColor In most situations it should result in a good contrast between fore ground and background red blue one of the predefined METAPOST colors these can be used multiplied with a factor 0 4 red in order to get dark red R G B a direct color specification in Red Green Blue color space Dimen Type pair the parameter specifies the spacing S between pattern elements and the linewidth W see figure 9 for some examples 5mm 2pt the parameter used in figure 8 S W any other combination of spacing and linewidth 7mm 4pt C1mm 0 2mm 8mm 6mm 8mm 3mm 3mm 1 5mm SE WI EHE Figure 9 Examples of different Dimen parameters 4 2 Defining a Private Pattern Method When you set the Method in the DefinePattern command to the value 0 then every time piechartMP needs a pattern with this number it calls the macro PrivatePattern There is already a definition included in piechartMP that defaults to the example given below but with some METAPOST experience you can re define PrivatePattern in order to employ a pattern that suits to your needs The macro has to return a M
5. description of the circle will be saved in k input piechartmp vardef PrivatePattern expr ulc lrc spc lwd save pic cntr C k picture pic pic nullpicture pair cntr numeric c path k As mentioned before here in the first step the co ordinates of the center are assigned to cntr and for c is calculated how many circles are needed to fill the whole area cntr 0 5 Irc ulc c i xpart ulc cntr ypart Culc cntr spc c floor c Next a loop starts wherein first a circular path is declared which has an appropriate radius depending on spc and the circular path is shifted to the co ordinates of cntr Then the path with an appropriate linewidth lwd is added to the picture pic for i 1 upto c k fullcircle scaled i 2 spc shifted cntr addto pic doublepath k withpen pencircle scaled Iwd endfor The last step of the macro is returning the picture The area marked by the both corner co ordinates and the content of the picture pic can be seen on the left side in figure 10 pic enddef Now a pattern method 0 can be used Here two patterns based on this method are defined DefinePattern 1 0 blue red 5mm 3mm DefinePattern 2 0 auto white 3mm 1pt The following segment declaration uses these patterns in segments 1 and 3 Drawing the pie chart results in figure 10 As you can see the pattern picture is clipped and colored automatically Segment 32 5 1
6. minimum effort 6 2 Presentations in different order 6 3 Presentations not segment by segment 7 piechartMP Internals 1 Getting started 1 Getting started In order to draw your first pie chart you have to write an input file for METAPOST here called pcfirst mp Then you can start METAPOST this will convert your input in a META POST graphic In order to pre view your pie chart you have to embed the graphic into a document since only in this way labels and other text elements will show up correctly An easy way for the preview is the MPtoPDF converter see section 5 2 Let s start with a simple input file The colored lines are piechartMP commands the others are plain METAPOST input piechartmp SetupPercent this DefinePattern 1 1 blue red 8mm 2pt Segment 32 5 first 1 J 3 Segment 12 8 second auto Segment 22 4 third 0 0 7 0 7 Segment 18 2 fourth auto SegmentState 2 hidden this beginfig 1 PieChart 3cm 0 1 65 0 0 Label 0 percent inwards 0 withcolor white Label auto 0 name outwards 0 endfig end Now you can convert this file using METAPOST The program name mpost can be differ ent at some systems e g mp or metapost mpost pcfirst The result is a METAPOST graphic in the file pcfirst 1 Depending on the TeX macro package you are using the graphic can now be embedded in your document In a BIX document using the graph
7. the T X format shall be called TeXFormat and the following settings in the verbatimtex etex block shall be called TeXSettings 3 3 2 Extended Typesetting Capabilities piechartMP requires that text strings can be concatenated from multiple strings This is no problem with the in the previous section first mentioned string based typesetting But there is still a problem with TpX based typesetting since everything between btex etex is typeset directly and a string variable containing a concataneted string can not be expanded The only solution is to write an external file including a verbatimtex etex block and the btex etex typesetting commands since in this step everything is only a string for METAPOST This file can be input again and results in the typeset text Since every METAPOST input file has its own verbatimtex etex block the block of your input file can not be used and you have to give your settings piechartMP thereby piechartMP can write your settings in the external file 1Thanks to Martin Buchmann J rgen Gobel Rolf Niepraschk Henning Hraban Ramm and Walter Schmidt who made up that list 16 3 piechartMP Setup Suppose a command called TeXText which takes a string as argument Furthermore there are two string variables TeXFormat and TeXSettings The command takes these three strings in order to write an external file inputs the file again and returns the typeset text TeXFormat amp latex TeXSettings
8. to display those gradients 28 6 Tips for Presentations Figure 11 Segment outsides with and without MetaFun SetupColors this 6 5 this Segment 7 Segment 18 Segment 2 Segment 5 beginfig 1 PieChart 4cm 0 15 60 0 0 endfig end 6 Tips for Presentations 6 1 Presentations with minimum effort The purpose to develop the piechartMP package was to be able drawing pie charts segment by segment for presentations With some METAPOST experience this can be done very easily The commands PieChart and Label draw segments and labels only for visible seg ments That means that you can use the command Label 1 2 5 and when only the segments 1 and 5 are visible no label for segment 2 will be drawn On page 12 you can see a complex pie chart Creating multiple figures for a step by step presentation needs some work since many code has to be written With the explanation above one may have the idea that the beginfig endfig block only has to be copied and occasionally SegmentState makes the next segment visible But it is easier PiechartBBox 1 input piechartmp SetupColors 7 7 this this SetupName the segment SetupPercent this Segment 50 first Segment 30 second Segment 10 third Segment 20 fourth Segment 20 fifth 29 6 Tips for Presentations SegmentState 4 this 0 3 The first part is already well known from pag
9. true grayscale colors this current value 14 3 piechartMP Setup default SetupColors 4 6 this this SetupColors this 6 7 this SetupColors this this true gt Figure 7 Examples of different color settings In figure 7 you can see some examples outgoing from the segment definitions in the introduction Here all segments are in normal state 3 3 Text 3 3 1 Metapost Typesetting Before the text setup is discussed some words about METAPOST typesetting capabilities are needed METAPOST knows two ways of typesetting text both shall be illustrated on the METAPOST command label label this is the text origin That command writes this is the text at a position in the graphic here it is the origin 0 0 This way has the disadvantage that you cannot modify text attributes of the text You can only modify the font of the whole text and its size Therefore you must set the METAPOST variables defaultfont and defaultscale For example defaultfont ptmr8r defaultscale 1 2 label this is the text origin typesets the text in Times Roman at 1 2 of the default size Since the default size is in most cases 10 pt it will be 12 pt The font name ptmrS8r is the name of the Times Roman tfm file Here the filename according to the Karl Berry naming scheme was used As you will see this way has some advantages It is fast and the text string can be concatenated from multiple strings which is required for p
10. 1 and pcfirst 2 The graphics can be seen in figure 2 input piechartmp SetupPercent this DefinePattern 1 1 blue red 8mm 2pt Segment 32 5 first 1 Segment 12 8 second auto Segment 22 4 third 0 0 7 0 7 Segment 18 2 fourth auto SegmentState 2 hidden this beginfig 1 PieChart 3cm 0 1 65 0 0 Label 0 percent inwards 0 withcolor white Label auto 0 name outwards 0 endfig SegmentState 2 normal this SegmentState 4 invisible this beginfig 2 PieChart 3cm 0 1 65 0 0 Label 0 name inwards 0 withcolor white endfig end In the following sections all piechartMP commands will be introduced The examples sometimes include commands which still are unknown to you Please refer to following sections when necessary 2 Basic Commands first second third Figure 2 Two charts in one input file 2 Basic Commands 2 1 Segment Declaration 2 1 1 Basic Segment Declaration Segments are defined with the command Segment Every segment gets an identifier which can be used to modify specific properties of a segment The identifier is a number accord ing to the order of the segment declarations starting with 1 Segment Value FillStyle Name AltValue Value Type numeric this parameter specifies the value data of the segment Together with the values of the other segments it specifies the size of the segments in the char
11. ETAPOST picture including the pattern therefore it has to be a METAPOST vardef macro The macro is called with four parameters PrivatePattern ULC LRC Spacing Linewidth The macro has to draw the pattern in a rectangular area The co ordinates of the area s upper left corner are the first parameter ULC LRC is accordingly the lower right corner The Spacing parameter is the first value of the Dimen parameter in DefinePattern which should define the spacing between pattern elements Linewidth is the second value of the Dimen parameter What you do with this data depends on what you want get but the macro always has to return a picture element A prototype of the macro can be vardef PrivatePattern expr ulc lrc spc lwd save pic picture pic pic nullpicture pic enddef Since you not operate on currentpicture but on an own picture variable you cannot use direct drawing commands Instead of draw or fill you can use addto pic which is described in detail in the METAPOST manual Hob 24 4 Fill Patterns The following private pattern method draws a fill pattern based on circles The input file starts as usual loading piechartMP Next starts the declaration of the private pattern method In contrast to the previous mentioned prototype here some additional variables are declared The variable cntr gets the co ordinates of the center of the rectangular drawing area The number of circles to draw is saved in c and a path
12. KIpX file the font of the value labels is the same as of the percent labels in the previous graphic beginfig 2 PieChart 4cm 0 1 65 0 0 SetupValue textbf itshape million EUR Label CO value inwards 0 Label auto 0 name outwards 0 endfig 21 3 piechartMP Setup the 1 segment the 2 segment the 4 segment the 371 segment An Advanced Example One thing not mentioned before is that in the TeX commands only commands can be used which do not need TEX specials Since for example color is not supported by the TeX DVI format this is implemented driver specific using TX specials Here an example shall be given where in the text the color changes in particular the ordinal numbers of the previous figure shall be appear in red The first part is equal to the previous figure beginfig 3 PieChart 4cm 0 1 65 0 0 SetupValue textbf itshape million EUR Label 0 value inwards 0 Next the segment name is setup again Here the basic segment name is enclosed in the TeX phantom command This command does not typeset the TeX code but inserts appropriate space therefore in this step the command Label name typeset the label with the ordinal number replaced by space SetupName the phantom Ord segment Label auto 0 name outwards 0 In the second step the name label is setup again but here the other parts of the declara tion are enclose
13. METAPOST pair That feature is mainly implemented in order to label small segments which give not enough space for labels 11 2 Basic Commands If you use the Label command the way as mentioned before all labels will be drawn centered at the point In order to align the label an extended definition has to be used Label Alignment Segments Data SegmentPoint Shift Alignment specifies the alignment of the label You can use the well known METAPOST alignments top bot Ift rt 1Ift Irt ulft and urt or the alignment auto which enables piechartMP to calculate a placement according to the specific situation top bot one of the default METAPOST alignments see figure 5 auto some magic ulft top urt lft e rt 11ft bot lrt Figure 5 Default METAPOST alignments input piechartmp SetupColors 7 7 this this SetupName the segment SetupPercent this Segment 50 first Segment 30 second Segment 10 third Segment 20 fourth Segment 20 fifth SegmentState 4 this 0 3 beginfig 1 PieChart 4cm 0 15 60 0 0 Label auto 0 name outwards 0 Label 3 4 5 value Cinwards 0 withcolor white Label 1 2 percent inwards 0 withcolor 1 1 0 Label Irt 4 C a segment with percent 0 9 0 8 2cm 1cm withcolor 0 8red pickup pencircle scaled 2pt Label auto 1 a green label C 0 9 0 1 2cm 1 5cm withcolor 0 8green e
14. Segment 12 8 auto Segment 22 4 2 Segment 18 2 red beginfig 1 PieChart 4cm 0 1 65 0 0 endfig end 25 5 Special Features Figure 10 A private pattern method 5 Special Features 5 1 BoundingBox for Presentations When you want use piechartMP for for presentations in order to build charts segment by segment you will have the problem that with some segments invisible the graphics have a different size This may cause extra work to place the graphics so that they occur always in the same place on the page If you declare a numeric variable with the name PiechartBBox before the piechartMP module is loaded then piechartMP adds extra code to fit all figures in the same bounding box Since piechartMP does not know the size of following figures when it draws the first figure it requires two METAPOST runs for a correct result In the first METAPOST run a file with name lt jobname gt pcb will be written which contains the maximum bounding box of all figures lt jobname gt is the name of your METAPOST input file without extension mp thus take care that not an important file with the same name is in the directory you are running METAPOST In the second run this bounding box will be used for all figures PiechartBBox 1 input piechartmp SetupColors 7 7 this this Segment 50 first Segment 30 second Segment 10 third Segment 20 fourth Segment 20
15. be used in order to build a chart segment by segment in a presentation or emphasize one segment via displacement in one but not in the following chart 2 Basic Commands SegmentState SegmentID State Offset SegmentID Type numeric this parameter is the identifier of the segment you want change the state As you already know the identifier depends on the declaration order thus for example you have to give here the value 2 to change the state of the segment declared as second State Type numeric one of the three supported states normal segment is visible invisible segment is not visible but space is inserted instead when PieChart draws the chart hidden segment will be ignored this if you want change the Offset but not State Offset Type numeric this parameter specifies the radial displacement of a segment The displacement depends in this parameter and the radius of the chart A value of 0 means no displacement and a value of 1 means that the segment is shifted radial the full radius of the chart 0 no displacement 1 full radial displacement X any other displacement factor this if you want change the State but not Offset The value of Offset will be added to the global offset specified in PieChart thus you can use a global offset and using a negative segment Offset you can reset the displacement for a segment input piechartmp SetupColors 0 7 0 7 this this Segment 52 234 first auto 52234 Segme
16. cro returning a METAPOST pair The command Label has a parameter SegmentPoint If you use this specification as parameter sp and a valid 34 7 piechartMP Internals segment number for s in the SegmentPoint command then the returned pair will be that point in the real METAPOST system of co ordinates SegmentColor s is a piechartMP macro returning the color of the segment specified as s For example the following METAPOST loop labels all visible segments in their specific segment color for i 1 upto pc_Count Label auto i name outwards 0 withcolor SegmentColor i endfor 35 References References Hob John D Hobby A User s Manual for METAPOST Computing Science Technical Re port No 162 AT amp T Bell Laboratories Murray Hill New Jersey April 1992 Con Hans Hagen MPtoPDF converter http www pragma ade com 36 Index addto command alignments bounding box chart drawing 9 co ordinates pattern area predefined segment color automatic 6 conversion grayscale saturation 14 segment sides 14 commands addto 24 DefinePattern PieChart 9 PrivatePattern Segment 6 SegmentState 8 SetupColors SetupName SetupNumbers SetupPercent SetupText SetupValue currentpicture variable 24 DefinePattern command 23 format mptopdf 28 Label command 10 label 10 alignment setup linethickness pattern declaration pri
17. d in the phantom command thus only the ordinal number will be printed out Using withcolor red the label is typeset in red SetupName phantom the NOrdf phantom segment Label auto 0 name outwards 0 withcolor red endfig end the 1 segment the 2 segment the 4 segment the 371 segment 22 4 Fill Patterns 4 Fill Patterns 4 1 Defining Patterns Segments can be filled in two major modes solid color or pattern fill Both modes have two minor modes direct color and auto color Direct color means that the user specifies the color auto color lets piechartMP calculate the colors Patterns have to be defined before they can be used in the segment declaration Segment DefinePattern ID Method FillColor PatternColor Dimen ID Type numeric this parameter is the unique identifier of the pattern The best way is to number all patterns starting from 1 1 X numeric identifier Method Type numeric this parameter specifies which pattern method shall be used to draw the pattern You can choose between 10 basic methods and can define one private method see 4 2 0 private method 4 9 w w M M M N 1 10 basic methods see figure 8 5 Figure 8 Basic pattern fill methods FillColor Type color the color used to draw the pattern background It is the main color of the segment auto piechartMP calculates the color for you red blue one of the predefined
18. e 12 where the label alignment has been discussed Next a loop can be used in order to switch all segments in state invisible for i 1 upto 5 SegmentState i invisible this endfor Then the whole figure expression preceded by the command that will change the segment state to normal has to be packed in a METAPOST command called for example MyChart The command has the parameter s to specify the segment and figure number def MyChart expr s SegmentState s normal this beginfig s PieChart 4cm 0 15 60 0 0 Label auto 0 name outwards 0 Label 3 4 5 value Cinwards 0 withcolor white Label 1 2 percent inwards 0 withcolor 1 1 0 Label I1rt 4 C a red label 0 9 0 8 2cm 1cm withcolor 0 8red pickup pencircle scaled 2pt Label auto 1 a green label 0 9 0 1 2cm 1 5cm withcolor 0 8green endfig enddef The last step is again a loop which ships out five figures each with one more segment visible Since only segments and labels of visible segments will be drawn you can first create the whole pie chart and pack it in a METAPOST command Thus there is no need to bother with appropriate segment specification in the Label commands for i 1 upto 5 MyChart i endfor end 30 6 Tips for Presentations the first segment a green label the first segment a green label the second segment the first segment a green label the first segment a green label the second segment
19. gShift are defined DoIf evaluates the expression e and performs a test whether the result is true or false If the result is true the command executes the statement given in the second parameter c The DoIf is not really 32 6 Tips for Presentations necessary since a normal if fi expression can be used too but it can make the code more readable ResetSegShift sets in a loop the displacement of all segments to 0 def DoIf text e text c if e c fi enddef def ResetSegShift for j 1 upto 6 SegmentState j this 0 endfor enddef In the command MyChart the DoIf statement is used in order to decide what segment has to be displaced and to show the percent values starting with the second figure def MyChart DoIf FigCounter 3 SegmentState 1 this 0 3 DoIf FigCounter 4 SegmentState 2 this 0 3 DoIf FigCounter 5 SegmentState 3 this 0 3 DoIf FigCounter 6 SegmentState 4 this 0 3 DoIf FigCounter 7 SegmentState 5 this 0 3 DoIf FigCounter 8 SegmentState 6 this 0 3 beginfig FigCounter PieChart 4cm 0 15 60 90 O Label auto 0 name outwards 0 DoIf FigCounter gt 1 Label 0 percent 8 5 0 withcolor white endfig enddef In the final loop the eight figures are drawn In each loop step the segment displace ments are reset using ResetSegShi ft for i 1 upto 8 FigCounter i ResetSegShift MyChart endfor end 33 7 p
20. icx package it is simply includegraphics pcfirst 1 When you use pdfKTpX the file extension 1 is not known to the graphicx package DeclareGraphicsRule mps in the preamble of your BIEX document declares all unknown extension to be METAPOST graphics You should get the graphic shown in figure I If you try it yourself you will find different fonts in your chart compared to this chart since here the fonts of this document are used How you can change fonts and font attributes will be discussed in an extra section As you can see the input file loads first the piechartMP module using input There upon follows code one would call setup section Here you can modify defaults with Setup commands or define fill patterns with DefinePattern Next the segments are declared The segments are numbered according to the order of their declaration In the example four segments have been declared The following 1 Getting started first Figure 1 The first pie chart SegmentState 2 modifies the state of the 2 segment making it hidden This means that the segment will be ignored when you draw the chart or labels Between beginfig and endfig the drawing and labeling commands follow Every beginfig endfig group creates one graphic This can be used in order to create mul tiple graphics sharing the same segment data If you extend the initial example with another graphics group this will give two META POST graphics pcfirst
21. iechartMP The second way uses TEX in an external process thus you can use TeX commands inside the text label btex this is sin x etex origin 15 3 piechartMP Setup The main disadvantage is that it is impossible to expand a variable between btex etex that means strings can not be concatenated One advantage is the enhanced typesetting capabilities an other useful property is to send TeX configurations to the external process verbatimtex documentclassf article begin document etex label btex this is textbf bold text etex origin sends a KIEX header to the TEX process If you now configure METAPOST to use BIX instead of TeX you can use KI X commands In general to setup METAPOST for KI X an environment variable with name TEX must be set to latex On a system with Bash shell this would be export TEX latex Some METAPOST version or TpX systems support the definition of the TpX format in the input file verbatimtex 68 latex Ndocumentclassfarticlej begin document etex label btex this is textbf bold text etex origin This will use BIEX without the need to set the environment variable Not all systems support this but it should work on the systems teT X fpTpX MikT X Oz TpX and CMacTpx Systems not supporting this feature are emTpX DECUS T X and VT X The last mentioned VT X has no METAPOST included thus you have to take METAPOST from another system The specification of
22. iechartMP Internals France USA Great Britain others Italy Netherlands Austria France Great Britain others Italy Netherlands Austria France Great Britain others Netherlands Austria France others 7 piechartMP Internals France Great Britain others Italy Netherlands Austria France USA Great Britain others Netherlands Austria France others Netherlands Austria France Great Britain others Italy Austria This section describes some internal variables and macros which can be useful when you need some information about the chart for more advanced graphics R is anumericvariable containing the radius of the pie chart that was specified in PieChart Thus the variable is only valid after the PieChart command has been used pc_Centre is a METAPOST variable of type pair which contains the centre of the pie chart Normally this is the origin of the METAPOST co ordinate system but you can modify the value in order to place the chart somewhere It is a matter of course that you shouldn t change this value between PieChart and the label commands pc_Count is anumeric variable containing the number of defined segments For example its value can be used in own loops But even you can set this value to 0 in order to start a completely new set of segment data piechartMP defines the macro ResetSegments which does exactly this SegmentPoint s sp is a ma
23. ith PieChart Since the text mode is still 0 that means string based typesetting the percent values Label percent will be typeset in the font declared by defaultfont beginfig 1 PieChart 4cm 0 1 65 0 0 Label 0 percent inwards 0 Now the EIpX text mode becomes active You see the Setup commands can be placed anywhere and modify the behaviour starting from this moment The command SetupName declares the string to be attached to the segment name thus prior to type setting the name string for example of the first segment is the Ord 1 segment In SetupName the NOrd command from the FTpx file is used thus the name labels have to be typeset in BIX mode SetupText 3 this input timessym SetupName the Ord segment Label auto 0 name outwards 0 endfig The command Label 0 name draws the name labels for all segments The result is the following figure the 1 segment the 2 segment the 4 segment the 371 segment The second figure starts as usual Since the BIFX text mode is still active all typesetting will be done in this mode In the chart the segment values shall be printed Suppose these values are in unit million Euro the SetupValue command declares the unit to be attached to the value string Furthermore KI X font commands modify the appearance of the text in order to make them bold italic Since the Times font is used here too usepackage times in the
24. le string will be typeset For this special example you have to switch in KT X text mode see section SegmentPoint Type pair Specifies the location of the label in a segment specific system of co ordinates The x co ordinate is along the radius of the segment whereby 0 specifies the center and 1 is at the out side You can give values greater than 1 The y co ordinate is along the angle the segment is spawning in the chart O is at begin and 1 is at the end of the segment For the y co ordinate only values in range 0 upto 1 are allowed Figure illustrates the co ordinate system X Y any valid co ordinate inwards predefined equal to 0 7 0 5 outwards predefined equal to 1 1 0 5 Figure 4 The segment specific system of co ordinates Shift Type pair numeric If you give here a pair that means a specification like x y the label will not be drawn at the position specified in SegmentPoint but moreover at the position of SegmentPoint shifted by the amount of Shift Additionally a line is drawn between the SegmentPoint and the shifted SegmentPoint The line uses the definition of defaultpen thus you can change the linethickness using pickup pencircle scaled 2pt in order to set the thickness to 2 pt O this value disables the shifting and the line 0 0 this results in no shift but it draws a line of length 0 0 1cm shifts the position 1 cm down 5mm 1cm shifts the position 1 cm up and 5 mm left x y any other valid
25. ndfig end 12 3 piechartMP Setup the first segment a green label the second segment the fifth segment the third segment the fourth segment a segment with 15 3 piechartMP Setup This section introduces the setup commands of the piechartMP module All setup commands configure more than one property Since you should not be forced to know the current value all setup commands support the value this which can be given for properties that shall be unmodified 3 1 Numbers SetupNumbers precision delimiter precision Type numeric this parameter allows to set the precision of calculated percent values 1 value is not rounded 0 3 rounds at given precision O is default this current value delimiter Type string the representation of numbers is different between languages here you can give your decimal delimiter default german users might like this 7 any other string of length 1 this current value Normally all setup commands can be placed at any position in the input file and modify the behaviour of the following commands In contrast the specification of the decimal delimiter has to be set before you declare segments using the Segment command 13 3 piechartMP Setup side color fill color maxV 0 4 reduce 0 saturation value maxS 0 6 1 factor 0 4 Figure 6 Shading process of side colors 3 2 Colors SetupColors auto SV shading SV grayscale aut
26. nt 8 5 second auto 8500 Segment 101 111 third auto 101111 Segment 20 222 fourth auto approx 20000 SegmentState 2 invisible this SegmentState 4 this 0 3 beginfig 1 PieChart 4cm 0 15 60 0 0 Label auto 0 value outwards 0 endfig end 2 Basic Commands 52234 approx 20000 2 2 Drawing Chart and Labels The commands which create real output are only two The first mentioned PieChart has to be the first drawing command in a beginfig endfig group since it performs some important setup and calculations for the following label commands 2 2 1 Drawing the Pie Chart PieChart Radius Height Observation Rotation Offset Radius Type numeric That parameter specifies the radius of the pie chart 2cm draws a pie chart with radius 2 cm X any other valid METAPOST numeric expression Height Type numeric The height or thickness of the pie chart can be specified with this parameter In contrast to Radius the parameter Height does not specify the height directly but moreover the height is the result of the multiplication of Radius and Height Observation Type numeric The observation angle in degrees can be specified using this parameter 0 minimum value since the observation on the pie chart is from above this results in a simple 2D chart 1 89 draws the pie chart in 3D parallel projection 89 is maxi mum value Rotation Type numeric The angle of rotation aro
27. o SV Type pair if you set the fill style of segments you can say auto This will calculate a fill color for the segment using the HSV color model The Hue H is taken from the position of the segment in the chart the values of saturation S and value V you can set here 1 1 the default S V any other combination of saturation and value S and V are between 0 and 1 this current value shading SV Type pair when piechartMP draws the side areas of segments in 3D mode it calculates the colors in a 2 step process Depending on the observation angle at a side a factor is calculated In the first step the saturation of the fill color is reduced depending on the factor but only upto a maximum value In the second step the resulting color is darkened depending also on the factor but again only upto an maximum value These both maximum values you can set here A value of 0 means in both cases no change of the color that is useless A saturation maximum of 1 allows colors become gray A value maximum of 1 allows colors become black Figure 6 illustrates the color conversion 0 4 0 3 the default maxS maxV any other combination of maximum reduction values maxS and maxV are between 0 and 1 this current value grayscale Type boolean all colors calculated and used for segment fills can be switched in grayscale mode This may help to see if the contrast for grayscale printing is suf ficient false no grayscale colors default
28. percent value empty string default 22222 any string this the current value For example you can use this in order to append a percent unit to the percent value In text mode 0 the setup is SetupPercent this But take care of text modes In text modes using TgX this setup uses the comment symbol In case of a TeX based text mode the setup has to be SetupPercent this or if want the percent value to be typeset bold italic in ATgX mode SetupPercent textbf itshape SetupValue PreString PostString PreString Type string a string attached before the string of the segment value empty string default 22222 any string this the current value PostString Type string a string attached after the string of the segment value empty string default 22222 any string this the current value An example could be that the unit of the segment values is million Euro and you want the currency symbol from the BIX marvosym package Ztake care that the package is loaded via TeXSettings of the SetupText command 19 3 piechartMP Setup SetupValue this million EUR SetupName PreString PostString PreString Type string a string attached before the string of the segment name empty string default 22222 any string this the current value PostString Type string a string attached after the string of the segment name empty string default 22222 any string this the cu
29. pieda Jens Uwe Morawski piechartMP Drawing pie charts with MetaPost Jens Uwe Morawski The piechartMP package is an easy way to draw pie charts with META POST The package implements an interface that enables even users with few METAPOST experience to draw their charts A highlight of piechartMP is that the user can hide defined segments from drawing or making them invisible in order to draw multiple different pie charts from one data set For example a presentation can be made whereby every slide has one more segment visible The special support for pre sentations was the chief purpose for the piechartMP development Contents Contents 1 Getting started 2 Basic Commands 2 1 Segment Declaration 2 1 1 Basic Segment Declaration 2 1 2 Segment States 2 2 Drawing Chart and Labels 2 2 1 Drawing the Pie Chart 2 2 2 Drawing the Labels 3 piechartMP Setup 3 1 Numbers 0 00000 3 2 Colors es sea ada w wy wad ww o k A 33 VOR ee g ee Ge gal woz hdr oo WAREZ 3 3 1 Metapost Typesetting 3 3 2 Extended Typesetting Capabilitie 3 3 3 piechartMP Text Setup 3 4 1 Label Setup 3 4 2 Label and Text Setup Examples 4 Fill Patterns 4 1 Defining Patterns 4 2 Defining a Private Pattern Method 5 Special Features 5 1 BoundingBox for Presentations 5 2 Enhanced Graphics with MetaFun 6 Tips for Presentations 6 1 Presentations with
30. re lt jobname gt is the name of your input file without extension In case of the file name used in the introduction the external file will have the name pcfirst pct TeXFormat Type string the TeX format string to be written on top in the external verbatimtex block 17 3 piechartMP Setup empty string default amp latex some systems support this 22222 any other string depending on your system this the current value TeXSettings Type string a string including T X commands which will be written after the TEX format in the external file empty string default 222 any string including TeX and KI Xpreamble commands this the current value If you set the text mode to O the string based typesetting is active That means you cannot use TeX commands in the strings You have only the posibility to change the font and its size using the METAPOST variables defaultfont and defaultscale Text mode 1 is the most general setting Here you have the full control and you can do anything required for your system Text mode 2 gives you control over the TeX format as mode 1 but it saves you from the BIEX specification since it loads a minimal BIEX setup This does not mean that the parameter TeXSettings is useless since the content of this parameter is written between documentclass and begin document Suppose the setup SetupText 2 amp latex usepackage latin1 inputenc The verbatimtex block written based on these se
31. rrent value 3 4 2 Label and Text Setup Examples In both examples a TEX or more concrete KI X input file will be used This file has the following contents its name is for example timessym tex The purpose of the Ord macro is to typeset correct ordinal numbers usepackage times usepackage marvosym newcommand Ord 1 ifcase 1 relax 1 textsuperscript th or 1 textsuperscript st or 1 textsuperscript nd or 1 textsuperscript rd else 1 textsuperscript th fi A Basic Chart As usual in the METAPOST input file first the piechartMP module is loaded The font for text in text mode 0 is set by assigning the name of the Times BoldItalic metric file to the METAPOST variable defaultfont Next the precision of the percent values is set to 1 and the decimal delimiter to which is more useful for german people The fourth statement appends the symbol on the percent value since the unit should be displayed too As you will see the percent values will be typeset in text mode 0 thus a real symbol is used and not the TX command N input piechartmp defaultfont ptmbi8r SetupNumbers 1 SetupPercent this 20 3 piechartMP Setup Next four segments are declared The segment names are not specified thus they de fault to the segment number Segment 32 5 Segment 12 8 Segment 22 4 Segment 18 2 Starting the first figure the first task is always to draw the pie chart w
32. rt a more realistic look Most recent TX distributions include pdfI X and ConTpXt ConTpXt includes a META POST package called MetaFun That package enables METAPOST besides many other in teresting features to draw gradients The package should work out of the box thus no ConTEXt setup is required but the gradient feature only works with pdfTpx MetaFun writes some special statements in the METAPOST output This requires an ex tension to interpret those specials The extension is loaded in the ConTpxXt macro package automatically thus ConTpXt users can embed the figure directly The KI X graphics package does not load that extension Thus BIEX users have to go a different way ConTpxt includes a pdfT X format called mptopdf It can be downloaded from the ConTgxt homepage as aindependent package called MPtoPDF That format can be used stand alone in order to convert your METAPOST output to PDF This is even the best way to preview your METAPOST figures Since that pdfT X format loads the graphics extension resulting PDF graphics have the segment s outside drawn as gradients Next KIEX users can include that PDF directly using pdfKT X or convert the PDF back to EPS for the KT X dvips way piechartMP automatically detects MetaFun when the package is loaded prior piechartMP See figure 11 to compare both ways of drawing segment outsides input metafun input piechartmp 3The current version 1 0 of the PDF Reader XPDF lacks support
33. t METAPOST has limited numeric capabilities that means that METAPOST can handle only numbers upto about 32600 This is the reason why the sum of all Values must not exceed this maximum value Since only the relation of the Values is important in order to calculate the size of a segment the absolut values can be divided by 10 100 1000 to keep the sum below the maximum But in some cases this might not be useful since it leads to wrong displayed values in the label command Then you have the possibility to give one value in the parameter Value which is used to calculate the segment size and specify the display value as string in the AltValue parameter of the Segment command Segment 30 255 large value auto 30225000 Name Type string the name of the segment can be specified here It is employed in the name label command The command SetupName see section 3 4 can be used in order to extend this text string an empty string 222 any string describing the name It can include TeX com mands when labelling commands are used in TpX text mode see section 3 3 3 FillStyle Type numeric color the fill style of the segment is specified with this param eter It can either be a numeric value if a pattern fill shall be used a color for a solid color fill or the value auto which lets piechartMP calculate the segment color 2 Basic Commands Figure 3 Automatic color specification 1 X the numeric ID of an alread
34. the second segment the third segment the third segment the fourth segment a red label the first segment a green label the second segment the fifth segment the third segment the fourth segment a red label The figures are scaled by factor 0 5 6 2 Presentations in different order The example of the previous section has a disadvantage since the segments have to be presented in the order of their declaration But what is about the order 1 3 5 2 4 The first part is already known from the previous example Thus this example starts after the first loop The order of the METAPOST figures has always to be 1 2 3 thus an additional counter for the figures is needed That counter FigCounter is set to 0 and used as figure number in the METAPOST command MyChart FigCounter 0 def MyChart expr s SegmentState s normal this beginfig FigCounter PieChart 4cm 0 15 60 0 0 Label auto 0 name outwards 0 Label 3 4 5 value Cinwards 0 withcolor white Label 1 2 percent inwards 0 withcolor 1 1 0 Label lrt 4 C a red label 0 9 0 8 2cm 1cm withcolor 0 8red pickup pencircle scaled 2pt Label auto 1 a green label C 0 9 0 1 2cm 1 5cm withcolor 0 8green endfig enddef In the final loop the Fi gCounter is incremented with each loop step The loop parameter i is only used for the segments in order to change their state for i 1 3 5 2 4 FigCounter FigCounter
35. ttings will be verbatimtex 8 latex documentclass minimal usepackage latin1 inputenc begin document etex If you need more packages or in general a long setup it makes no sence to give all in the parameter TeXSettings It is easier to write everything in an extra TpX file and input them If you need for example Latin 1 input encoding the labels shall be written in Times and you need some symbols from Martin Vogel s symbol font you can write this TE file named pcset tex usepackage latin1 inputenc usepackage times usepackage marvosym and use the following piechartMP text setup SetupText 2 amp latex input pcset The following descriptions of the label setup commands correspond to the text setup therefore examples can be found in section 3 4 Labels 18 3 piechartMP Setup 3 4 1 Label Setup The piechartmP module knows three label types segment names segment values and percent values Segment names and values are declared using Segment and the percent value is calculated by piechartMP The purpose of the label setup commands is to specify strings that will be attached before and after the data string prior to the whole string will be typeset SetupPercent PreString PostString PreString Type string a string attached before the string of the percent value empty string default 22222 any string this the current value PostString Type string a string attached after the string of the
36. und the center of the pie chart 0 359 any numeric value in that range Offset Type numeric The third parameter of the command SegmentState specifies the radial displacement for a single segment Using Offset in the PieChart command an offset is applied for all segments 0 no displacement 1 full radial displacement X any other displacement factor 2 Basic Commands PieChart 2cm 0 0 0 0 PieChart 3cm 0 4 70 0 0 PieChart 3cm 0 1 30 120 0 PieChart 2cm 0 3 60 220 0 2 2 2 2 Drawing the Labels Label Segments Data SegmentPoint Shift Segments Type suffix That parameter specifies for which segments a label should be created It can either be a comma seperated list of segment numbers or the value 0 for all visible segments 2 asingle segment 1 2 5 7 alist of segments 0 all visible segments Data Type string predefined Using that parameter you can specify what data the label should contain value uses the segment values percent uses the calculated percent values name uses the segment names a label typesets the string a label any other text string You can use a comma seperated list of above values The data will then be concate nated to one label string For example Label 0 C name Ntextbff percent outwards 0 10 2 Basic Commands will result for a segment with name first and a percent value of 22 5 to the string first textbf 22 5 before the who
37. vate method PieChart command 9 PiechartBBox variable 26 PrivatePattern command 24 Segment command 6 segment color 6 declaration 6 states SegmentState command 8 setup color name numbers percent text valet SetupColors command SetupName command SetupNumbers command SetupPercent command SetupText command SetupValue command variables currentpicture pencircle 11 PiechartBBox piechartMP drawing 2D 3D pie charts with METAPOST Jens Uwe Morawski morawski gmx net May 14 2002
38. y defined pattern see 4 1 red blue one of the default METAPOST colors R G B acolor specification in the Red Green Blue color space auto depending on the position of the segment in the chart piechartMP calculates the color see figure The ap pearance can be modified with SetupColors see section AltValue Type string an alternate Value that is used when the segment value is dis played in label commands Compared to other piechartMP commands the Segment command has not a fixed number of parameters At least the Value has to be specified All other parameters can be omitted if the parameter is the most right in the parameter order An omitted AltValue parameter is substituted by the Value converted in a text string An ommited FillStyle is substituted by auto and if the Name is ommited too then the segment name is a string including the segment number If one of the following declarations is the third Segment command then all declarations are equivalent Segment 32 5 3 auto 32 5 Segment 32 5 3 auto Segment 32 5 3 Segment 32 5 But even it means that when the parameter AltValue has to be specified then the pa rameters Name and FillStyle cannot be omitted or if you want specify the FillStyle then the Name has to be given too 2 1 2 Segment States Chart segments can have three different states The main purpose is to support different appearances of one set of segment data in one input file This can
Download Pdf Manuals
Related Search
piechartmp. piechart.js pie chart maker pie chart pizza pie chart press pie chart.com pie chart.ai
Related Contents
INSTALACIÓN Y RETENSIONADO 30W KIT - user manual v5 as of 19 May 2014 Samsung YP-P2AB Manual de Usuario END-USER SOFTWARE LICENSE AGREEMENT FOR STEPHEN 取 扱 説 明 書 PASCO Capstone シングルユーザー QUICK START GUIDE - 5 Star Car Alarms Plantilla deseño técnico - Servizo Público de Emprego de Galicia simple solutions to everyday complexities Hikvision 9600 series NVR User Manual Samsung Galaxy 3 manual do usuário(Claro) Copyright © All rights reserved.
Failed to retrieve file