cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
tnodd
Level II

Creating a Bivariate and Variability Chart Side by Side inside a loop for mutiple parameters and groups

I have an idea what may need to be done but not sure how to implement it. I have a small sample table (say) like this (just showing 4 rows)

 

dt

         Group    Parameter   Value    Class     PhaseLabel      Date 

 

           A              X               2            pq             z                  xxxxx

           A              Y               6            re              z                  xxxxx

           A              R               2.6         uy             u                  yyyyy

           B             X                4            yt              z                  qqqqq

           B             R                3            er            s                    rrrrrrr

           .................................................................

 

So I want to create jrn-> html for each of my groups ( distinct html files). In each html file there will be plots which will be appended using a V List Box. However, the issue is that I need to have a side by side ( one Bivariate & one Variability Chart)

I am able to produce either a Bivariate or Variab Chart, but cannot do both. I put the skeleton of the code below:

 

 

dt = Current Data Table();

out_path  = "*****"

Summarize( groupid = by(:Group));

Summarize(paramgrp = by(:Parameter));

mydf = {};

For (k=1, k<=N items(groupid),k++,

     grp_name = groupid[k];

      myhtm = New Window( "30d Trend Plots Group Wise", myhtm[k] = V List Box() );



      For( i = 1, i <= N Items( paramgroup ), i++,

               idname = Char( paramgroup[i] );



               outfile = out_path || grp_name || "_" || "trend_plots" || ".html";



               df_ooc = dt_month << Bivariate(
                     Y( :Value),
                     X( :DATE),
                    Where( :Parameter == idname),
                    Where (:Group == groupname),
                    By(:Group :Parameter),
                    );

                 mydf[k] << append( Report( myhtm)) 

          ); ///// 2nd for loop end



           

             jrn_df = New Window("Trend Correlation Report", << Journal) ;


            mydf[k] << Journal(Freeze All) << show window(0);

           

             jrn_df << Save HTML(outfile);



             Close All (Journals, "No Save");



);   1st for loop end

 

 

