Home Forums Chart Support Loading data series from an external file

Loading data series from an external file

Viewing 13 posts - 1 through 13 (of 13 total)
  • #27981

    Hi there,

    In CanvasJS, is it possible to load a data series from an external file? For example, i have a file named data.txt with the content:

    { x: 10, y: 71 },
    { x: 22, y: 55},
    { x: 31, y: 50 },
    { x: 44, y: 65 },
    { x: 50, y: 95 },
    { x: 64, y: 68 },
    { x: 72, y: 28 },
    { x: 84, y: 34 },
    { x: 90, y: 14}

    How can i assign this content to a CanvasJS variable and plot it, if possible?

    Thanks in advance. Best regards.

    #28020

    @gutemberg,

    Kindly refer this JSFiddle on creating chart from an external text file.

    The format of the text file( e.g. dataPoints.txt ) should be:

    10 71 
    22 55
    31 50
    44 65
    50 95
    64 68
    72 28


    Shashi Ranjan
    Team CanvasJS

    #28038

    @Sashi, thanks for your reply.
    Is it possible to load the content from a file without using an “input” html tag?
    I’ve searched through Internet and I realized that input tag is the easiest and most used way to do this, but I really want to do it programatically with CanvasJS without using any type kind of html tag.

    Thanks in advance for your attention.
    Best Regards

    #28062

    @gutemberg,

    You can achieve the above requirement using the jQuery get() method. Please refer to this StackOverflow article for more information on the same.


    Shashi Ranjan
    Team CanvasJS

    #28073

    Hi Sashi, thanks again.
    I have a new question:In running CanvasJS line graphic (and maybe others) could exist marks on x axis without corresponding marks on y axis.
    How can I eliminated this x axis points related no value in y axis, pls?

    Thanks in advance. Best regards.

    #28101

    @gutemberg,

    Can you kindly share a pictorial representation and brief us more about your requirement so that we can understand your scenario better and help you out?


    Shashi Ranjan
    Team CanvasJS

    #28118

    @Sashi, thanks for your almost infinite patiente with us.
    I put an exemple here .
    How can I eliminate the columns space related to dates 03 and 04/01/2020 (brazilian date format)?

    Thanks in advance.
    Best Regards

    #28119
    #28124

    @Sashi, I found a proposed solution by @Indranil that is almost what I’m looking for.
    In his solution, @Indranil worked with date and time variables, excluding x-points that don’t have y-points.

    Best regards.

    #28125

    #28126
    #28152

    @Sashi, don’t bother with my question anymore.

    @Idranil’s solution worked. I only made a litle adjustment on my own data.

    Thanks a lot guys.

    Best regards

    #28160

    @gutemberg,

    Glad that it worked for you :)


    Shashi Ranjan
    Team CanvasJS

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

You must be logged in to reply to this topic.