Refreshing a SubChart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
JayG
Newbie
Newbie
Posts: 71
Joined: Mon Sep 04, 2006 12:00 am

Refreshing a SubChart

Post by JayG » Thu Jul 23, 2009 10:04 pm

Using TeeChart .NET 4.0.2009.21355
Using VB Express 2008

I am trying to refresh a SubChart using the following method, which worked in TeeChart 3.5:

Dim objects at class level:

Code: Select all

    Dim SubTool As Steema.TeeChart.Tools.SubChartTool
    Dim WithEvents SubChart As Steema.TeeChart.TChart
In the load event handler for the window, after the main chart (TChart1) is set up, I create the SubChart:

Code: Select all

        If SubTool Is Nothing Then
            SubTool = New Steema.TeeChart.Tools.SubChartTool(TChart1.Chart)
            SubChart = SubTool.Charts.AddChart("ZoomChart")
            SubChart.Left = 0
            SubChart.Top = 0
            SubChart.Width = TChart1.Width / 4
            SubChart.Height = TChart1.Height / 4
            SubChart.Header.Visible = False
            SubChart.Aspect.View3D = False
            SubChart.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels
            SubChart.Panel.MarginLeft = 0
            SubChart.Panel.MarginRight = 0
            SubChart.Panel.MarginTop = 0
            SubChart.Panel.MarginBottom = 0
            SubChart.Axes.Bottom.Labels.Visible = False
            SubChart.Axes.Left.Labels.Visible = False
            Line1 = New Steema.TeeChart.Styles.Line(SubChart.Chart)
            Line1.DataSource = FlowTable     'set data source for this series
            Line1.Title = FlowTable.Columns(1).ColumnName    'set series title
            Line1.YValues.DataMember = FlowTable.Columns(1).ColumnName   'which column of table has the Y values
            Line1.XValues.DataMember = FlowTable.Columns(0).ColumnName    'which column of table has the X values
            Line1.XValues.DateTime = True       'x values are date and time values
            Line1.Brush.Transparency = 0        'not transparent
            Line1.Color = Color.Green
            Line1 = New Steema.TeeChart.Styles.Line(SubChart.Chart)
            Line1.DataSource = FlowTable     'set data source for this series
            Line1.Title = FlowTable.Columns(2).ColumnName    'set series title
            Line1.YValues.DataMember = FlowTable.Columns(2).ColumnName   'which column of table has the Y values
            Line1.XValues.DataMember = FlowTable.Columns(0).ColumnName    'which column of table has the X values
            Line1.XValues.DateTime = True       'x values are date and time values
            Line1.Brush.Transparency = 0        'not transparent
            Line1.Color = Color.Red
        End If
In TChart1's AfterDraw event handler, I refresh the SubChart:

Code: Select all

            SubChart.Refresh()
In SubChart's AfterDraw event handler, I do:

Code: Select all

            SubChart.Axes.Bottom.Automatic = False
            SubChart.Axes.Bottom.Minimum = Math.Floor(NPTool.Series.XValues(NPTool.Point))
            SubChart.Axes.Bottom.Maximum = Math.Floor(NPTool.Series.XValues(NPTool.Point)) + 1
