DownSampling does not work

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
AIS
Newbie
Newbie
Posts: 70
Joined: Wed Jun 25, 2008 12:00 am

DownSampling does not work

Post by AIS » Mon Apr 18, 2011 10:12 am

Hello,

i have tried to test the downsampling functionality within a simple silverlight project. During implementation i recognized a strange behaviour for this function. This behaviour occures with the winforms and also with the silverlight assembly. I try to explain this with a simple winforms example.
Create a new form and add a TChart control and a button. Use the following code in the code behind:

Code: Select all

public Form1()
{
    InitializeComponent();

    tChart1.Aspect.View3D = false;
    tChart1.Legend.Visible = false;
}

private void Form1_Load(object sender, EventArgs e)
{
    //InitializeChart(); // works like expected
}

private void button1_Click(object sender, EventArgs e)
{
    InitializeChart(); // empty chart
}

private void InitializeChart()
{
    Points points;
    FastLine fastLine;

    tChart1.Series.Add(points = new Points());
    tChart1.Series.Add(fastLine = new FastLine());
    DownSampling downSampling1 = new DownSampling(tChart1.Chart);

    points.FillSampleValues(5000);
    points.Active = false;

    downSampling1.DisplayedPointCount = 100;
    downSampling1.Tolerance = 10.0;
    downSampling1.Method = DownSamplingMethod.Average;

    fastLine.DataSource = points;
    fastLine.Function = downSampling1;
}
Image
Image

If the InitializeChart method is called during the Form_Load event all works pretty well. If the method is called during Button_Click event the chart is empty. What should i do to get it to work?
I use TeeChart version 4.0.2011.2087.

Thanks in advance!

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: DownSampling does not work

Post by Sandra » Tue Apr 19, 2011 10:17 am

Hello AIS,

I have modified slightly your code, changing the order of points.Active and points.FillSampleValues() as you can see in next lines:

Code: Select all

 public Form1()
        {
            InitializeComponent();
//            InitializeChart();

            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
          //  InitializeChart(); // works like expected
        }

        private void button1_Click(object sender, EventArgs e)
        {
           InitializeChart(); // empty chart
        }

        private void InitializeChart()
        {
            Steema.TeeChart.Styles.Points points;
            Steema.TeeChart.Styles.FastLine fastLine;

            points = new Steema.TeeChart.Styles.Points(tChart1.Chart);
            fastLine = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            Steema.TeeChart.Functions.DownSampling downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
                        
            downSampling1.DisplayedPointCount = 100;
            downSampling1.Tolerance = 10.0;
            downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.Average;

            fastLine.DataSource = points;
            fastLine.Function = downSampling1;

            points.FillSampleValues(5000);
            points.Active = false;
        }
Could you confirm us if previous code works as you expected?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

AIS
Newbie
Newbie
Posts: 70
Joined: Wed Jun 25, 2008 12:00 am

Re: DownSampling does not work

Post by AIS » Tue Apr 19, 2011 1:54 pm

Hello Sandra,

yes, this works but it is not clear for me why it does. I mean, it should also not work within the load event,but why it works also without any changes?
By the way the downsampling is only usefull if you choose a fastline series with DrawAllPoints=False otherwise the drawing of the second series takes a lot of time because the chart draws the complete chart with the orginal series as first step before it is deactivated... This should be improved. It would be nicer if this works without a "dummy series".

EDIT:
Your suggested change works very well within my winforsm test project but do not within my silverlight test project with the same code... Any other suggestions?

Bye

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: DownSampling does not work

Post by Sandra » Thu Apr 21, 2011 8:18 am

Hello AIS,

We haven't forgotten you. We'll be back to you asap.

Thanks,
Best Regards,
Sandra Pazos / 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

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: DownSampling does not work

Post by Sandra » Thu Apr 21, 2011 2:22 pm

Hello Ais,

We have done many tests with DownSimpling function and we have arrived a conclusion that this problem is a bug that is fixed for next maintenance releases of TeeChart.Net. At the moment, you can use next code as a work around in Silverlight and WinForms.

WinForms:

Code: Select all

 private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;
            Steema.TeeChart.Styles.Points points;
            Steema.TeeChart.Styles.FastLine fastLine;

            tChart1.Series.Add(points = new Steema.TeeChart.Styles.Points());
            tChart1.Series.Add(fastLine = new Steema.TeeChart.Styles.FastLine());
            Steema.TeeChart.Functions.DownSampling downSampling1 = new Steema.TeeChart.Functions.DownSampling();

            points.FillSampleValues(5000);
            points.Active = false;
            downSampling1.DisplayedPointCount = 100;
            downSampling1.Tolerance = 10.0;
            downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.Average;

            tChart1.Chart.ChartRect = Steema.TeeChart.Utils.EmptyRectangle; //<- work around not necessary for next release

            fastLine.Function = downSampling1;
            fastLine.DataSource = points;
        }
Silverlight

Code: Select all

    private void InitializeChart()
{
 tChart1.Aspect.View3D = false;
 tChart1.Legend.Visible = false;
 Steema.TeeChart.Silverlight.Styles.Points points;
 Steema.TeeChart.Silverlight.Styles.FastLine fastLine;

 tChart1.Series.Add(points = new Steema.TeeChart.Silverlight.Styles.Points());
 tChart1.Series.Add(fastLine = new Steema.TeeChart.Silverlight.Styles.FastLine());
 Steema.TeeChart.Silverlight.Functions.DownSampling downSampling1 = new Steema.TeeChart.Silverlight.Functions.DownSampling();

 points.FillSampleValues(5000);
 points.Active = false;
 downSampling1.DisplayedPointCount = 100;
 downSampling1.Tolerance = 10.0;
 downSampling1.Method = Steema.TeeChart.Silverlight.Functions.DownSamplingMethod.Average;

 tChart1.Chart.ChartRect = Steema.TeeChart.Silverlight.Utils.EmptyRectangle; //<- work around not necessary for next release

 fastLine.Function = downSampling1;
 fastLine.DataSource = points;
}
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

AIS
Newbie
Newbie
Posts: 70
Joined: Wed Jun 25, 2008 12:00 am

Re: DownSampling does not work

Post by AIS » Tue Apr 26, 2011 5:37 am

Hello Sandra,

thanks for the help. Now it works like expected :)

Post Reply