Hallo. Ich erstelle ein Skript für ein Balkendiagramm im Graph Builder, weil bei der Verwendung eines Standarddiagramms keine leeren Balken entfernt werden, wo dies beim Graph Builder der Fall ist. Ich erlaube die Verwendung kontinuierlicher Modellierungstypen als X-Faktor. Lassen Sie mich erklären, wie ich an die Sache herangehe.
Der Benutzer wählt einige Spalten aus, anhand derer er ein Balkendiagramm zeichnen möchte. Ich erstelle das Diagramm mit dem Graph Builder und wähle die erste Spalte aus. Wenn dann mehr als eine Spalte ausgewählt ist, gehe ich hinein und <
Hat jemand eine Idee, wie ich das so machen kann, wie ich es möchte? Hier ist eine vereinfachte Version meines Skripts:
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" )}
)}
);
);
Tatsächlich habe ich herausgefunden, wie das geht, indem ich Schritt für Schritt die Variablen der Graph Builder-Box überprüft habe. Wenn die Spalte kontinuierlich ist, ändere ich sie in eine Ordinalspalte und wenn ich eine Variable hinzufüge, muss ich einen inneren Positionsterm hinzufügen. Hier ist der entsprechende Skriptteil.
//graph builder can not add factors unless they are ordinal or nominal
//so if it is continuous, change to ordinal, and set a column property to change back later
If( xcol << Get Modeling Type == "Continuous",
xcol << Set Property( "change", {1} );
xcol << Modeling Type( "Ordinal" );
myRep << Add Variable( {xcol, Role( "X" ), Position( 1 ), Inner Position[i]} ),
,
myRep << Add Variable( {xcol, Role( "X" ), Position( 1 )} )
);Das macht genau das, was ich will.
H
Danke schön. Ja, ich weiß, dass das Erstellen eines String-Skripts eine Option ist, aber ich zögere immer, das zu tun. In diesem Fall kann es jedoch erforderlich sein.Ich bin enttäuscht, dass das der Fall ist.
am besten
H