Jump to content

Gráfico Google Charts


Recommended Posts

Bom dia

Estou montando um gráfico em Google charts, php e banco mysql

preciso de ajuda para colocar os valores aparentes nas barras. tem exemplo n a documentação, mas não trazendo os dados do banco..

alguém consegue me dar uma luz?

segue código.

<!DOCTYPE html>

	<meta charset="utf-8">
	<link rel="stylesheet" type="text/css" href="../css/stilo.css">
	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
	<meta name="author" content="">
	<meta name="description" content="">
	<meta name="viewport" content="width=device-width" scale="1">
	<!-- transforma a pagina em  responsivel-->
	<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
	<script type="text/javascript">
		google.charts.load('current', {'packages':['corechart']});

		function drawVisualization() {
        // Some raw data (not necessarily accurate)
        var data = google.visualization.arrayToDataTable([
        	['Hora', 'UPM','Erros', 'Meta' ],
        	include 'conexao.php';          
        	$sql = "SELECT * FROM upm_hora";
        	$buscar = mysqli_query($conexao,$sql);

        	while ($dados = mysqli_fetch_array($buscar)) {
        		$hora = $dados['horasG'];
        		$upm = $dados['upm'];
        		$erros = $dados['difErros'];
        		$tempo = $dados['horasD'];
        		$meta = 800;
        		['<?php echo $hora ?> <?php echo $tempo ?>', <?php echo $upm ?>, <?php echo $erros ?>, <?php echo $meta ?>],	
        	<?php } ?>

        var options = {
        	title: 'Evolução da UPM',
        	vAxis: {title: 'UPM'},
        	hAxis: {title: 'Hora'},
        	seriesType: 'bars',        	
        	series: {2: {type: 'line'}},  

        var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
        chart.draw(data, options);
			<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
			<div id="chart_div" style = " width : 100% ; height : 500px	 ; " ></div>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.