0
I’m trying to create a graph with the framework Highcharts, to create a chart, which framewor itself makes available, highstock.
I’m trying to generate a graph like line, the values are correct, but the date is wrong. I looked at a filing cabinet of the framework where, in the examples they demonstrate, they search for the data.
A part of the excerpt:
[
[1285718400000,41.05],
[1285804800000,40.54],
/* Oct 2010 */
[1285891200000,40.36],
[1286150400000,39.81],
[1286236800000,41.28],
[1286323200000,41.31],
[1286409600000,41.32],
[1286496000000,42.01],
[1286755200000,42.19],
[1286841600000,42.65],
[1286928000000,42.88],
[1287014400000,43.19],
[1287100800000,44.96],
[1287360000000,45.43],
[1287446400000,44.21],
[1287532800000,44.36],
[1287619200000,44.22],
[1287705600000,43.92],
[1287964800000,44.12],
[1288051200000,44.01],
[1288137600000,43.98],
[1288224000000,43.61],
[1288310400000,43.00],
/* Nov 2010 */
[1288569600000,43.45],
[1288656000000,44.19],
[1288742400000,44.69],
[1288828800000,45.47],
[1288915200000,45.30],
[1289174400000,45.52],
I soon realized that the values on the left, with 13 characters, could be the date.
In my code I did this way:
Observing: The two code snippets are in the same file.
PHP:
$valorTendencia[] = array(strtotime($value->DataHoraPrevisao),$value->Valor);
$encodeValorTendencia = json_encode($valorTendencia, JSON_NUMERIC_CHECK);
Javascript:
<script type="text/javascript">
// Create the chart
Highcharts.stockChart('container', {
rangeSelector: {
selected: 1
},
title: {
text: 'AAPL Stock Price'
},
series: [{
name: 'AAPL',
data: <?php echo $encodeValorTendencia; ?>
},{
name: 'Teste',
data: <?php echo $encodeValorObtencao; ?>
}]
});
</script>
But it takes a date from 1970, and the dates I want are current.
In the variable $value->DataHoraPrevisao
are the dates I want to use and are in this format: (string) 2017-09-01 03:00:00
.
In the API I couldn’t find anything related.