Drawing a data series w/out it appearing on the legend

372 views
Skip to first unread message

jne...@iotoptech.com

unread,
Feb 2, 2017, 10:24:53 AM2/2/17
to dygraphs-users
Ok, so a rather odd request here, so a little background data on the information:

The primary datapoint is measuring the temperature of a large engine/motor at a wastewater treatment facility.  Our given warning/critical thresholds are set as a differential between ambient temperature.  On typical charts, I can use the built in canvas.drawRect to do some horizontal shading for set thresholds, but this becomes complicated when the threshold is a moving target.

The above image is the motor temp paired with NOAA historical ambient data.
So my first issue is thus: The sample rate for the two data series are different (once per minute for motor temp, 1-4 times per hour for noaa ambient).  Without running a lerp script on the data, I get a lot of "undefined" in the legend, so it would be easier just to "turn the series off" for data purposes, and essentially just have it drawn as a reference/correlation set.

This compounds when I draw the warning threshold levels (ambient + 60 & 70)


So in addition hiding these 3 or more series from the legend, I'd also like to be able to:

Draw an inverted 'fillGraph' for the two threshold series and possibly hide the actual data line itself (or change it to match the background color if it's not possible to hide them)

To clarify a bit, on the above image, the two "purple" lines are the threshold.  The area above the topmost would be shaded red, and the area above the one below it would be shaded amber (darkish yellow), similar to how I have thresholds set in one of my more "standard" graphs:


I know it's a rather odd compound situation... I've done a lot of googling/researching on the individual components of my task at hand, and a lot of it seems to be unanswered on Reddit/here/stackoverflow... so any assistance would be appreciated.


On a side note: since 'connectSeparatedPoints' does a canvas draw over unknown values, it "should" in theory have all the data internalized to do an "on the fly" linear interpolation.  Is there any current plan to make some sort of data callback on the draw function available, possibly through an additional boolean flag, to prevent the 'undefined' datapoints?




 

Dan Vanderkam

unread,
Feb 2, 2017, 10:14:56 PM2/2/17
to dygraph...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "dygraphs-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dygraphs-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jne...@iotoptech.com

unread,
Feb 3, 2017, 10:05:14 AM2/3/17
to dygraphs-users
Thanks danvk,
   Based on that answer I was able to generate the following:


And here's the code that got me there:



gs2 = new Dygraph(document.getElementById("div2"),
<?php

$sql = "SELECT testdata.date, testdata.time, testdata.motorintemp, noaadata.drybulbf
FROM testdata
LEFT JOIN `noaadata`
ON (testdata.date = noaadata.date) AND (testdata.time = noaadata.time)";
$result = $conn->query($sql);

echo "[";

while($r = mysqli_fetch_array($result)){
$test = $r['date'] . " " . $r['time'];
$a = date('Y-m-d H:i:s',strtotime($test));
$a= '"'.$a.'"';
$b = ((float) $r['motorintemp']);
if ($r['drybulbf'] != null){
 $c = ((float) $r['drybulbf']);
$d = $c + 60.0;
$e = $c + 70.0;
} else {
$c = $d = $e = "null";
}
$f = (float) 199.9;
echo '['."(new Date($a))".','.$b.','.$c.','.$d.','.$e.','.$f.'],';
}
echo "]";
?>,
{
labels:["Timestamp", "Motor Inboard Temp", "Ambient Temp", "warn","crit","upper"],
legend: 'always',
connectSeparatedPoints: true,
valueRange:[-20, 200],
series: {
upper: {
color: rednoa,
fillGraph: true,
fillAlpha: 1.0,
},

crit: {
color: ambernoa,
fillGraph: true,
fillAlpha: 1.0,
},
warn: {
color: greennoa,
fillGraph: true,
fillAlpha: 1.0,
//
},
'Motor Inboard Temp': {
color: 'black',
}
},
legendFormatter: function(data) {
data.series = [data.series[0]];
return Dygraph.Plugins.Legend.defaultFormatter.call(this, data);
}
}
 )


To unsubscribe from this group and stop receiving emails from it, send an email to dygraphs-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages