Jump to content
Software FX Community

ChartFX crashes with "invalid cast" error when dragging marker...


User (Legacy)

Recommended Posts

I think this may be related to Q6002124 in the Knowledge Base, but not

exactly...and that article says it was fixed in Build <followed by a

blank> - does that mean the build hasn't been released yet?

Build a chart, set AllowDrag to True, make the markers Diamond. Add two

series to it - make one of them all zeros. Use the ListProvider object as

the DataSource for the Chart. On running it, it will let you drag the

markers for the non-zero series, but the minute you mouseclick on a marker

from the all-zero series you get an "Invalid Cast" error.

Here's the sample code on my form - hope I'm not doing a faux pas by making

a newsgroup post too long :)

--TG

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents Chart1 As SoftwareFX.ChartFX.Chart

Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid

<System.Diagnostics.DebuggerStepThrough()> Private Sub

InitializeComponent()

Dim ImageBorder1 As SoftwareFX.ChartFX.Borders.ImageBorder = New

SoftwareFX.ChartFX.Borders.ImageBorder(SoftwareFX.ChartFX.Borders.ImageBorde

rType.Emboss)

Me.Chart1 = New SoftwareFX.ChartFX.Chart()

Me.DataGrid1 = New System.Windows.Forms.DataGrid()

CType(Me.DataGrid1,

System.ComponentModel.ISupportInitialize).BeginInit()

Me.SuspendLayout()

'

'Chart1

'

Me.Chart1.AllowDrag = True

Me.Chart1.BorderObject = ImageBorder1

Me.Chart1.DesignTimeData = "C:\Program Files\ChartFX for

.NET\Wizard\StepLines.txt"

Me.Chart1.Gallery = SoftwareFX.ChartFX.Gallery.Step

Me.Chart1.LineWidth = 3

Me.Chart1.Location = New System.Drawing.Point(60, 8)

Me.Chart1.MarkerShape = SoftwareFX.ChartFX.MarkerShape.Diamond

Me.Chart1.Name = "Chart1"

Me.Chart1.NValues = 10

Me.Chart1.Size = New System.Drawing.Size(652, 304)

Me.Chart1.TabIndex = 0

'

'DataGrid1

'

Me.DataGrid1.DataMember = ""

Me.DataGrid1.HeaderForeColor =

System.Drawing.SystemColors.ControlText

Me.DataGrid1.Location = New System.Drawing.Point(60, 316)

Me.DataGrid1.Name = "DataGrid1"

Me.DataGrid1.Size = New System.Drawing.Size(652, 192)

Me.DataGrid1.TabIndex = 1

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(816, 545)

Me.Controls.AddRange(New System.Windows.Forms.Control()

{Me.DataGrid1, Me.Chart1})

Me.Name = "Form1"

Me.Text = "Form1"

CType(Me.DataGrid1,

System.ComponentModel.ISupportInitialize).EndInit()

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load

Dim arlSeries1 As New ArrayList()

Dim arlSeries2 As New ArrayList()

Dim arlAllSeries As New ArrayList()

Dim lstProvider As New

SoftwareFX.ChartFX.Data.ListProvider(arlAllSeries)

Dim intAxisCounter As Integer

Dim intCounter As Integer

For intCounter = 1 To 10

Chart1().AxisX().Label(intCounter) = Now.AddHours(intCounter)

arlSeries1.Add(0)

arlSeries2.Add(intCounter)

Next

arlAllSeries.Add(arlSeries1)

arlAllSeries.Add(arlSeries2)

Chart1.Series(1).YAxis() = CType(3, SoftwareFX.ChartFX.YAxis)

Chart1.Axis(0).AutoScale = True

Chart1.Axis(1).AutoScale = True

Chart1.Axis(0).Position = SoftwareFX.ChartFX.AxisPosition.Near

Chart1.Axis(1).Position = SoftwareFX.ChartFX.AxisPosition.Near

Chart1.DataSource = lstProvider

Chart1.RecalcScale()

For intAxisCounter = 0 To Chart1.Axis.Count - 1

If intAxisCounter < 1 Or intAxisCounter > 2 Then

If Chart1.Axis(intAxisCounter).Min =

Chart1.Axis(intAxisCounter).Max Then

Chart1.Axis(intAxisCounter).Min -= 1

Chart1.Axis(intAxisCounter).Max += 1

End If

End If

Chart1.Axis(intAxisCounter).Visible = True

Next

End Sub

End Class

Link to comment
Share on other sites

Do you have multiple Y-Axis ? if so, this is indeed what is described in

article Q6002124.

This article is shown as a "Known Problem" meaning that we fixed it

internally but the build that contains this fix hasn't been released yet. We

should be releasing a new SP in the next few days, if you need this fix

urgently please contact our support department.

--

FP

Software FX, Inc.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...