Zoom control not clearing when in update panel

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
richheim
Newbie
Newbie
Posts: 58
Joined: Tue Sep 18, 2007 12:00 am

Zoom control not clearing when in update panel

Post by richheim » Tue May 27, 2008 2:12 pm

I'm using a financial graph - place graph in ASP.NET AJAX Update panel. All works well except the zoom tool does not clear from the screen after use.

thanks,
Rich

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.Web.Handlers;
using System.IO;
using System.Text;

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

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

    private DataBase db = new DataBase(); 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillChart();
            getDetailedData();

        }

        ChartSession();
        CheckZoom(WebChart1);
    }

    protected void FillChart()
    {
        Steema.TeeChart.Chart chart1 = WebChart1.Chart;
        Steema.TeeChart.Styles.Volume series1 = (Steema.TeeChart.Styles.Volume)chart1.Series[0];
        chart1.Tools.Add(new Steema.TeeChart.Tools.ZoomTool());
        ((Steema.TeeChart.Tools.ZoomTool)chart1.Tools[0]).ZoomPenColor = Color.OliveDrab;
        //chart1.Tools.Add(new Steema.TeeChart.Tools.ScrollTool());

        series1.XValues.DateTime = true;
        chart1.Axes.Bottom.Labels.DateTimeFormat = "MM/yyyy";
        chart1.Axes.Bottom.Labels.MultiLine = true;
        chart1.Panel.MarginBottom = 10;

        // Legend
        Steema.TeeChart.Legend legend = chart1.Legend;
        legend.ImageMode = Steema.TeeChart.Drawing.ImageMode.Stretch;


        DataSet ds = new DataSet();
        ds = getSummaryData();
        series1.Title = "Date/Time";
        int numOfRows = ds.Tables["summary"].Rows.Count;
        /*
        double[] arrTime = new double[numOfRows];
        DateTime[] arrDate = new DateTime[numOfRows];
        for (int i = 0; i < numOfRows; i++)
        {
            DataRow row = db.dtSummary.Tables["summary"].Rows[i];
            arrTime[i] = Convert.ToDouble(row["TOTAL_TIME"]);
            arrDate[i] = Convert.ToDateTime(row["APPROVE_DT"]);
        }
         */
        series1.Clear();
        series1.DataSource = ds.Tables["summary"];
        series1.XValues.DataMember = "APPROVE_DT";
        series1.YValues.DataMember = "TOTAL_TIME";
        series1.CheckDataSource();
        //series1.Add(arrDate, arrTime);
    }


    private DataSet getSummaryData()
    {
        DataSet ds = new DataSet();
        if (db.open())
        {
            db.getSummaryDataSet();
            ds = db.dtSummary;
        }
        return ds;
    }


    private DataSet getDetailedData()
    {
        DataSet ds = new DataSet();
        if (db.open())
        {
            db.getDetailedDataSet();
            ds = db.dtDetailed;
        }
        return ds;
    }


    protected void ChartSession()
    {
        Steema.TeeChart.Chart ch1 = WebChart1.Chart;
        MemoryStream tmpChart = new MemoryStream();
        if (Session["WebChart1"] == null)
        {
            //export Chart to a MemoryStream template
            ch1.Export.Template.Save(tmpChart);
            //save template to a Session variable
            Session.Add("WebChart1", tmpChart);
        }
        else
        {
            //retrieve the session stored Chart
            tmpChart = (MemoryStream)Session["WebChart1"];
            //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);


        }
    }


    private void CheckZoom(WebChart wChart)
    {
    
        ArrayList zoomedState = (ArrayList)Session[wChart.ID + "Zoomed"];
        if (wChart.Chart.Tools.Count > 0)
        {
            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);
                
            }
        }
    }


    public void WebChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
        //output text message to the rendered Chart.

        if (clickedX != -1)
        {
            //g.Font.Bold=true;
            g.Font.Color = Color.OrangeRed;
            g.TextOut(clickedX, clickedY, msgText);
        }

    }



    public void WebChart1_ClickBackground(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        //event triggered when any point on the Chart is clicked. If the ClickSeries event is active
        //it will take precedence when a Series is clicked.
        clickedX = e.X;
        clickedY = e.Y;
        msgText = "Clicked background\n\rX:" + WebChart1.Chart.Axes.Bottom.CalcPosPoint(clickedX).ToString("#0.00")
            + ", Y:" + WebChart1.Chart.Axes.Left.CalcPosPoint(clickedY).ToString("#0.00");
    }

    public void WebChart1_ClickSeries(object sender, Steema.TeeChart.Styles.Series s, int valueIndex, System.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");
    }

}


// Database obj
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.OracleClient;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;

/// <summary>
/// Summary description for DataBase
/// </summary>
public class DataBase
{
    //Database access variables
    
    private string ConnectionString;
    protected System.Data.OracleClient.OracleConnection dbConnection;
    protected System.Data.OracleClient.OracleCommand dbCommand;
    protected System.Data.OracleClient.OracleDataReader dbReader;
    protected System.Data.OracleClient.OracleDataAdapter dbAdapter;
    
