Page 1 of 1
Programming with TeeChart on Sharepoint webpart
Posted: Wed Feb 06, 2008 9:58 pm
by 9641714
I had worked on TeeChart with .Net web pages. Now I need to do the same thing with Teechart but in a webpart. Do you have any tutorials or walk though on this?
thanks a lot.
best, Jane
Posted: Thu Feb 07, 2008 9:05 am
by narcis
Hi Jane,
TeeChart for .NET may be used with Sharepoint Server, principally in the following two ways:
- Creating a Webpart that contains an image and generating the image via a call to a Chart generator process via dynamic parameter updates from the webpage. I've sent you an example project of that type of Webpart format.
The Chart generator process would similar to that included in the TeeChart ASP.NET demo under "Interacting with Charts:Chart as Image:Series Types as Image"
- Creating a UserControl (.ascx) that contains the Chart. We have no current example of that to send you but tests were made to support a customer information request so we can confirm that the option functions.
Thanks!
Posted: Thu Feb 07, 2008 5:38 pm
by 9641714
Narcís, thanks for such a quick response. I will try this out and let you know the result.
In .NET web page, we already had a Teechart user control. So I am curious how to use that user control directly in webpart to make it easier. Please let me know when you have such code(test version is fine)...
regards, Jane
Tried the first approach
Posted: Thu Feb 07, 2008 11:18 pm
by 9641714
I tried the first approach. This way I still have to get data from ShowSeries.aspx. I will need to get away from .aspx and feed data in the webpart itself. So I copied the code in ShowSeries.aspx.cs and put it in webpart, it's like this:
------------------------------------------------------------------------------
Steema.TeeChart.Web.WebChart webchart = new Steema.TeeChart.Web.WebChart();
Chart chart = webchart.Chart;
chart.Series.Add(new Steema.TeeChart.Styles.Line());
.
.
.
MemoryStream tempStream = new MemoryStream();
chart.Export.Image.PNG.Save(tempStream);
//tempStream.Flush();
Response.ContentType = "Image/PNG";
Response.OutputStream.Write(tempStream.ToArray(), 0, (int)tempStream.Length);
tempStream.Close();
chart.AutoRepaint = true;
Controls.Add(webchart);
-------------------------------------------------------------------------------------
I got the "object is null " error at the first line, seems that I can not create the object, do not know why...?
Also, how can I handle "Response" at the end to output the stream to an image, since Repsonse is not avaliable here?
Or, will my assumed approach work at all?
thanks, Jane
Posted: Fri Feb 08, 2008 8:18 am
by narcis
Hi Jane,
Please let me know when you have such code(test version is fine)...
Did you receive the e-mail with the example I sent you yesterday to your forums profile e-mail address?
Thanks in advance.
Got the mail
Posted: Fri Feb 08, 2008 6:33 pm
by 9641714
Narcís, yes I got your email and looked into the webpart code within zipped file. I notice it still uses the ShowSeries.aspx to get the data and render image. I want to see if it's possible to put all of these functionalities in a webpart, so I tried the above code. Obviously it does not work...Can you tell what's wrong with it?
For the second approach of User Control(.ascx), we had developed a user control before, all we do in each web page is just feed the data to the user control . So I am thinking if we can do the same thing in a web part. But I am not sure:
1) how to refer user control in web part?
2) how to handle the GetChart.aspx file now?
So I want to see if you have some code sample on this as you mentioned you are test something on this.
thanks again for your help, Jane