cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

Interactive journals

ConvergentWhale
Level I

Hello,

I am working with JMP and need assistance with creating an interactive journal. My goal is to include a feature that allows users to select and highlight specific batches within a graph. Here are the details of the script and what I am trying to achieve:

 

 

Names Default To Here(1);

Current Data Table(dt);
dt << New Column("Time Point Months", Formula(Round(:Time Point Days / 30.438), 2));

// Loop for each parameter
For(i = 1, i <= N Items(numPar), i++,
	col1 = Col Box("");
	col2 = Col Box("");
	col3 = Col Box("");

// Create all batches plot
	gb = Graph Builder(
		invisible,
		Size(500, 500),
		Variables(X(:Time Point Months), Y(:Result), Overlay(:Batch)),
		Elements(Points(X, Y))
	);
	gb << Local Data Filter(
		Add Filter(
			columns(:Component, :Batch, :Source Table),
			Where(:Component == numPar[i]),
			Where(:Batch == {cyc, bat}),
			Where(:Source Table == dt_name)
		)
	);
	dt << Clear Select();

	gbb = Report(gb)[GraphBuilderBox(1)];
	gbb << Add Element(1, 1, {Type("Line Of Fit"), X, Y, Confidence of Fit(0), Equation(0)});

// Set Y axis
	minval = Min(
		:Result[dt << get rows where(
			:Component == numPar[i] & :Batch == cyc & :Source Table == dt_name | :Batch == bat
			 & :Component == numPar[i] & :Source Table == dt_name
		)]
	) * 0.95;
	maxval = Max(
		:Result[dt << get rows where(
			:Component == numPar[i] & :Batch == cyc & :Source Table == dt_name | :Batch == bat
			 & :Component == numPar[i] & :Source Table == dt_name
		)]
	) * 1.05;
	maxvalts = Max(
		:Time Point Months[dt << get rows where(
			:Component == numPar[i] & :Batch == cyc & :Source Table == dt_name | :Batch == bat
			 & :Component == numPar[i] & :Source Table == dt_name
		)]
	) * 1.05;

	gbb[AxisBox(1)] << Min(-0.1);
	gbb[AxisBox(1)] << Max(maxvalts);
	gbb[AxisBox(2)] << Min(minval);
	gbb[AxisBox(2)] << Max(maxval);
	gbb[AxisBox(2)] << inc((maxval - minval) / 10);

// Set Y axis label
	unitList = Associative Array(
		:Result Unit[dt << get rows where(
			:Component == numPar[i] & :Batch == cyc & :Source Table == dt_name | :Batch == bat
			 & :Component == numPar[i] & :Source Table == dt_name
		)]
	) << Remove("") << Get Keys;
	If(N Items(unitList) == 1,
		gbb[Text Edit Box(4)] << Set text(numPar[i] || " [" || unitList[1] || "]")
	);
	If(N Items(unitList) != 1,
		gbb[Text Edit Box(4)] << Set text(numPar[i])
	);

// Set graph title
	gbb[Text Edit Box(1)] << Set text(numPar[i] || " vs. Time Point ");
	gbba = Report(gb);
	col1 << Append(gbba);
	gb << close window;

	For(k = 1, k <= N Items(cyc), k++,
		check = dt << get rows where(
			:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt_name | :Batch ==
			bat[k] & :Component == numPar[i] & :Source Table == dt_name
		);
		If(N Items(check) > 0,
			gb = Graph Builder(
				invisible,
				Size(500, 500),
				Variables(X(:Time Point Months), Y(:Result), Overlay(:Batch)),
				Elements(Points(X, Y))
			);
			gb << Local Data Filter(
				Add Filter(
					columns(:Component, :Batch, :Source Table),
					Where(:Component == numPar[i]),
					Where(:Batch == {cyc[k], bat[k]}),
					Where(:Source Table == dt_name)
				)
			);
			dt << Clear Select();

			gbb = Report(gb)[GraphBuilderBox(1)];
			gbb << Add Element(
				1,
				1,
				{Type("Line Of Fit"), X, Y, Confidence of Fit(0), Equation(0)}
			);

			minval = Min(
				:Result[dt << get rows where(
					:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt_name |
					:Batch == bat[k] & :Component == numPar[i] & :Source Table == dt_name
				)]
			) * 0.95;
			maxval = Max(
				:Result[dt << get rows where(
					:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt_name |
					:Batch == bat[k] & :Component == numPar[i] & :Source Table == dt_name
				)]
			) * 1.05;
			maxvalts = Max(
				:Time Point Months[dt << get rows where(
					:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt_name |
					:Batch == bat[k] & :Component == numPar[i] & :Source Table == dt_name
				)]
			) * 1.05;

			gbb[AxisBox(1)] << Min(-0.1);
			gbb[AxisBox(1)] << Max(maxvalts);
			gbb[AxisBox(2)] << Min(minval);
			gbb[AxisBox(2)] << Max(maxval);
			gbb[AxisBox(2)] << inc((maxval - minval) / 10);

			unitList = Associative Array(
				:Result Unit[dt << get rows where(
					:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt_name |
					:Batch == bat[k] & :Component == numPar[i] & :Source Table == dt_name
				)]
			) << Remove("") << Get Keys;
			If(N Items(unitList) == 1,
				gbb[Text Edit Box(4)] << Set text(numPar[i] || " [" || unitList[1] || "]")
			);
			If(N Items(unitList) != 1,
				gbb[Text Edit Box(4)] << Set text(numPar[i])
			);

			gbb[Text Edit Box(1)] << Set text(numPar[i] || " vs. Time Point ");
			gbba = Report(gb);
			col2 << Append(gbba);
			gb << close window;

			gb2 = Graph Builder(
				invisible,
				Size(500, 500),
				Variables(X(:Time Point Months), Y(:Difference), Color(:Batch)),
				Elements(Points(X, Y))
			);
			gb2 << Local Data Filter(
				Add Filter(
					columns(:Component, :Batch, :Source Table),
					Where(:Component == numPar[i]),
					Where(:Batch == cyc[k]),
					Where(:Source Table == dt5_name)
				)
			);
			dt4 << Clear Select();

			gbb2 = Report(gb2)[GraphBuilderBox(1)];
			gbb2 << Add Element(1, 1, {Type("Line"), X, Y});

			l_idx = dt4 << Get rows where(dt4:Component == numPar[i] & :Batch == cyc[k]);
			ul = Min(dt4:HC[l_idx]);

			If(Is Missing(ul),
				If(
					Min(
						:Difference[dt << get rows where(
							:Component == numPar[i] & :Batch == cyc[k] & :Source Table ==
							dt5_name
						)]
					) == 0,
					minval = -5;
					maxval = 5;
				,
					minval = Min(
						:Difference[dt << get rows where(
							:Component == numPar[i] & :Batch == cyc[k] & :Source Table ==
							dt5_name
						)]
					) * 0.95;
					maxval = Max(
						:Difference[dt << get rows where(
							:Component == numPar[i] & :Batch == cyc[k] & :Source Table ==
							dt5_name
						)]
					) * 1.05;
				)
			,
				minval = Min(
					:Difference[dt << get rows where(
						:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt5_name
					)],
					-ul
				) * 1.05;
				maxval = Max(
					:Difference[dt << get rows where(
						:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt5_name
					)],
					ul
				) * 1.05;
			);

			If(!Is Missing(ul),
				gbb2[AxisBox(2)] << Add Ref Line(ul, "solid", "black", Char(Round(ul, 2)));
				gbb2[AxisBox(2)] << Add Ref Line(-ul, "solid", "black", Char(Round(-ul, 2)));
			);

			gbb2[AxisBox(2)] << Add Ref Line(0, "Dashed");
			gbb2[AxisBox(2)] << Min(minval);
			gbb2[AxisBox(2)] << Max(maxval);
			gbb2[AxisBox(2)] << inc((maxval - minval) / 10);

			gbba2 = Report(gb2);
			col3 << Append(gbba2);
			gb2 << close window;
		);
	);

	results << append(ob = Outline Box(numPar[i], V List Box(col1, H List Box(col2, col3))));
	ob << close;
);

Edit (jthi 2024-08-26): Added JSL formatting



  1. Interactive Dropdown Menu: I want to create a dropdown menu that lists the unique batch values (:Batch column) in my data table.
  2. Highlighting Functionality: When a user selects a batch from the dropdown menu, the corresponding points in the graph should be highlighted.
  3. Embedding in a Journal: The dropdown menu and the graph should be embedded in a journal that can be saved and shared.


2 REPLIES 2
Byron_JMP
Staff


Re: Interactive journals

Did parts of this script work at some point?

 

JMP Systems Engineer, Health and Life Sciences (Pharma)


Re: Interactive journals

Yes the script works

Recommended Articles

No recommendations found