Skip to content

Commit

Permalink
include hourly ticks in the right hour range
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed Nov 14, 2018
1 parent bdd0c5a commit 06cf98b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions assets/src/js/components/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Chart extends Component {

// instantiate JS Date objects
data = data.map((d) => {
d.Date = new Date(d.Date)
d.Date = new Date(d.Date);
return d
})

Expand All @@ -98,7 +98,9 @@ class Chart extends Component {

// grab data that falls between currentDate & nextDate
for(let i=data.length-offset-1; i>=0; i--) {
if( data[i].Date > nextDate) {

// Because 9AM should be included in 9AM-10AM range, check for equality here
if( data[i].Date >= nextDate) {
break;
}

Expand Down Expand Up @@ -145,7 +147,10 @@ class Chart extends Component {

// tooltip
this.tip = d3.tip().attr('class', 'd3-tip').html((d) => {
let title = this.state.diffInDays <= 1 ? d.Date.toLocaleString() : d.Date.toLocaleDateString();
let title = d.Date.toLocaleDateString();
if(this.state.diffInDays <= 1) {
title += ` ${d.Date.getHours()}:00 - ${d.Date.getHours() + 1}:00`
}
return (`<div class="tip-heading">${title}</div>
<div class="tip-content">
<div class="tip-pageviews">
Expand Down

0 comments on commit 06cf98b

Please sign in to comment.