Home forums Using CanvasJS Collection data with Ajax

This topic contains 8 replies, has 4 voices, and was last updated by  Vishwas R 5 months, 2 weeks ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #10378

    michael9xhp
    Member

    please help me collection live data with Ajax from Json.
    It like:
    $(document).ready(function () {
    $.ajax({
    type: ‘GET’,
    url: ‘http://example/functions.php’,
    data: { get_param: ‘value’ },
    success: function (data) {
    var names = data
    $(‘#cand’).html(data);
    }
    });
    });

    I take it from: http://stackoverflow.com/questions/8951810/how-to-parse-json-data-with-jquery-javascript
    Help me to collection Json to render graph
    Thanks!!!

    #10390

    Vishwas R
    Keymaster

    Michael,

    Here is an example for loading JSON data from external source using AJAX.

    You can also refer loading data from external JSON in this example.

    #10584

    ASK123
    Member

    Code_file

    This is my implementation, using AJAX requests. Unfortunately, i’m unable to find out why it is not working, Kindly help finding where I have gone wrong.

    #10587

    Vishwas R
    Keymaster

    Generally JavaScript code will function in the head before code in the body. The head section is usually used to contain information about the page that you don’t necessarily see like the meta keywords meta description or title of a page.

    Here in your case, Buttons with id ‘chart1’ and ‘chart2’ are created after script is run, but where it fails to fetch buttons with those ids. You can move script tag to body so that it works fine. Here is your working code.

    Refer these links for more info on placement of JavaScript code.
    TutorialPoints
    W3Schools
    Stackoverflow

    • This reply was modified 6 months, 1 week ago by  Vishwas R.
    #10903

    ASK123
    Member

    Hi,
    Thank you for the help.
    It doesn’t seem to work after including the processdata function. It throws a “Chart not defined error”.
    This is the code

    #11040

    Vishwas R
    Keymaster

    Kindly update the code with absolute path of the CSV-file, so that we can look into it and help you out. Refer this jsfiddle for rendering multiple charts from multiple external CSV.

    #11280

    ASK123
    Member

    Thank you so much! Passing the “chart” as parameter solved it!

    #11408

    saimeera.jp
    Member

    Hi, Im creating a chart from a collection data with ajax using example like you (@Vishwas R) mentioned above. My code seems to be working in jsfiddle in this my chart but it doesn’t seem to be working when I use the same code in a text editor(in my case Sublime Text)

    • This reply was modified 5 months, 2 weeks ago by  saimeera.jp.
    • This reply was modified 5 months, 2 weeks ago by  saimeera.jp.
    #11413

    Vishwas R
    Keymaster

    Saimeera,

    We observed that you are using dateTime over axis-X. Kindly refer this link for JavaScript date-time object.

    Here is the working fiddle.
    Screenshot

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.