mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Option to switch off bolus amount outputs (#5522)
* Option to switch off bolus amount outputs (#5514) * Fixing issue with carb value not be output when set to "none" (#5514) * Adding additional output options (#5514) * Adding environment variable option for 'x U and Over' option. This option is BOLUS_RENDER_OVER with a default value of 1 and the value can be an integer or a float, e.g. 0.3, 1.5, 2, etc... * Adding change to change the font size depending on the bolus value. * Merge two "all" options to create an option that displays as SMB had.
This commit is contained in:
+20
-16
@@ -531,7 +531,7 @@ function init (client, d3) {
|
||||
};
|
||||
}
|
||||
|
||||
function prepareArc (treatment, radius) {
|
||||
function prepareArc (treatment, radius, renderBasal) {
|
||||
var arc_data = [
|
||||
// white carb half-circle on top
|
||||
{ 'element': '', 'color': 'white', 'start': -1.5708, 'end': 1.5708, 'inner': 0, 'outer': radius.R1 }
|
||||
@@ -568,16 +568,13 @@ function init (client, d3) {
|
||||
|
||||
if (treatment.insulin > 0) {
|
||||
var dosage_units = '' + Math.round(treatment.insulin * 100) / 100;
|
||||
|
||||
var unit_of_measurement = ' U'; // One international unit of insulin (1 IU) is shown as '1 U'
|
||||
var enteredBy = '' + treatment.enteredBy;
|
||||
|
||||
if ((treatment.insulin < 1 && !treatment.carbs && enteredBy.indexOf('openaps') > -1) || treatment.isSMB) { // don't show the unit of measurement for insulin boluses < 1 without carbs (e.g. oref0 SMB's). Otherwise lot's of small insulin only dosages are often unreadable
|
||||
unit_of_measurement = '';
|
||||
// remove leading zeros to avoid overlap with adjacent boluses
|
||||
|
||||
if (renderBasal === 'all-remove-zero-u') {
|
||||
dosage_units = (dosage_units + "").replace(/^0/, "");
|
||||
}
|
||||
|
||||
var unit_of_measurement = (renderBasal === 'all-remove-zero-u' ? '' : ' U'); // One international unit of insulin (1 IU) is shown as '1 U'
|
||||
|
||||
arc_data[3].element = dosage_units + unit_of_measurement;
|
||||
}
|
||||
|
||||
@@ -971,11 +968,15 @@ function init (client, d3) {
|
||||
.attr('id', 'label')
|
||||
.style('fill', 'white');
|
||||
|
||||
// reduce the treatment label font size to make it readable with SMB
|
||||
var fontBaseSize = (opts.treatments >= 30) ? 40 : 50 - Math.floor((25 - opts.treatments) / 30 * 10);
|
||||
|
||||
label.append('text')
|
||||
.style('font-size', fontBaseSize / opts.scale)
|
||||
.style('font-size', function(d) {
|
||||
var fontSize = ( (opts.treatments >= 30) ? 40 : 50 - Math.floor((25 - opts.treatments) / 30 * 10) ) / opts.scale;
|
||||
var elementValue = parseFloat(d.element);
|
||||
if (!isNaN(elementValue) && elementValue < 1) {
|
||||
fontSize = (25 + Math.floor(elementValue * 10)) / opts.scale;
|
||||
}
|
||||
return fontSize;
|
||||
})
|
||||
.style('text-shadow', '0px 0px 10px rgba(0, 0, 0, 1)')
|
||||
.attr('text-anchor', 'middle')
|
||||
.attr('dy', '.35em')
|
||||
@@ -993,6 +994,7 @@ function init (client, d3) {
|
||||
renderer.drawTreatments = function drawTreatments (client) {
|
||||
|
||||
var treatmentCount = 0;
|
||||
var renderBasal = client.settings.extendedSettings.bolus.render;
|
||||
chart().focus.selectAll('.draggable-treatment').remove();
|
||||
|
||||
_.forEach(client.ddata.treatments, function eachTreatment (d) {
|
||||
@@ -1001,15 +1003,17 @@ function init (client, d3) {
|
||||
|
||||
// add treatment bubbles
|
||||
_.forEach(client.ddata.treatments, function eachTreatment (d) {
|
||||
var showLabels = ( !d.carbs && ( ( renderBasal == 'none') || ( renderBasal === 'over' && d.insulin < client.settings.bolusRenderOver) ) ) ? false : true;
|
||||
renderer.drawTreatment(d, {
|
||||
scale: renderer.bubbleScale()
|
||||
, showLabels: true
|
||||
, showLabels: showLabels
|
||||
, treatments: treatmentCount
|
||||
}, client.sbx.data.profile.getCarbRatio(new Date()));
|
||||
}, client.sbx.data.profile.getCarbRatio(new Date()),
|
||||
renderBasal);
|
||||
});
|
||||
};
|
||||
|
||||
renderer.drawTreatment = function drawTreatment (treatment, opts, carbratio) {
|
||||
renderer.drawTreatment = function drawTreatment (treatment, opts, carbratio, renderBasal) {
|
||||
if (!treatment.carbs && !treatment.protein && !treatment.fat && !treatment.insulin) {
|
||||
return;
|
||||
}
|
||||
@@ -1027,7 +1031,7 @@ function init (client, d3) {
|
||||
return;
|
||||
}
|
||||
|
||||
var arc = prepareArc(treatment, radius);
|
||||
var arc = prepareArc(treatment, radius, renderBasal);
|
||||
var treatmentDots = appendTreatments(treatment, arc);
|
||||
appendLabels(treatmentDots, arc, opts);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user