Page 1 of 1

Refreshing a SubChart

Posted: Thu Jul 23, 2009 10:04 pm
by 9792387
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

Re: Refreshing a SubChart

Posted: Fri Jul 24, 2009 11:20 am
by narcis
Hi Jay,

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

Thanks in advance.

Re: Refreshing a SubChart

Posted: Fri Jul 24, 2009 10:39 pm
by 9792387
I'm not sure if this is all the files you need, let me know if you ned more.

Jay

Re: Refreshing a SubChart

Posted: Mon Jul 27, 2009 9:58 am
by narcis
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.

Re: Refreshing a SubChart

Posted: Mon Jul 27, 2009 5:02 pm
by 9792387
OK, here it is.

Jay

Re: Refreshing a SubChart

Posted: Tue Jul 28, 2009 9:58 am
by 10050769
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,

Re: Refreshing a SubChart

Posted: Tue Jul 28, 2009 3:06 pm
by 9792387
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

Re: Refreshing a SubChart

Posted: Wed Jul 29, 2009 8:19 am
by 10050769
Hello JayG,

Thanks, for information. I could check that this versions works fine.

Re: Refreshing a SubChart

Posted: Wed Aug 05, 2009 7:44 am
by 10050769
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,

Re: Refreshing a SubChart

Posted: Wed Aug 05, 2009 8:47 pm
by 9792387
Thanks, I like that workaround better.

Jay