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

Commit

Permalink
Refactor and clarify variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Irmas committed Jul 16, 2019
1 parent f0d5863 commit 0439413
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions dist/subtotal.js

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions src/examples/subtotal/subtotal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ const vis: Subtotal = {
pivotSet[pivot] = true
}

const htmlForCell = (cell: Cell) => {
return cell.html ? LookerCharts.Utils.htmlForCell(cell) : cell.value
}

const ptData = []
for (const row of data) {
const ptRow: { [key: string]: any } = {}
for (const key of Object.keys(row)) {
const obj = row[key] as Cell
const cell = row[key] as Cell
if (pivotSet[key]) continue
const value = obj.html ? LookerCharts.Utils.htmlForCell(obj) : obj.value
ptRow[key] = value
const cellValue = htmlForCell(cell)
ptRow[key] = cellValue
}
if (pivots.length === 0) {
// No pivoting, just add each data row.
Expand All @@ -113,9 +117,9 @@ const vis: Subtotal = {
pivotRow[pivot] = LOOKER_ROW_TOTAL_KEY
}
for (const measure of measures) {
const obj = row[measure.name][pivotKey]
const value = obj.html ? LookerCharts.Utils.htmlForCell(obj) : obj.value
pivotRow[measure.name] = value
const cell = row[measure.name][pivotKey] as Cell
const cellValue = htmlForCell(cell)
pivotRow[measure.name] = cellValue
}
}
} else {
Expand All @@ -124,9 +128,9 @@ const vis: Subtotal = {
pivotRow[pivots[i]] = pivotValues[i]
}
for (const measure of measures) {
const obj = row[measure.name][flatKey]
const value = obj.html ? LookerCharts.Utils.htmlForCell(obj) : obj.value
pivotRow[measure.name] = value
const cell = row[measure.name][flatKey] as Cell
const cellValue = htmlForCell(cell)
pivotRow[measure.name] = cellValue
}
}
ptData.push(pivotRow)
Expand Down

0 comments on commit 0439413

Please sign in to comment.