Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
How to add the attribute of title in chart.render() method of canvas js dynamically with the help of select elements

<!DOCTYPE HTML>
<html>

<head>
<script type="text/javascript">
    window.onload = function () {
        var dps = []; //dataPoints. 

        var chart = new CanvasJS.Chart("chartContainer", {
            title: {
                text: "Accepting DataPoints from User Input"
            },
            data: [{
                type: "line",
                dataPoints: dps
            }]
        });

        function addDataPointsAndRender() {
            xValue = Number(document.getElementById("xValue").value);
            yValue = Number(document.getElementById("yValue").value);
            dps.push({
                x: xValue,
                y: yValue
            });
            chart.render();
        }

        var renderButton = document.getElementById("renderButton");
        renderButton.addEventListener("click", addDataPointsAndRender);
    }
  </script>
  <script type="text/javascript" 
  src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</head>

<body>
X Value:
<input id="xValue" type="number" step="any" placeholder="Enter X-Value"> Y Value:
<input id="yValue" type="number" step="any" placeholder="Enter Y-Value">


<select id="select1">
    <option value="bar">Bar</option>
    <option value="pie">Pie</option>
    <option value="column">Column</option>
</select>
</p>


<button id="renderButton">Add DataPoint & Render</button>
<div id="chartContainer" style="height: 270px; width: 100%;">
</div>
</body>

</html>

In the above code how I can change the value of chart type in data attribute of this function data: [{ type: "line", dataPoints: dps }] dynamically with the help of html select options?? plz help me as I am beginner in JS and solutions with the help of jquery will also be welcomed...

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!