Home Forums Chart Support Rendering a Chart with a button click

Rendering a Chart with a button click

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

    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 10 years, 10 months ago by mbatilando.
    #4300

    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

    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

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

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

    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/

    Render chart on button click

    #4306

    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.