I'm working on a weekend project to monitor temperature and humidity using a DHT22 sensor and my raspberryPi. The readings are working great and now I'm trying to plot everything using Highcharts.
This is the Highcharts options I'm using:
Highcharts.setOptions({global:{useUTC:false}});options={
chart:{
renderTo:"content",
type:"spline",
zoomType: 'xy'
},
title:{
text:"title"
},
subtitle:{
text:""
},
xAxis:{
type:"datetime",
dateTimeLabelFormats:{
hour:"%H. %M"
}
},
yAxis: [{ // temperature axis
title: {
text:"T (°C)"
},
labels: {
format: '{value}',
style: {
fontSize: '10px'
}
}
}, { // humidity axis
title: {
text: "Humidity (%)",
},
labels: {
format: '{value}',
style: {
fontSize:'10px'
}
},
opposite: true,
gridLineWidth: 0
}],
tooltip:{
shared: true
},
series: [{
name: 'Temperature',
data:[],
tooltip: {
valueSuffix: ' °C'
}
},
{
name: 'Humidity',
data:[],
yAxis:1,
tooltip: {
valueSuffix: ' %'
}
}]
}
and this is the actual code to insert data into the graph:
<script type="text/javascript">
$(document).ready(function(){
var urls = [GetTempXml(),GetHumidityXml()];
var xmlTemp;
var xmlHum;
$.get(GetTempXml(), function(xmlTemp) {
$.get(GetHumidityXml(), function(xmlHumid) {
var $xmlTemp = $(xmlTemp), $xmlHumid = $(xmlHumid);
//populate with data
function populate(xml, index) {
$(xml).find("row").each(function() {
var t = parseInt($(this).find("t").text())*1000
$(this).find("v").each(function(index){
var v = parseFloat($(this).text())
v = v || null
if (v != null) {
options.series[index].data.push([t,v])
};
});
});
};
populate(xmlTemp, 0);
populate(xmlHumid,1);
options.title.text = "Temperature and Humidity";
//add sunrise and sunset
options.xAxis.plotBands = []
for (var i = GetBandsNumber(); i >= 0; i--) {
var d = new Date();
d.setHours(0,0,0,0);
d.setDate(d.getDate()-i);
var sunrise = d.getTime()+computeSunrise(dayOfYear(), true);
var sunset = d.getTime()+computeSunrise(dayOfYear(), false);
options.xAxis.plotBands.push({
from: sunrise,
to: sunset,
color: '#FCFFC5'
});
};
chart = new Highcharts.Chart(options);
});
});
});
</script>
But as you can see there are a few issues:

The Humidity axis is not using a different collor. I even tried using on the axis definition but didn't work:
style: { color: Highcharts.getOptions().colors[0] }
- The tooltip was supposed to be shared but only displays humidity data
- There is a weird curve from the first humidity value to the last temperature value. How can I remove that?
serienotaxisthat you are mentioning. Secondly, It seems your humidity serie has no data. Thats why it doesn't show any red lines or doesn't show in the tooltip. That curve may be because your data is not sorted. Do you have any errors in your page console? As @RocoCTZ mentioned it would be much easier for us to help you if you could implement your code in jsfiddle.net - Raein Hashemi