Skip to content

Commit

Permalink
Merge pull request #953 from MilosKozak/wip/reports
Browse files Browse the repository at this point in the history
axis updates
  • Loading branch information
MilosKozak committed Sep 6, 2015
2 parents 29a6541 + 8a1fbe9 commit 03529c5
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/report_plugins/daytoday.js
Expand Up @@ -57,22 +57,23 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) {
var report_plugins = Nightscout.report_plugins;
var scaledTreatmentBG = report_plugins.utils.scaledTreatmentBG;

var padding = { top: 15, right: 15, bottom: 30, left: 35 };
var
FORMAT_TIME_12 = '%I'
, FORMAT_TIME_24 = '%H';
var padding = { top: 15, right: 22, bottom: 30, left: 35 };

daytoday.prepareHtml(daystoshow) ;
_.each(daystoshow, function (n, day) {
drawChart(day,datastorage[day],options);
});

function getTimeFormat() {
var timeFormat = FORMAT_TIME_12;
function timeTicks(n,i) {
var t12 = [
'12am', '', '2am', '', '4am', '', '6am', '', '8am', '', '10am', '',
'12pm', '', '2pm', '', '4pm', '', '6pm', '', '8pm', '', '10pm', '', '12am'
];
if (Nightscout.client.settings.timeFormat === '24') {
timeFormat = FORMAT_TIME_24;
return ('00' + i).slice(-2);
} else {
return t12[i];
}
return timeFormat;
}

function drawChart(day,data,options) {
Expand Down Expand Up @@ -157,7 +158,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) {

// define the parts of the axis that aren't dependent on width or height
xScale2 = d3.time.scale()
.domain(d3.extent(data.sgv, function (d) { return d.date; }));
.domain(d3.extent(data.sgv, dateFn));

if (options.scale === report_plugins.consts.SCALE_LOG) {
yScale2 = d3.scale.log()
Expand All @@ -175,7 +176,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) {

xAxis2 = d3.svg.axis()
.scale(xScale2)
.tickFormat(d3.time.format(getTimeFormat(true)))
.tickFormat(timeTicks)
.ticks(24)
.orient('bottom');

Expand Down

0 comments on commit 03529c5

Please sign in to comment.