Problem with TreatNulls when adding Values to FastLine

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Stein41
Newbie
Newbie
Posts: 3
Joined: Wed May 23, 2007 12:00 am
Location: Hannover Germany
Contact:

Problem with TreatNulls when adding Values to FastLine

Post by Stein41 » Wed Jan 28, 2009 5:49 pm

Hi,

I have several FastLines in a Chart, which data sources are datatables filled from a Database.
All of them are Timeseries with TreatNullsStyle = DoNotPaint and the X-Values order is set to Ascending.
When the User scrolls the Chart, I only fetch the yet not shown values into a new datatable and use the Series.Add-function.
That works fine when the added values are future to the last series-value.
But when adding a block of values before the first series-value, the TreatNull is ignored.
We bought the Source of Steema so we could have a look.
It seems to me, that when adding values before the first series-value the iColors-array of the series is not set as well. So the function ‘series.IsNull(int index)’ called in FastLine.ShouldDrawPoint returns the wrong result.

I made a little application to reproduce this issue as below.
I ran it in a form with one TeeChart, one Fastline and two buttons.
The Sub ‘AddAfter’ works as expected. The Sub ‘AddBefore’ causes the issue (when calling at least two times).

Is it possible to do something like that?

Thank you ,
Marco

Code: Select all

Imports System.Data.SqlClient

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.TChart1.ShowEditor()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim s As Steema.TeeChart.Styles.FastLine
        s = Me.TChart1.Series(0)

        s.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint
        s.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending
        FillData()
    End Sub

    Private Sub FillData()
        Dim source As DataTable
        Dim r As DataRow

        source = New DataTable("data")

        source.Columns.Add("xval", GetType(Double))
        source.Columns.Add("yval", GetType(Double))

        For i As Integer = 0 To 99
            r = source.Rows.Add
            r("xval") = i
            r("yval") = i
        Next

        Dim s As Steema.TeeChart.Styles.FastLine
        s = Me.TChart1.Series(0)

        s.XValues.DataMember = "xval"
        s.YValues.DataMember = "yval"

        s.DataSource = source

        s.CheckDataSource()
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        addBefore()
    End Sub

    Private Sub addBefore()
        Static start As Integer = -200
        Dim source As DataTable
        Dim r As DataRow

        source = New DataTable("data")

        source.Columns.Add("xval", GetType(Double))
        source.Columns.Add("yval", GetType(Object))

        r = source.Rows.Add
        r("xval") = start
        r("yval") = System.DBNull.Value

        For i As Integer = start To start + 99
            r = source.Rows.Add
            r("xval") = i
            r("yval") = i
        Next

        Dim s As Steema.TeeChart.Styles.FastLine
        s = Me.TChart1.Series(0)

        s.Add(source)

        start -= 200
    End Sub

    Private Sub addAfter()
        Static start1 As Integer = 200
        Dim source As DataTable
        Dim r As DataRow

        source = New DataTable("data")

        source.Columns.Add("xval", GetType(Double))
        source.Columns.Add("yval", GetType(Object))

        r = source.Rows.Add
        r("xval") = start1
        r("yval") = System.DBNull.Value

        For i As Integer = start1 To start1 + 99
            r = source.Rows.Add
            r("xval") = i
            r("yval") = i
        Next

        Dim s As Steema.TeeChart.Styles.FastLine
        s = Me.TChart1.Series(0)

        s.Add(source)

        start1 += 200
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        addAfter()
    End Sub
End Class

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

Post by Narcís » Thu Jan 29, 2009 10:32 am

Hi Marco,

Could you please send us example application's project so that we can run it "as-is"?

You can either post it at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

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

Stein41
Newbie
Newbie
Posts: 3
Joined: Wed May 23, 2007 12:00 am
Location: Hannover Germany
Contact:

Post by Stein41 » Thu Jan 29, 2009 12:36 pm

Hi Narcís,

i' have posted the sample application in your newsgroup.

Thank you,

Marco

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

Post by Narcís » Thu Jan 29, 2009 2:37 pm

Hi Marco,

Thanks for the example project. The problem here is that in addBefore() you need to add the null values after your new dataset and before existing data instead of at the beginning of the new data set. So that implementing the method as shown below works fine for me here.

Code: Select all

    Private Sub addBefore()
        Static start As Integer = -200
        Dim source As DataTable
        Dim r As DataRow

        source = New DataTable("data")

        source.Columns.Add("xval", GetType(Double))
        source.Columns.Add("yval", GetType(Object))

        r = source.Rows.Add
        r("xval") = start
        r("yval") = System.DBNull.Value

        For i As Integer = start To start + 99
            r = source.Rows.Add
            r("xval") = i
            r("yval") = i
        Next

        r = source.Rows.Add
        r("xval") = start + 100
        r("yval") = System.DBNull.Value

        Dim s As Steema.TeeChart.Styles.FastLine
        s = Me.TChart1.Series(0)

        s.Add(source)

        start -= 200
    End Sub
Can you please check if this code works fine for you?

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

Stein41
Newbie
Newbie
Posts: 3
Joined: Wed May 23, 2007 12:00 am
Location: Hannover Germany
Contact:

Post by Stein41 » Thu Jan 29, 2009 4:06 pm

Hi Narcís,

thanks so far but the code you send dosn't work for me because i am getting the datatable from a database. The code i wrote was just to show the problem i have.
Because of loading values from database, it is not possible to set the NULL-values where i want.
I testet the code anyway and here with TeeChart version 3.5.3274.30663 the results is the same issue.

While make changes at the apllication to show you wat i mean i found the reason and a workaround for my problem:

In my first post i wrote that the problem perhaps is caused by the color-array of the series(fastline) which is not set when adding values. So i added a 3rd column to my datatable and bound it to series' ColorMember to see if i am right.
After bounding this Color, the chart treat the NULLs as i want it to do. When deactivating the series.ColorMember i got the known issue.

I made two images to show it.
This one is with the ColorMember-property set:
Image

This one is without ColorMember-property:
Image

So i use the ColorMember in all my datatables to get it work. But doing this is use an unnecessary amount of memory and CPU.

It would be nice if you can confirm and ,if so, add it to to your ToDo-List for a future release.

Thank you,

Marco

Post Reply