Draw All Points of FastLine series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Marc
Site Admin
Site Admin
Posts: 1266
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Draw All Points of FastLine series

Post by Marc » Mon May 28, 2012 9:33 am

Hello Rajesh,

I've tried this with v3. The smoothing is not as good, the smoothed curve frequency falls longer than the input data frequency for this dataset; v2012 is a definite improvement as it's able to smooth at the same frequency as the input data.

With TeeChart v2012 the example screenshot has been created by adding a smoothing function to the Chart, turning Interpolation off (interpolation creates a too large a virtual dataset in memory for this case because of the volume of data in the sample) and setting the FastLine as source for the function. The source may optionally be set to Active True (visible) or False and the smoothing factor adjusted according to preference (eg. 1 to 4). The Chart is 2D.

Regards,
Marc

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: Draw All Points of FastLine series

Post by asupriya » Sat Jun 09, 2012 3:58 pm

Marc,

I am not having much luck with the evaluation version of V2012 with the example data set posted in this message. The code snippet as follows.

Code: Select all

Dim mySmoooth As New Steema.TeeChart.Functions.Smoothing(GraphChart.Chart)
            mySmoooth.Interpolate = False
            mySmoooth.Period = 1 ' 1 to 4 values didn't make any difference
           
            Dim txtReader As New System.IO.StreamReader("..\..\input.txt")
            Dim tmpStr As String()
            While Not txtReader.EndOfStream
                tmpStr = Split(txtReader.ReadLine, ",")
                FastLine1.Add(CDbl(tmpStr(0)), CDbl(tmpStr(1)))
            End While
            txtReader.Close()

            Dim fs2 As New Steema.TeeChart.Styles.FastLine
            fs2.DataSource = FastLine1
            FastLine1.Active = False
            fs2.Function = mySmoooth
            GraphChart.Series.Add(fs2)

Marc
Site Admin
Site Admin
Posts: 1266
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Draw All Points of FastLine series

Post by Marc » Mon Jun 11, 2012 9:10 am

Hi,

Your code sample works ok here with the latest version, I'll download the current evaluation version to see if there's any particular problem there. What symptoms are you seeing? An empty Chart, partial data? One Series or two in the Chart?

**I correct an earlier edit of this post, testing here, changing the mySmoooth.Period value should still make a difference with Interpolate at False.

Further update:
I have downloaded the latest evaluation build, 4.1.2012.05104. Results are the same as with previous tests made.

Regards,
Marc

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: Draw All Points of FastLine series

Post by asupriya » Mon Jun 11, 2012 11:53 am

Marc, I am using evaluation 4.1.2012.02284 as it was lat installed while trying Fastline.DrawAllPointsStyle option. Do you advice retrying with latest eval version?

I am getting the screenshots as shown below. Display of both original and smoothed series.
1.jpg
1.jpg (74.43 KiB) Viewed 18707 times
After some zoom
2.jpg
2.jpg (85.49 KiB) Viewed 18685 times
Further zoom
3.jpg
3.jpg (82.66 KiB) Viewed 18695 times

Marc
Site Admin
Site Admin
Posts: 1266
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Draw All Points of FastLine series

Post by Marc » Mon Jun 11, 2012 2:17 pm

Hello,

That plot looks like an earlier version. I'm not sure if there was a recent change to this during 2012, I think not, but please use the latest build anyway just in case. Check too that the reference is correctly updated to the new teechart.dll, that your project isn't picking up an earlier version (and that an earlier assembly isn't in the GAC or set as AssemblyFolders), the screenshots do give the impression that an earlier version of TeeChart is being used.

Regards,
Marc
Steema Support

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: Draw All Points of FastLine series

Post by asupriya » Wed Jun 13, 2012 12:33 pm

Marc,

The 4.1.2012.5106 build in the current evaluation setup fixed the issue. Now, the curve fitting is smooth.

I will upgrade from V3 to this version soon in next couple of days.

Thanks,
Rajesh

asupriya
Newbie
Newbie
Posts: 8
Joined: Mon Jun 18, 2012 12:00 am

Re: Draw All Points of FastLine series

Post by asupriya » Mon Jun 18, 2012 1:03 pm

Marc,

We have upgraded to latest version of Teechart and are in the process of updating our project.

We noticed a problem with the smoothing solution you suggested while we are implementing it with our project. This solutions requires that there are two series for each data; one with raw data and the other with smoothed data. Maintaining multiple series for same data creates several issues as our graph displays have several user interactions supported. All such events and features are to be modified to work with smoothed series data. This will be a lot of work for development and testing teams. Also, given the amount of data, this solution creates much higher need for memory.

Is there a simpler solution you suggest that uses only one series, but applies smoothing to its data without requiring us to create another one?

Thanks

Marc
Site Admin
Site Admin
Posts: 1266
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Draw All Points of FastLine series

Post by Marc » Thu Jun 21, 2012 8:53 am

Hello,

The smoothing function needs to create the points according to the input data so I can't suggest a way of completely avoiding the memory space that that incurs. However you could reduce the timeframe during which the whole memory space for the two data Series is used by removing the first Series from the Chart after the data has been populated to the smoothing Series.

eg.

Code: Select all

            Dim fastSmooth As New Steema.TeeChart.Styles.FastLine(GraphChart.Chart)
            Dim smoothingFunc As New Steema.TeeChart.Functions.Smoothing

            smoothingFunc.Interpolate = False
            fastSmooth.Title = "smoothed data"
            fastSmooth.Function = smoothingFunc
            fastSmooth.DataSource = FastLine1 'GraphChart(0)
            GraphChart.Series.Add(fastSmooth)

            GraphChart.Series.Remove(FastLine1)
The smoothed Series' data will remain visible if it is not refreshed (eg. Series.CheckDatasource would fail).

Alternatively you could run the process externally to the Chart. It is not necessary to add the FastLine Series to the Chart to process it. You could prepare the smoothed data at the server and then export the smoothed data as the data to be plotted at the clients.

Regards,
Marc
Steema Support

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: Draw All Points of FastLine series

Post by asupriya » Thu Jun 21, 2012 11:21 am

Marc,

TChart object gets refreshed several times as our desktop Application lets users to interact with the graph display with many tools.

Thanks for the hint for "offline" processing. For a desktop app., how can i apply smoothing function "offline" and load only the smoothed data to the TChart. Is there is an easy way to generate a "smoothed data" for a desktop application?

Thanks,

Marc
Site Admin
Site Admin
Posts: 1266
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Draw All Points of FastLine series

Post by Marc » Fri Jun 22, 2012 10:44 am

Hello,

To smooth the data offline fill/load the input FastLine to prepare the data (can be the same machine or different as you can save to file or stream - ie. for example, to a database BLOB field). You can optionally create a Chart to load the first Series (source), or not. You can add the smoothingFunction Series to a Chart to export the data.

Options:

1. Create your own save routine ..... step through the Series' valuelists with you own code and write the values to a stream to be saved to memory or as a file (you don't need to load either Series in a Chart if you run it this way).

