Skip to content
This repository was archived by the owner on Apr 21, 2022. It is now read-only.

Commit 0439413

Browse files
author
Cameron Irmas
committed
Refactor and clarify variable names
1 parent f0d5863 commit 0439413

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

dist/subtotal.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/examples/subtotal/subtotal.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,18 @@ const vis: Subtotal = {
9191
pivotSet[pivot] = true
9292
}
9393

94+
const htmlForCell = (cell: Cell) => {
95+
return cell.html ? LookerCharts.Utils.htmlForCell(cell) : cell.value
96+
}
97+
9498
const ptData = []
9599
for (const row of data) {
96100
const ptRow: { [key: string]: any } = {}
97101
for (const key of Object.keys(row)) {
98-
const obj = row[key] as Cell
102+
const cell = row[key] as Cell
99103
if (pivotSet[key]) continue
100-
const value = obj.html ? LookerCharts.Utils.htmlForCell(obj) : obj.value
101-
ptRow[key] = value
104+
const cellValue = htmlForCell(cell)
105+
ptRow[key] = cellValue
102106
}
103107
if (pivots.length === 0) {
104108
// No pivoting, just add each data row.
@@ -113,9 +117,9 @@ const vis: Subtotal = {
113117
pivotRow[pivot] = LOOKER_ROW_TOTAL_KEY
114118
}
115119
for (const measure of measures) {
116-
const obj = row[measure.name][pivotKey]
117-
const value = obj.html ? LookerCharts.Utils.htmlForCell(obj) : obj.value
118-
pivotRow[measure.name] = value
120+
const cell = row[measure.name][pivotKey] as Cell
121+
const cellValue = htmlForCell(cell)
122+
pivotRow[measure.name] = cellValue
119123
}
120124
}
121125
} else {
@@ -124,9 +128,9 @@ const vis: Subtotal = {
124128
pivotRow[pivots[i]] = pivotValues[i]
125129
}
126130
for (const measure of measures) {
127-
const obj = row[measure.name][flatKey]
128-
const value = obj.html ? LookerCharts.Utils.htmlForCell(obj) : obj.value
129-
pivotRow[measure.name] = value
131+
const cell = row[measure.name][flatKey] as Cell
132+
const cellValue = htmlForCell(cell)
133+
pivotRow[measure.name] = cellValue
130134
}
131135
}
132136
ptData.push(pivotRow)

0 commit comments

Comments
 (0)