Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda