<script type="text/javascript">
$(function() {
$.getJSON('data2.php', function(data) { // on récupère les data du json.
// on créer le graphe dans la div id : container
$('#container').highcharts({
title : {
text : 'pointchaud'
},
tooltip: {
shared: true
},
yAxis: [ { // Premier yAxis
title: {
text: 'temperature',
style: {
color: Highcharts.getOptions().colors[1]
}
},
min : 15,
max : 35,
opposite: true,
labels: {
format: '{value} °C',
style: {
color: Highcharts.getOptions().colors[1]
}
},
tooltip: {
valueSuffix: '°C',
}
},{ // Second yAxis
labels: {
format: '{value}%',
style: {
color: Highcharts.getOptions().colors[0]
}
},
min : 20,
max : 60,
tooltip: {
valueSuffix: ' %'
},
title: {
text: 'humidity',
style: {
color: Highcharts.getOptions().colors[0]
}
}
}],
// le xAxis
xAxis: {
categories: data[0]['data'] //correspond au 1er groupe de donnée du json créer par data.php (dateandtime pointchaud)
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 0,
floating: true,
borderWidth: 0
},
series: [{
type: 'spline',
name: 'humidity',
tooltip: {
valueSuffix: ' %'
},
yAxis: 1,
data: data[2].data, //correspond au 3 ème groupe de donnée du json créer par data.php (humidité pointchaud)
}, {
type: 'spline',
name: 'temperature',
tooltip: {
valueSuffix: ' °C'
},
yAxis: 0,
data: data[1].data //correspond au 2 ème groupe de donnée du json créer par data.php (temperature pointchaud)
}]
});
});
});
</script>
<div id="container"></div>