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

Chart manual output

3 Answers 85 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Rac
Top achievements
Rank 1
Rac asked on 20 Jun 2008, 01:55 AM

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> 

3 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 23 Jun 2008, 08:19 AM
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
0
Rac
Top achievements
Rank 1
answered on 23 Jun 2008, 03:16 PM
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
0
Giuseppe
Telerik team
answered on 24 Jun 2008, 09:15 AM
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
Tags
Chart (Obsolete)
Asked by
Rac
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Rac
Top achievements
Rank 1
Share this question
or