Teechart .NET v2 Zooming Focus Problem?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
LordWhorfin
Newbie
Newbie
Posts: 24
Joined: Wed Feb 22, 2006 12:00 am
Location: Flagstaff, Arizona, USA

Teechart .NET v2 Zooming Focus Problem?

Post by LordWhorfin » Fri Aug 14, 2009 4:07 pm

Hello,

I have a website that displays weather data using Teechart .NET v2 and Visual Basic. If I zoom into one webchart and then switch to a second webchart, the second webchart uses the same zoom level as the first webchart did. Is there a way to force a webchart to default to it's maximum zoom as defined by the WebChart1.Chart.Axes.Left.Maximum and WebChart1.Chart.Axes.Left.Minimum statements? Below is the code behind for one of my pages.

Code: Select all

Imports mysql.data.mysqlclient
Imports System.IO
Imports System.Data
Imports System.Windows
Imports Steema.TeeChart.TChart
Imports System.Data.SqlClient

Partial Class Data_display_rock_effect
    Inherits System.Web.UI.Page
    Protected Sub startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load



        'Create the DataTable
        Dim dt As New DataTable()
        Dim dt2 As New DataTable()
        'Dim myConnection As New MySqlConnection("server=egr3.egr.nau.edu;uid=wis_str_datt_usr;pwd=gtdnj;database=wisard_streamed_data_test;")
        Dim myConnection As New MySqlConnection("server=wisard-serv1.egr.nau.edu;uid=arb_webpage;pwd=m0(!3lasKc;database=Arb_At_Flagstaff;")
        'Dim myConnection As New MySqlConnection("server=wisard-serv1.egr.nau.edu;uid=ph_web_app;pwd=Jns5@iHD$;database=Arb_At_Flagstaff;")
        'Dim myConnection As New MySqlConnection("server=egr249a-02.egr.nau.edu;uid=wis_str_datt_usr;pwd=gtdnj;database=wisard_streamed_data_test;")
        'Dim myConnection As New SqlConnection("server=mprlsrvr1.bio.nau.edu;uid=wiz_reader;pwd=$x15g53p;database=wiz_test;")
        Dim strSQL, strSQL2 As String

        'get the data into a datatable

        strSQL = "SELECT * FROM processed_data WHERE ProbeID = 7 AND SensorID = 251"
        Dim myAdapter As New MySqlDataAdapter()
        myAdapter.SelectCommand = New MySqlCommand(strSQL, myConnection)
        myAdapter.Fill(dt)
        'test binding to a gridview  (requires empty gridview on aspx page with identifer dgdata
        'dgdata.DataSource = dt
        'dgdata.DataBind()

        'fill sql server version of data adapter
        'strSQL = "SELECT * FROM data WHERE ProbeID = 7 AND SensorID = 251"
        'Dim myAdapter As New SqlDataAdapter()
        'myAdapter.SelectCommand = New SqlCommand(strSQL, myConnection)
        'myAdapter.Fill(dt)

        'create a second table
        strSQL2 = "SELECT * FROM processed_data WHERE ProbeID = 10 AND SensorID = 251"
        Dim myAdapter2 As New MySqlDataAdapter()
        myAdapter2.SelectCommand = New MySqlCommand(strSQL2, myConnection)
        myAdapter2.Fill(dt2)

        'create a second table sql server version
        'strSQL2 = "SELECT * FROM data WHERE ProbeID = 10 AND SensorID = 251"
        'Dim myAdapter2 As New SqlDataAdapter()
        'myAdapter2.SelectCommand = New SqlCommand(strSQL2, myConnection)
        'myAdapter2.Fill(dt2)

        'lets make a teechart!
        'create first series
        Dim Temperature As New Steema.TeeChart.Styles.Points(WebChart1.Chart)
        WebChart1.Chart.Axes.Bottom.Labels.DateTimeFormat = "mm/dd/yyyy"
        WebChart1.Chart.Axes.Bottom.Labels.Angle = 90
        WebChart1.Chart.Axes.Bottom.Labels.Color = Drawing.Color.Black
        WebChart1.Chart.Axes.Left.Maximum = 50
        WebChart1.Chart.Axes.Left.Minimum = -15


        'add one series using datatable dt
        Temperature.DataSource = dt
        Temperature.YValues.DataMember = dt.Columns("measurement").ToString()

        Temperature.XValues.DataMember = dt.Columns("TimeStamp").ToString()
        Dim srt1 As String = dt.Columns("TimeStamp").ToString
        Temperature.LabelMember = srt1
        Temperature.Color = Drawing.Color.DarkBlue
        Temperature.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Cross
        Temperature.Title = "1cm from rock"

        'Dim seriesHotSpot1 As Steema.TeeChart.Tools.SeriesHotspot = New Steema.TeeChart.Tools.SeriesHotspot(WebChart1.Chart)
        'Steema.TeeChart.Styles.MapAction.Mark is the default value
        'seriesHotSpot1.MapAction = Steema.TeeChart.Styles.MapAction.Mark

        'add second series
        Dim Battery_Voltage As New Steema.TeeChart.Styles.Points(WebChart1.Chart)
        'add second series using datatable dt2
        Battery_Voltage.DataSource = dt2
        Battery_Voltage.YValues.DataMember = dt2.Columns("measurement").ToString()

        Battery_Voltage.XValues.DataMember = dt2.Columns("TimeStamp").ToString()
        Battery_Voltage.Color = Drawing.Color.DarkRed
        Battery_Voltage.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Diamond
        Battery_Voltage.Title = "60cm from rock"

        ' add third series (highlight line)
        'Dim highlight As New Steema.TeeChart.Styles.Line(WebChart1.Chart)
        'highlight.XValues.DateTime = True
        'highlight.Add(0, "8/21/2007 11:14:00 AM")
        'highlight.Add(70, DateTime.Parse("8/21/2007 11:14:00 AM")
        'highlight.Title = "Restart of Data Collection"
        'highlight.Color = Drawing.Color.Aqua

        'Dim colorLine1 As New Steema.TeeChart.Tools.ColorLine(WebChart1.Chart)
        'colorLine1.AllowDrag = False
        'colorLine1.Axis = WebChart1.Chart.Axes.Bottom
        'colorLine1.Pen.Color = Drawing.Color.Yellow
        'colorLine1.Value = DateTime.Parse("8/21/2007 11:14:00 AM")
        'colorLine1.Value = Now.ToOADate()

        'add zoom functionality

        Dim zoomTool1 As Steema.TeeChart.Tools.ZoomTool = New Steema.TeeChart.Tools.ZoomTool(WebChart1.Chart)
        CheckZoom(WebChart1)

    End Sub
    Private Sub CheckZoom(ByVal wChart As Steema.TeeChart.Web.WebChart)
        Dim zoomedState As ArrayList = CType(Session((wChart.ID + "Zoomed")), ArrayList)
        zoomedState = CType(wChart.Chart.Tools(0), Steema.TeeChart.Tools.ZoomTool).SetCurrentZoom(Request, zoomedState)
        If (zoomedState Is Nothing) Then
            Session.Remove((wChart.ID + "Zoomed"))
        Else
            Session.Add((wChart.ID + "Zoomed"), zoomedState)
        End If
    End Sub

    Protected Sub ImageButton3_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton3.Click
        Response.Redirect("http://mprlsrvr1.bio.nau.edu/wisard/data_display/rock_effect.aspx")
    End Sub

    Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
        Response.Redirect("http://mprlsrvr1.bio.nau.edu/wisard/data_display/cinder.aspx")
    End Sub

    Protected Sub ImageButton2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton2.Click
        Response.Redirect("http://mprlsrvr1.bio.nau.edu/wisard/data_display/rock_wall.aspx")
    End Sub

    Protected Sub ImageButton4_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton4.Click
        Response.Redirect("http://mprlsrvr1.bio.nau.edu/wisard/data_display/shade_sun.aspx")
    End Sub

    Protected Sub ImageButton5_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton5.Click
        Response.Redirect("http://mprlsrvr1.bio.nau.edu/wisard/default.aspx")
    End Sub

    Protected Sub ImageButton6_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton6.Click
        Response.Redirect("http://mprlsrvr1.bio.nau.edu/wisard/data_display/rock_effect_moist.aspx")
    End Sub

    Protected Sub ImageButton7_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton7.Click
        Response.Redirect("http://mprlsrvr1.bio.nau.edu/wisard/data_display/rock_effect.aspx")
    End Sub
