Skip to content

Commit

Permalink
Merge pull request #2770 from isenseDev/revert-2765-ds2560
Browse files Browse the repository at this point in the history
Revert "Make Group by Number Fields work on Pie again"
  • Loading branch information
doug-salvati authored Dec 1, 2017
2 parents 82b59f6 + af3d445 commit e54cbbd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 36 deletions.
35 changes: 5 additions & 30 deletions app/assets/javascripts/visualizations/highvis/baseVis.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -232,36 +232,10 @@ $ ->
when @ANALYSISTYPE_MEDIAN then data.getMedian
when @ANALYSISTYPE_COUNT then data.getCount

# PROBLEM:
# Fields aren't necessarily in alphabetical order in DB
# SOLUTION:
# Map the group selection to reflect the discrepency

hiddenFields = data.fields.map((field) -> field.fieldID).filter((id) -> id == -1).length

# Relevant fields in alpahbetical selection list order
selectionOrder = data.groups

# Relevant fields in internally-stored project order
internalOrder = []
for elt, i in data.fields
internalOrder[i] = elt
internalOrder = internalOrder.splice(hiddenFields, internalOrder.length)
ignoredFields = internalOrder.findIndex (f) -> f.typeID is data.types.NUMBER
internalOrder = internalOrder.filter (f) -> f.typeID is data.types.NUMBER
internalOrder = internalOrder.map (f) -> f.fieldName

# Map the group selection to reflect the discrepency
mappedSelections = []
for elt in data.groupSelection
correspondingField = selectionOrder[elt]
actualIdxOfField = internalOrder.findIndex (fieldName) -> fieldName is correspondingField
mappedSelections[actualIdxOfField] = elt

# Get the data
for fieldId, index in mappedSelections
unless fieldId is undefined
fData[fieldId] = analysisMethod.call(data, index + hiddenFields + ignoredFields, null, dp)
for fieldId, index in data.groupSelection
fData[index] = analysisMethod.call(data, fieldId + hiddenFields, null, dp)

return fData

###
Expand Down Expand Up @@ -1074,7 +1048,8 @@ $ ->
temp =
text: "#{data.fields[globals.configs.fieldSelection[0]].fieldName} " +
"(#{data.fields[globals.configs.fieldSelection[0]].unitName})"
@chart.yAxis[0].setTitle title, false

@chart.yAxis[0].setTitle title, false

# Remove curent data
while @chart.series.length > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,6 @@ $ ->
if data.fields[f].fieldID != -1
groups.push(data.fields[f].fieldName)
else
for dp in @dataPoints
if dp[gIndex] isnt null
result[String(dp[gIndex])] = true
groups = for keys of result
keys

if gIndex == data.TIME_PERIOD_FIELD #and globals.configs.isPeriod
timestampIndex = data.timeFields[0]
Expand All @@ -492,7 +487,14 @@ $ ->
else
period = globals.getCurrentPeriod(new Date(timestamp))
point[data.TIME_PERIOD_FIELD] = period


for dp in @dataPoints
if dp[gIndex] isnt null
result[String(dp[gIndex])] = true

groups = for keys of result
keys

groups.sort()

###
Expand Down

0 comments on commit e54cbbd

Please sign in to comment.