Programatically Modify X Axis Increment and Chart Width and HeightI've been looking through the script guide, but I can't find what I'm looking for. I create charts iterating a group by query. By default, all of the charts are the same width and have the same increment for the axis. I'd like to be able to change the width of the chart and the increment of the X Axis based on the number of values in the X Axis. How can I do this? Here is a code snippet:
planetP = Control Chart(invisible,
Sample Label( :ReleaseMonth ),
Phase( :Phase ),
Sample Size( :Name( "Sum-Total" ) ),
KSigma( 3 ),
Chart Col( :OnTimePct, P( Phase Level( "1" ), Phase Level( "2" ) ) ),
By( :Planet )
);
Re: Programatically Modify X Axis Increment and Chart Width and HeightIf I want to customize a graph I "tune" it in until it looks like I want it to, with a desired width, height, scaling etc. Then I right click the little red triangle and select Copy Script. The script shows you what commands are necessary to script the graph. Might be a little easier than digging through the tree structure.
Re: Programatically Modify X Axis Increment and Chart Width and Height
@Mark_Bailey wrote:
.......
You can right-click on the button to the left of any outline box in your platform and select Edit > Show Tree Structure. This display will help you identify the display box that you need to work with.
I think this is the biggest take away. I've used the Scripting Index before and found it useful (when I could find what I was looking for). I didn't know anything about what the Tree Structure meant, until now.
Thanks!
Re: Programatically Modify X Axis Increment and Chart Width and HeightThe Scripting Guide a reference, not a bookd of solutions or a cookbook. There is a cookbook style reference available through SAS Press.
See the "Display Trees" and "Scripting Graphs" chapters in the Scripting Guide for more information about what you are trying to do.
You might also find the Help > Scripting Index helpful. Change the Browser to display Display Boxes. Then select Axis Box in the left hand list. The second list will show you the complete protocol for these objects.
You can right-click on the button to the left of any outline box in your platform and select Edit > Show Tree Structure. This display will help you identify the display box that you need to work with.
Re: Programatically Modify X Axis Increment and Chart Width and HeightYou click the red triangle to the left of the title of the post that you want to change and select Edit Reply.
1. The index of the target axis box depends on the platform but generally the index for the Y axis is 1 and the index for the X axis is 2.
2. Your syntax is the same as mine. Your names are different.
3. I do not know what the 'count' of an axis is but you can use the << Get Min and << Get Max messages to determine the range, which might help to determine the increment that you want to use.
Re: Programatically Modify X Axis Increment and Chart Width and HeightLet me make a correction to my above post (since I don't know how to edit a post).
1. I discovered that I can affect the X Axis by changing AxisBox(1) to AxisBox(2).
2. I am using the syntax of "pp = planetP << Report"
3. How can I get a count of the X-Axis values so I can determine what to use for the increment?Re: Programatically Modify X Axis Increment and Chart Width and Height
@Mark_Bailey wrote:
You should see Help > Books > Scripting Guide. Each platform is composed of two objects: the analysis layer and the report layer. All the initial messages go to the analysis layer. You need to get a reference to the report layer and send messages to specific objects in the report. This eample gives you an idea of what I mean:
planetP = Control Chart(
invisible,
Sample Label( :ReleaseMonth ),
Phase( :Phase ),
Sample Size( :Name( "Sum-Total" ) ),
KSigma( 3 ),
Chart Col( :OnTimePct, P( Phase Level( "1" ), Phase Level( "2" ) ) ),
By( :Planet )
);
planetP report = planetP << Report;
planetP[FrameBox(1)] << Frame Size( 200, 200 );
planetP[AxisBox(1)] << Inc( 2 );
Mark - I appreciate the response. A few things:
1. I tried your suggestion but cannot affect the X Axis at all. I can change the framebox size just fine.
2. Is "planetP report = planetP << Report" the same as "pp = planetP << Report" (and then using pp[FrameBox(1)] << Frame Size( 200, 200 ))
2. I looked online at the Scripting Guide. It is NOT very newbie friendly. I could not find anything that discussed the axisbox object, nor what the object names are in general. I searched for "report" and had a ton of instances, but zero for axisbox. Is there some place that specifically discusses the different objects and how to interact with them?
Re: Programatically Modify X Axis Increment and Chart Width and HeightYou should see Help > Books > Scripting Guide. Each platform is composed of two objects: the analysis layer and the report layer. All the initial messages go to the analysis layer. You need to get a reference to the report layer and send messages to specific objects in the report. This eample gives you an idea of what I mean:
planetP = Control Chart(
invisible,
Sample Label( :ReleaseMonth ),
Phase( :Phase ),
Sample Size( :Name( "Sum-Total" ) ),
KSigma( 3 ),
Chart Col( :OnTimePct, P( Phase Level( "1" ), Phase Level( "2" ) ) ),
By( :Planet )
);
planetP report = planetP << Report;
planetP[FrameBox(1)] << Frame Size( 200, 200 );
planetP[AxisBox(1)] << Inc( 2 );