Page 1 of 1

Chart zoom very slow

Posted: Mon Dec 13, 2010 9:03 am
by 15656586
Hi.
I'm using visual studio 2005 aspx c#.net
the problem is my data are very big
i have about 40-250 series in one chart and record data is about 2000-3000 but the time is very very long.it's take about 50-60 second when i zoom or render. i think it's take too much time.
do yo have any idea for improve process time ?

here this is my testing code

P.S. i'm so sorry about my English language. :mrgreen:

Code: Select all

   <tchart:WebChart id="WebChart1" style="Z-INDEX: 100; LEFT: 24px; POSITION: absolute; TOP: 40px" runat="server"
				Width="432px" Height="290px" 
				Config="AAEAAAD/////AQAAAAAAAAAMAgAAAFJUZWVDaGFydCwgVmVyc2lvbj00LjEuMjAxMC4xMTMwMSwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj05YzgxMjYyNzZjNzdiZGI3DAMAAABRU3lzdGVtLkRyYXdpbmcsIFZlcnNpb249Mi4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iMDNmNWY3ZjExZDUwYTNhBQEAAAAVU3RlZW1hLlRlZUNoYXJ0LkNoYXJ0SwAAABAuQ3VzdG9tQ2hhcnRSZWN0Fy5QYW5lbC5JbWFnZUJldmVsLldpZHRoHS5QYW5lbC5JbWFnZUJldmVsLlBlbi5WaXNpYmxlEi5QYW5lbC5CZXZlbC5Jbm5lchUuUGFuZWwuQmV2ZWwuQ29sb3JPbmUVLlBhbmVsLkJldmVsLkNvbG9yVHdvEi5QYW5lbC5CZXZlbC5PdXRlchYuUGFuZWwuU2hhZG93LkJsdXJTaXplFS5QYW5lbC5TaGFkb3cuVmlzaWJsZSAuUGFuZWwuQnJ1c2guR3JhZGllbnQuU3RhcnRDb2xvciEuUGFuZWwuQnJ1c2guR3JhZGllbnQuTWlkZGxlQ29sb3IQLlBhbmVsLlBlbi5Db2xvchIuUGFuZWwuUGVuLlZpc2libGURLlBhbmVsLlBlbi5FbmRDYXAeLkxlZ2VuZC5TeW1ib2wuU2hhZG93LkJsdXJ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XMBAAAAB3ZhbHVlX18ACAIAAAACAAAABfv///8UU3lzdGVtLkRyYXdpbmcuQ29sb3IEAAAABG5hbWUFdmFsdWUKa25vd25Db2xvcgVzdGF0ZQEAAAAJBwcDAAAACoAAAP4AAAAAAAACAAH6////+////wqAAAD+AAAAAAAAAgAB+f////z///8BAAAABAAAAAEB+P////v///8K/+rq/gAAAAAAAAIAAff////7////Cv/q6v4AAAAAAAACAAH2////+////wqAAAD+AAAAAAAAAgABBfX///8gU3lzdGVtLkRyYXdpbmcuRHJhd2luZzJELkxpbmVDYXABAAAAB3ZhbHVlX18ACAMAAAACAAAABAAAAAQAAAAEAAAABAAAAAH0////+////woAAAD/AAAAAAAAAgAEAAAACQ0AAAAGDgAAAAZUYWhvbWEMAAAAAABAQQHx////+////wrAwMD/AAAAAAAAAgAEAAAAAfD////7////CsDAwP8AAAAAAAACAAEB7/////v///8Kqamp/wAAAAAAAAIABAAAAAQAAAAB7v////v///8Kqamp/wAAAAAAAAIABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAEAAAAAAEEAAAABAAAAAHt////+////wr/6ur/AAAAAAAAAgAEAAAAAAAEAAAABAAAAAEAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAQAAAAEAAAAAQAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAARDQAAAAEAAAAGFAAAAA1DaGFydCBab29taW5nCw=="
				TempChart="Httphandler" 
				AutoPostback="True" 
				GetChartFile="GetChart.aspx"
				 OnAfterDraw="WebChart1_AfterDraw" 
				 OnClickAxis="WebChart1_ClickAxis" 
				 OnClickSeries="WebChart1_ClickSeries"></tchart:WebChart>

