Data visualization with SAS programming

drill down in graph by click on value of x axis possible?

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

drill down in graph by click on value of x axis possible?

Dear all,

I have a simple subgrouped vbar chart with proc gchart. I's like to do a drill down when the user clicks on one value of the x axis (not a click an one bar). Is that possible?

I tried to change the values of the x axis by putting an html link around it like this:

data work.for_graph;

     set work.mydata;

     xaxis_value = cats("<a href='http://www.sas.de'>",myValue,"</a>");

run;

But SAS then prints the whole string from above as value under the x axis. A click has no effect.

Best regards

Eva


Accepted Solutions
Solution
‎01-03-2013 08:26 AM
SAS Employee
Posts: 967

Re: drill down in graph by click on value of x axis possible?

There's no built-in feature in gchart to do this, but you can suppress the default bar midpoint text labels, and then annotate them, and have html drilldown for the annotated text.  Here's an example:

%let name=anno_xaxis;

filename odsout '.';

/*

Suppress the usual midpoint axis text values,

and then annotate your own with html drilldown.

*/

data mydata;

format population comma12.0;

input st $ 1-2 population;

year=2000;

datalines;

VA  7078515

NC  8049313

SC  4012012

GA  8186453

FL 15982378

;

run;

data myanno; set mydata;

length html $500 text $20;

xsys='2'; ysys='1';

function='label';

style='albany amt';

position='5';

midpoint=st;

y=-3;

when='a';

text=trim(left(st));

html='title='||quote(

'State: '|| trim(left(st)) ||'0D'x||

'Population: '|| trim(left(put(population,comma12.0)))

)||

' href="http://www.state.'||trim(left(lowcase(st)))||'.us"';

run;

GOPTIONS DEVICE=gif;

ODS LISTING CLOSE;

ODS HTML path=odsout body="&name..htm"

(title="GCHART w/ GIF ODS HTML Drilldown")

style=sasweb;

goptions noborder gunit=pct htitle=6 htext=3.5;

axis1 label=none value=(color=white);

axis2 label=none order=(0 to 20000000 by 5000000) minor=none offset=(0,0);

pattern v=solid color=cx43a2ca; 

title1 "Year 2000 U.S. Census Population";

title2 color=gray "GCHART w/ GIF ODS HTML Drilldown";

footnote color=gray "(text annotated as bar labels has drilldown)";

proc gchart data=mydata anno=myanno;

vbar st / discrete

type=sum sumvar=population

ascending

width=8

maxis=axis1

raxis=axis2

autoref cref=gray

clipref

coutline=black

des='' name="&name" ; 

run;

quit;

ODS HTML CLOSE;

ODS LISTING;

View solution in original post


All Replies
Solution
‎01-03-2013 08:26 AM
SAS Employee
Posts: 967

Re: drill down in graph by click on value of x axis possible?

There's no built-in feature in gchart to do this, but you can suppress the default bar midpoint text labels, and then annotate them, and have html drilldown for the annotated text.  Here's an example:

%let name=anno_xaxis;

filename odsout '.';

/*

Suppress the usual midpoint axis text values,

and then annotate your own with html drilldown.

*/

data mydata;

format population comma12.0;

input st $ 1-2 population;

year=2000;

datalines;

VA  7078515

NC  8049313

SC  4012012

GA  8186453

FL 15982378

;

run;

data myanno; set mydata;

length html $500 text $20;

xsys='2'; ysys='1';

function='label';

style='albany amt';

position='5';

midpoint=st;

y=-3;

when='a';

text=trim(left(st));

html='title='||quote(

'State: '|| trim(left(st)) ||'0D'x||

'Population: '|| trim(left(put(population,comma12.0)))

)||

' href="http://www.state.'||trim(left(lowcase(st)))||'.us"';

run;

GOPTIONS DEVICE=gif;

ODS LISTING CLOSE;

ODS HTML path=odsout body="&name..htm"

(title="GCHART w/ GIF ODS HTML Drilldown")

style=sasweb;

goptions noborder gunit=pct htitle=6 htext=3.5;

axis1 label=none value=(color=white);

axis2 label=none order=(0 to 20000000 by 5000000) minor=none offset=(0,0);

pattern v=solid color=cx43a2ca; 

title1 "Year 2000 U.S. Census Population";

title2 color=gray "GCHART w/ GIF ODS HTML Drilldown";

footnote color=gray "(text annotated as bar labels has drilldown)";

proc gchart data=mydata anno=myanno;

vbar st / discrete

type=sum sumvar=population

ascending

width=8

maxis=axis1

raxis=axis2

autoref cref=gray

clipref

coutline=black

des='' name="&name" ; 

run;

quit;

ODS HTML CLOSE;

ODS LISTING;

Regular Contributor
Regular Contributor
Posts: 156

Re: drill down in graph by click on value of x axis possible?

I don't know annotate yet. But it seems worth learning.What you gave me as an example is exactly what I need. I guess I can use the html= option as addition to the above example? Because my customer wants to be able to click on the bar and the xaxis value (and also in a subgrouped bar chart by the way where clicking on a subgroup versus clicking on the value of the x axis makes sense in that I give a different target site depending on whether the user clicks on the subgroup or the xaxis value).

SAS Employee
Posts: 967

Re: drill down in graph by click on value of x axis possible?

Yep - exactly!  You can use both at the same time ... gchart's html= option to control the drilldown for the bar segments, and the html variable in the annotate data set to control the annotated bar midpoint labels (for your drilldown for the whole bar).

Regular Contributor
Regular Contributor
Posts: 156

Re: drill down in graph by click on value of x axis possible?

Great! Many thanx for your help.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 339 views
  • 3 likes
  • 2 in conversation