Jump to content
Fórum Script Brasil
  • 0

Grafico javascript html


roberto82

Question

Olá!

Preciso de uma ajuda! 

Fiz um site, onde após questionário geram valores numéricos, através da:

function totalScore(){
    var total_score =
    answers.question1+
    answers.question2+
    answers.question3+
    answers.question4+
    answers.question5+
    answers.question6+
    answers.question7+
    answers.question8;
    
    return total_score;
}

 document.getElementById("printtotalscore").innerHTML = totalScore();

agora preciso gerar um gráfico, mas não estou conseguindo buscar esse número nem como "variável" ou como "document.getElementById('printtotalscore').innerHTML"...

para dentro desse código que gera o gráfico:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
        google.charts.load('current', { packages: [ 'corechart' ] })
        google.charts.setOnLoadCallback(drawChart)
                
    function totalScore(){
    var total_score =
    answers.question1+
    answers.question2+
    answers.question3+
    answers.question4+
    answers.question5+
    answers.question6+
    answers.question7+
    answers.question8;
    
    return total_score;
}


               
        function drawChart() {
            const container = document.querySelector('#chart')
            const data = new google.visualization.arrayToDataTable([
             
            [ 'Character', 'que' ],
                [ 'Visual', totalScore],
                [ 'Vg', 100],
                [ 'vz', 250 ],
                [ 'ab', 300 ],
                [ 'pc', 100]
            ])
            const options = {
                title: 'Processamento Sensorial',
                height: 400,
                width: 720
            }

            //const chart = new google.visualization.ColumnChart(container)
            //const chart = new google.visualization.BarChart(container)
            //const chart = new google.visualization.LineChart(container)
            const chart = new google.visualization.PieChart(container)
            chart.draw(data, options)
        }
    </script>

alguém poderia ajudar, por favor?

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      651.7k
×
×
  • Create New...