Code: Select all

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;

using Steema.TeeChart.Web;
using Steema.TeeChart.Styles;

public partial class testPage : System.Web.UI.Page
{
    private int clickedX;
    private int clickedY;
    private string msgText;

    protected void Page_Load(object sender, EventArgs e)
    {

        clickedX = -1;
        clickedY = -1;
        msgText = "";
        // Put user code to initialize the page here
        // ****************************************************
        // The data load code for WebChart1 demostrates a technique to save 
        // data between page calls. The Chart is saved as a TeeChart template 
        // to a session variable.
        // ****************************************************
        Steema.TeeChart.Chart ch1 = WebChart1.Chart;
        MemoryStream tmpChart = new MemoryStream();

        if (Session["ch1"] == null)
        {



            if (ch1.Tools.Count < 1)
            {
                ch1.Tools.Add(new Steema.TeeChart.Tools.ZoomTool());
                ch1.Tools.Add(new Steema.TeeChart.Tools.SeriesHotspot());
            }

            ((Steema.TeeChart.Tools.ZoomTool)ch1.Tools[0]).ZoomPenColor = Color.OliveDrab;
            ((Steema.TeeChart.Tools.SeriesHotspot)ch1.Tools[1]).Style = MarksStyles.LabelPercentTotal;
            //((Points)ch1.Series[0]).Pointer.Pen.Visible = false;
            //((Points)ch1.Series[0]).Pointer.HorizSize = 2;
            //((Points)ch1.Series[0]).Pointer.VertSize = 2;
            //((Points)ch1.Series[1]).Pointer.Pen.Color = Color.FromArgb(79, 79, 255);
            //((Points)ch1.Series[1]).Pointer.HorizSize = 2;
            //((Points)ch1.Series[1]).Pointer.VertSize = 2;

            DataTable Volt = new DataTable();
            DataTable newVolt = new DataTable();

            newVolt = createSrcChart("123", "2010-12-01 06:30", "2010-12-10 06:30");

            //MyTbCollection objTb = new MyTbCollection();
            //newVolt = objTb.Select("", Volt, "strID=1");




            //string[] blockName = {   "b01", "b02", "b03", "b04", "b05"
            //                    ,"b06", "b07", "b08", "b09", "b10" 
            //                    ,"b11", "b12", "b13", "b14", "b15"
            //                    ,"b16", "b17", "b18", "b19", "b20" 
            //                    ,"b21", "b22", "b23", "b24", "b25"
            //                    ,"b26", "b27", "b28"};

            string[] blockName = {   "b01", "b02", "b03", "b04", "b05"
                                    ,"b06", "b07", "b08", "b09", "b10" 
                                    ,"b11", "b12", "b13", "b14", "b15"
                                    ,"b16", "b17", "b18", "b19", "b20" 
                                    ,"b21", "b22", "b23", "b24"};

            TransLate tran = new TransLate();
            MyCalender calendar = new MyCalender();
            for (int i = 0; i < 24; i++)
            {
                ch1.Series.Add(new Steema.TeeChart.Styles.Line());

                for (int j = 0; j < newVolt.Rows.Count; j++)
                {
                    string colName = blockName[i].ToString();
                    DateTime dt1 = calendar.ToEnDate(newVolt.Rows[j]["RecTime"].ToString());
                    string value = newVolt.Rows[j][colName].ToString();
                    if (value == "")
                    {

                    }
                    else
                    {
                        double y = double.Parse(tran.ToVoltage(value));
                        ch1.Series[i].Add(dt1, y, Color.DarkMagenta);

                    }
                }
            }

            ch1.Chart.Axes.Left.Automatic = false;
            ch1.Chart.Axes.Left.SetMinMax(0, 20);


            ch1.Chart.Axes.Bottom.Automatic = false;
            ch1.Chart.Axes.Bottom.SetMinMax(calendar.ToEnDate("2010-12-01 06:30"), calendar.ToEnDate("2010-12-11 06:30"));

            //export Chart to a MemoryStream template
            ch1.Export.Template.Save(tmpChart);
            //save template to a Session variable
            Session.Add("ch1", tmpChart);
        }
        else
        {
            //retrieve the session stored Chart
            tmpChart = (MemoryStream)Session["ch1"];
            //set the Stream position to 0 as the last read/write
            //will have moved the position to the end of the stream
            tmpChart.Position = 0;
            //import saved Chart
            WebChart1.Chart.Import.Template.Load(tmpChart);

            //check whether zoom request is being sent
            CheckZoom(WebChart1);
        }

    }

