I have a bar chart using gchart within a stored process displayed within a portlet in SAS Information Delivery Portal 9.4, using this code (within a larger stored process):
goptions reset=all;
ods graphics on / imagemap=on height=3in width=3in border=off;
axis1 label=none;
axis2 label=none;
legend1 label=none;
title height=10pt 'FACR Generated and Recovered - Fiscal YTD' ;
proc gchart data=FACR_TotalYTD_Display;
vbar FiscalYear / noframe sumvar=FACRSum discrete subgroup=FACRType nostats maxis=axis1 raxis=axis2 legend=legend1 ;
format FACRSum DOLLAR14.2;
run;
quit;
Adding "ods graphics on / imagemap=on height=3in width=3in border=off;" does resize the bar chart, but the graph seems distorted and if I change the values for height and width it doesn't affect the size of the displayed chart. And when I add that line, the hover tip disappears. I've tried to add the hover tip back in with this code:
ROLENAME=(Year=FiscalYear) TIP=(Year Y ) tiplabel=(Year="Fiscal Year" Y="FACR YTD")
within the proc gchart, but it doesn't work. I want to customize the displayed text for the hover text on the chart.
I looks like you are mixing GTL (graph template language) syntax into your GCHART syntax. Also, the ODS GRAPHICS statement applies only to GTL and SG procedure output.
To change the size of GCHART output, you should use the XPIXELS and YPIXELS (or HSIZE and VSIZE) options on the GOPTIONS statement. To do imagemaps in SAS/Graph, you have to create a column in your data that contains the correct HTML syntax for the imagemap. Then, refer to that variable using the HTML option on the VBAR statement.
As Reeza said, you might want to consider creating this chart using SGPLOT, as it will be a lot easier to create the imagemap. The equivalent SGPLOT code to your example would look something like the following:
ods graphics on / imagemap=on height=3in width=3in border=off;
title height=10pt 'FACR Generated and Recovered - Fiscal YTD' ;
proc sgplot data=FACR_TotalYTD_Display noborder;
xaxis display=(nolabel);
yaxis display=(nolabel);
vbar FiscalYear / response=FACRSum group=FACRType;
format FACRSum DOLLAR14.2;
run;
Do you have the option to switch to SG Procedures?
Also, what image type are you using? Have you made sure it's SVG?
I looks like you are mixing GTL (graph template language) syntax into your GCHART syntax. Also, the ODS GRAPHICS statement applies only to GTL and SG procedure output.
To change the size of GCHART output, you should use the XPIXELS and YPIXELS (or HSIZE and VSIZE) options on the GOPTIONS statement. To do imagemaps in SAS/Graph, you have to create a column in your data that contains the correct HTML syntax for the imagemap. Then, refer to that variable using the HTML option on the VBAR statement.
As Reeza said, you might want to consider creating this chart using SGPLOT, as it will be a lot easier to create the imagemap. The equivalent SGPLOT code to your example would look something like the following:
ods graphics on / imagemap=on height=3in width=3in border=off;
title height=10pt 'FACR Generated and Recovered - Fiscal YTD' ;
proc sgplot data=FACR_TotalYTD_Display noborder;
xaxis display=(nolabel);
yaxis display=(nolabel);
vbar FiscalYear / response=FACRSum group=FACRType;
format FACRSum DOLLAR14.2;
run;
Thank you, this worked perfectly.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.