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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

AJAX data to Line Chart is failing

Thread ID:





126246 Oct 4,2016 06:02 AM UTC Oct 5,2016 12:41 PM UTC ASP.NET MVC 1
Tags: Chart
Asked On October 4, 2016 06:02 AM UTC

Dear Team,

This is a follow-up of the post https://www.syncfusion.com/forums/126169/need-assistance-to-identify-the-contextual-charting

I have modified the code to try load the data via Ajax. However I am getting errors like sender is not defined. I have even initialized the sender to ejChart instance of the page. Also for some reason if I use ViewBag. format to assign the value to var chart, the " and ' are escaped causing Javascript errors. Is this format not supported.

And what is the issue with Ajax?

    $(document).ready(function () {
        $.get("home/GetData", function (data) {
            var chartData = data;

            $("#chart").ejChart("option", { series: [{ dataSource: data }] });

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

            for (var i = 0; i < chartObj.model.series.length; i++) {
                chartObj.model.series[i].dataSource = chartData[i].points;
                chartObj.model.series[i].xName = "index";

            chartObj.model.series[0].yName = "parameterX";
            chartObj.model.series[1].yName = "parameterY";
            chartObj.model.series[2].yName = "parameterZ";
            chartObj.model.series[3].yName = "inputX";
            chartObj.model.series[4].yName = "inputY";
            chartObj.model.series[5].yName = "inputZ";



Dharanidharan Dharmasivam [Syncfusion]
Replied On October 5, 2016 12:41 PM UTC

Hi Deepak, 

Thanks for using Syncfusion product. 
We have analyzed your query. You are trying to  get the instance for the chart using ajax call in the $(document).ready() function, but at this point chart won’t get loaded in the page and hence you might get this error. In this case you can use window.onload() function, this will executed only after the page is fully loaded, so that you can get instance for the chart. Find the code snippet below, 

Code Snippet: 

window.onload=function () { 
            type: "POST", 
            url: '@Url.Action("chart","Home")', 
            async: false, 
            success: function (data) { 
                var resp = eval("" + data + ""); 
                var chart = $("#Container").ejChart("instance"); 
                chart.model.series = []; 
                for (var i = 0; i < 6; i++) { 
                    chart.model.series.push({ dataSource: resp[i].points }); 
                    chart.model.series[i].xName = "index"; 
                chart.model.series[0].yName = "parameterX"; 
                chart.model.series[1].yName = "parameterY"; 
                chart.model.series[2].yName = "parameterZ"; 
                chart.model.series[0].yAxisName = "yAxis1"; 
                chart.model.series[1].yAxisName = "yAxis1"; 
                chart.model.series[2].yAxisName = "yAxis1"; 
                chart.model.series[3].yName = "inputX"; 
                chart.model.series[4].yName = "inputY"; 
                chart.model.series[5].yName = "inputZ"; 

For your reference, we have attached the sample. Kindly find the attachment below, 
We are not clear with the query  also for some reason if I use ViewBag. format to assign the value to var chart, the " and ' are escaped causing Javascript errors. Are you passing any format to the chart from ViewBag? Kindly provide us more information on this query and modify the sample/provide your sample with replication steps, so that we can able to provide the solution sooner. 



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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon