Rendering Chart from WebService

Thread is closed for posting
3 posts, 0 answers
  1. Alexander
    Alexander avatar
    1 posts
    Member since:
    Sep 2008

    Posted 06 Aug 2010 Link to this post

    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. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 11 Aug 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. kulashaker
    kulashaker avatar
    5 posts
    Member since:
    Jul 2006

    Posted 31 Jan 2012 Link to this post

    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
Back to Top