End Class
And here is the URL for the page...

http://mprlsrvr1.bio.nau.edu/wisard/dat ... ffect.aspx

cheers, Paul

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Teechart .NET v2 Zooming Focus Problem?

Post by Sandra » Wed Aug 19, 2009 10:44 am

Hello Paul,
If I zoom into one webchart and then switch to a second webchart, the second webchart uses the same zoom level as the first webchart did. Is there a way to force a webchart to default to it's maximum zoom as defined by the WebChart1.Chart.Axes.Left.Maximum and WebChart1.Chart.Axes.Left.Minimum statements?
I made a simple project I think that works as you want and you can use a similar code for your application. Please, check next code works correctly and solve your problem:

Code: Select all

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim zoomTool1 As Steema.TeeChart.Tools.ZoomTool
    Protected Sub startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load

        Dim tmpChart As System.IO.MemoryStream
        Dim ch1 As Steema.TeeChart.Chart = WebChart1.Chart

        If (Session("ch1") Is Nothing) Then
            Dim bar As Steema.TeeChart.Styles.Bar = New Steema.TeeChart.Styles.Bar(WebChart1.Chart)
            bar.FillSampleValues(100)
            bar.Marks.Visible = False
            WebChart1.Chart.Aspect.View3D = False
            zoomTool1 = New Steema.TeeChart.Tools.ZoomTool(WebChart1.Chart)
            bar.XValues.DateTime = True
            tmpChart = New System.IO.MemoryStream
            WebChart1.Chart.Export.Template.Save(tmpChart)
            'save template to a Session variable
            Session.Add("ch1", tmpChart)
        Else
            'retrieve the session stored Chart
            tmpChart = CType(Session("ch1"), System.IO.MemoryStream)
            '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)
            CheckZoom(WebChart1)
        End If
    End Sub
    Dim y, y1 As Integer
    Private Sub CheckZoom(ByVal wChart As Steema.TeeChart.Web.WebChart)
        Dim zoomedState As ArrayList = Nothing
        zoomedState = CType(wChart.Chart.Tools(0), Steema.TeeChart.Tools.ZoomTool).SetCurrentZoom(Request, zoomedState)
        If (zoomedState Is Nothing) Then
            Session.Remove((wChart.ID + "Zoomed"))
        Else
            Session.Add((wChart.ID + "Zoomed"), zoomedState)
            WebChart1.Chart.Axes.Left.SetMinMax(y, y1 / 2)
        End If
    End Sub
    Protected Sub WebChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles WebChart1.AfterDraw
        y = WebChart1.Chart.Axes.Left.CalcPosValue(WebChart1.Chart.Axes.Left.Maximum)
        y1 = WebChart1.Chart.Axes.Left.CalcPosValue(WebChart1.Chart.Axes.Left.Minimum)
    End Sub
End Class
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

Post Reply