    private string strDetailedSelect = "SELECT PROGRAM_ID, ORDERID, ORDERSEQ, CONTRACT_NUM, DELIVERY_ORDER_NUM, APPROVED_CD, APPROVE_BUYER, LOAD_DT, SUBMIT_DT, " +
            "VENDOR_REVIEW_DT, DSCP_TIME, VEND_TIME, CAT_TYPE FROM PV_USAGE_HDR WHERE APPROVED_CD = 'A' AND SUBSTR(APPROVE_BUYER,1,4) <> 'AUTO'";
    private string strSummarySelect = "SELECT PROGRAM_ID, ORDERID, CONTRACT_NUM, DELIVERY_ORDER_NUM, APPROVE_BUYER, APPROVE_DT, SUBMIT_DT, " +
            "TOTAL_TIME, CAT_TYPE FROM PV_USAGE_SUMMARY WHERE SUBSTR(APPROVE_BUYER,1,4) <> 'AUTO'";
    public DataSet dtDetailed = new DataSet();
    public DataSet dtSummary = new DataSet();

    public DataBase()
    {

    }

    public bool open()
    {

        
        ConnectionString = "User ID=myid;Password=mypass;Data Source=mydb";
        dbConnection = new OracleConnection(ConnectionString);
        dbConnection.Open();
        if (dbConnection.State != ConnectionState.Open)
        {
            return false;
        }
        return true;
    }

    public void getDetailedDataSet()
    {
        if (dtDetailed.Tables.Count != 0)
            return;
        if (dbConnection.State != ConnectionState.Open)
            dbConnection.Open();
        dbCommand = new OracleCommand();
        dbCommand.CommandType = CommandType.Text;
        dbCommand.Connection = dbConnection;

        //Read detailed dataset from database

        dbCommand.CommandText = strDetailedSelect;
        dbAdapter = new OracleDataAdapter(strDetailedSelect, dbConnection);
        dbAdapter.Fill(dtDetailed, "detailed");
        dbAdapter.Dispose();
        dbConnection.Close();
    }

    public void getSummaryDataSet()
    {
        if (dtSummary.Tables.Count != 0)
            return;
        if (dbConnection.State != ConnectionState.Open)
            dbConnection.Open();
        dbCommand = new OracleCommand();
        dbCommand.CommandType = CommandType.Text;
        dbCommand.Connection = dbConnection;

        //Read detailed dataset from database

        dbCommand.CommandText = strDetailedSelect;
        dbAdapter = new OracleDataAdapter(strSummarySelect, dbConnection);
        dbAdapter.Fill(dtSummary, "summary");
        dbAdapter.Dispose();
        dbConnection.Close();


    }

    public DateTime OracleDateToDateTime(string oDate)
    {
        // taking the format of dd/mm/yyyy ...

        string[] arr = oDate.Split(new char[] { '/' });
        int day = int.Parse(arr[0]);
        int month = int.Parse(arr[1]);
        int year = int.Parse(arr[2]);
        DateTime dt = new DateTime(year, month, day);

        return dt;
    }
}

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue May 27, 2008 2:52 pm

Hi Rich,

This works fine for me here. I have sent you an example at your forums contact e-mail address. Could you please check if it works fine at your end?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

richheim
Newbie
Newbie
Posts: 58
Joined: Tue Sep 18, 2007 12:00 am

Get same problem

Post by richheim » Wed May 28, 2008 6:19 pm

I get the same problem using the code you emailed.

I DID change the tmpChart to HttpHandler and added
<add verb="*" path="TeeChartImgGen.ashx" type="Steema.TeeChart.Web.TeeChartImgGen, TeeChart"/>
to the WebConfig. I did this because, otherwise (using "session") I just get a box with a red 'X' in it ... no chart.

thanks,
Rich

richheim
Newbie
Newbie
Posts: 58
Joined: Tue Sep 18, 2007 12:00 am

GetChart

Post by richheim » Wed May 28, 2008 6:31 pm

Ah - I got the tmpChart=Session working. forgot to add GetChart.aspx.

Same issue however...

richheim
Newbie
Newbie
Posts: 58
Joined: Tue Sep 18, 2007 12:00 am

In VS 2005

Post by richheim » Wed May 28, 2008 6:34 pm

BTW - I am running the program from within the Visual Studio 2005 environment using .net 2.0, just in case this makes any difference. I choose the "ZoomUpdatePanel.aspx" as a start page and ran from Debug/Start w/o debugging option.


Rich

richheim
Newbie
Newbie
Posts: 58
Joined: Tue Sep 18, 2007 12:00 am

Post by richheim » Mon Jun 02, 2008 12:57 pm

If you'd like I can send you the complete project I built around the sample code you gave me - this would possibly narrow the problem down to my machine.

Can you give me the link to the file area again?

thanks,
rich

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Jun 02, 2008 1:48 pm

Hi rich,

Thanks for your collaboration but it's not necessary. We could reproduce the issue here and we are investigating it. We'll get back to you when we have further news.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jun 04, 2008 12:23 pm

Hi rich,

We have been doing some more tests here and we are not able to reproduce the issue using latest TeeChart for .NET v3 maintenance release (23rd May build). Could you please try using latest version available at the client area?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

richheim
Newbie
Newbie
Posts: 58
Joined: Tue Sep 18, 2007 12:00 am

Post by richheim » Wed Jun 04, 2008 2:20 pm

Ok - I thought I had that release but - I'll download it again and give it another try.

thanks,
Rich

richheim
Newbie
Newbie
Posts: 58
Joined: Tue Sep 18, 2007 12:00 am

Working!

Post by richheim » Wed Jun 04, 2008 7:25 pm

Yup - this seems to work.

thanks,
Rich

Post Reply