Hi all,
I am doing a graph builder with a moving Y variables, the output of the graph will appear like this:
But, I am struggling to script the Y axis in JSL. How can I do so ?
For( i = 1, i <= N Items( NamesList ), i++,
obj = Graph Builder(
Size( 534, 464 ),
Show Control Panel( 0 ),
Variables(
X( :TETEST_MONTH ),
X( :TETEST_WEEK, Position( 1 ) ),
Y( :Name ("Y")) , // how do I insert the moving Y variable here ?
Y( :Name ("Y")), // how do I insert the moving Y variable here ?
Color( :TETEST_MONTH )
),
Elements( Position( 1, 1 ), Histogram( X( 2 ), X( 1 ), Y, Legend( 14 ) ) ),
Elements(
Position( 1, 2 ),
Box Plot( X( 2 ), X( 1 ), Y, Legend( 16 ) ),
Line( X( 2 ), X( 1 ), Y, Legend( 17 ) )
),
SendToReport( Dispatch( {}, "400", LegendBox, {Set Title( "" )} ) )
));
My error......get rid of all of the gb[i] references and change them to just gb.
Assuming that "NamesList" contains the Y columns you want to use as your Y columns, then replace
:Names( "Y" )
with:
as Column( NamesList[i] )
Thanks Jim.
But I have not idea why this error kept prompting me during debugging.
For( i = 1, i <= N Items( numericColNamesList ), i++,
gb = dt << Graph Builder(
Size( 900, 850 ),
Show Control Panel( 0 ),
Variables(
X( :MONTH ),
X( :WEEK, Position( 1 ) ),
Y( Column( numericColNamesList[i])) ,
Y( Column( numericColNamesList[i])) ,
Color( :MONTH )
),
Elements( Position( 1, 1 ), Histogram( X( 2 ), X( 1 ), Y, Legend( 14 ) ) ),
Elements(
Position( 1, 2 ),
Box Plot( X( 2 ), X( 1 ), Y, Legend( 16 ) ),
Line( X( 2 ), X( 1 ), Y, Legend( 17 ) )
),
SendToReport( Dispatch( {}, "400", LegendBox, {Set Title( "" )} ) )
));
Report(gb[1]) << Save Presentation( "C:\Users\Ann Ann\1.pptx" );
For( i = 2, i <= N Items( numericColNamesList ), i++,
Report (gb[i] << Save Presentation( "C:\Users\Ann Ann\1.pptx", Append )
));
Open( "C:\Users\Ann Ann\1.pptx" );
//wait(0);
//obj << close window();
You are using
gb = dt << Graph Builder(.........
for each execution of the Graph Builder Platform. It is not a vector of values. Each time you run the Graph Builder script, you are creating a new value for the variable "gb". That is, the pointer to the last instance of Graph Builder is moved to point to the new instance of Graph Builder. There is not a gb[1], gb[2], etc. the way you have the code setup.
One way to overcome this, is to move the Save Presentation area of code, inside the inititial For() loop.
Another way to solve this is in the initial For() Loop, save the values of "gb" into a list after it's creation. Then, point to the elements in the list in the second For() Loop, instead of gb[i] etc.
For( i = 1, i <= N Items( numericColNamesList ), i++,
gb = dt << Graph Builder(
Size( 900, 850 ),
Show Control Panel( 0 ),
Variables(
X( :MONTH ),
X( :WEEK, Position( 1 ) ),
Y( Column( numericColNamesList[i] ) ),
Y( Column( numericColNamesList[i] ) ),
Color( :MONTH )
),
Elements( Position( 1, 1 ), Histogram( X( 2 ), X( 1 ), Y, Legend( 14 ) ) ),
Elements(
Position( 1, 2 ),
Box Plot( X( 2 ), X( 1 ), Y, Legend( 16 ) ),
Line( X( 2 ), X( 1 ), Y, Legend( 17 ) )
),
SendToReport( Dispatch( {}, "400", LegendBox, {Set Title( "" )} ) )
);
If( i == 1,
Report( gb ) << Save Presentation( "C:\Users\Ann Ann\1.pptx" ),
Report( gb[i] << Save Presentation( "C:\Users\Ann Ann\1.pptx", Append ) )
);
);
Open( "C:\Users\Ann Ann\1.pptx" );
Thanks, Jim. But I still ecounter error. I guess something may not right with my segmentation.
/* Open a sample data table */
dt = Open( "C:\Users\1.jmp", invisible );
// Find the Y Columns
numericColNamesList = dt << get column names( string, numeric );
For( i = N Items( numericColNamesList ), i >= 1, i--,
If(
Not(
Is Missing( Num( Word( 1, numericColNamesList[i], ":" ) ) ) == 0 &
Word( 2, numericColNamesList[i], ":" ) != ""
),
numericColNamesList = Remove( numericColNamesList, i, 1 )
)
);
// Run the Variance Charts
// With dynamic Y columns and fixed X columns
Fo( i = 1, i <= N Items( numericColNamesList ), i++,
gb = dt << Graph Builder(
Invisible,
Size( 752, 508 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables(
X( :Month ),
Y( Column ( numericColNamesList[i] ) ),
Overlay( :Month )
),
Elements(
Box Plot(
X,
Y,
Legend( 15 ),
Jitter( 0 ),
Outliers( 0 ),
Box Style( "Solid" )
),
Histogram( X, Y, Legend( 12 ) )
));
gb = LIST (gb[i]);
If( i == 1,
Report( gb ) << Save Presentation( "C:\Users\Ann Ann\1.pptx" ),
Report( gb[i] << Save Presentation( "C:\Users\Ann Ann\1.pptx", Append ) )
));
My error......get rid of all of the gb[i] references and change them to just gb.