Page 1 of 1

Programmatically Created Chart and Functions

Posted: Fri Feb 24, 2012 9:18 pm
by 15661479
if I run this code:

Code: Select all

            WebChart lChart = new WebChart();
            Bar lBar1 = new Bar(lChart.Chart);
            lBar1.FillSampleValues(10);
            lChart.Chart.Aspect.View3D = false;
            Bar lBar2 = new Bar(lChart.Chart);
            lBar2.FillSampleValues(10);
            Line lLine = new Line(lChart.Chart);
            lLine.Function = new Steema.TeeChart.Functions.MovingAverage();
            lLine.Function.Period = 3;
            lLine.DataSource = lBar1;
            lChart.TempChart = TempChartStyle.Httphandler;
            
            Page.Form.Controls.Add(lChart);
I get an exception saying: IChart.FindParentForm().
It doesn't happen if I add the chart declaratively.

Any Hints?
thanks!

Re: Programmatically Created Chart and Functions

Posted: Tue Feb 28, 2012 12:39 pm
by 10050769
Hello Hermes,

Your problem is produced by the order as you have added the components, so, you have to add WebChart in the page before add series as do in next lines of code:

Code: Select all

 //chart
        WebChart lChart = new WebChart();
        this.Form.Controls.Add(lChart);
        lChart.TempChart = TempChartStyle.Httphandler;
        //Series
        Bar lBar1 = new Bar(lChart.Chart);
        lBar1.FillSampleValues(10);
        lChart.Chart.Aspect.View3D = false;
        Bar lBar2 = new Bar(lChart.Chart);
        lBar2.FillSampleValues(10);
        Line lLine = new Line(lChart.Chart);
        lLine.Function = new Steema.TeeChart.Functions.MovingAverage();
        lLine.Function.Period = 3;
        lLine.DataSource = lBar1;  
Can you tell us, if previous code works as you expect?

Thanks,

Re: Programmatically Created Chart and Functions

Posted: Wed Feb 29, 2012 10:35 am
by 15661479
Hi Sandra,

That code works, but we generate charts in a service and then send its stream to a web page so we don't have Page there.
As a workaround we instanciated a Form and added the chart to it and it seems to work. It sounds a bit dummy as the form isn't on a page or anything but untill we reach a solution it works.

Do I need to always have the chart added to a page before working with it? Even to add series or functions?

Thanks!

Re: Programmatically Created Chart and Functions

Posted: Mon Mar 05, 2012 4:38 pm
by 10050769
Hello Hermes,

I inform you that your problem is solved for next maintenance release of TeeChartFor .Net. I recommend you to be aware at this forum, our RSS news feed, twitter and facebook accounts for new release announcements and what's implemented on them.

Thanks,

Re: Programmatically Created Chart and Functions

Posted: Tue Mar 06, 2012 10:25 am
by 15661479
That's great! Thanks!