diff --git a/lib/client/renderer.js b/lib/client/renderer.js index 239c9afdf05..03982937b63 100644 --- a/lib/client/renderer.js +++ b/lib/client/renderer.js @@ -444,13 +444,18 @@ function init (client, d3) { } if ( treatment.insulin > 0) { - var dosage_units = Math.round(treatment.insulin * 100)/100; + 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' - if ( treatment.insulin < 1 && !treatment.carbs ) { // 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 + var enteredBy = '' + treatment.enteredBy; + + if ( treatment.insulin < 1 && !treatment.carbs && enteredBy.indexOf('openaps') > -1) { // 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 + dosage_units = (dosage_units+"").replace(/^0/,""); } - // remove leading zeros to avoid overlap with adjacent boluses - arc_data[3].element = (dosage_units+"").replace(/^0/,"")+unit_of_measurement; + + arc_data[3].element = dosage_units + unit_of_measurement; } if (treatment.status) { @@ -855,10 +860,12 @@ function init (client, d3) { .attr('class', 'path') .attr('id', 'label') .style('fill', 'white'); + + // reduce the treatment label font size to make it readable with SMB + var fontBaseSize = (opts.treatments >= 50) ? 40 : 50 - Math.floor((60-opts.treatments)/50 * 10); label.append('text') - // reduce the treatment label font size to make it readable with SMB - .style('font-size', 30 / opts.scale) + .style('font-size', fontBaseSize / opts.scale) .style('text-shadow', '0px 0px 10px rgba(0, 0, 0, 1)') .attr('text-anchor', 'middle') .attr('dy', '.35em') @@ -874,11 +881,19 @@ function init (client, d3) { } renderer.drawTreatments = function drawTreatments(client) { + + var treatmentCount = 0; + + _.forEach(client.ddata.treatments, function eachTreatment (d) { + if (Number(d.insulin) > 0 || Number(d.carbs) > 0) { treatmentCount += 1; }; + }); + // add treatment bubbles _.forEach(client.ddata.treatments, function eachTreatment (d) { renderer.drawTreatment(d, { scale: renderer.bubbleScale() , showLabels: true + , treatments: treatmentCount }, client.sbx.data.profile.getCarbRatio(new Date())); }); };