ColorGrid: index out of bound exception

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
yves bourgeois
Newbie
Newbie
Posts: 29
Joined: Wed Mar 05, 2008 12:00 am

ColorGrid: index out of bound exception

Post by yves bourgeois » Tue Apr 22, 2008 12:48 pm

Hi, Narcis

I have the following problem with the colorgrid. In my project, I have three webcharts, each containing a colorgrid serie. When the web page is loaded, the main colorgrid is shown nicely in the center of the screen. After capturing a clickSerie event on that grid, I need to show the two other colorgrids. When trying to do so, I got an index out of bounds exception, which occurs outside the scope of my source code.

Since the structure of the page is rather complex, I have tried to reproduce this behaviour using a simple, seperate project, which I have uploaded on your upload page (it's called 'ColorGridTest.rar'). Here, I get the same error after drawing a line which has its begin point inside the area of the colorgrid, and its end point outside the area, but with its y-coordinate below the maximum z-coordiante of the colorgrid. Only in this way, I get the error message (you can try different combinations by switching the different possibilities in the source code, they will not cause any exception).

Please note that this is not completely in line with the original project structure. Originaly, I draw the main colorgrid, capture a click event on this colorgrid, fill the flat arrays with data and try to draw the two other colorgrids. This results in the uncatchable exception.

Since this is blocking my progress of the project completely, I would like to add that this has a high priority for us, much more than the issues I have described in the other forum topic.

With kind regards,

Yves Bourgeois

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 Apr 22, 2008 2:08 pm

Hi Yves,

Thanks for the example project. I've been able to reproduce the issue here and added it (TF02012994) to our defect list as a high priority item to be fixed for next releases.

In the meantime you can use code below that populates ColorGrid series without using arrays.

Code: Select all

    Dim x(120) As Double
    Dim y(120) As Double
    Dim z(120) As Double
    Dim colorArray(120) As System.Drawing.Color

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        SetWebChartProperties()

        'CreateTestData()

        DrawColorGrid()

        DrawLine()
    End Sub

    Private Sub SetWebChartProperties()
        WebChart1.Chart.Axes.Bottom.Automatic = True
        WebChart1.Chart.Axes.Left.Automatic = True
        WebChart1.Chart.Aspect.View3D = False
    End Sub

    Private Sub DrawLine()
        Dim tempLine As Steema.TeeChart.Styles.Line
        tempLine = New Steema.TeeChart.Styles.Line(WebChart1.Chart)
        tempLine.LinePen.Width = 3

        'Begin point
        tempLine.Add(0, 8)
        'tempLine.Add(0, 75)

        'End point
        'tempLine.Add(150, 75)
        'tempLine.add(75, 75)
        tempLine.Add(150, 25)
        'tempLine.add(75, 25)
    End Sub


    Private Sub DrawColorGrid()
        Dim tempColorGrid As Steema.TeeChart.Styles.ColorGrid
        tempColorGrid = New Steema.TeeChart.Styles.ColorGrid(WebChart1.Chart)

        tempColorGrid.IrregularGrid = True

        Dim counter As Integer = 0
        For i As Integer = 0 To 10
            For j As Integer = 0 To 10
                x(counter) = i * 10
                y(counter) = 0
                z(counter) = j * 5
                colorArray(counter) = System.Drawing.Color.Blue
                tempColorGrid.Add(x(counter), y(counter), z(counter), colorArray(counter))
                counter += 1
            Next
        Next
        'tempColorGrid.Add(x, y, z, colorArray)
    End Sub

    Private Sub CreateTestData()
        Dim counter As Integer = 0
        For i As Integer = 0 To 10
            For j As Integer = 0 To 10
                x(counter) = i * 10
                y(counter) = 0
                z(counter) = j * 5
                colorArray(counter) = System.Drawing.Color.Blue
                counter += 1
            Next
        Next
    End Sub
Hope this helps.
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

Post Reply