Page 1 of 1

How to dynamic adding webchart into aspx page?

Posted: Wed Jul 18, 2007 7:04 am
by 9638303
Dear Sir

How to I dynamic adding webchart into aspx page?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As system.EventArgs) Handles Me.Load
Dim WebChart1 As New Steema.TeeChart.Web.WebChart
form1.Controls.Add(WebChart1)
end sub

Above the code occurs a error
[NullReferenceException: Object reference not set to an instance of an object.]
Steema.TeeChart.Web.WebChart.CreatePictureFile(HtmlTextWriter writer) +418
Steema.TeeChart.Web.WebChart.Render(HtmlTextWriter output) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +59
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +68
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +37
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.Page.Render(HtmlTextWriter writer) +26
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1896


Thank
Yong

Posted: Wed Jul 18, 2007 7:59 am
by 9638303
Dear Sir

I search around the forum, I found some example to create the webchart dynamic, But i'm not understand how to do it...

example on page_load

create web chart and chart setting....

Response.Write("<tchart:WebChart id=\"WebChart1\" style=\"Z-INDEX: 104; LEFT: 56px; POSITION: absolute; TOP: 56px\" runat=\"server\"Width=\"760px\" Height=\"448px\" TempChart=\"File\" ClickedY=\"0\" ClickedX=\"0\" GetChartFile=\"GetChart.aspx\" AutoPostback=\"False\" Config=\"AAEA.....Cut it, cause too long"></tchart:WebChart>");


But I'm still not able to see the chart show in the aspx page and I also want to know whether the javascript event able to work. example as below the code

sub GetHTMLMap(....)
e.PointPolygon.Attributes = "onclick=alert('dd');"
end sub

Posted: Wed Jul 18, 2007 1:31 pm
by Chris
Hello!

You can add webcontrols to webforms dynamically using the techniques in this MSDN article:
http://msdn2.microsoft.com/en-us/librar ... s.80).aspx

But I'm still not able to see the chart show in the aspx page and I also want to know whether the javascript event able to work. example as below the code
I believe we had already resolved this problem in this thread:
http://www.teechart.net/support/viewtopic.php?t=6314

Posted: Wed Jul 18, 2007 2:33 pm
by 9638303
Dear Sir

Ya.. It work already....

anyway, Thank your help

Yong

Posted: Thu Jan 10, 2008 11:02 am
by 9644371
Hi, I'm try to do the same. I'm trying to use the following code. But I just get a chart to show but with no data.

Any ideas. Do i need to redraw the chart some how?

Cheers?

Steema.TeeChart.Web.WebChart newWebChart = new Steema.TeeChart.Web.WebChart();
newWebChart.Width = 800;
newWebChart.Height = 500;
newWebChart.ID = "newWebChart";
//newWebChart.Style. = "Z-INDEX: 107; LEFT: 24px; POSITION: absolute; TOP: 60px;";
newWebChart.Config = "AAEAAAD/////AQAAAAAAAAAMAgAAAFJUZWVDaGFydCwgVmVyc2lvbj0yLjAuMjY1Mi4yMjMyNSwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj05YzgxMjYyNzZjNzdiZGI3DAMAAABRU3lzdGVtLkRyYXdpbmcsIFZlcnNpb249Mi4wLjAuMCwgQ3VsdHVyZT1u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AAAAAAAAAABAQAAAAHg////5f///wEAAAAAAAAAAAAAAAEBAAAAAd/////l////AQAAAAAAAAAAAAAAEQ8AAAABAAAABiIAAAAaTGluZSBhbmQgSG9yaXouIExpbmUgU3R5bGUL";
newWebChart.TempChart = Steema.TeeChart.Web.TempChartStyle.Session;
newWebChart.AutoPostback = true;
newWebChart.GetChartFile = "GetChart.aspx";

//thePage.Controls.Add(newWebChart);

Steema.TeeChart.Styles.FastLine fastLine1;

fastLine1 = new Steema.TeeChart.Styles.FastLine();
newWebChart.Chart.Series.Add(fastLine1);
double[] yValues = { 10, 15, 20, 2, 23, 63, 33, 1, 33, 77, 94, 65, 45, 23, 32, 4, 54, 2, 18, 21, 80, 67, 45, 32, 3, 10, 56, 13, 52, 23, 72, 66, 32, 54, 74, 21, 86, 15 };
fastLine1.Add(yValues);

// Set some nulls
fastLine1.SetNull(13);
fastLine1.SetNull(25);
fastLine1.SetNull(40);

fastLine1.IgnoreNulls = true;
fastLine1.Stairs = true;

// Apply palette
Steema.TeeChart.Themes.ColorPalettes.ApplyPalette(newWebChart.Chart, 7);

thePage.Controls.Add(newWebChart);

Posted: Thu Jan 10, 2008 11:37 am
by 9644371
Ok i've kind of fixed it. But it is a bit annoying.

If you add the series to the chart after adding the webchart to the div then it works.

IE last few line of code are changed to

newWebChart.Chart.Series.Add(fastLine1);

thePage.Controls.Add(newWebChart);

Posted: Thu Jan 10, 2008 11:47 am
by narcis
Hi keynetix,

Your code also worked fine for me here commenting in the line setting newWebChart.Config.