I am currently working with a form that contains values I would like to display in a chart. The code segment related to this task is provided below:
var chart;
function createChart() {
console.log($("#kok").val()); // this prints a number
try {
chart = new CanvasJS.Chart("chart", {
theme: "theme2",
title: {text:"Support"},
data: [{
type:"column",
dataPoints: [
{label:"KOK", y:$("#kok").val()}, // the issue lies here
{label:"KESK", y:$("#kesk").val()},
{label:"SDP", y:$("#sdp").val()},
{label:"PS", y:$("#ps").val()},
]
}]
});
} catch(e) {
console.log(e.message);
}
chart.render();
Can you identify what could be going wrong in this script? Would it be advisable to switch to a different library?