Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3 cleanup #5236

Merged
merged 4 commits into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/client/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var scrolling = false
, scrollRange = null;

var PADDING_BOTTOM = 30
, OPEN_TOP_HEIGHT = 8
, CONTEXT_MAX = 420
, CONTEXT_MIN = 36
, FOCUS_MAX = 510
Expand Down Expand Up @@ -438,7 +439,7 @@ function init (client, d3, $) {
chart.context.append('line')
.attr('class', 'open-top')
.attr('stroke', '#111')
.attr('stroke-width', 12);
.attr('stroke-width', OPEN_TOP_HEIGHT);

// add a x-axis line that closes the the brush container on left side
chart.context.append('line')
Expand Down Expand Up @@ -539,9 +540,9 @@ function init (client, d3, $) {
// transition open-top line to correct location
chart.context.select('.open-top')
.attr('x1', chart.xScale2(currentRange[0]))
.attr('y1', chart.yScale2(utils.scaleMgdl(CONTEXT_MAX)))
.attr('y1', chart.yScale2(utils.scaleMgdl(CONTEXT_MAX)) + Math.floor(OPEN_TOP_HEIGHT/2.0)-1)
.attr('x2', chart.xScale2(currentRange[1]))
.attr('y2', chart.yScale2(utils.scaleMgdl(CONTEXT_MAX)));
.attr('y2', chart.yScale2(utils.scaleMgdl(CONTEXT_MAX)) + Math.floor(OPEN_TOP_HEIGHT/2.0)-1);

// transition open-left line to correct location
chart.context.select('.open-left')
Expand Down Expand Up @@ -621,9 +622,9 @@ function init (client, d3, $) {
// transition open-top line to correct location
chart.context.select('.open-top')
.attr('x1', chart.xScale2(currentRange[0]))
.attr('y1', chart.yScale2(contextYDomain[1]))
.attr('y1', chart.yScale2(contextYDomain[1]) + Math.floor(OPEN_TOP_HEIGHT / 2.0)-1)
.attr('x2', chart.xScale2(currentRange[1]))
.attr('y2', chart.yScale2(contextYDomain[1]));
.attr('y2', chart.yScale2(contextYDomain[1]) + Math.floor(OPEN_TOP_HEIGHT / 2.0)-1);

// transition open-left line to correct location
chart.context.select('.open-left')
Expand Down
12 changes: 11 additions & 1 deletion lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ client.load = function load (serverSettings, callback) {
}

function mergeDeviceStatus (retro, ddata) {
if (!retro) {
return ddata;
}

var result = retro.map(x => Object.assign(x, ddata.find(y => y._id == x._id)));

var missingInRetro = ddata.filter(y => !retro.find(x => x._id == y._id));
Expand Down Expand Up @@ -545,7 +549,7 @@ client.load = function load (serverSettings, callback) {

function clearCurrentSGV () {
currentBG.text('---');
container.removeClass('urgent warning inrange');
container.removeClass('alarming urgent warning inrange');
}

var nowDate = null;
Expand Down Expand Up @@ -839,6 +843,12 @@ client.load = function load (serverSettings, callback) {

container.toggleClass('alarming-timeago', status !== 'current');

if (status === 'warn') {
container.addClass('warn');
} else if (status === 'urgent') {
container.addClass('urgent');
}

if (alarmingNow() && status === 'current' && isTimeAgoAlarmType()) {
stopAlarm(true, times.min().msecs);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/direction.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function init() {

direction.setProperties = function setProperties (sbx) {
sbx.offerProperty('direction', function setDirection ( ) {
if (sbx.data.inRetroMode && !sbx.isCurrent(sbx.lastSGVEntry())) {
if (!sbx.isCurrent(sbx.lastSGVEntry())) {
return undefined;
} else {
return direction.info(sbx.lastSGVEntry());
Expand Down Expand Up @@ -77,4 +77,4 @@ function init() {

}

module.exports = init;
module.exports = init;