Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda