diff --git a/README.md b/README.md index 4378a63708d..bd55ebf8094 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs/ or * The `linear` option has equidistant tick marks; the range used is dynamic so that space at the top of chart isn't wasted. * The `log-dynamic` is similar to the default `log` options, but uses the same dynamic range and the `linear` scale. * `EDIT_MODE` (`on`) - possible values `on` or `off`. Enables the icon allowing for editing of treatments in the main view. + * `BOLUS_RENDER_OVER` (1) - U value over which the bolus values are rendered on the chart if the 'x U and Over' option is selected. This value can be an integer or a float, e.g. 0.3, 1.5, 2, etc... ### Predefined values for your server settings (optional) * `INSECURE_USE_HTTP` (`false`) - Redirect unsafe http traffic to https. Possible values `false`, or `true`. Your site redirects to `https` by default. If you don't want that from Nightscout, but want to implement that with a Nginx or Apache proxy, set `INSECURE_USE_HTTP` to `true`. Note: This will allow (unsafe) http traffic to your Nightscout instance and is not recommended. diff --git a/app.json b/app.json index 814262b6802..46c2fe0ae46 100644 --- a/app.json +++ b/app.json @@ -72,6 +72,11 @@ "value": "180", "required": false }, + "BOLUS_RENDER_OVER": { + "description": "U value over which the bolus values are rendered on the chart if the 'x U and Over' option is selected.", + "value": "1", + "required": false + }, "BRIDGE_PASSWORD": { "description": "Your Dexcom account password, to receive CGM data from the Dexcom Share service. Also make sure to include 'bridge' in your ENABLE line.", "value": "", diff --git a/lib/client/browser-settings.js b/lib/client/browser-settings.js index 2119b39da40..f45631f4b6f 100644 --- a/lib/client/browser-settings.js +++ b/lib/client/browser-settings.js @@ -71,6 +71,8 @@ function init (client, serverSettings, $) { $('#basalrender').val(settings.extendedSettings.basal ? settings.extendedSettings.basal.render : 'none'); + $('#bolusrender').val(settings.extendedSettings.bolus ? settings.extendedSettings.bolus.render : 'all'); + if (settings.timeFormat === 24) { $('#24-browser').prop('checked', true); } else { @@ -161,6 +163,7 @@ function init (client, serverSettings, $) { storage.remove(name); }); storage.remove('basalrender'); + storage.remove('bolusrender'); event.preventDefault(); client.browserUtils.reload(); }); @@ -213,6 +216,7 @@ function init (client, serverSettings, $) { , language: $('#language').val() , scaleY: $('#scaleY').val() , basalrender: $('#basalrender').val() + , bolusrender: $('#bolusrender').val() , showPlugins: checkedPluginNames() , storageVersion: STORAGE_VERSION }); @@ -268,8 +272,15 @@ function init (client, serverSettings, $) { settings.extendedSettings.basal = {}; } - var stored = storage.get('basalrender'); - settings.extendedSettings.basal.render = stored !== null ? stored : settings.extendedSettings.basal.render; + var basalStored = storage.get('basalrender'); + settings.extendedSettings.basal.render = basalStored !== null ? basalStored : settings.extendedSettings.basal.render; + + if (!settings.extendedSettings.bolus) { + settings.extendedSettings.bolus = {}; + } + + var bolusStored = storage.get('bolusrender'); + settings.extendedSettings.bolus.render = bolusStored !== null ? bolusStored : settings.extendedSettings.bolus.render; } catch (err) { console.error(err); diff --git a/lib/client/index.js b/lib/client/index.js index 5c611306d9f..29dc9593ae8 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -399,6 +399,12 @@ client.load = function load (serverSettings, callback) { } } + function updateBolusRenderOver () { + var bolusRenderOver = (client.settings.bolusRenderOver || 1) + ' U and Over'; + $('#bolusRenderOver').text(bolusRenderOver); + console.log('here'); + } + function alarmingNow () { return container.hasClass('alarming'); } @@ -1240,6 +1246,7 @@ client.load = function load (serverSettings, callback) { prepareEntries(); updateTitle(); + updateBolusRenderOver(); // Don't invoke D3 in headless mode diff --git a/lib/client/renderer.js b/lib/client/renderer.js index 7ea154ff0fd..818ee6f41d0 100644 --- a/lib/client/renderer.js +++ b/lib/client/renderer.js @@ -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); }; diff --git a/lib/settings.js b/lib/settings.js index dbe9e893e30..5a19ba6309c 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -51,6 +51,7 @@ function init () { , deNormalizeDates: false , showClockDelta: false , showClockLastTime: false + , bolusRenderOver: 1 , frameUrl1: '' , frameUrl2: '' , frameUrl3: '' diff --git a/views/index.html b/views/index.html index 156aa331325..6ef0dc2cce6 100644 --- a/views/index.html +++ b/views/index.html @@ -215,6 +215,18 @@ +