RadChart + Callback

Thread is closed for posting
2 posts, 0 answers
  1. Robson L
    Robson L avatar
    1 posts
    Member since:
    Feb 2010

    Posted 23 Feb 2010 Link to this post

    Hi, I have a page loading some radcharts dinamically.
    I'm using javascript SetInterval to refresh the charts every 30 seconds by callback.
    The series values in the radchart object are updated but the image of chart is not updated, someone has an example to help me?

    thanks
    Robson

  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 26 Feb 2010 Link to this post

    Hello Robson L,

    Here is a sample code snippet that achieves the desired effect:

    ASPX:
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <telerik:RadCodeBlock ID="cb1" runat="server">
     
        <script type="text/javascript">
            function pageLoad() {
                window.setTimeout(refresh, 1000);
            }
     
            function refresh() {
                var ajaxPanel = $find("<%= RadAjaxPanel1.ClientID %>");
                ajaxPanel.ajaxRequest("");
            }
        </script>
     
    </telerik:RadCodeBlock>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" OnAjaxRequest="RadAjaxPanel1_AjaxRequest">
        <telerik:RadChart ID="RadChart1" runat="server">
        </telerik:RadChart>
    </telerik:RadAjaxPanel>

    C#:
    private Random rand = new Random(DateTime.Now.Millisecond);
     
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RadChart1.DataSource = new int[] { rand.Next(10, 100), rand.Next(10, 100), rand.Next(10, 100) };
            RadChart1.DataBind();
        }
    }
     
    protected void RadAjaxPanel1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        RadChart1.DataSource = new int[] { rand.Next(10, 100), rand.Next(10, 100), rand.Next(10, 100) };
        RadChart1.DataBind();
    }



    Sincerely yours,
    Manuel
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top