DownSampling vs Series.Active flag

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
AgileSoft s.c.
Newbie
Newbie
Posts: 7
Joined: Mon Jun 02, 2008 12:00 am

DownSampling vs Series.Active flag

Post by AgileSoft s.c. » Tue Oct 21, 2008 9:15 am

i'm trying to use DownSampling with Ponits Series contains over 86k points.

Code: Select all

        private void GenerateSeries() 
        {
            Line oryginalPoints = new Line();
            FastLine reduceLine = new FastLine();

            double[] speedData = new double[60 * 60 * 24]; // sec per day
            DateTime[] times = new DateTime[60 * 60 * 24];

            /*
             * preparing sample data
             * car speed in each second (24h period)
             * gives over 86 000 points
             * this amount slows TeeChart extemlly
             */
            DateTime x = DateTime.Now.Date;
            Random rand = new Random((int)DateTime.Now.Second);
            double prev = 0;
            for (int i = 0; i < 60 * 60 * 24; i++) 
            {
                times[i] = x + TimeSpan.FromSeconds(i);
                speedData[i] = prev + rand.Next(-10, 10);
                if (speedData[i] < 0) speedData[i] *= -1;
                if (speedData[i] > 120)
                {
                    double tmp = 120 - (speedData[i] - 120);
                    speedData[i] = tmp;
                }
                prev = speedData[i];
            }

            oryginalPoints.Color = Colors.Red;
            oryginalPoints.Title = "oryginal";

            reduceLine.Color = Colors.Green;
            reduceLine.Title = "reduce";
            
            tChart.Series.Add(oryginalPoints);
            tChart.Series.Add(reduceLine);

            DownSampling sampling = new DownSampling(tChart.Chart);
            
            /*
             * 
             * change to True to see something on chart
             * False generates empty chart
             * 
             */            
            oryginalPoints.Active = true;
            
            
            oryginalPoints.Add(times, speedData);
            oryginalPoints.XValues.DateTime = true;
            sampling.Method = DownSamplingMethod.Average;
            sampling.DisplayedPointCount = 1000;
            sampling.PeriodStyle = PeriodStyles.Range;
            sampling.Period = 5;
            reduceLine.DataSource = oryginalPoints;
            reduceLine.XValues.DateTime = true;
            reduceLine.Function = sampling;
            reduceLine.CheckDataSource();

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            GenerateSeries();
        }
i draw points on chart - it take a lot of time, just freeze app.
To reduce generation time i try to use DownSamplingMethod.Avarage in this
way:
Line.Function = DownSampling;

the problem is when i set
points.active = false;
nothing is drawn on chart! (screen 2)
if Active is True chart drawing time is biiiig (for over 86k points) but
Line with DownSampling works very good, as i expected! (screen 1)

i need to set something?
i write my code based on Yours sample:
"NetTutorialsContentsTutorial7-WorkingwithFunctions custom"

Im using TeeChart.WPF from
TeeChart.NET version 3
Release Notes 23rd September 2008
TeeChart.NET version 3
Build 3.5.3188.18562
installation

Screen 1
Image

Screen 2
Image

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 Oct 21, 2008 1:38 pm

Hi AgileSoft,

Thanks for the example.

I got it working moving the Active=false line to the very end of GenerateSeries method.

Anyway, notice that WPF is much slower than GDI+ and WinForms applications.
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

AgileSoft s.c.
Newbie
Newbie
Posts: 7
Joined: Mon Jun 02, 2008 12:00 am

Post by AgileSoft s.c. » Wed Oct 22, 2008 9:15 am

hi
thank you for quick asware
i make change, which u suggest and get "part" solution :?
when making ZoomIn everything works perfect (just line "reduce" is on chart), but result of ZoomOut is identical as You can see on Screen 2 (first post) - clear chart.

may i ask for solution? :)

ps. can you explain why this line must be the last one? in your sample code it isn't....

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

Post by Narcís » Wed Oct 22, 2008 10:45 am

Hi AgileSoft s.c.,

I've been able to reproduce the issue here and it's a TeeChart for WPF bug as it works fine in WinForms applications. I've added this issue (TF02013477) to the defect list to be fixed for next releases.
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

AgileSoft s.c.
Newbie
Newbie
Posts: 7
Joined: Mon Jun 02, 2008 12:00 am

Post by AgileSoft s.c. » Wed Oct 22, 2008 12:50 pm

is any method to "work around" this bug?

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

Post by Narcís » Wed Oct 22, 2008 1:10 pm

Hi AgileSoft s.c.,

Yes, setting source series color to Color.Transparent is an option that works:

Code: Select all

					points.Color = Colors.Transparent;
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

AgileSoft s.c.
Newbie
Newbie
Posts: 7
Joined: Mon Jun 02, 2008 12:00 am

Post by AgileSoft s.c. » Wed Oct 22, 2008 1:26 pm

this is some solution
but in this way usage of DownSampling is pointless
i've used it to boost up chart drawing process (reduce amount of point when chat has oryginal zoom). on each ZoomIn DownSampling with set DisplayedPointCount = 1000 makes green line more "oryginal".

work around, that You suggest, don't boost my app, just make oryginal line invisible.
in this case DownSampling is pointless, becouse i don't get boost up in place of oryginal series deformation :(

i've tryed to not add oryginal series to chart, but this solution generate exception on DownSampling - NullReferenceException.

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

Post by Narcís » Wed Oct 22, 2008 1:30 pm

Hi AgileSoft s.c.,

Yes, you are right. DownSampling function needs source data series being added to the chart as it is used internally for calculation function's output.

In that case there's no other alternative I can think of at the moment.
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

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 Oct 23, 2008 8:07 am

Hi AgileSoft s.c.,

Regarding TF02013477, we found that getting rid of the subscriptions to the Zoomed and UndoneZoom event resolves the problem. That is, comment out these events and it will work fine.
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

AgileSoft s.c.
Newbie
Newbie
Posts: 7
Joined: Mon Jun 02, 2008 12:00 am

Post by AgileSoft s.c. » Fri Oct 31, 2008 9:27 am

hi

first of all, sorry for delay in replay
i tryed yours solution
it's not so perfect for me

on atached images im tryind to show main difference: how important to me is recalculation on zoom events...
on first image i don't make recalculations. efect: on each zoom in chart i based on constant point amount(from oryginal chart calculation). last zoom (with period 10 min) i have only 2 points on chart... (real sampling is with point per sec).

second image represents situation with recalculaton. on each zoom in i have max 1000 point (recalculation limit). this operation provides situation when deformation is less with next zoom in.
and, as is presents on last zoom in (image two), i give to user oryginal sampling chart (selected 5 points in 5sec period). it's VERY important feature for me...
every thing crashed on zoom out... and here i have two situations (zoom in recalculation present):
- with recalculations on zoom out
- with out recalculation on zoom out

in first situation i get blank char (1st post, 2nd image)
in second option o first zoom out i gets previous zoom in image (eg. 4 zoom in's, then zoom out = result, 3rd zoom in chart). next zoom out gives nothing.

conclution: any way to workaround zoom out problems? (with recalculation ofc)

whitout recalculation on zoom events
Image

with recalculation on zoom event
Image

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

Post by Narcís » Fri Oct 31, 2008 3:24 pm

Hi AgileSoft s.c.,

Thanks for the information.

We have checekd that not having the zoom events in does make a difference. So defect TF02013477, which had been closed, has been reopened and definitively fixed. The fix will be in the next maintenance release due out early next week.
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