Skip to content

Commit 1fb9798

Browse files
committed
bar chart reduce functions can now work with both mean speed this hour and percent diff this hour
1 parent 7b3a2f4 commit 1fb9798

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/components/Sidebar/TimeFilters/chart.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dc/dc.css'
88
// Callback for when data is added to the current filter results
99
const reduceAdd = function (p, v) {
1010
p.count++
11-
p.sum += v.meanSpeedThisHour
11+
p.sum += v.value // value can be mean speed this hour OR percent diff this hour
1212
if (p.count > 0) {
1313
p.avg = (p.sum / p.count)
1414
} else {
@@ -21,7 +21,7 @@ const reduceAdd = function (p, v) {
2121
const reduceRemove = function (p, v) {
2222
// return p - p.
2323
p.count--
24-
p.sum -= v.meanSpeedThisHour
24+
p.sum -= v.value // value can be mean speed this hour OR percent diff this hour
2525
if (p.count > 0) {
2626
p.avg = (p.sum / p.count)
2727
} else {
@@ -33,7 +33,7 @@ const reduceRemove = function (p, v) {
3333
// Initialize `p`
3434
const reduceInitial = function () {
3535
return {
36-
meanSpeedThisHour: 0,
36+
value: 0,
3737
count: 0,
3838
sum: 0,
3939
avg: 0

src/store/actions/barchart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ export function setBarchartData (speedsArray, diffsArray, countArray) {
3737
hoursForCrossFilter.push({
3838
'dayOfWeek': index[0] + 1,
3939
'hourOfDay': index[1] + 1,
40-
'meanSpeedThisHour': speed
40+
'value': speed
4141
})
4242
})
4343
percentDiffArray.forEach((diff, index) => {
4444
hoursForDiffCrossFilter.push({
4545
'dayOfWeek': index[0] + 1,
4646
'hourOfDay': index[1] + 1,
47-
'percentDiffThisHour': diff
47+
'value': diff
4848
})
4949
})
5050
return {

0 commit comments

Comments
 (0)