Dynamically replace object values from html textarea

Dynamically replace object values from html textarea

Good Day;

I’m creating bar charts utilizing JavaScript. What i would like is the consumer to enter values for the chart. At the second i wrote code (by way of a tutorial) the place the values are onerous coded on to the script.I have to amend the onerous coded so the worth may be entered by way of a textarea and dynamically the chart modifications in keeping with the values (i choose to not have a button – dynamical modifications).

This is my javascript object:

const traditional = doc.getElementById('traditional').worth; var myBarchart = new BarChart({ canvas: myCanvas, seriesName: "Vinyl records", padding: 40, gridStep: 5, gridColor: "black", information: { Classical_Music: traditional, "Alternative Rock": 12, Pop: 18, Jazz: 32 }, colours: ["#a55ca5", "#67b6c7", "#bccd7a", "#eb9743"], titleOptions: { align: "middle", fill: "black", font: { weight: "daring", dimension: "18px", household: "Lato" } } }); 

What i would like the worth from the traditional must be used to vary the worth within the information object.

HTML Code:

<physique> <textarea id="traditional"></textarea><br> <canvas id="myCanvas" fashion="background: white;"></canvas> <legend for="myCanvas"></legend> <script kind="textual content/javascript" src="script.js"></script> 

Any steerage will likely be appreachiated.

Vinyl

by way of Active questions tagged javascript – Stack Overflow https://ift.tt/AfiLy43

November 1, 2023 at 08:03AM