Data visualization with SAS programming

legend: change font within one value?

Accepted Solution Solved
Reply
Regular Contributor
Regular Contributor
Posts: 156
Accepted Solution

legend: change font within one value?

Dear all,

I have a subgrouped vbar proc gchart with a legend:

legend1 label=none value=(font="wingdings" h=1.3 'LL' 'L' 'K' 'J' 'JJ');

which results into:

smiley.gif

Now I'd like to and some "normal" Text behind each smiley like

:-(( very unhappy

:-( unhappy

:-| indifferent

:-) happy

:-)) very happy

I'd have to change fonts then in the legend statement. But when I do this e.g. the string "very unhappy" is treated as the value for the next shape:

legend1 label=none value=(font="wingdings" 'LL' font="arial" "very unhappy"  ....... )

Does anybody know how I can combine the smileys and the text?

Best regards

Eva


Accepted Solutions
Solution
‎01-04-2013 09:05 AM
SAS Employee
Posts: 963

Re: legend: change font within one value?

Hmm...  Upon further experimentation, I need to correct my previous reply...

It *is* possible to change the font (between wingdings and normal text) in the middle of legend text values!  I just now tried it, and it works.  (Note this works in device=png, but does not seem to be supported with device=activex -- I mention this because you mentioned in other threads that you were using activex).

Here's a short (nonsense) example just to demonstrate:

goptions htext=4pct;

legend1 position=(top left inside) mode=share across=1 label=none

value=(

   t=1 f="wingdings" '4a'x f="albany amt" ' Happy'

   t=2 f="wingdings" '4c'x f="albany amt" ' Unhappy'

   );

proc gplot data=sashelp.class;

plot height*weight=sex / legend=legend1;

run;

smiley.png

View solution in original post


All Replies
Grand Advisor
Posts: 9,713

Re: legend: change font within one value?

Have you tried additional parantheses to keep one "value" together. Untested:

value = (  (font="wingdings" h=1.3 'LL' font="arial" 'very unhappy')

               (font="wingdings" 'L'  font="arial" 'unhappy')

/* continue the pattern*/

           );

Regular Contributor
Regular Contributor
Posts: 156

Re: legend: change font within one value?

Hello ballardw,

the additional brackets don't work :-(

The smilies are left out and the text is printed only.

Hello Mohammad,

thanx for the white papers. They are very useful for legends. A solution for the mentioned problem though is not in them.

Hello Anca,

maybe something like that. The tooltip when you move your mouse over the bars shows the text as well. I guess the users have to live with that.

Contributor
Posts: 62

Re: legend: change font within one value?

These articles may be useful:

Super Contributor
Posts: 543

Re: legend: change font within one value?

I believe that instead if using the legend, you may want to use a footnote statement that will allow you to change fonts.

I don't think I was able to find the answer when I had similar problem.

:smileyconfused: Confused.

SAS Employee
Posts: 963

Re: legend: change font within one value?

Using an official gplot legend, I don't know of a way to switch the font 1/2-way through the text.

One work-around is to either show the plain text in the legend, and annotate the wingding faces beside them ... or show the wingding faces in the legend and annotate the text.  Using this technique, you'll have to determine the x/y for the annotated stuff by trial-and-error, and then hard-code the values - and if any later changes cause the legend to move, then you'll have to manually update the annotate x/y positions (you can usually avoid that problem by annotating using the data's coordinate system, but since this is positioning based on the legend rather than the data, we can't do that).

Anca's suggestion to use the footnote (or a title2) would also be a decent work-around, assuming you're ok with a legend at the bottom (or top, using title2) of the page, arranged horizontally.

Regular Contributor
Regular Contributor
Posts: 156

Re: legend: change font within one value?

I talked with my customer and we'll probably have some info box. As we have a complete web application which contains the SAS graphs we have enough room on the left to have an <i> Button. The customers says that in the long run the emoticons are better than text and new users have to click on that info buttons then. I think that's a good solution. Emoticons speak a language of their own.

And as you said - positioning the legend is difficult because the user can switch beetween parameters and then the legend's position on the web page might be somewhere else or the size of the graph.

Solution
‎01-04-2013 09:05 AM
SAS Employee
Posts: 963

Re: legend: change font within one value?

Hmm...  Upon further experimentation, I need to correct my previous reply...

It *is* possible to change the font (between wingdings and normal text) in the middle of legend text values!  I just now tried it, and it works.  (Note this works in device=png, but does not seem to be supported with device=activex -- I mention this because you mentioned in other threads that you were using activex).

Here's a short (nonsense) example just to demonstrate:

goptions htext=4pct;

legend1 position=(top left inside) mode=share across=1 label=none

value=(

   t=1 f="wingdings" '4a'x f="albany amt" ' Happy'

   t=2 f="wingdings" '4c'x f="albany amt" ' Unhappy'

   );

proc gplot data=sashelp.class;

plot height*weight=sex / legend=legend1;

run;

smiley.png

Regular Contributor
Regular Contributor
Posts: 156

Re: legend: change font within one value?

Yes, I want to switch to png anyway because there are now several features which I need and activex does not support. I still have that insufficient authorization problem but there's a collegue who solved this problem before on our platform. So I hope I can do that too.

I didn't know that legend values support tick marks :-)
Thanx for your example!

Post a Question
Discussion Stats
  • 8 replies
  • 373 views
  • 6 likes
  • 5 in conversation