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.
Unfortunately, activation email could not send to your email. Please try again.

Rebind chart data and update chart settings

Thread ID:

Created:

Updated:

Platform:

Replies:

116581 Jun 12,2014 03:24 AM Jun 18,2014 04:40 AM JavaScript 1
loading
Tags: ejChart
Rekha J [Syncfusion]
Asked On June 18, 2014 04:40 AM

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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;