eg. To Create/Save (there are several ways to saveSeries data - although this uses a simple step-through you could try binaryFormat save the whole X and Y Valuelists in two instructions, I didn't try that)

Code: Select all

        FastLine1.DrawAllPoints = True

        FastLine1.LinePen.Width = 1
        FastLine1.LinePen.Style = Drawing2D.DashStyle.Solid

        FastLine1.XValues.DateTime = True
        Dim txtReader As New System.IO.StreamReader("..\..\input.txt")
        Dim tmpStr As String()
        While Not txtReader.EndOfStream
            tmpStr = Split(txtReader.ReadLine, ";")
            FastLine1.Add(CDbl(tmpStr(0)), CDbl(tmpStr(1)))
        End While
        txtReader.Close()

        Dim fastSmooth As New Steema.TeeChart.Styles.FastLine(GraphChart.Chart)
        Dim smoothingFunc As New Steema.TeeChart.Functions.Smoothing

        smoothingFunc.Interpolate = False

        fastSmooth.Title = "smoothed data"

        fastSmooth.Function = smoothingFunc
        fastSmooth.DataSource = FastLine1 'GraphChart(0)
        GraphChart.Series.Add(fastSmooth)

        GraphChart.Series.Remove(FastLine1)

        Dim i
        Dim dataArray As System.Collections.ArrayList
        Dim tmpPoint As Steema.TeeChart.Drawing.PointDouble
        Dim binFormat As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter

        dataArray = New System.Collections.ArrayList
        binFormat = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
        Dim mySaveStream As System.IO.FileStream

        mySaveStream = New System.IO.FileStream("c:\output\smoothData.dat", IO.FileMode.Create)

        For i = 0 To fastSmooth.Count - 1
            tmpPoint = New Steema.TeeChart.Drawing.PointDouble(fastSmooth.XValues(i), fastSmooth.YValues(i))
            dataArray.Add(tmpPoint)
        Next

        binFormat.Serialize(mySaveStream, dataArray)

        mySaveStream.Flush()
        mySaveStream.Close()
To load back into a Chart:

Code: Select all

        Dim i
        Dim dataArray As System.Collections.ArrayList
        Dim tmpPoint As Steema.TeeChart.Drawing.PointDouble
        Dim binFormat As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
        Dim newFastSmooth As Steema.TeeChart.Styles.FastLine

        dataArray = New System.Collections.ArrayList
        binFormat = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
        Dim mySaveStream As System.IO.FileStream

        mySaveStream = New System.IO.FileStream("c:\output\smoothData.dat", IO.FileMode.Open)

        dataArray = binFormat.Deserialize(mySaveStream)

        GraphChart.Series.Clear()

        newFastSmooth = New Steema.TeeChart.Styles.FastLine()

        For i = 0 To dataArray.Count - 1
            tmpPoint = CType(dataArray(i), Steema.TeeChart.Drawing.PointDouble)
            newFastSmooth.Add(tmpPoint.X, tmpPoint.Y)
        Next

        mySaveStream.Close()

        GraphChart.Series.Add(newFastSmooth)

2. Use Chart data export .... If you wish to use TeeChart's own export features then the easiest way would be to do something like the following:
eg. Save as text

Code: Select all

GraphChart.Export.Data.Text.Save( /* to filename or memory stream */)
Use a TeeChart TextSource component to import the data. See Demo's "Welcome !\Components\Text Source" for usage information.

3. Export the entire Chart as a template file. This option saves the Chart with the smoothedData as a template (.ten) file. That saves all Chart setup characteristics, automatically therefore saving/setting the XValues marked as DateTime when imported, and the Chart Title, colours, etc.

Save:

Code: Select all

DraftChart.Export.Theme.Save( /* to filename or memory stream */)
Load:

Code: Select all

GraphChart.Import.Theme.Load( /* to filename or memory stream */)
Regards,
Marc

Post Reply