Hello. I am scripting a bar chart in graph builder because using a standard chart does not eliminate empty bars where as the graph builder does. I am allowing for the use of continuous modeling types as an X factor. Let me explain how I am approaching this.
The user selects some columns by which to plot a bar chart. I create the chart using graph builder and the first column selected. Then if there are more than one columns selected, I go in and <<add variables to the graph builder. This works exactly as I want it except when one of the selected columns is continuous. Then the graph builder replaces the entire X with the continuous variable and says there are more variables there but it is only plotting versus the one. When I create the chart manually like this by changing the continuous variable to ordinal, it works the way I want it. So I change each continuous column to oridinal but the graph still does not add the variable but replaces it.
Does anyone have any ideas how I can make this work the way I want it? Here is a simplified version of my script:
myWin = Column Dialog( FactorCol = Col List( "Multivariate Factor(s)" ) );
myFactor = myWin["FactorCol"];
myPlot = Graph Builder(
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables( X( Eval( myFactor[1] ) ), Y( yCol ), Color( Eval( myColor ) ) ),
Elements( Bar( X, Y, Summary Statistic( "Std Dev" ), Label( "Label by Value" ) ) ),
SendToReport(
Dispatch(
{},
ScaleBox,
{Label Row( 1, {Automatic Tick Marks( 0 ), Show Major Ticks( 1 ), Lower Frame( 1 ), Tick Mark Style( "Long Divider" )} )}
)
)
);
//If there is more than one factor then need to add variables to the graph
If( N Items( myFactor ) > 1,
myRep = Report( myPlot )[Graph Builder Box( 1 )];
For( j = 2, j <= N Items( myFactor ), j++,
xcol = Column( dtmm, myFactor[j] );
If( xcol << Get Modeling Type == "Continuous",
//set a column property so I can change it back later
xcol << Set Property( "change", 1 );
xcol << Modeling Type( "Ordinal" );
);
myRep << Add Variable( {xcol, Role( "X" ), Position( 1 )} );
);
//now I have to adjust all the x-axis for the way I want it
For( j = 1, j <= N Items( myFactor ), j++,
Report( myPlot )[Axisbox( 1 )] << {Label Row(
j,
{Automatic Tick Marks( 0 ), Show Major Ticks( 1 ), Lower Frame( 1 ), Tick Mark Style( "Long Divider" )}
)}
);
);