Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- how to write JSL script for basic equations, and then make an overlay plot out o...

Topic Options

- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

how to write JSL script for basic equations, and then make an overlay plot out of it?

Oct 29, 2015 9:00 AM
(1784 views)

I have several points defined in an JSL script and running that would generate a table and also overlay plots for each point.

Say I have point1, point2, point3

I want to define that

RATIO1 = point1*100/(point1+point2+point3)

RATIO2 = point2*100/(point1+point2+point3)

RATIO3 = point3*100/(point1+point2+point3)

Then plot overlay of RATIO1, RATIO2, RATIO3 versus timestamp.

I tried to use Assign(RATIO1, point1*100/(point1+point2+point3)) but did not work. I also tried the operators such as

Assign(RATIO1, Multiply(100, Divide(point1, Add(point1, point2, point3))));

but it still didn't work for the overlay plot as the error said it cannot find the role of defined Y. Can you please let me know if there's anything wrong with the script? I also tried :"RATIO1" or name("RATIO1") or putting the exact equation above when plotting Y below...all didn't work.

DT is the database:

DT << **Overlay Plot(**

X**(** :Timestamp **)**,

Y**( **** **

:RATIO1

:RATIO2

:RATIO3

**)**,

);

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: how to write JSL script for basic equations, and then make an overlay plot out of it?

Is this close to what you require? Copy and paste this code into an editor window, then 'Edit > Run Script'. Then look at the formulas in the 'RATIOn' columns.

NamesDefaultToHere**(****1****)**;

// Example table

dt = New Table**(** "Date and Times in 2014",

Add Rows**(** **100** **)**,

New Column**(** "Date",

Numeric,

"Continuous",

Format**(** "ddMonyyyy h:m:s", **22**, **0** **)**,

Input Format**(** "ddMonyyyy h:m:s", **0** **)**,

Formula**(**

Random Integer**(** Date DMY**(** **1**, **1**, **2014** **)**, Date DMY**(** **31**, **12**, **2014** **)** **)**

**)**

**)**,

New Column**(** "p1", Numeric, Continuous, Formula**(** Random Uniform**()** **))**,

New Column**(** "p2", Numeric, Continuous, Formula**(** Random Uniform**()** **))**,

New Column**(** "p3", Numeric, Continuous, Formula**(** Random Uniform**()** **))**,

New Column**(** "RATIO1", Numeric, Continuous, Formula**(** :p1***100**/**(**:p1 + :p2 + :p3 **)))**,

New Column**(** "RATIO2", Numeric, Continuous, Formula**(** :p2***100**/**(**:p1 + :p2 + :p3 **)))**,

New Column**(** "RATIO3", Numeric, Continuous, Formula**(** :p3***100**/**(**:p1 + :p2 + :p3 **)))**,

**)**;

// Shoow time series in Graph Builder

dt << **Graph Builder****(**

Show Control Panel**(** **0** **)**,

Variables**(** X**(** :Date **)**, Y**(** :RATIO1 **)**, Y**(** :RATIO2 **)**, Y**(** :RATIO3 **)** **)**,

Elements**(** Position**(** **1**, **1** **)**, Line**(** X, Y, Legend**(** **11** **)** **)** **)**,

Elements**(** Position**(** **1**, **2** **)**, Line**(** X, Y, Legend**(** **12** **)** **)** **)**,

Elements**(** Position**(** **1**, **3** **)**, Line**(** X, Y, Legend**(** **13** **)** **)** **)**

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: how to write JSL script for basic equations, and then make an overlay plot out of it?

Here's my code with extracting the points, and currently it's plotted with each point but I want to do some arithmetic formulas using those points and plot them as overlay. How to correctly define the formula/equation in the script and then how to plot in Y. You can see the previous effort I tried in the first message.

DT = Open Database("DRIVER=S Server;SERVER=SP.trend.com,0000",

"DECLARE @StartDateTime datetime = DATEADD(dy, -1, GETDATE())

DECLARE @EndDateTime datetime = GETDATE()

EXEC ListData @Criteria='

<SPORTAL>

<Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"120m\!">

<Columns>

<Column Name=\!"Timestamp\!" />

<Column Name=\!"Project\!" />

<Column Name=\!"Point\!" />

<Column Name=\!"DataValue\!" />

</Columns>

<Where>

<Column Name=\!"Point\!" Project=\!"XX\!" Value=\!"XX_POINTA\!" />

<Column Name=\!"Point\!" Project=\!"XX\!" Value=\!"XX_POINTB\!" />

<Column Name=\!"Point\!" Project=\!"XX\!" Value=\!"XX_POINTC\!" />

<Column Name=\!"Point\!" Project=\!"XX\!" Value=\!"XX_POINTD\!" />

</Where>

</Data>

</SPORTAL>'

, @StartDateTime=@StartDateTime

, @EndDateTime=@EndDateTime"

);

plotRATIOS = DT << Overlay Plot(

X( :Timestamp ),

Y(

:XX_POINTA,

:XX_POINTB,

:XX_POINTC,

:XX_POINTD

),

Sort X( 0 ),

Connect Thru Missing( 1 ),

Connect Points( 1 ),

Automatic Recalc( 0 ),

SendToReport(

Dispatch( {}, "102", ScaleBox, {Format( "Best", 10 )} ),

Dispatch(

{},

"101",

ScaleBox,

{Format( "m/d/y", 10 ), Rotated Labels( "Vertical" )}

),

Dispatch( {}, "Overlay Plot Graph", FrameBox, {Frame Size( 571, 450 )} )

)

);