    public DataTable createSrcChart(string deviceID
                                  , string startTime, string endTime)
    {
        MyTbCollection objTb = new MyTbCollection();
        MyCalender calendar = new MyCalender();
        DateTime dtStart = calendar.ToEnDate(startTime);
        DateTime dtEnd = calendar.ToEnDate(endTime);

        StringInfo strInfo = new StringInfo();
        DataTable stringTb = new DataTable();
        DataTable newVoltTb = new DataTable("newVoltTb");
        try
        {

            startTime = calendar.ToQuery(startTime, false);
            endTime = calendar.ToQuery(endTime, false);
            stringTb = strInfo.Info(deviceID);
            newVoltTb = strInfo.execVoltage(deviceID, startTime, endTime);

        }
        catch (Exception ex)
        //catch
        {
            WebAlert.WriteLog("Device/History", "createSrcChart", ex.Message);
        }
        return newVoltTb;

    }



    private void CheckZoom(WebChart wChart)
    {
        ArrayList zoomedState = (ArrayList)Session[wChart.ID + "Zoomed"];
        zoomedState = ((Steema.TeeChart.Tools.ZoomTool)wChart.Chart.Tools[0]).SetCurrentZoom(Request,
           zoomedState);
        if (zoomedState == null)
            Session.Remove(wChart.ID + "Zoomed");
        else
            Session.Add(wChart.ID + "Zoomed", zoomedState);
    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
        //
        // CODEGEN: This call is required by the ASP.NET Web Form Designer.
        //
        InitializeComponent();
        base.OnInit(e);

    }

    /// 
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// 
    private void InitializeComponent()
    {

    }
    #endregion

    protected void WebChart1_ClickAxis(object sender, ImageClickEventArgs e)
    {
        Steema.TeeChart.Axis axis = (Steema.TeeChart.Axis)sender;
        clickedX = e.X;
        clickedY = e.Y;
        double axisValue = 0;
        if (axis.Horizontal)
            axisValue = ((Steema.TeeChart.Axis)sender).CalcPosPoint(clickedX);
        else
            axisValue = ((Steema.TeeChart.Axis)sender).CalcPosPoint(clickedY);
        msgText = "Clicked Axis at:" + "\n\rValue: " + axisValue.ToString("#.00");
    }
    protected void WebChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
        if (clickedX != -1)
        {
            g.Font.Color = Color.Maroon;
            g.TextOut(clickedX, clickedY, msgText);
        }
    }
    protected void WebChart1_ClickSeries(object sender, Series s, int valueIndex, EventArgs e)
    {
        Steema.TeeChart.Chart tChart = ((WebChart)sender).Chart;

        clickedX = s.CalcXPos(valueIndex);
        clickedY = s.CalcYPos(valueIndex);
        msgText = "Clicked Series: " + tChart.Series.IndexOf(s).ToString() + "\n\rValue: " + s.YValues[valueIndex].ToString("#0.00");
    }



}


Re: Chart zoom very slow

Posted: Mon Dec 13, 2010 2:39 pm
by 10050769
Hello aonzuza,

I recommend you take a look in our technical articles concretely in the Real-time Charting that can give you ideas how do your chart faster.

On the other hand, I try to reproduce your problem with your attached code and it doesn't works for me. Can you please, send us a simple project, because we can reproduce your problem exactly here?

Thanks,