filter search by dates in highcharts

0

I find myself testing this library highcharts and I would like to filter by date by consulting a BD, what would be the better way? the sql would be the least because there goes a WHERE however I have two fields in PHP for the date. The question is easy, how do I make highcharts take the rank of that query?

For now I have this:

<?php
include('../../modelo/conexion.php');
$con = new conectar();//CONECTO CON POSTGRESQL   
?>
<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>CODERU | AGROPATRIA</title>

        <center><img id="banner" src="../../images/cintillo_agro.JPG" height="60%" width="80%"></center>
        <script src="../../template/plugins/jQuery/jQuery-2.1.4.min.js"></script>   
        <style type="text/css">
${demo.css}
        </style>
        <script type="text/javascript">
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Cantidad de Despachos'
        },
        subtitle: {
            text: 'Despachos por fecha'
        },
        xAxis: {
            categories: [
<?php
$sql=pg_query("select * from despacho order by fecha");
while($res=pg_fetch_array($sql)){           
?>

            ['<?php echo $res['fecha'] ?>'
            ,'<?php echo $res['placa_camion'] ?>'],

<?php
}
?>

            ],
            title: {
                text: null
            }
        },
        yAxis: {
            min: 0,
            title: {
               // text: 'Population (millions)',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            }
        },
        tooltip: {
            //valueSuffix: ' millions'
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -40,
            y: 100,
            floating: true,
            borderWidth: 1,
            backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
            shadow: true
        },
        credits: {
            enabled: false
        },
        series: [{
            name: 'Toneladas',
            data: [
            <?php
$sql=pg_query("select * from despacho");
while($res=pg_fetch_array($sql)){            
?>          
            [<?php echo $res['cantidad'] ?>],

<?php
}
?>          
            ]
        }]
    });
});
        </script>
    </head>
    <body>
<script src="../reportes_graficos/Highcharts-4.1.5/js/highcharts.js"></script>
<script src="../reportes_graficos/Highcharts-4.1.5/js/modules/exporting.js"></script>
<link rel="stylesheet" href="../../template/bootstrap/css/bootstrap.min.css">
<div id="container" style="min-width: 410px; max-width: 900px; height: 650px; margin: 0 auto"></div>
<center><a href="../../vista/vistaPrincipal.php"><input type="button" value="INICIO" class="btn btn-info"></a></center>    

    </body>
</html>

There he takes all the information and shows it to me, but when are 100 dates? I hope this one a little clearer my doubt.

    
asked by Gilberto Asuaje 26.11.2016 в 04:57
source

0 answers