End date range Highcharts

0

Hello, I have a json that php creates for through a select in mysql.

I'm putting the data on a chart with a start date until the end date. At the beginning everything is in order, but the final date does not match the final of the select.

Detail : I convert my datetime to milliseconds so that highchart interprets the date, and the last date in ms of my json being converted to datetime beats with the correct value.

Can anyone help me?! I am grateful now. Here is an excerpt from the code below:

$sql = "SELECT temp_max,temp_min ,temp_inst, 
               UNIX_TIMESTAMP(timestep)*1000 as datemiliseconds 
        FROM INMET.data_inmet 
        where cod_pcd = '$name' and temp_max is not null
        order by datemiliseconds asc";

$connection = mysql_connect('minhas informações');
if (!$connection) {
    die('Not connected : ' . mysql_error());
}
$db_selected = mysql_select_db('meu bd', $connection);
if (!$db_selected) {
    die('Can\'t use db : ' . mysql_error());
}

$sth = mysql_query($sql);
if (!$sth) {
    die('Invalid query: ' . $sql . mysql_error());
}
$rows = array();
$r = null;
while ($r = mysql_fetch_array($sth)) {
    $rows ['dataini'] [] = $r ['datemiliseconds'];
    $rows ['data'] [] = $r ['temp_max'];
    $rows ['data1'] [] = $r ['temp_min'];
    $rows ['data2'] [] = $r ['temp_inst'];
}

$result = array();
array_push($result, $rows);

print json_encode($result, JSON_NUMERIC_CHECK);

And like this graphic ..

$.getJSON("all-data.php?name=<?php echo $_GET["name"]; ?>", function (data) {
    // console.log(data);
    var start = +new Date();
    // Create a timer
    // Create the chart
    $('#alltemp').highcharts('StockChart', {
        credits: {
            text: '', href: '',
        },
        chart: {
            events: {
                load: function () {
                    if (!window.isComparing) {
                        this.setTitle(null, {
                            text: 'Construído em ' + (new Date() - start) + 'ms'
                        });
                    }
                }
            },
            zoomType: 'x'
        },
        rangeSelector: {
            buttons: [{
                type: 'day',
                count: 3,
                text: '3d'
            }, {
                type: 'week',
                count: 1,
                text: '1w'
            }, {
                type: 'month',
                count: 1,
                text: '1m'
            }, {
                type: 'month',
                count: 6,
                text: '6m'
            }, {
                type: 'year',
                count: 1,
                text: '1y'
            }, {
                type: 'all',
                text: 'All'
            }],
            selected: 3
        },


        yAxis: {
            title: {
                text: 'Temperatura ( °C)'
            }
        },
        title: {
            text: 'Representação período completo'
        },
        subtitle: {
            text: 'Costruído em ...' // dummy text to reserve space for dynamic subtitle
        },
        plotOptions: {
            line: {
                dataLabels: {
                    enabled: false
                },
                marker: {
                    enabled: false
                },
                enableMouseTracking: true
            }
        }
        ,
        legend: {
            enabled: true,
            align: 'right',
            backgroundColor: '#FCFFC5',
            borderColor: 'black',
            borderWidth: 2,
            layout: 'vertical',
            verticalAlign: 'top',
            y: 100,
            shadow: true,
            reversed: true
        },
        series: [
            {
                name: 'Temperatura máxima',
                data: data[0].data,
                dashStyle: 'longdash',
                pointStart: data[0].dataini[0],


                pointInterval: 3600000,

                tooltip: {
                    valueDecimals: 2, valueSuffix: ' °C'
                }
            },
            {
                name: 'Temperatura instantânea',
                data: data[0].data2,
                pointStart: data[0].dataini[0],

                pointInterval: 3600000,
                tooltip: {
                    valueDecimals: 2,
                    valueSuffix: ' °C'
                }
            },
            {
                name: 'Temperatura mínima',
                data: data[0].data1,
                pointStart: data[0].dataini[0],

                pointInterval: 3600000,
                tooltip: {
                    valueDecimals: 2,
                    valueSuffix: ' °C'
                }
            }
        ]

    });
}

Thank you!

Here is an image:

Done, the ending date that is displayed is wrong .. My bd has until 17 Dec 2015. And the initial all right ...

    
asked by anonymous 07.01.2016 / 20:45

0 answers