tideline 1.37.0-develop.1 → 1.37.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M9 0.75C13.5563 0.75 17.25 4.44365 17.25 9C17.25 13.5563 13.5563 17.25 9 17.25C4.44365 17.25 0.75 13.5563 0.75 9C0.75 4.44365 4.44365 0.750001 9 0.75Z" fill="white" stroke="#CC6D00" stroke-width="1.5"/>
3
+ <path d="M9 9.10053V5.99951M9 12.0237V12.1064" stroke="#CC6D00" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M9 0.75C13.5563 0.75 17.25 4.44365 17.25 9C17.25 13.5563 13.5563 17.25 9 17.25C4.44365 17.25 0.75 13.5563 0.75 9C0.75 4.44365 4.44365 0.750001 9 0.75Z" fill="white" stroke="#CC6D00" stroke-width="1.5"/>
3
+ <path d="M9 9.10053V5.99951M9 12.0237V12.1064" stroke="#CC6D00" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4
+ </svg>
package/js/index.js CHANGED
@@ -48,6 +48,7 @@ module.exports = {
48
48
  smbg: require('./plot/smbg'),
49
49
  suspend: require('./plot/suspend'),
50
50
  alarm: require('./plot/alarm'),
51
+ event: require('./plot/event'),
51
52
  pumpSettingsOverride: require('./plot/pumpSettingsOverride'),
52
53
  wizard: require('./plot/wizard'),
53
54
  carb: require('./plot/carb'),
package/js/oneday.js CHANGED
@@ -32,22 +32,21 @@ module.exports = function(emitter, opts) {
32
32
  timePrefs: {
33
33
  timezoneAware: false,
34
34
  timezoneName: dt.getBrowserTimezone(),
35
- }
35
+ },
36
+ minHeight: 400,
37
+ minWidth: 300,
36
38
  };
37
39
  _.defaults(opts, defaults);
38
40
 
39
- // constants
40
- var MS_IN_24 = 86400000;
41
-
42
41
  // basic attributes
43
42
  var id,
44
- minWidth = 300, minHeight = 400,
43
+ minWidth = opts.minWidth, minHeight = opts.minHeight,
45
44
  width = minWidth, height = minHeight,
46
45
  poolScaleHeight,
47
46
  nav = {
48
- scrollNav: true,
49
- scrollNavHeight: 50,
50
- scrollGutterHeight: 20,
47
+ scrollNav: !opts.endpoints,
48
+ scrollNavHeight: !opts.endpoints ? 50 : 0,
49
+ scrollGutterHeight: !opts.endpoints ? 20 : 0,
51
50
  scrollThumbRadius: 24,
52
51
  currentTranslation: 0
53
52
  },
@@ -55,7 +54,7 @@ module.exports = function(emitter, opts) {
55
54
  buffer = 2,
56
55
  pools = [], poolGroup,
57
56
  xScale = d3.time.scale.utc(),
58
- currentCenter, data, tidelineData, renderedData = [], endpoints,
57
+ currentCenter, data, renderedData = [], endpoints,
59
58
  mainSVG, mainGroup,
60
59
  scrollNav, scrollHandleTrigger = true, mostRecent = false, annotations, tooltips;
61
60
 
@@ -155,8 +154,8 @@ module.exports = function(emitter, opts) {
155
154
  });
156
155
  };
157
156
 