Now the above code works perfectly fine when I want to have 1 journal for each group which plots wither a Bivariate( shown here) or if I want a Var Chart ( if I just replace Bivariate with var Chart as a function of Class & Phase Label). However, what I want is inside each group( first for loop for each parameter( inside 2nd loop ) the bivariate and var chart side by side. So that means say if I have 4 groups then I should have 4 journals ( html file) and if for each group say I have 5 parameters then on each html file I will have total 10 plots in 2 columns ( 1st Column say Bivariate and 2nd Column say Var Chart) . I was trying to use H Box inside the 2nd for loop and trying to append the two plots but its not working.

 

I will really appreciate help. If any other info is needed I can provide it. 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Creating a Bivariate and Variability Chart Side by Side inside a loop for mutiple parameters and groups

I have reworked your script a bit.  You will need to go through it an study what I have done.  The basic issue is that when you use a BY() on the platforms, it generates a separate report for each level of by.

The script as written will generate the journals for each group.  I have commented out the show window and the saving of the journal to html.  I did this, so to start with you will see the different journals.  You just need to take the comments out, and it should work the way you want.

Names Default To Here( 1 );
dt = Current Data Table();

out_path = "*****";

Summarize( groupid = by( :Group ) );

Summarize( paramgroup = by( :Parameter ) );

mydf = {};

For( k = 1, k <= N Items( groupid ), k++,
	grp_name = groupid[k];
	myhtm = New Window( "30d Trend Plots Group Wise", lb = Lineup Box( N Col( 2 ) ) );
	For( i = 1, i <= N Items( paramgroup ), i++,
		idname = Char( paramgroup[i] );
		outfile = out_path || grp_name || "_" || "trend_plots" || ".html";
		df_ooc = dt << Bivariate(invisible,
			Y( :Value ),
			X( :DATE ),
			Where( :group == grp_name ),
			By( :Parameter ), 

		);
		vc = Variability Chart(invisible,
			Y( :Value ),
			X( :Date ),
			Std Dev Chart( 0 ),
			where( :group==grp_name ),
			By( :parameter )
		);
		
		// For each value in the By group, there is a separate report
		theEnd=.;
		try(theEnd=nitems(df_ooc)); if(ismissing(theEnd), theEnd=1);
		For( rptGroup = 1, rptGroup <= theEnd, rptGroup++,
			IF( theEnd == 1,
				lb << append( Report( df_ooc ) );
				lb << append( Report( vc ) );
			,
				lb << append( Report( df_ooc[rptGroup] ) );
				lb << append( Report( vc[rptGroup] ) );
			);
		);
		df_ooc << close window;
		vc << close window;
	); ///// 2nd for loop end

	jrn_df = New Window( "Trend Correlation Report", <<Journal );
	text box("Group = " || grp_name)<<journal;
	lb << Journal( Freeze All );// << show window( 0 );
	myhtm << close window;
	//jrn_df << Save HTML( outfile );
	//Close All( Journals, "No Save" );
);   //1st for loop end



The script worked without error on your supplied sample data.

Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Creating a Bivariate and Variability Chart Side by Side inside a loop for mutiple parameters and groups

I have reworked your script a bit.  You will need to go through it an study what I have done.  The basic issue is that when you use a BY() on the platforms, it generates a separate report for each level of by.

The script as written will generate the journals for each group.  I have commented out the show window and the saving of the journal to html.  I did this, so to start with you will see the different journals.  You just need to take the comments out, and it should work the way you want.

Names Default To Here( 1 );
dt = Current Data Table();

out_path = "*****";

Summarize( groupid = by( :Group ) );

Summarize( paramgroup = by( :Parameter ) );

mydf = {};

For( k = 1, k <= N Items( groupid ), k++,
	grp_name = groupid[k];
	myhtm = New Window( "30d Trend Plots Group Wise", lb = Lineup Box( N Col( 2 ) ) );
	For( i = 1, i <= N Items( paramgroup ), i++,
		idname = Char( paramgroup[i] );
		outfile = out_path || grp_name || "_" || "trend_plots" || ".html";
		df_ooc = dt << Bivariate(invisible,
			Y( :Value ),
			X( :DATE ),
			Where( :group == grp_name ),
			By( :Parameter ), 

		);
		vc = Variability Chart(invisible,
			Y( :Value ),
			X( :Date ),
			Std Dev Chart( 0 ),
			where( :group==grp_name ),
			By( :parameter )
		);
		
		// For each value in the By group, there is a separate report
		theEnd=.;
		try(theEnd=nitems(df_ooc)); if(ismissing(theEnd), theEnd=1);
		For( rptGroup = 1, rptGroup <= theEnd, rptGroup++,
			IF( theEnd == 1,
				lb << append( Report( df_ooc ) );
				lb << append( Report( vc ) );
			,
				lb << append( Report( df_ooc[rptGroup] ) );
				lb << append( Report( vc[rptGroup] ) );
			);
		);
		df_ooc << close window;
		vc << close window;
	); ///// 2nd for loop end

	jrn_df = New Window( "Trend Correlation Report", <<Journal );
	text box("Group = " || grp_name)<<journal;
	lb << Journal( Freeze All );// << show window( 0 );
	myhtm << close window;
	//jrn_df << Save HTML( outfile );
	//Close All( Journals, "No Save" );
);   //1st for loop end



The script worked without error on your supplied sample data.

Jim
tnodd
Level II

Re: Creating a Bivariate and Variability Chart Side by Side inside a loop for mutiple parameters and groups

Let me check out on the real data and I will get back soon. Thanks so much Jim. You always are fabulous!
tnodd
Level II

Re: Creating a Bivariate and Variability Chart Side by Side inside a loop for mutiple parameters and groups

Thanks, Jim. Yes, I tested on my real data. It worked like charm. Learnt a new thing!