From: "Lane, Jim" on
Hi, Richard

The labeling part of this works like a charm. Thanks. I'll have a go at
figuring out the rest of it for my self.

/JL

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of
Richard DeVenezia
Sent: 2009, September, 22 11:20 AM
To: SAS-L(a)LISTSERV.UGA.EDU
Subject: Re: Reference line on PROC GCHART output

Hi Jim:

The annotation code I posted used a trick.

The gray area is really two filled rectangles.
A filled rectangle is drawn using the BAR function.
The Bar function draws a rectangle using the x,y from the previous row
in the annotate data, to the x,y in the current row (having
function='BAR')

The first x,y of the first rectangle is
0,0 in coordinate system '1','1'
Coordinate system '1' means % of graphics output area (the area inside
the frame where the bars are drawn) 0,0 of course means the lower left
of that area.

The second x,y of the first rectangle is
'01oct2005'd, 100 in coordinate systems '2','1'
Coordinate system '2' means data coordinates So x='01oct2005'd will set
the right edge of the rectangle at where-ever that midpoint is plotted
by the system, and y=100 will set the top edge of the rectangle at 100%
of graphics output area (which is the top of the frame)

The second gray rectangle is the trick and is used to expand the grayish
background past the midpoint of the '01oct2005'd bar to its right edge.
How is the trick done ? Look at the anno data, the third row output has
xsys = '7'; x=0.8; y = 0;

Function will remain BAR from the prior assignment, so a bar will be
drawn from the upper right (UR) corner of the first bar (because UR was
the second row) to the next corner at
current x + 0.8% of frame width - Huh? What ?
- coordinate system xsys='7' means _relative_ % of graphics output
area. x=0.8, so x change is relative to current x (from prior row which
is pixel position associated with midpoint)
y=0 (ysys coordinate system still '1') 0% of graphics output area
(which is the bottom of the frame)

So, the meat of the trick is changing coordinate systems mid-stride to
tweak the visual.
You would not be able to do this with the %BAR macro function that is
part of the annotate facility.

Thus, when you change the pattern to something other than solid, it will
be patterned into _two_ rectangles, and look ugly

Is there a fix ? Yes.
Use two annotate rows to position the first corner, and then a single
bar to 0,0.
The idea would be
MOVE to 100,my midpoint
MOVE to 100,0.8% relative
BAR to 0,0

Since you are drawing only one bar, there will be only one pattern and
less ugliness.

Try and code it up, and let me know if you get a better looking chart.

As for labelling with annotate, use the MOVE function to set a position
and TEXT to render it. The %LABEL macro simplifies this...
you can add this code to the step that creates your annotate data.

---
length text $40;

xsys='1';ysys='1';
%label(1,98,"Actual",black,0,0,2,Comic Sans MS,>);

xsys='1';ysys='1';
%label(95,98,"Forecast",black,0,0,2,Comic Sans MS,<);
--

Take note of the last parameter (> and <). This parameter is for the
POSITION feature that specifies how text is drawn relative to the
current x,y. The docs have a good picture explaining it all.

--
Richard A. DeVenezia
http://www.devenezia.com
Independent Consultant

On Tue, Sep 22, 2009 at 9:48 AM, Lane, Jim <jim.lane(a)rbc.com> wrote:
> You say X must correspond to the bar midpoints. I wonder if that
> explains something odd I've noticed working with your code. As
> written, if I set X to a midpoint value ('01jul2009'd for example) I
> get gray shading starting at the rightmost edge of the July 2009 bar
> and covering the otherwise white background of everything to the left
of that.
> However if I change style='solid' to something like style='L3' I get
> the same area shaded with cross-hatch bars but with a gray line
> running up the centre of the July 2009 bar. That looks ugly. What
> would cause that do you think?
>
> As for low quality audiences, I think I should learn enough annotate
> to label the shaded and unshaded areas with text like 'Actual' and
> 'Forecast' which would explain it for them.
>
> Thanks for your help.
>
> /JL
>
> -----Original Message-----
> From: Richard DeVenezia [mailto:rdevenezia(a)gmail.com]
> Sent: 2009, September, 22 9:34 AM
> To: Lane, Jim
> Subject: Re: Re: Reference line on PROC GCHART output
>
> On Tue, Sep 22, 2009 at 7:20 AM, Lane, Jim <jim.lane(a)rbc.com> wrote:
>> Richard: thanks for this. When I ran your code on my system I get a
>> graph where the otherwise white background behind the bars is gray
>> for
>
>> all the bars up to and including Oct 2005. Is that what you expected
>> it to do?
>
> That is the correct visual. I figured the different background would
> better pronounce the different time periods. It all depends on the
> audience though.
> The tricky part is the the annotate 'X' values, must correspond to the

> quarter midpoints.
>
>> I think this will give me what I'm after if I just change the hard
>> coded month value for x as required.
>
> Correct. The color can also be adjusted, look for CXrrggbb You could
> macroize the code to make it more reusable.
> If you have parameter for the 'transition date', you could use INTNX
> to ensure the parameter is tweaked to be year quarter-value, and thus
> match a midpoint.
>
>> BTW you wouldn't happen to know where this annotate facility is
>> documented for beginners such as myself? All the examples I've ever
>> seen dive right into it assuming a lot of background I don't have.
>
> Did you try the online help (F1) ?
> In Contents, drill to SAS Products/SAS Graph/Examples/Annotate
>
> You can also search the SAS-L archives at
> http://www.listserv.uga.edu/archives/sas-l.html
> or conference papers at
> http://www.lexjansen.com/sugi/
_______________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Ce courrier �lectronique est confidentiel et prot�g�. L'exp�diteur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) d�sign�(s) est interdite.
Si vous recevez ce courrier �lectronique par erreur, veuillez m'en aviser imm�diatement, par retour de courrier �lectronique ou par un autre moyen.