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 upgrade (library for visualizing data such as main view, graphs, etc.) #5081

Merged
merged 61 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7349a12
initial commit for d3 upgrade
Oct 12, 2019
285fe97
d3 v5 mostly working except brush
Oct 14, 2019
c340e74
more work on the brush
Oct 14, 2019
9716c38
brush and layout mostly working now
Oct 15, 2019
dd760a9
make open-right and open-left lines visible
Oct 15, 2019
c510246
make brush selection hidden
Oct 15, 2019
fd53c45
fix open-right, open-top, and now-line in retro mode
Oct 15, 2019
ae176c8
fix setting brush to now
Oct 15, 2019
fcceeec
fix updateBrushToNow to set start correctly
Oct 15, 2019
8a1765a
add extent to updateBrushToNow
Oct 15, 2019
824604e
fix inRetro to use dataExtent instead of domain
Oct 15, 2019
c91e7bd
move a debug log message to better location
Oct 15, 2019
f9e579b
debug for brush movements
Oct 15, 2019
9a07f45
cleanup adjusted range vs. brushed range
Oct 15, 2019
b6551cd
fix syntax error
Oct 15, 2019
4e874ff
remove transitions for brush movements
Oct 16, 2019
cc82be9
log message for dataUpdate
Oct 16, 2019
a8c91e7
fix updating brush range when new data arrives
Oct 16, 2019
dfa06be
fix keeping up with data when not in retro
Oct 16, 2019
3fb44f1
keep brush range at focusRangeMS during update
Oct 16, 2019
da00bb8
fix variable name error
Oct 16, 2019
5c82495
keep chart in sync with current time when not in retro
Oct 16, 2019
47bb747
use short transition time
Oct 16, 2019
bb68263
test no opacity changes
Oct 16, 2019
28866ed
remove one more highlight and use small transition duration
Oct 16, 2019
f14ab53
fix race condition
Oct 16, 2019
f5afde5
fix for uncommanded going to retro
Oct 16, 2019
f8bc44f
fix syntax error
Oct 16, 2019
dadc3a9
update chart scales when new data arrives in retro mode
Oct 17, 2019
c537d91
Use consistent transition for scroll
Oct 17, 2019
ed319ad
clean chart.updateContext
Oct 17, 2019
199f5ec
comment out debug messages
Oct 17, 2019
3772547
merge current dev to resolve conflicts
Oct 17, 2019
ffe5d99
remove unused variable
Oct 17, 2019
258fec6
update renderer to account for no structure arg for d3 attr
Oct 17, 2019
a5d8378
fix syntax error
Oct 17, 2019
4c655d8
one more syntax error
Oct 17, 2019
85dc644
use requestAnimationFrame
Oct 17, 2019
0916f36
forgot to update current scroll data
Oct 17, 2019
b9c13d5
remove extra treatment circles
Oct 18, 2019
713a99f
try using class for selection
Oct 18, 2019
7b7d375
reduce update required for focus circles
Oct 18, 2019
e7a8523
reduce update required for focus treatments
Oct 18, 2019
a52bd7e
fix update prepare treat circles
Oct 18, 2019
974dc32
use _id for treatments key
Oct 18, 2019
eca33c7
do not use opacity for past entry circles
Oct 18, 2019
e4fd55b
replace scale.linear with scaleLinear
PieterGit Oct 18, 2019
54cf245
d3 upgrade axis
PieterGit Oct 18, 2019
123395f
d3 upgrade axis
PieterGit Oct 18, 2019
e8618ae
fix tooltip location
Oct 19, 2019
bd4ed4e
fix plugin tooltip location
Oct 19, 2019
62b830f
update reports for d3 v5
Oct 19, 2019
cf63611
fix inner radius default for insulin distribution pie
Oct 19, 2019
23a182b
fix dynamic scaling issues
Oct 19, 2019
739b01e
fix single click scroll
Oct 20, 2019
bec4bc6
Fix font size on axis labels
sulkaharo Oct 20, 2019
64d9dfb
Render ticks on top of everything
sulkaharo Oct 20, 2019
7f1ea07
Merge pull request #2 from nightscout/pr/5081
jpcunningh Oct 20, 2019
84f7c66
Merge branch 'd3-upgrade' of ssh://github.com/jpcunningh/cgm-remote-m…
Oct 20, 2019
b07dbd2
fix click to scroll jankiness
Oct 20, 2019
3e07c62
move loading finished to the bottom of updateHeader
Oct 21, 2019
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
444 changes: 279 additions & 165 deletions lib/client/chart.js

