Chartjs-Using number/text input field to set the data values in ChartJs stops the chart from being displayed

0👍

It is hard to evaluate my solution when I do not have a complete example. So I’m not sure, but I hope the following helps you: It could be that you have a simple type error as the code

var input = document.getElementById("testId").value;

assigns a string value to the input variable. However, I think, you need an integer as input for your chart.

A solution could be:

var input = parseInt(document.getElementById("testId").value)

Although you have defined your input field as “number”, javascript does not use this type to convert the value automatically. So, you have to convert the value by yourself.

Leave a comment