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 6 years ago.
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?
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.
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.
Thanks for helping! Here you go: http://jsfiddle.net/jx9sJ/
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.
Awesome, it works! Thank you so much!
You must be logged in to reply to this topic.