Line chart widget and global variables
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 16
- Joined: Thu Mar 20, 2008 9:45 pm
Line chart widget and global variables
I am trying to incorporate the Linechart widget into a project that scores and graphs neuropsychological test results. I reviewed the online tutorial on Linechart, which as helpful and included a script for specifying the values to be graphed (these can be entered in the Linechart properties or sent to Linechart with a script). My question is whether static integer values in the example can be replaced with dynamic variables that are generated by the scoring procedure:
Sample script:
My attempt to modify the script (which doesn't work):
local tData
put "Jan,6,22" & return &
"Feb,6,22" & return &
"Mar,8,20" & return &
"Apr,11,17" & return &
"May,14,15" & return &
"Jun,17,12" & return &
"Jul,11,18" & return &
"Aug,18,13" & return &
"Sep,16,15" & return &
"Oct,12,16" & return &
"Nov,9,18" & return &
"Dec,7,20" into tData
set the graphData of widget "Line Graph" to tData
on mouseUp
global gDRSTotT, gTrailsAT, gTrailsBT, gBDST, gCowaT, gBNTT, gBVMIT, gHVLTTotT, gHVLTretainT, gBVMTTotT, gBVMTretainT
local tGraphValues
put "DRS total," & gDRSTotT & return &
"Trails A," & gTrailsAT & return &
"Trails B," & gTrailsBT & return &
"BDS," & gBDST & return &
"COWA," & gCowaT & return &
"BNT," & gBNTT & return &
"Beery VMI," gBVMIT & & return &
"HVLT learning," & gHVLTTotT & return &
"HVLT retain," & gHVLTretainT & return &
"BVMT learning" & gBVMTTotT & return &
"BVMT retain" & gBVMTretainT into tData
set the graphData of widget "Line Graph" to tGraphValues
end mouseUp
Can anyone tell me if this is possible? Perhaps an array would be the way to go? Thanks.
Sample script:
My attempt to modify the script (which doesn't work):
local tData
put "Jan,6,22" & return &
"Feb,6,22" & return &
"Mar,8,20" & return &
"Apr,11,17" & return &
"May,14,15" & return &
"Jun,17,12" & return &
"Jul,11,18" & return &
"Aug,18,13" & return &
"Sep,16,15" & return &
"Oct,12,16" & return &
"Nov,9,18" & return &
"Dec,7,20" into tData
set the graphData of widget "Line Graph" to tData
on mouseUp
global gDRSTotT, gTrailsAT, gTrailsBT, gBDST, gCowaT, gBNTT, gBVMIT, gHVLTTotT, gHVLTretainT, gBVMTTotT, gBVMTretainT
local tGraphValues
put "DRS total," & gDRSTotT & return &
"Trails A," & gTrailsAT & return &
"Trails B," & gTrailsBT & return &
"BDS," & gBDST & return &
"COWA," & gCowaT & return &
"BNT," & gBNTT & return &
"Beery VMI," gBVMIT & & return &
"HVLT learning," & gHVLTTotT & return &
"HVLT retain," & gHVLTretainT & return &
"BVMT learning" & gBVMTTotT & return &
"BVMT retain" & gBVMTretainT into tData
set the graphData of widget "Line Graph" to tGraphValues
end mouseUp
Can anyone tell me if this is possible? Perhaps an array would be the way to go? Thanks.
Re: Line chart widget and global variables
Hi Paul,
not sure I understand your problem, but you are filling the variable "tData"
in your mouseup handler but set the graphdata to ANOTHER local variable "tGraphValues "
which is obviously empty!
...
local tGraphValues
put "DRS total," & gDRSTotT & return &
...
"BVMT retain" & gBVMTretainT into tData
set the graphData of widget "Line Graph" to tGraphValues
...
Best
Klaus
not sure I understand your problem, but you are filling the variable "tData"
in your mouseup handler but set the graphdata to ANOTHER local variable "tGraphValues "
which is obviously empty!
...
local tGraphValues
put "DRS total," & gDRSTotT & return &
...
"BVMT retain" & gBVMTretainT into tData
set the graphData of widget "Line Graph" to tGraphValues
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 3990
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Line chart widget and global variables
Hi Paul,
this works
note that you have to use \ at the end of a line instead of just a return when doing this in a script. In the script editior on a Mac you do alt-return instead of just return. Using Windows or Linux should be something similar.
Kind regards
Bernd
this works
Code: Select all
on mouseUp
global gDRSTotT, gTrailsAT, gTrailsBT, gBDST, gCowaT, gBNTT, gBVMIT, gHVLTTotT, gHVLTretainT, gBVMTTotT, gBVMTretainT
-- this just fills in some data into the global variables, you would use the values of the globals
put 2 into gDRSTotT; put 5 into gTrailsAT; put 3 into gTrailsBT; put 7 into gBDST; put 6 into gCowaT
put 1 into gBNTT; put 9 into gBVMIT; put 7 into gHVLTTotT; put 3 into gHVLTretainT; put 4 into gBVMTTotT; put 8 into gBVMTretainT
-- end fill in
local tData
put "DRS total," & gDRSTotT & return & \
"Trails A," & gTrailsAT & return & \
"Trails B," & gTrailsBT & return & \
"BDS," & gBDST & return & \
"COWA," & gCowaT & return & \
"BNT," & gBNTT & return & \
"Beery VMI," & gBVMIT & return & \
"HVLT learning," & gHVLTTotT & return & \
"HVLT retain," & gHVLTretainT & return & \
"BVMT learning," & gBVMTTotT & return & \
"BVMT retain," & gBVMTretainT into tData
set the graphData of widget "Line Graph" to tData
end mouseUp
Kind regards
Bernd
-
- Posts: 16
- Joined: Thu Mar 20, 2008 9:45 pm
Re: Line chart widget and global variables
Thank you very much B. I will give this a try later today.
-
- Posts: 16
- Joined: Thu Mar 20, 2008 9:45 pm
Re: Line chart widget and global variables
Thanks, Klaus for catching that error. I forgot to change that instance of tData.Klaus wrote:Hi Paul,
not sure I understand your problem, but you are filling the variable "tData"
in your mouseup handler but set the graphdata to ANOTHER local variable "tGraphValues "
which is obviously empty!
...
local tGraphValues
put "DRS total," & gDRSTotT & return &
...
"BVMT retain" & gBVMTretainT into tData
set the graphData of widget "Line Graph" to tGraphValues
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 7214
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Line chart widget and global variables
Actually it's better to use a backslash on all platforms. If you use the special Mac continuation character, you'll get errors when the stack runs on a different OS.bn wrote: In the script editior on a Mac you do alt-return instead of just return.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 16
- Joined: Thu Mar 20, 2008 9:45 pm
Re: Line chart widget and global variables
Thanks to all for the solutions. They worked.
Now I have another problem.
The scores I am trying to plot range from +20 to -20. The LineChart widget seems to randomly display the vertical axis values incorrectly, with a different increment in the positive direction and negative direction (e.g. one point in the positive direction and two in the negative direction). In addition, some intervals are repeated (e.g. "2" will appear twice at two different horizontal line positions). Is this a known bug? Is there a way to set the vertical axis range and increments?
Now I have another problem.
The scores I am trying to plot range from +20 to -20. The LineChart widget seems to randomly display the vertical axis values incorrectly, with a different increment in the positive direction and negative direction (e.g. one point in the positive direction and two in the negative direction). In addition, some intervals are repeated (e.g. "2" will appear twice at two different horizontal line positions). Is this a known bug? Is there a way to set the vertical axis range and increments?
-
- VIP Livecode Opensource Backer
- Posts: 3990
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Line chart widget and global variables
Hi Paul,
could you please post your data. Please copy the data from the Properties Inspecort for the Line Graph widget.
Also it would be helpful if you could post your intended data.
Kind regards
Bernd
could you please post your data. Please copy the data from the Properties Inspecort for the Line Graph widget.
Also it would be helpful if you could post your intended data.
Kind regards
Bernd
-
- Posts: 16
- Joined: Thu Mar 20, 2008 9:45 pm
Re: Line chart widget and global variables
Thanks, Bernd. This seems to be working properly now. Not sure what I was doing wrong. It would be nice to be able to set the range and increments on the axes. Perhaps that will come in future iterations of the line Graph widget.