Chart manual output

Thread is closed for posting
4 posts, 0 answers
  1. Rac
    Rac avatar
    3 posts
    Member since:
    Dec 2005

    Posted 19 Jun 2008 Link to this post

    Please follow the code below.
    I'm trying to generate a chart using the WebMethod and try to send the response (either the whole rendered output of RadChart or just the ChartImage.axd url) as a repsonse in an Ajax method.

    How can I achieve? Or is this undoable?

    [System.Web.Services.WebMethod()]  
        public static string GetChart1()  
        {  
            Telerik.Web.UI.RadChart chart = new Telerik.Web.UI.RadChart();  
             
            chart.ChartTitle.TextBlock.Text = "My title";  
            chart.DefaultType = ChartSeriesType.Line;  
            chart.Appearance.ImageQuality = Telerik.Charting.Styles.ImageQuality.HighQuality;  
            ChartSeries data1 = new ChartSeries("Page Views", ChartSeriesType.Line);  
            data1.AddItem(100);  
            data1.AddItem(25);  
            data1.AddItem(500);  
            data1.AddItem(1000);  
            data1.AddItem(5000);  
     
            ChartSeries data2 = new ChartSeries("Hits", ChartSeriesType.Line);  
            data2.AddItem(50);  
            data2.AddItem(100);  
            data2.AddItem(300);  
            data2.AddItem(2000);  
            data2.AddItem(4000);  
     
            chart.Series.Add(data1);  
            chart.Series.Add(data2);  
              
            //determine the output  
        } 

    <script type="text/javascript">  
          
            function CreateChart1()  
            {  
                PageMethods.GetChart1(Chart1Render, OnFailure);  
            }  
          function Chart1Render(res)  
          {  
            $get("chart1").innerHTML = res;  
          }  
          function OnFailure(res)  
          {  
            alert(res);  
          }  
          
        </script> 
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 23 Jun 2008 Link to this post

    Hello Rac,

    You cannot get the rendered output of the RadChart control, nor the ChartImage.axd url like this. You can still use the RadChart.Save(...) method API to save the image file on the server and then serve it via your own custom HttpHandler to the client-side e.g. from the page method you will need to return your custom HttpHandler url that points to the saved image on the server.


    Regards,
    Manuel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Rac
    Rac avatar
    3 posts
    Member since:
    Dec 2005

    Posted 23 Jun 2008 Link to this post

    Manuel,

    Can you provide me a quick example? Basically, I want to refresh the DIV with the new png (graph image) when the user clicks on the button on a page (which will make a WebMethod call to generate the image as you mentioned). No serverside tag/control dropped on the page.

    Thx,
    Rac
  4. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 24 Jun 2008 Link to this post

    Hi Rac,

    We have attached a sample application that demonstrates the described approach to get you started.

    Hope this helps.


    Best wishes,
    Manuel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top