158
- container.newPool = function() {
159
- var p = new Pool(container);
157
+ container.newPool = function(opts) {
158
+ var p = new Pool(container, opts);
160
159
  pools.push(p);
161
160
  return p;
162
161
  };
@@ -506,19 +505,24 @@ module.exports = function(emitter, opts) {
506
505
  container.data = function(a) {
507
506
  if (!arguments.length) return data;
508
507
 
509
- if (! (a && Array.isArray(a) && a.length > 0)) {
508
+ data = a;
509
+
510
+ if (opts.endpoints) {
511
+ endpoints = container.endpoints = container.initialEndpoints = opts.endpoints;
512
+ return container;
513
+ }
514
+
515
+ if (! (data && Array.isArray(data) && data.length > 0)) {
510
516
  /* jshint ignore:start */
511
517
  throw new Error("Sorry, I can't render anything without /some/ data.");
512
518
  /* jshint ignore:end */
513
519
  }
514
- else if (a.length === 1) {
520
+ else if (data.length === 1) {
515
521
  /* jshint ignore:start */
516
522
  throw new Error("Sorry, I can't render anything with only *one* datapoint.");
517
523
  /* jshint ignore:end */
518
524
  }
519
525
 
520
- data = a;
521
-
522
526
  var first = new Date(data[0].normalTime);
523
527
  var lastObj = _.sortBy(data, function(d) {
524
528
  return d.normalEnd ? d.normalEnd : d.normalTime;
package/js/plot/cbg.js CHANGED
@@ -157,7 +157,8 @@ module.exports = function(pool, opts) {
157
157
  opts.onCBGHover({
158
158
  data: d,
159
159
  rect: rect,
160
- class: categorizer(opts.classes, opts.bgUnits)(d)
160
+ class: categorizer(opts.classes, opts.bgUnits)(d),
161
+ chartEndpoints: opts.chartEndpoints,
161
162
  });
162
163
  }
163
164
  };
@@ -0,0 +1,93 @@
1
+ var d3 = require('d3');
2
+ var _ = require('lodash');
3
+
4
+ var eventImage = require('../../img/event/event.svg');
5
+
6
+ /**
7
+ * Module for adding event markers to a chart pool
8
+ *
9
+ * @param {Object} pool the chart pool
10
+ * @param {Object|null} opts configuration options
11
+ * @return {Object} event object
12
+ */
13
+ module.exports = function(pool, opts = {}) {
14
+ function event(selection) {
15
+ selection.each(function(currentData) {
16
+ var filteredData = _.filter(currentData, d => _.isString(d.tags?.event));
17
+
18
+ var events = d3.select(this)
19
+ .selectAll('g.d3-event-group')
20
+ .data(filteredData, function(d) {
21
+ return d.id;
22
+ });
23
+
24
+ var eventGroup = events.enter()
25
+ .append('g')
26
+ .attr({
27
+ 'class': 'd3-event-group',
28
+ id: function(d) {
29
+ return 'event_' + d.id;
30
+ }
31
+ });
32
+
33
+ event.addeventToPool(eventGroup);
34
+
35
+ events.exit().remove();
36
+
37
+ // tooltips
38
+ selection.selectAll('.d3-event-group').on('mouseover', function() {
39
+ var parentContainer = document.getElementsByClassName('patient-data')[0].getBoundingClientRect();
40
+ var chartNavContainer = document.getElementById('tidelineScrollNav').getBoundingClientRect();
41
+ var container = this.getBoundingClientRect();
42
+ container.y = container.top - parentContainer.top;
43
+
44
+ var chartExtents = {
45
+ left: chartNavContainer.left,
46
+ right: chartNavContainer.right,
47
+ width: chartNavContainer.right - chartNavContainer.left,
48
+ };
49
+
50
+ event.addTooltip(d3.select(this).datum(), container, chartExtents);
51
+ });
52
+
53
+ selection.selectAll('.d3-event-group').on('mouseout', function() {
54
+ if (_.get(opts, 'onEventOut', false)) {
55
+ opts.onEventOut();
56
+ }
57
+ });
58
+ });
59
+ };
60
+
61
+ event.addTooltip = function(d, rect, chartExtents) {
62
+ if (_.get(opts, 'onEventHover', false)) {
63
+ opts.onEventHover({
64
+ data: d,
65
+ rect: rect,
66
+ chartExtents,
67
+ });
68
+ }
69
+ };
70
+
71
+ event.addeventToPool = function(selection) {
72
+ opts.xScale = pool.xScale().copy();
73
+ selection.append('image')
74
+ .attr({
75
+ 'xlink:href': eventImage,
76
+ x: event.xPositionCorner,
77
+ y: event.yPositionCorner,
78
+ width: opts.size,
79
+ height: opts.size
80
+ })
81
+ .classed({'d3-image': true, 'd3-event': true});
82
+ };
83
+
84
+ event.xPositionCorner = function(d) {
85
+ return opts.xScale(d.normalTime) - opts.size / 2;
86
+ };
87
+
88
+ event.yPositionCorner = function(d) {
89
+ return pool.height() / 2 - opts.size / 2;
90
+ };
91
+
92
+ return event;
93
+ };
package/js/plot/smbg.js CHANGED
@@ -114,7 +114,8 @@ module.exports = function(pool, opts) {
114
114
  opts.onSMBGHover({
115
115
  data: d,
116
116
  rect: rect,
117
- class: categorizer(opts.classes, opts.bgUnits)(d)
117
+ class: categorizer(opts.classes, opts.bgUnits)(d),
118
+ chartEndpoints: opts.chartEndpoints,
118
119
  });
119
120
  }
120
121
  };
@@ -30,7 +30,7 @@ module.exports = function(pool, opts) {
30
30
  textShiftX: 5,
31
31
  textShiftY: 5,
32
32
  tickLength: 15,
33
- longTickMultiplier: 3.75,
33
+ longTickMultiplier: opts.dayLabel ? 3.75 : 1,
34
34
  timePrefs: {
35
35
  timezoneAware: false,
36
36
  timezoneName: dt.getBrowserTimezone(),
@@ -41,43 +41,45 @@ module.exports = function(pool, opts) {
41
41
 
42
42
  var mainGroup = pool.parent();
43
43
 
44
- var stickyLabel = mainGroup.select('#tidelineLabels')
45
- .append('g')
46
- .attr('class', 'd3-axis')
47
- .append('text')
48
- .attr({
49
- 'class': 'd3-day-label',
50
- x: opts.leftEdge + 4,
51
- // this is the same as dailyx.dayYPosition
52
- // we just don't have a datum to pass here
53
- y: pool.height() - opts.tickLength * opts.longTickMultiplier
44
+ if (opts.dayLabel) {
45
+ var stickyLabel = mainGroup.select('#tidelineLabels')
46
+ .append('g')
47
+ .attr('class', 'd3-axis')
48
+ .append('text')
49
+ .attr({
50
+ 'class': 'd3-day-label',
51
+ x: opts.leftEdge + 4,
52
+ // this is the same as dailyx.dayYPosition
53
+ // we just don't have a datum to pass here
54
+ y: pool.height() - opts.tickLength * opts.longTickMultiplier
55
+ });
56
+
57
+ opts.emitter.on('zoomstart', function() {
58
+ stickyLabel.attr('opacity', '0.2');
54
59
  });
55
60
 
56
- opts.emitter.on('zoomstart', function() {
57
- stickyLabel.attr('opacity', '0.2');
58
- });
59
-
60
- opts.emitter.on('zoomend', function() {
61
- stickyLabel.attr('opacity', '1.0');
62
- });
61
+ opts.emitter.on('zoomend', function() {
62
+ stickyLabel.attr('opacity', '1.0');
63
+ });
63
64
 
64
- opts.emitter.on('navigated', function(a) {
65
- var offset = 0, d;
66
- if (opts.timePrefs.timezoneAware) {
67
- offset = -dt.getOffset(a[0].start, opts.timePrefs.timezoneName);
68
- d = moment(a[0].start).tz(opts.timePrefs.timezoneName);
69
- }
70
- else {
71
- d = moment(a[0].start).utc();
72
- }
73
- // when we're close to midnight (where close = five hours on either side)
74
- // remove the sticky label so it doesn't overlap with the midnight-anchored day label
75
- if ((d.hours() >= 19) || (d.hours() <= 4)) {
76
- stickyLabel.text('');
77
- return;
78
- }
79
- stickyLabel.text(format.xAxisDayText(d.toISOString(), offset));
80
- });
65
+ opts.emitter.on('navigated', function(a) {
66
+ var offset = 0, d;
67
+ if (opts.timePrefs.timezoneAware) {
68
+ offset = -dt.getOffset(a[0].start, opts.timePrefs.timezoneName);
69
+ d = moment(a[0].start).tz(opts.timePrefs.timezoneName);
70
+ }
71
+ else {
72
+ d = moment(a[0].start).utc();
73
+ }
74
+ // when we're close to midnight (where close = five hours on either side)
75
+ // remove the sticky label so it doesn't overlap with the midnight-anchored day label
76
+ if ((d.hours() >= 19) || (d.hours() <= 4)) {
77
+ stickyLabel.text('');
78
+ return;
79
+ }
80
+ stickyLabel.text(format.xAxisDayText(d.toISOString(), offset));
81
+ });
82
+ }
81
83
 
82
84
  function dailyx(selection) {
83
85
 
@@ -112,7 +114,7 @@ module.exports = function(pool, opts) {
112
114
  return format.xAxisTickText(d.normalTime, d.displayOffset);
113
115
  });
114
116
 
115
- tickGroups.filter(function(d) {
117
+ if (opts.dayLabel) tickGroups.filter(function(d) {
116
118
  var date = new Date(d.normalTime);
117
119
  date = new Date(dt.applyOffset(date, d.displayOffset));
118
120
  if (date.getUTCHours() === 0) {
package/js/pool.js CHANGED
@@ -1,15 +1,15 @@
1
1
  /*
2
2
  * == BSD2 LICENSE ==
3
3
  * Copyright (c) 2014, Tidepool Project
4
- *
4
+ *
5
5
  * This program is free software; you can redistribute it and/or modify it under
6
6
  * the terms of the associated License, which is identical to the BSD 2-Clause
7
7
  * License as published by the Open Source Initiative at opensource.org.
8
- *
8
+ *
9
9
  * This program is distributed in the hope that it will be useful, but WITHOUT
10
10
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
11
  * FOR A PARTICULAR PURPOSE. See the License for more details.
12
- *
12
+ *
13
13
  * You should have received a copy of the License along with this program; if
14
14
  * not, you can obtain one from Tidepool Project at tidepool.org.
15
15
  * == BSD2 LICENSE ==
@@ -25,10 +25,15 @@ var legend = require('./plot/util/legend');
25
25
  var log = require('bows')('Pool');
26
26
 
27
27
 
28
- function Pool (container) {
28
+ function Pool (container, opts) {
29
+ opts = _.defaults(opts || {}, {
30
+ hidden: false,
31
+ label: true,
32
+ legend: true
33
+ });
29
34
 
30
35
  var id, label, labelBaseline = 4, legends = [],
31
- index, heightRatio, gutterWeight, hidden = false, yPosition,
36
+ index, heightRatio, gutterWeight, hidden = opts.hidden, yPosition,
32
37
  height, minHeight = 20, maxHeight = 300,
33
38
  group,
34
39
  mainSVG = d3.select('#' + container.id()),
@@ -60,14 +65,8 @@ function Pool (container) {
60
65
 
61
66
  this.drawAxes();
62
67
  this.updateAxes();
63
- if (__DEV__ === true) {
64
- var that = this;
65
- setTimeout(function() { that.drawLabel(); that.drawLegend(); }, 250);
66
- }
67
- else {
68
- this.drawLabel();
69
- this.drawLegend();
70
- }
68
+ opts.label && this.drawLabel();
69
+ opts.legend && this.drawLegend();
71
70
  };
72
71
 
73
72
  this.clear = function() {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "node": "20.8.0"
5
5
  },
6
6
  "packageManager": "yarn@3.6.4",
7
- "version": "1.37.0-develop.1",
7
+ "version": "1.37.0-rc.2",
8
8
  "description": "Tidepool's timeline data visualization",
9
9
  "repository": {
10
10
  "type": "git",