This is a migrated thread and some comments may be shown as answers.

Rendering Chart from WebService

2 Answers 70 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 06 Aug 2010, 04:32 PM
Got html from WebServices.
With these additional settings to chart control:

chert.UseSession =

 

false;

 

chert.TempImagesFolder =

 

"~/TempImages/";

 



Having problem getting chart html from WebService. My task it to have it on client side from WS.
Failed with both of implementations below:
1.

 

 

 

[WebMethod]
public string GetChart()
{
   RadChart chert = new RadChart();
   chert.ID = "olapChart";
  
string result = string.Empty;
using (MemoryStream stream = new MemoryStream())
{
       StreamWriter writer = new StreamWriter(stream);
       HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
       chert.RenderControl(htmlWriter);
       System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
       writer.Flush();
       result = encoding.GetString(stream.ToArray());
 }

Having "Object reference not set to an instance of an object." on call chert.RenderControl(htmlWriter);

2.

[WebMethod]
        public string GetChart()
        {
           return GetChartRendered(chert);
        }
  
        private string GetChartRendered(RadChart chert)
        {
            string result = string.Empty;
  
            TempRenderer pageHolder = new TempRenderer();
            HtmlForm tempForm = new HtmlForm();
            tempForm.ID = "TempForm";
            pageHolder.Controls.Add(tempForm);
            tempForm.Controls.Add(new ScriptManager());
            tempForm.Controls.Add(chert);
  
            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(pageHolder, output, false);
  
            result = output.ToString();
            return result;
        }
  
        public partial class TempRenderer : System.Web.UI.Page
        {
        }

Having "Error executing child request for handler 'ChartTest.TempRenderer'" there on Server.Execute.

3. Eventually created just page "chart.aspx" wiht just single chart control decalred

<

 

 

telerik:RadChart ID="chert" runat="server" Width="500px" Height="290px" EnableViewState="false" SkinsOverrideStyles="false" ></telerik:RadChart>

 

 

 


and trying this in WebMethod:
StringWriter output = new StringWriter();
HttpContext.Current.Server.Execute("chart.aspx", output, false);
string result = output.ToString();

Having ex:" Error executing child request for chart.aspx."

As I understand the reason of all these exceptions is ChartImage.axd
handler.

If somebody can help - please, it's very urgent.
Thank you.

 

 

2 Answers, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 11 Aug 2010, 06:48 PM
Hello Alexander,

I do not think that this would be possible as the chart image is not just a bunch of html but it is actually served by the ChartImage.axd HttpHandler.

You might try saving the chart image to a stream via RadChart.Save(...) method and process the result with your service.


Greetings,
Bart.
0
kulashaker
Top achievements
Rank 1
answered on 01 Feb 2012, 04:32 AM
Hi, I know this thread is quite old, but I actually need to run Chart.RenderControl.

Reason is that I need to extract the ImageMap collection from the resulting HTML that RenderControl produces. I know it sounds messy but there is no property that exposes the ImageMap in the RadChart control.

Is there another way of doing this?

Cheers
Bruce
Tags
Chart (Obsolete)
Asked by
Alexander
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
kulashaker
Top achievements
Rank 1
Share this question
or