Home forums Using CanvasJS Rendering a Chart with a button click

This topic contains 5 replies, has 2 voices, and was last updated by  mbatilando 3 years, 7 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4298

    mbatilando
    Participant

    I really like CanvasJS and I’m currently using it for a class project for a bit of probability data visualization. I basically have a form with a series of inputs and I’m trying to use the information in the form along with the onsubmit attribute to render a chart upon submitting it. Everything works fine but when it comes to rendering the chart with chart.render, it quickly disappears after a split second. Every time I click the submit button, it displays a chart then it quickly disappears. Could anyone give a reason as to why this is happening?

     

    Thanks!

    • This topic was modified 3 years, 7 months ago by  mbatilando.
    #4300

    mbatilando
    Participant

    After a bit of tinkering, I figured that one of the problem was that I was not using window.onload . But now after I’ve put it, It will not let me update the chart upon clicking the submit button so it’s not displaying any data since there are no inputs in the form directly after the page has loaded.

    #4301

    Sunil Urs
    Keymaster

    thank you… we are glad that you like CanvasJS 🙂

    Can you please post the code that you have written so that we get some idea on what is going wrong… you can also use jsfiddle for the same.

    #4303

    mbatilando
    Participant

    Thanks for helping! Here you go: http://jsfiddle.net/jx9sJ/

    • This reply was modified 3 years, 7 months ago by  mbatilando.
    #4305

    Sunil Urs
    Keymaster

    Chart is not getting rendered because its getting submitted upon click. If you just want to render chart on click of a button, don’t use “form”. Use normal text field and render the chart upon button click.

    Here is your working code. Note that jsfiddle is set to execute the javascript upon onLoad event – so, you have to write onload explicitly on your local machine

    http://jsfiddle.net/jx9sJ/5/

    #4306

    mbatilando
    Participant

    Awesome, it works! Thank you so much!

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

You must be logged in to reply to this topic.