The SubChart never refreshes; neither the AfterDraw or Invalidated events fire (I didn't test any other events).

Jay

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

Re: Refreshing a SubChart

Post by Narcís » Fri Jul 24, 2009 11:20 am

Hi Jay,

Could you please attach a simple example project we can run "as-is" to reproduce the problem here?

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

JayG
Newbie
Newbie
Posts: 71
Joined: Mon Sep 04, 2006 12:00 am

Re: Refreshing a SubChart

Post by JayG » Fri Jul 24, 2009 10:39 pm

I'm not sure if this is all the files you need, let me know if you ned more.

Jay
Attachments
SubChartDemo.zip
VB Express 2008 project
(5.6 KiB) Downloaded 691 times

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

Re: Refreshing a SubChart

Post by Narcís » Mon Jul 27, 2009 9:58 am

Hi Jay,

Thanks for the example project but could you also include the "My Project" folder? Otherwise we can not compile your application. There's no need to include "bin" or "lib" folders.

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

JayG
Newbie
Newbie
Posts: 71
Joined: Mon Sep 04, 2006 12:00 am

Re: Refreshing a SubChart

Post by JayG » Mon Jul 27, 2009 5:02 pm

OK, here it is.

Jay
Attachments
My Project.zip
(5.86 KiB) Downloaded 682 times

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

Re: Refreshing a SubChart

Post by Sandra » Tue Jul 28, 2009 9:58 am

Hello JayG,

I could reproduce the problem of refresh subChart with version 4, but we can reproduce with version 3 too. Please you could say what is the exactly version 3, you tested and has not appeared the issue?

On the other hand,It has to communicate that you can solve problem assign for example SubChart BeforeDraw Event to TChart1 BeforeDraw Event. Please add next changes in your code.

Code: Select all

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Line1 As Steema.TeeChart.Styles.Line
        Line1 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
        Line1.FillSampleValues(200)
        MinX.Text = 0
        MaxX.Text = 201
        If SubTool Is Nothing Then
            SubTool = New Steema.TeeChart.Tools.SubChartTool(TChart1.Chart)
            SubChart = SubTool.Charts.AddChart("SubChart")
            SubChart.Left = 0
            SubChart.Top = 0
            SubChart.Width = TChart1.Width / 4
            SubChart.Height = TChart1.Height / 4

            SubChart.Header.Visible = False
            SubChart.Aspect.View3D = False
            SubChart.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels
            SubChart.Panel.MarginLeft = 0
            SubChart.Panel.MarginRight = 0
            SubChart.Panel.MarginTop = 0
            SubChart.Panel.MarginBottom = 0
            SubChart.Axes.Bottom.Labels.Visible = True
            SubChart.Axes.Left.Labels.Visible = False
            Line1 = New Steema.TeeChart.Styles.Line(SubChart.Chart)
            Line1.FillSampleValues(200)
            Line1.Color = Color.Red

        End If
        'Asign SubChart_BeforeDraw Event to TChart1.BeforeDraw Event<--this solve the problem
        AddHandler TChart1.BeforeDraw, AddressOf SubChart_BeforeDraw
    End Sub
Also, we considered that if you have assign to SubChart one event should not be assigned to the Chart , so we added this issue to list of bug Report with number[TF02014298]and we will try to fix it for next versions of TeeChart .NET.


I hope that 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

JayG
Newbie
Newbie
Posts: 71
Joined: Mon Sep 04, 2006 12:00 am

Re: Refreshing a SubChart

Post by JayG » Tue Jul 28, 2009 3:06 pm

It works using TeeChart .NET version 3.5.3056.18834 and VB Express 2005. I didn't try that version of TeeChart .NET in VB Express 2008.

Thanks for the suggested workaround.

Jay

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

Re: Refreshing a SubChart

Post by Sandra » Wed Jul 29, 2009 8:19 am

Hello JayG,

Thanks, for information. I could check that this versions works fine.
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

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

Re: Refreshing a SubChart

Post by Sandra » Wed Aug 05, 2009 7:44 am

Hello JayG,

I found other solution for, your problem with SubChart and events works.You only, must to reset SubChart.Parent. Please see next example and check that works fine.

Code: Select all

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles MyBase.Load
    Dim Line1 As Steema.TeeChart.Styles.Line
        Line1 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
        Line1.FillSampleValues(200)
        MinX.Text = 0
        MaxX.Text = 201
        If SubTool Is Nothing Then
            SubTool = New Steema.TeeChart.Tools.SubChartTool(TChart1.Chart)
      SubChart = SubTool.Charts.AddChart("SubChart")
      SubChart.Chart.Parent = SubChart 'add this line


            SubChart.Left = 0
            SubChart.Top = 0
            SubChart.Width = TChart1.Width / 4
            SubChart.Height = TChart1.Height / 4

            SubChart.Header.Visible = False
            SubChart.Aspect.View3D = False
            SubChart.Panel.MarginUnits = 
Steema.TeeChart.PanelMarginUnits.Pixels
            SubChart.Panel.MarginLeft = 0
            SubChart.Panel.MarginRight = 0
            SubChart.Panel.MarginTop = 0
            SubChart.Panel.MarginBottom = 0
            SubChart.Axes.Bottom.Labels.Visible = True
            SubChart.Axes.Left.Labels.Visible = False
            Line1 = New Steema.TeeChart.Styles.Line(SubChart.Chart)
            Line1.FillSampleValues(200)
            Line1.Color = Color.Red

    End If
    AddHandler SubChart.BeforeDraw, AddressOf SubChart_BeforeDraw 'set event
    End Sub

Also, I has communicated that the bug has been fixed for next maintenance release.

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

JayG
Newbie
Newbie
Posts: 71
Joined: Mon Sep 04, 2006 12:00 am

Re: Refreshing a SubChart

Post by JayG » Wed Aug 05, 2009 8:47 pm

Thanks, I like that workaround better.

Jay

Post Reply