Doughboyjtd Posted May 13, 2010 Share Posted May 13, 2010 I'm going to be graphing up to 5 different traces from 5 channels on one graph. I would like to make 5 toggle buttons somewhere on the page, one for each trace, so I can graph any combination of traces at a time. Basically I need to be able to turn on or off any of the 5 traces. How would I go about doing this? Link to comment Share on other sites More sharing options...
AzeoTech Posted May 13, 2010 Share Posted May 13, 2010 Look at the quickmodpro.ctl sample and its associated help files. It shows and describes exactly how to do this. Link to comment Share on other sites More sharing options...
Doughboyjtd Posted May 19, 2010 Author Share Posted May 19, 2010 I think I've added the correct sequence to my file but I'm not sure. I've created 5 buttons to turn off and on each trace, but I can't get them to work. I'll send you my file to look at if you don't mind and let me know what you think. Thanks. 051910Acidizer.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted May 19, 2010 Share Posted May 19, 2010 Sorry, not really even close. You need to declare some variables (from StartUp in QuickModPro): // graphtraces is an array of booleans, 1 if the channel should be graphed, 0 if not. Default is only the first. global graphtraces = fill(0,CHANCOUNT) graphtraces[0] = 1 // this temptraces is used to update the graph from UpdateTypeCombo. Compares it to graphtraces and if a change // is detected, updates the graph. global temptraces = fill(-1,CHANCOUNT) global tracenames = {"Pressure1","Pressure2","Flow1","Flow2","FlowTotal"} global tracecolors tracecolors[0] = rgb(0,0,0xff) tracecolors[1] = rgb(0xff,0,0) tracecolors[2] = rgb(0,0x80,0) tracecolors[3] = rgb(0x80,0x80,0) tracecolors[4] = rgb(0,0,0x80) Then inside the while() loop in UpdateTypeCombo (which you probably can rename to something more appropriate): if (min(temptraces == graphtraces) == 0) // this is a trick to compare an entire array. // If min == 0, then at least one element didn't match temptraces = graphtraces component.maingraph.DeleteAllTraces() for (private x = 0, x < numrows(graphtraces), x++) if(!graphtraces[x]) continue endif component.maingraph.AddTrace(traceNames[x]) // CurrentScaleFrom and CurrentScaleTo are internal variables of the axes that hold the current scaling of the bottom axis. // This can vary from our variables if the user zooms or pans the graph execute("component.maingraph." + traceNames[x] + ".strYExpression = '" + traceNames[x] + "[BottomAxis.CurrentScaleFrom,BottomAxis.CurrentScaleTo]'") execute("component.maingraph." + traceNames[x] + ".color = " + doubletostr(tracecolors[x])) endfor endif Finally, you need to name your graph "maingraph" Link to comment Share on other sites More sharing options...
Doughboyjtd Posted May 19, 2010 Author Share Posted May 19, 2010 Sorry for the trouble. I applied the info you gave me but I'm still not having any luck. Since I'm using a button to do this instead of a checkbox, do I need to have my Pressure1 button toggle graphtraces[Pressure1] or do I need to use something else? 051910Acidizer.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted May 19, 2010 Share Posted May 19, 2010 Yes, you need it to toggle, and you can't use [Pressure1] unless Pressure1 is a variable (equal to 0 if you use my script). You just want: graphtraces[0] = !graphtraces[0] or use the toggle between action. For pressure2 it'd be [1], etc. It has to match up with the ordering of the tracenames variable. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.