Large diffs are not rendered by default.

49 changes: 33 additions & 16 deletions lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ client.load = function load (serverSettings, callback) {

function formatTime (time, compact) {
var timeFormat = getTimeFormat(false, compact);
time = d3.time.format(timeFormat)(time);
time = d3.timeFormat(timeFormat)(time);
if (client.settings.timeFormat !== 24) {
time = time.toLowerCase();
}
Expand Down Expand Up @@ -375,14 +375,14 @@ client.load = function load (serverSettings, callback) {
// clears the current user brush and resets to the current real time data
function updateBrushToNow (skipBrushing) {

// get current time range
var dataRange = client.dataExtent();

// update brush and focus chart with recent data
d3.select('.brush')
.transition()
.duration(UPDATE_TRANS_MS)
.call(chart.brush.extent([new Date(dataRange[1].getTime() - client.focusRangeMS), dataRange[1]]));
var brushExtent = client.dataExtent();

brushExtent[0] = new Date(brushExtent[1].getTime() - client.focusRangeMS);

// console.log('Resetting brush in updateBrushToNow: ', brushExtent);

chart.theBrush && chart.theBrush.call(chart.brush.move, brushExtent.map(chart.xScale2));

if (!skipBrushing) {
brushed();
Expand All @@ -398,21 +398,34 @@ client.load = function load (serverSettings, callback) {
}

function brushed () {
// Brush not initialized
if (!chart.theBrush) {
return;
}

// default to most recent focus period
var brushExtent = client.dataExtent();
brushExtent[0] = new Date(brushExtent[1].getTime() - client.focusRangeMS);

var brushExtent = chart.brush.extent();
var brushedRange = d3.brushSelection(chart.theBrush.node());

// ensure that brush extent is fixed at 3.5 hours
if (brushExtent[1].getTime() - brushExtent[0].getTime() !== client.focusRangeMS) {
if (brushedRange) {
brushExtent = brushedRange.map(chart.xScale2.invert);
}

// console.log('Brushed to: ', brushExtent);

if (!brushedRange || (brushExtent[1].getTime() - brushExtent[0].getTime() !== client.focusRangeMS)) {
// ensure that brush updating is with the time range
if (brushExtent[0].getTime() + client.focusRangeMS > client.dataExtent()[1].getTime()) {
brushExtent[0] = new Date(brushExtent[1].getTime() - client.focusRangeMS);
d3.select('.brush')
.call(chart.brush.extent([brushExtent[0], brushExtent[1]]));
} else {
brushExtent[1] = new Date(brushExtent[0].getTime() + client.focusRangeMS);
d3.select('.brush')
.call(chart.brush.extent([brushExtent[0], brushExtent[1]]));
}

// console.log('Updating brushed to: ', brushExtent);

chart.theBrush.call(chart.brush.move, brushExtent.map(chart.xScale2));
}

function adjustCurrentSGVClasses (value, isCurrent) {
Expand All @@ -428,7 +441,6 @@ client.load = function load (serverSettings, callback) {
currentBG.toggleClass('icon-hourglass', value === 9);
currentBG.toggleClass('error-code', value < 39);
currentBG.toggleClass('bg-limit', value === 39 || value > 400);
container.removeClass('loading');
}

function updateCurrentSGV (entry) {
Expand Down Expand Up @@ -546,6 +558,8 @@ client.load = function load (serverSettings, callback) {

var top = (client.bottomOfPills() + 5);
$('#chartContainer').css({ top: top + 'px', height: $(window).height() - top - 10 });

container.removeClass('loading');
}

function sgvToColor (sgv) {
Expand Down Expand Up @@ -1130,6 +1144,7 @@ client.load = function load (serverSettings, callback) {
}

function dataUpdate (received) {
console.info('got dataUpdate', new Date(client.now));

var lastUpdated = Date.now();
receiveDData(received, client.ddata, client.settings);
Expand Down Expand Up @@ -1171,6 +1186,8 @@ client.load = function load (serverSettings, callback) {
chart.update(false);
client.plugins.updateVisualisations(client.nowSBX);
brushed();
} else {
chart.updateContext();
}
}
};
Expand Down
Loading