User (Legacy) Posted November 2, 2006 Report Share Posted November 2, 2006 Thanks with http://support.softwarefx.com/ShowArticle.aspx?Type=KB&Product=CfxNet70&Source=http://support.softwarefx.com/kb/765/1/001.htm I did What I want ^_____^ I like to share my sample code here. I drew the real-chart with Ajax which is supported by ChartFX2005(Evaluation Version). And the data source from Web-service is using to draw. The chart draw every second with Javascript. DB connection and Some other methods are not included. Have a good day~ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<cs code> public partial class sampleWorks_AsyncChart : System.Web.UI.Page { Interfaces serv; string[] clientInfo; //{xflow, point, min, max} "0,0,0,4" string lsSql; string[] lsArg; string[] rstPoint; protected void Page_Load(object sender, EventArgs e) { Chart1.UseCallbacksForEvents = true; serv = new Interfaces(); //Sample Web-Service lsArg = new string[2]; lsArg[0] = "time"; lsArg[1] = "point1"; } //Callback protected void Chart1_UserCallback(object sender, ChartFX.WebForms.UserCallbackEventArgs e) { clientInfo = e.Param.Split(new char[] { ´,´ }); //{xflow, point, min, max} "0,0,0,4" int lvTime = int.Parse(clientInfo[0]); int lvPoint = int.Parse(clientInfo[1]); int lvMin = int.Parse(clientInfo[2]); int lvMax = int.Parse(clientInfo[3]); if (lvTime == 0) { CustomChart(0, 5, false); ResetChart(); } if (lvPoint == 5) //0 ~ 4 { lvMin = lvMax + 1; lvMax = lvMax + 5; clientInfo[1] = "0"; lvPoint = 0; clientInfo[2] = lvMin.ToString(); clientInfo[3] = lvMax.ToString(); ResetChart(); CustomChart(lvMin, lvMax, true); } lsSql = "SELECT time, point1 FROM points WHERE time = " + lvTime; rstPoint = SrvUtility.pasStr((serv.getSampleRc(lsSql, lsArg))); Chart1.Data[0, lvPoint] = Int32.Parse(rstPoint[1]); lvTime += 1; lvPoint += 1; clientInfo[0] = lvTime.ToString(); clientInfo[1] = lvPoint.ToString(); e.Result = arrToStr(clientInfo); } //Array to String private string arrToStr(string[] tmp) { string rtn; if (tmp != "") rtn = tmp[0] + "," + tmp[1] + "," + tmp[2] + "," + tmp[3]; else rtn = "0,0,0,4"; return rtn; } //Initiate Data private void ResetChart() { Chart1.Data.Clear(); // Chart1.Series.Clear(); } //Design Chart private void CustomChart(int arMin, int arMax, bool arRefresh) { Chart1.Data.Series = 1; Chart1.Data.Points = 5; // Chart1.Series[0].MarkerShape = MarkerShape.None; Chart1.Series[0].Color = Color.Red; Chart1.Series[0].Line.Width = 1; Chart1.Highlight.Enabled = false; if (!arRefresh) { Chart1.AxisY.Grids.Major.Visible = false; Chart1.AxisY.Min = 0; Chart1.AxisY.Step = 50; Chart1.AxisY.Max = 800; Chart1.AxisY.LabelsFormat.CustomFormat = "0.0h"; Chart1.AxisY.ScaleUnit = 1; Chart1.AxisY.LabelsFormat.Decimals = 1; } Chart1.AxisX.LabelsFormat.Decimals = 1; Chart1.AxisX.Grids.Major.Visible = false; Chart1.AxisX.Min = arMin; Chart1.AxisX.Max = arMax; Chart1.AxisX.Step = 1; Chart1.AxisX.LabelsFormat.CustomFormat = "0s"; Chart1.AxisX.ScaleUnit = 1; } } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<java code> <script language="javascript" type="text/javascript"> var oInterval=""; var getValue = "0,0,0,4"; //{xflow, point, min, max} var setArray = new Array(4); function fnStopInterval(){ if(oInterval!=""){ window.clearInterval(oInterval); oInterval=""; } } function Button1_onclick() { if(oInterval=="") { SFX_onCallbackReadyDelegate = function (context, result) { var resultTexbox = document.getElementById(´ctl00$ContentPlaceHolder1$txtPoint´); getValue = result; resultTexbox.value = getValue; } oInterval=window.setInterval("test()",1000); // 1 sec } else{ fnStopInterval(); } } function test(){ setArray = getValue.split(","); SFX_SendUserCallback(´ctl00$ContentPlaceHolder1$Chart1´ ,setArray, false); } </script> "Software FX" <noreply@softwarefx.com> wrote in message news:$gdpqWjEHHA.564@webserver3.softwarefx.com... > Yes, you can have a real-time chart using AJAX. > > Can you please post the code you are using and the results (screenshot) you > are getting. > > -- > Francisco Padron > www.chartfx.com > > Link to comment Share on other sites More sharing options...
User (Legacy) Posted November 7, 2006 Author Report Share Posted November 7, 2006 Is that possible make a Real-time chart with Ajax? I know ChartFx2005 support the Real-time chart only on the win form. But I need to make the chart on the web form with flowing X Axis. Actually I did it in first initialized X Axis but while it was changing to next X Axis, a series disapeared. Link to comment Share on other sites More sharing options...
Software FX Posted November 27, 2006 Report Share Posted November 27, 2006 Yes, you can have a real-time chart using AJAX. Can you please post the code you are using and the results (screenshot) you are getting. -- Francisco Padron www.chartfx.com Link to comment Share on other sites More sharing options...
Sri Posted June 19, 2009 Report Share Posted June 19, 2009 Hello,.... I try to draw real time chart, like your desc in this forum. I use linq to sql to retrieve data from db each 1 minute. But...after few minutes, my chart stop (not move/scrolling). If data for my chart get in random, its ok. But if I use linq to sql to retrieve data from db each 1 minute.....again..my chart stop its self after few minutes run (not scrolling again). I think..it is may be because SFX_SendUserCallback not send user callback...so my chart does haven't data. But..may be I am wrong...Any suggestion to resolve it? Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.