我有一个视图,根据日期时间范围和选择列表中的一个值显示图表,它目前在我的本地工作完美,但在我的服务器中它只是没有图表任何东西,任何人都可以帮助我。< / p>
以下是视图代码:
<html>
<head>
<title>Gráfico</title>
<link href="<?php echo base_url(); ?>css/bootstrap-combined.min.css" rel="stylesheet">
<link href="<?php echo base_url(); ?>css/bootstrap-glyphicons.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Lato:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
<link href="<?php echo base_url(); ?>estilos.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="screen"
href="<?php echo base_url(); ?>css/bootstrap-datetimepicker.min.css"> <meta charset="utf-8" />
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
//Funcion para generar un gráfico en Lineas
function LineChart() {
var data = google.visualization.arrayToDataTable(<?= $grafico2;?>);
var options = {
title: '<?php echo "Paquetes recibidos por la IP: ".$ip." en las fechas: ".$fechainicio." - ".$fechafin; ?>',
'width':900,
'height':400,
hAxis: {title: 'Fechas', titleTextStyle: {color: 'black'},},
vAxis: {title: 'Paquetes', titleTextStyle: {color: 'black'},}
};
var chart = new google.visualization.LineChart(document.getElementById('linechart_div'));
chart.draw(data, options);
}
google.setOnLoadCallback(LineChart);
</script>
</head>
<body>
<div id="contenido">
<div class="container">
<?php include_once "header.php"; ?>
<?php echo form_open('home/graph'); ?>
<font color="#27A7D6">Seleccione fecha inicial:<br></font>
<div id="datetimepicker" class="input-append date">
<input type="text" name="fechainicio"></input>
<span class="add-on">
<i data-time-icon="glyphicon glyphicon-time" data-date-icon="glyphicon glyphicon-minus"></i>
</span>
</div>
<script type="text/javascript"
src="<?php echo base_url(); ?>js/jquery-1.11.0.js">
</script>
<script type="text/javascript"
src="<?php echo base_url(); ?>js/bootstrap.min.js">
</script>
<script type="text/javascript"
src="<?php echo base_url(); ?>js/bootstrap-datetimepicker.min.js">
</script>
<script type="text/javascript"
src="<?php echo base_url(); ?>js/bootstrap-datetimepicker.es.js">
</script>
<script type="text/javascript">
$('#datetimepicker').datetimepicker({
format: 'yyyy/MM/dd hh:mm:ss',
language: 'es'
});
</script>
<font color="#27A7D6">Seleccione fecha final:<br></font>
<div id="datetimepicker2" class="input-append date">
<input type="text" name="fechafin"></input>
<span class="add-on">
<i data-time-icon="glyphicon glyphicon-time" data-date-icon="glyphicon glyphicon-minus"></i>
</span>
</div>
<script type="text/javascript"
src="<?php echo base_url(); ?>js/jquery-1.11.0.js">
</script>
<script type="text/javascript"
src="<?php echo base_url(); ?>js/bootstrap.min.js">
</script>
<script type="text/javascript"
src="<?php echo base_url(); ?>js/bootstrap-datetimepicker.min.js">
</script>
<script type="text/javascript"
src="<?php echo base_url(); ?>js/bootstrap-datetimepicker.es.js">
</script>
<script type="text/javascript">
$('#datetimepicker2').datetimepicker({
format: 'yyyy/MM/dd hh:mm:ss',
language: 'es'
});
</script>
<!-- INICIO DEL SELECT IP-->
<?php
require_once ('funciones.php');
$con=fullconectar();
$res=mysql_query("select * from alarmas",$con);
?>
<font color="#27A7D6">Seleccione su IP:<br></font>
<select id="ip" name ="ip" style="width:235px">
<?php while($fila=mysql_fetch_array($res)){ ?>
<option><?php echo $fila['ip']; ?></option>
<?php } ?>
</select>
<div><input type="submit" value="Enviar" /></div>
<?php echo form_close(); ?>
<?php echo "Total de tiempo offline para la IP: ".$ip." entre las fechas: ".$fechainicio." - ".$fechafin.": ".$tiempooff." minutos."; ?>
<div id="linechart_div"></div>
</div></div>
</body>
</html>
答案 0 :(得分:0)
查看实际输出,问题在于:
var data = google.visualization.arrayToDataTable(<?= $grafico2;?>);
你会注意到你的PHP引擎没有解析<?= $grafico2;?>
。这表示您的服务器上没有启用短标签。目前,只需将该行改为:
var data = google.visualization.arrayToDataTable(<?php echo $grafico2;?>);
但是你可能希望将来enable short-tags。