question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating Chart Data via Ajax?

See original GitHub issue

Hi,

I have an ajax on the setinterval timer and would load the line chart data (the data loads nicely, formatted in json) but It error out update() function. Can someone point me the right direction?. Thank you.

$(function() { $(document).ready(function(){

     var get_data = setInterval(function(){         
        var ajaxrequest;
        ajaxrequest = $.ajax({
            type:"post",
            datatype:"Json",
            url:"index.php?r=site%2FChartdata",
            data: (typeof data ==="string"? data:null),
            success: function(data) { 

                 var mychart //= $('#LineChart .ct-chart');
              mychart.data = data;
              mychart.update();  //<-- Error on this, Function not found.               
            },
        });  
    },3000);
}); 

});

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
gionkunzcommented, May 19, 2015

If you don’t have the original chart object that was returned during instanciation in this context, then try this:

var mychart = $('#LineChart .ct-chart');
mychart.get(0).__chartist__.update(data);
0reactions
Gurupriya-Royalitcommented, Jan 24, 2020

Hello, i am using Chartist JS. and i want to change it when click on date means i want to send date value by ajax and then according to date, chart series value fetch from data base and according to value chart should be change. please any one help me…

Read more comments on GitHub >

github_iconTop Results From Across the Web

HOWTO: Update your charts dynamically with AJAX
To update your charts using AJAX requires you to understand that the page you're requesting via AJAX doesn't generate the chart. It only...
Read more >
Chart.js - Dynamically Update Chart Via Ajax Requests
You can use the CSS from another Pen by using its URL and the proper URL extension.
Read more >
Refresh the Bar Char in ChartJS (v2.6.0) Using Ajax ...
And update the data to what you get from your ajax call, and use the chart.update() method, so you can keep using the...
Read more >
Live Updating JavaScript Charts from JSON API & AJAX
A tutorial on creating Live Updating JavaScript Charts with Data coming from an external JSON API using AJAX.
Read more >
Update Charts from JSON API & AJAX
A guide on how to update the charts from JSON API & AJAX. In many cases, you might not have the data available...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found