Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*HTML*/
- <!doctype html>
- <html>
- <head>
- <title>Bar Chart</title>
- <script src="Chart.js-master/Chart.js"></script>
- </head>
- <body>
- <div style="width: 50%">
- <canvas id="pergunta1" height="450" width="600"></canvas>
- </div>
- <script>
- var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
- var barChartData = {
- labels : ["0","1","2","3","4","5"],
- datasets : [
- {
- label: "Dados primários",
- fillColor: "rgba(220,220,220,0.2)",
- strokeColor: "rgba(220,220,220,1)",
- pointColor: "rgba(220,220,220,1)",
- pointStrokeColor: "#fff",
- pointHighlightFill: "#fff",
- pointHighlightStroke: "rgba(220,220,220,1)",
- <?php
- include('query.php');
- ?>
- }
- ]
- }
- window.onload = function(){
- var ctx = document.getElementById("pergunta1").getContext("2d");
- window.myBar = new Chart(ctx).Bar(barChartData, {
- responsive : true
- });
- }
- </script>
- </body>
- </html>
- /*CONSULTA*/
- <?php
- $total = mysql_query("SELECT * FROM tabela WHERE statusPesquisa=2");
- $linhaTotal = mysql_num_rows($total);
- $inicio = 0;
- echo "data : [";
- while($inicio <= 5){
- $query = "$query$inicio";
- $row = "$row$inicio";
- $notapergunta = "notapergunta$inicio";
- $query = mysql_query("SELECT * FROM tabela WHERE notapergunta1=$inicio AND statusPesquisa=2");
- $row = mysql_num_rows($query);
- if($inicio == 0) {
- $percent = 0;
- } else{
- $percent = 359 / $row;
- }
- if($inicio != 5) {
- echo round($percent).",";
- }
- else {
- echo round($percent);
- }
- $inicio++;
- }
- echo "]";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement