User (Legacy) Posted March 22, 2004 Report Share Posted March 22, 2004 Hi, I get totally strange behaviour when adding data to ChartFx Internet (Realtime Chart - not the realtime extension) over Javascript. Initializing data with AdoResultset runs (nearly) fine (x-axis seems to be to short), but after I add data (by using Javascript) the previous points jumps to a new timestamp, and the x-Axis is (sometimes) to short (that depends on the amount of data I added). Please look at the attached screenshot One (serious) question: Is it a good way adding data by using Javascript. If not, how can I add data without reload the whole page (including Chart-Control) Please help, I've tried for hours but did not find a proper solution. Thanks very much Berthold My code: ' ----------------------------- initialize chart with data (see below for adding data) -------------------------------------- 'Preparing the chart to be RealTime ChartAnalyse.TypeMask = ChartAnalyse.TypeMask Or CT_EVENSPACING 'Setting a buffer size of 50 points ChartAnalyse.MaxValues = 5000 'Add a Loop marker and hiding the hourglass cursor ChartAnalyse.RealTimeStyle = CRT_LOOPPOS Or CRT_NOWAITARROW ' get data from database Set mConnection = Server.CreateObject("ADODB.Connection") mConnection.Open "MyData",mUser,mPwd Set mRecordSet = mConnection.Execute("SELECT .....") ' Specify how SQL fields are used ChartAnalyse.DataType(0) = CDT_XVALUE ChartAnalyse.DataType(1) = CDT_VALUE ChartAnalyse.DataType(2) = CDT_VALUE ' set data ChartAnalyse.AdoResultset mRecordSet mRecordSet.Close mConnection.Close ' format x-axis as datetime XAxis = ChartAnalyse.Axis(AXIS_X) XAxis.Format = AF_DATETIME --------------------------- adding data (by using javascript) --------------------------------------------- <SCRIPT LANGUAGE="JavaScript" FOR="ChartAnalyse"> // function is called from somewhere, but the array contained the correct values function AddPoints(valueArray) { len = valueArray.length; ChartAnalyse.OpenDataEx( 6 + 1024 ,1,len); // for(i = 0 ; i<len ; i++) { ChartAnalyse.ValueEx(0,i) = 12; // for better controlling ChartAnalyse.XValueEx(0,i) = valueArray[i][0]; ChartAnalyse.ValueEx(1,i) = 25; // for better controlling ChartAnalyse.XValueEx(1,i) = valueArray[i][0]; } ChartAnalyse.CloseData(6 + 768); } </script> Quote Link to comment Share on other sites More sharing options...
Software FX Posted March 23, 2004 Report Share Posted March 23, 2004 Adding data using JavaScript should not be a problem. What kind of data are you adding ? Are they dates ? Can you post a small sample (including JavaScript code) that reproduces this behavior ? -- Regards, JC Software FX Support "Andris" <andris@b-andris.de> wrote in message news:sKaVx7BEEHA.4068@webserver3.softwarefx.com... > Hi, > > I get totally strange behaviour when adding data to ChartFx Internet > (Realtime Chart - not the realtime extension) over Javascript. > > Initializing data with AdoResultset runs (nearly) fine (x-axis seems to be > to short), > but after I add data (by using Javascript) the previous points jumps to a > new timestamp, and the x-Axis is (sometimes) to short (that depends on the > amount of data I added). > > Please look at the attached screenshot > > One (serious) question: > Is it a good way adding data by using Javascript. > If not, how can I add data without reload the whole page (including > Chart-Control) > > Please help, I've tried for hours but did not find a proper solution. > > Thanks very much > Berthold > > > My code: > > ' ----------------------------- initialize chart with data (see below for > adding data) -------------------------------------- > 'Preparing the chart to be RealTime > ChartAnalyse.TypeMask = ChartAnalyse.TypeMask Or CT_EVENSPACING > 'Setting a buffer size of 50 points > ChartAnalyse.MaxValues = 5000 > 'Add a Loop marker and hiding the hourglass cursor > ChartAnalyse.RealTimeStyle = CRT_LOOPPOS Or CRT_NOWAITARROW > > ' get data from database > Set mConnection = Server.CreateObject("ADODB.Connection") > mConnection.Open "MyData",mUser,mPwd > Set mRecordSet = mConnection.Execute("SELECT .....") > > ' Specify how SQL fields are used > ChartAnalyse.DataType(0) = CDT_XVALUE > ChartAnalyse.DataType(1) = CDT_VALUE > ChartAnalyse.DataType(2) = CDT_VALUE > > ' set data > ChartAnalyse.AdoResultset mRecordSet > mRecordSet.Close > mConnection.Close > > ' format x-axis as datetime > XAxis = ChartAnalyse.Axis(AXIS_X) > XAxis.Format = AF_DATETIME > > > --------------------------- adding data (by using > javascript) --------------------------------------------- > <SCRIPT LANGUAGE="JavaScript" FOR="ChartAnalyse"> > // function is called from somewhere, but the array contained the correct > values > function AddPoints(valueArray) > { > > len = valueArray.length; > > ChartAnalyse.OpenDataEx( 6 + 1024 ,1,len); // > for(i = 0 ; i<len ; i++) > { > ChartAnalyse.ValueEx(0,i) = 12; // for better controlling > ChartAnalyse.XValueEx(0,i) = valueArray[i][0]; > ChartAnalyse.ValueEx(1,i) = 25; // for better controlling > ChartAnalyse.XValueEx(1,i) = valueArray[i][0]; > } > ChartAnalyse.CloseData(6 + 768); > > } > </script> > > > Quote Link to comment Share on other sites More sharing options...
User (Legacy) Posted March 24, 2004 Author Report Share Posted March 24, 2004 Hi, thanks a lot for trying to help me. Attached you find the example code you wanted. Note: the example will not run until you setup your database in the same way as I did Table definition: CREATE TABLE [measurement_values] ( [time_stamp] [datetime] NULL , [spo2] [int] NULL , [heart_rate] [int] NULL , [fk_patient] [int] NOT NULL ) ON [PRIMARY] Please have also a look at the comments in the code How it works: - Start frame.asp - page (code1.asp) contains ChartFX and two action buttons. - First it should be initialized (by pressing "Initialize") > the data were loaded from db, > the ChartFx-Control were visualized, > data were assigned to ChartFx by using "ChartAnalyse.AdoResultset" - After pressing "Add next values" > fillup parameters in form "newVal" on page "Code2.asp" > submit "newVal" (on page "Code2.asp") > data were received from db (time_stamp is converted into a float-value) > create a javascript-based array containing the received values > call AddPoints() on page Code1.asp > AddPoints() adds the x-axis values by using float values. I didn't found out how to set date-time values directly (whatever I used I got: "wrong format") General: Am I on the right way? Or is it completely stupid how I try to use a realtime chart? Hope you can help me Berthold "SoftwareFX Support" <noreply@softwarefx.com> schrieb im Newsbeitrag news:QZsZ54SEEHA.196@webserver3.softwarefx.com... > Adding data using JavaScript should not be a problem. What kind of data are > you adding ? Are they dates ? > > Can you post a small sample (including JavaScript code) that reproduces this > behavior ? > > -- > Regards, > > JC > Software FX Support > "Andris" <andris@b-andris.de> wrote in message > news:sKaVx7BEEHA.4068@webserver3.softwarefx.com... > > Hi, > > > > I get totally strange behaviour when adding data to ChartFx Internet > > (Realtime Chart - not the realtime extension) over Javascript. > > > > Initializing data with AdoResultset runs (nearly) fine (x-axis seems to be > > to short), > > but after I add data (by using Javascript) the previous points jumps to a > > new timestamp, and the x-Axis is (sometimes) to short (that depends on the > > amount of data I added). > > > > Please look at the attached screenshot > > > > One (serious) question: > > Is it a good way adding data by using Javascript. > > If not, how can I add data without reload the whole page (including > > Chart-Control) > > > > Please help, I've tried for hours but did not find a proper solution. > > > > Thanks very much > > Berthold > > > > > > My code: > > > > ' ----------------------------- initialize chart with data (see below for > > adding data) -------------------------------------- > > 'Preparing the chart to be RealTime > > ChartAnalyse.TypeMask = ChartAnalyse.TypeMask Or CT_EVENSPACING > > 'Setting a buffer size of 50 points > > ChartAnalyse.MaxValues = 5000 > > 'Add a Loop marker and hiding the hourglass cursor > > ChartAnalyse.RealTimeStyle = CRT_LOOPPOS Or CRT_NOWAITARROW > > > > ' get data from database > > Set mConnection = Server.CreateObject("ADODB.Connection") > > mConnection.Open "MyData",mUser,mPwd > > Set mRecordSet = mConnection.Execute("SELECT .....") > > > > ' Specify how SQL fields are used > > ChartAnalyse.DataType(0) = CDT_XVALUE > > ChartAnalyse.DataType(1) = CDT_VALUE > > ChartAnalyse.DataType(2) = CDT_VALUE > > > > ' set data > > ChartAnalyse.AdoResultset mRecordSet > > mRecordSet.Close > > mConnection.Close > > > > ' format x-axis as datetime > > XAxis = ChartAnalyse.Axis(AXIS_X) > > XAxis.Format = AF_DATETIME > > > > > > --------------------------- adding data (by using > > javascript) --------------------------------------------- > > <SCRIPT LANGUAGE="JavaScript" FOR="ChartAnalyse"> > > // function is called from somewhere, but the array contained the correct > > values > > function AddPoints(valueArray) > > { > > > > len = valueArray.length; > > > > ChartAnalyse.OpenDataEx( 6 + 1024 ,1,len); // > > for(i = 0 ; i<len ; i++) > > { > > ChartAnalyse.ValueEx(0,i) = 12; // for better controlling > > ChartAnalyse.XValueEx(0,i) = valueArray[i][0]; > > ChartAnalyse.ValueEx(1,i) = 25; // for better controlling > > ChartAnalyse.XValueEx(1,i) = valueArray[i][0]; > > } > > ChartAnalyse.CloseData(6 + 768); > > > > } > > </script> > > > > > > > > Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.