postscript piechart

V

vijay

Hello
i'm new to postscript lang and have a code of piechart which is in grey
color. i wanted to make pie chart in color. Here i'm attaching code wat
i written for grey piechart. plz find me solution for this.
Regards

/pidict 10 dict def
pidict begin
/DrawSlice
{ /shade exch def
/end exch def
/start exch def
/label exch def
newpath 0 0 moveto
0 0 radius start end arc
closepath

gsave
shade setgray
fill
grestore
stroke

gsave
start end add 2 div rotate
radius 0 translate
%newpath
%0 0 moveto labelps .8 mul 0 lineto stroke
%labelps 0 translate
0 0 transform
grestore

itransform
/y exch def /x exch def
x y moveto
%x 0 lt
{ label stringwidth pop neg 0 rmoveto }
%if
%y 0 lt { 0 labelps neg rmoveto }
label show
} def

/findgray
{ /i exch def /n exch def
i 2 mod 0 eq
{ i 2 div n 2 div round add n div }
{ i 1 add 2 div n div }
ifelse
} def
%end

/drw-pi
{ pidict begin
/radius exch def
/ycenter exch def /xcenter exch def
/PieArray exch def
/labelps exch def
/title exch def
%gsave
xcenter ycenter translate

%/Helvetica findfont titleps scalefont setfont

%title stringwidth pop 2 div neg radius neg
%titleps 3 mul sub moveto
%title show
/Helvetica findfont labelps scalefont setfont
/nums PieArray length def
/slicecnt 0 def
/curangle 0 def
PieArray

{ /ary exch def
ary aload pop
/per exch def
/label exch def
/perangle per 360 mul def
/slicecnt slicecnt 1 add def
label curangle curangle perangle add
nums slicecnt findgray DrawSlice
/curangle curangle perangle add def
} forall
grestore
end
} def

(pie-chart) 10 12
[
[(AAA) .12 ]
[(BBB) .10 ]
[(CCC) .22 ]
[(DDD) .16 ]
[(EEE) .04 ]
[(FFF) .08 ]
[(GGG) .10 ]
[(HHH) .18 ]
] 306 396 140 drw-pi
showpage
 
M

macropod

Hi vijay,

Try asking in comp.lang.postscript. You're much more likely to get help
there than in an Excel forum.

As it is, your code looks like its little more than a slightly touched-up
copy & paste from Program 14 in the Postscript 'Tutorial and Cookbook'.

Hint: lookup setgray, setrgbcolor, sethsbcolor, setcmykcolor, setcolor, and
setpattern in the PostScript 'Language Reference' manual.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top