Skip to content

Commit 3348757

Browse files
committed
Merge branch 'develop'
When pointer moves over graph, show data values at that point.
2 parents 9b80a51 + 038f9b2 commit 3348757

File tree

3 files changed

+97
-9
lines changed

3 files changed

+97
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Basic feature list:
88
* supports multiple [iSpindel](https://github.com/universam1/iSpindel) temperature/hydrometer devices
99
* supports multiple DS18B20 temperature sensors
1010
* supports multiple [SainSmart](http://www.sainsmart.com/sainsmart-relay-module-for-arduino-raspberry-pi.html) 5V relay modules for total of up to 20x relays
11+
* supports multiple simultaneous jobs, limited only by numbers of attached input sensors and relay outputs
1112

1213
This is a complete javascript rewrite of the original (pre 0.3) python version.
1314

src/scripts/status.js

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,21 +1621,51 @@ window.onload = function () {
16211621
.attr("d", historyTemperatureLineFunction(scaledTemperatureLineData))
16221622
.attr("stroke", temperatureColours[sensor_instance])
16231623
.attr("stroke-width", temperatureStrokeWidth)
1624-
.attr("fill", "none");
1625-
}
1624+
.attr("fill", "none")
1625+
.on("mouseover", function() {
1626+
//console.log("in container: " + longName + " at: " + mouse(this)[0] + "," + mouse(this)[1]);
1627+
//console.log("X: " + tickText(historyLinearScaleX.invert(mouse(this)[0])));
1628+
//console.log("Y: " + historyLinearScaleY.invert(mouse(this)[1]));
1629+
1630+
1631+
/* Set the tooltip text, then move it into position and display it.
1632+
*/
1633+
select("#detailTooltipText_" + longName.replace('%', '\\%'))
1634+
.append("tspan").attr("x",0).attr("y",0).attr('dx', '0.9em').attr('dy', '1.1em').text("At: " + tickText(historyLinearScaleX.invert(mouse(this)[0])))
1635+
.append("tspan").attr("x",0).attr("y",18).attr('dx','0.9em').attr('dy', '1.1em').text("T = " + (historyLinearScaleY.invert(mouse(this)[1])).toFixed(2));
1636+
1637+
select("#detailTooltipGroup_" + longName.replace('%', '\\%'))
1638+
.attr("transform",
1639+
"translate(" + (historyJobsGraphMargin.left + mouse(this)[0]) + "," + (historyJobsGraphMargin.top + mouse(this)[1]) + ")")
1640+
.style("opacity", 0.9);
1641+
1642+
})
1643+
.on("mouseout", function() {
1644+
//console.log("out");
1645+
1646+
select("#detailTooltipGroup_" + longName.replace('%', '\\%'))
1647+
.transition()
1648+
.duration(200)
1649+
.style("opacity", 0.0);
1650+
1651+
// Remove previous entry
1652+
select("#detailTooltipGroup_" + longName.replace('%', '\\%'))
1653+
.selectAll("tspan").remove();
16261654

1655+
});
1656+
}
16271657
// Scale gravity data
16281658
if (gravityLineDataHolder[sensor_instance].length > 0) {
16291659
var scaledGravityLineData = [];
16301660
gravityLineData = gravityLineDataHolder[sensor_instance];
1631-
for ( sp=0;sp<gravityLineData.length;sp++) {
1661+
for (sp=0;sp<gravityLineData.length;sp++) {
16321662
//console.log("scaled sp = " + gravityLineData[sp].x + " : " + gravityLineData[sp].y);
16331663
scaledGravityLineData.push({
16341664
"x":historyLinearScaleX(gravityLineData[sp].x),
16351665
"y":historyLinearScaleY(gravityLineData[sp].y)
16361666
});
16371667
}
1638-
// Draw temperature graph
1668+
// Draw gravity graph
16391669
var historyGravityLineFunction = line()
16401670
.x(function(d) { return d.x; })
16411671
.y(function(d) { return d.y; });
@@ -1646,10 +1676,60 @@ window.onload = function () {
16461676
.attr("d", historyGravityLineFunction(scaledGravityLineData))
16471677
.attr("stroke", gravityColours[sensor_instance])
16481678
.attr("stroke-width", gravityStrokeWidth)
1649-
.attr("fill", "none");
1679+
.attr("fill", "none")
1680+
.on("mouseover", function() {
1681+
//console.log("gravity in");
1682+
1683+
/* Set the tooltip text, then move it into position and display it.
1684+
*/
1685+
select("#detailTooltipText_" + longName.replace('%', '\\%'))
1686+
.append("tspan").attr("x",0).attr("y",0).attr('dx', '0.9em').attr('dy', '1.1em').text(" At: " + tickText(historyLinearScaleX.invert(mouse(this)[0])))
1687+
.append("tspan").attr("x",0).attr("y",18).attr('dx','0.9em').attr('dy', '1.1em').text("SG = " + (historyLinearScaleY.invert(mouse(this)[1])).toFixed(2));
1688+
1689+
select("#detailTooltipGroup_" + longName.replace('%', '\\%'))
1690+
.attr("transform",
1691+
"translate(" + (historyJobsGraphMargin.left + mouse(this)[0]) + "," + (historyJobsGraphMargin.top + mouse(this)[1]) + ")")
1692+
.style("opacity", 0.9);
1693+
1694+
})
1695+
.on("mouseout", function() {
1696+
//console.log("gravity out");
1697+
1698+
select("#detailTooltipGroup_" + longName.replace('%', '\\%')).transition()
1699+
.duration(200)
1700+
.style("opacity", 0.0);
1701+
1702+
// Remove previous entry
1703+
select("#detailTooltipGroup_" + longName.replace('%', '\\%'))
1704+
.selectAll("tspan").remove();
1705+
1706+
});
16501707
}
16511708
}
16521709

1710+
/* Show time & value as a tooltip
1711+
at any particular point of the graph
1712+
*/
1713+
historyJobsGraphHolder.append("g")
1714+
.attr("id", "detailTooltipGroup_" + longName.replace('%', '\\%'))
1715+
.attr("class", "detailtooltipgroup")
1716+
.attr("transform",
1717+
"translate(" + historyJobsGraphMargin.left + "," + historyJobsGraphMargin.top + ")")
1718+
.style("opacity", 0.0);
1719+
1720+
select("#detailTooltipGroup_" + longName.replace('%', '\\%'))
1721+
.append("rect")
1722+
.attr('id', 'detailTooltipBox_' + longName.replace('%', '\\%'))
1723+
.attr('class', 'detailtooltipbox')
1724+
.attr('width', 96) .attr('height', 40)
1725+
.attr('rx', 6).attr('ry', 4);
1726+
1727+
select("#detailTooltipGroup_" + longName.replace('%', '\\%'))
1728+
.append("text")
1729+
.attr('id', 'detailTooltipText_' + longName.replace('%', '\\%'))
1730+
.attr('class', 'detailtooltip');
1731+
1732+
16531733
// Group for Resume/Waiting button & text
16541734
var lastUpdate = updates[updates.length - 1];
16551735
//console.log("lastUpdate = " + JSON.stringify(lastUpdate));
@@ -1669,7 +1749,6 @@ window.onload = function () {
16691749
.attr('class', 'runningResumeButton')
16701750
.attr('x', 0) .attr('y', 0)
16711751
.attr('width', 96).attr('height', 40)
1672-
.attr('rx', 6).attr('ry', 6)
16731752
.on("click", function() {
16741753
//console.log("RESUME running " + longName.replace('%', '\\%'));
16751754
//console.log("RESUME running jobStatus: " + jobStatus[longName.replace('%', '\\%')].running);
@@ -2539,7 +2618,6 @@ window.onload = function () {
25392618
.attr('class', 'profileSaveCancelButton')
25402619
.attr('x', 0) .attr('y', 0)
25412620
.attr('width', 96).attr('height', 40)
2542-
.attr('rx', 6).attr('ry', 6)
25432621
.on("click", function() {
25442622
//console.log("SAVE & RETURN to " + profileOwner);
25452623
select("#profilesGraphHolder").selectAll("*").remove();
@@ -2569,7 +2647,6 @@ window.onload = function () {
25692647
.attr('class', 'profileSaveCancelButton')
25702648
.attr('x', 0) .attr('y', '3.6em')
25712649
.attr('width', 96).attr('height', 40)
2572-
.attr('rx', 6).attr('ry', 6)
25732650
.on("click", function() {
25742651
//console.log("CANCEL to " + profileOwner);
25752652
select("#profilesGraphHolder").selectAll("*").remove();

styles/brewable.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ td {
184184
div.tooltip {
185185
position: absolute;
186186
text-align: center;
187-
width: 71;
187+
width: 71px;
188188
height: 14px;
189189
padding: 2px;
190190
font: 12px sans-serif;
@@ -198,6 +198,16 @@ div.tooltip {
198198
text-align: center;
199199
font: 12px sans-serif;
200200
}
201+
.detailtooltipbox {
202+
text-align: center;
203+
padding: 2px;
204+
font: 12px sans-serif;
205+
fill: lightsteelblue;
206+
stroke: white;
207+
stroke-width: 1;
208+
border-radius: 8px;
209+
pointer-events: none;
210+
}
201211

202212

203213
div#live_updateHolderContainer {

0 commit comments

Comments
 (0)