We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Rebind chart data and update chart settings

Hi there,

I need to rebind the chart data on click of button and also update its settings such as range and interval type as per the data fetched from services. I tried redraw, destroy in my javascript code but these methods are undefined for the chart object. Please let me know if I am missing anything in it.

Attachment: Index_ec29e073.zip

1 Reply

RJ Rekha J Syncfusion Team June 18, 2014 08:40 AM UTC

Hi Chirag,

Thanks for using Syncfusion products.

We have analyzed your requirement and we suggest you to use “dataSource” property of chart series for rebind the data and update its settings such as range and interval type as per the data fetched from services. we have created “chartdata.js” file for storing the data which is rendered after the button is clicked.

Please refer the code snippet to achieve this:

<code>

[JS]

$('#id').click(function()

                        {

$.ajax({

                type: "GET",

           //create js file for creating data that render when this button is clicked

                url: "chartdata.js",

                dataType:"json",

                  error: function (xhr, ajaxOptions, thrownError) {

                    alert(xhr.status);

                    alert(thrownError);

                },

                                                success: function (result) {

                                                debugger;

                                                var chart=$("#container").ejChart("instance");

                                                chart.model.series[0].points=null;

                                                chart.model.series[0].dataSource={};

                                                chart.model.series[0].dataSource.data=result;

                                                  chart.model.series[0].dataSource.xName="x";

                                                  chart.model.series[0].dataSource.yName="y";

                                                  $("#container").ejChart("redraw");

                                                }

           

            });

}

</code>

We have created a simple sample and it can be downloaded in the following link.

http://www.syncfusion.com/downloads/support/directtrac/general/Ajax-447988740.zip

Please let us know if you have any concern.

Regards,

Rekha.


Loader.
Up arrow icon