My end goal is to have a heat chart based on hour of day/day of week for calls for service. However, I have a filter on the date range so the color heat groups need to adjust as the data adjusts. I'm unable to figure out a way to gather all sum values and put in an array for me to get the max and min from the whole table. Below is where I'm at but I believe I need to somehow loop through the table using $rowindex?
Thank you in advance!
// gather all sum values from chart to find max, min, and create 5 color groups
var myArray = [$datapoint.sum_Mon,$datapoint.sum_Tue,$datapoint.sum_Wed, $datapoint.sum_Thur, $datapoint.sum_Fri, $datapoint.sum_Sat, $datapoint.sum_Sun]
var groupDiff = (Max(myArray)-Min(myArray))/5
var groupTwo = groupDiff * 2
var groupThree = groupDiff * 3
var groupFour = groupDiff * 4
function cellColor(callStatByDay){
return When(callStatByDay < groupDiff, '#eecb9a',
callStatByDay >= groupDiff && callStatByDay < groupTwo, '#e7b48f',
callStatByDay >= groupTwo && callStatByDay < groupThree, '#e09d85',
callStatByDay >= groupThree && callStatByDay < groupFour, '#d9867a', '#c06677' )
}
return {
cells: {
Hour: {
displayText : $datapoint.Hour,
textColor: '',
backgroundColor: '',
textAlign: 'left',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
sum_Mon: {
displayText : $datapoint.sum_Mon,
textColor: '',
backgroundColor: cellColor($datapoint.sum_Mon),
textAlign: 'center',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
sum_Tue: {
displayText : $datapoint.sum_Tue,
textColor: '',
backgroundColor: cellColor($datapoint.sum_Tue),
textAlign: 'center',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
sum_Wed: {
displayText : $datapoint.sum_Wed,
textColor: '',
backgroundColor: cellColor($datapoint.sum_Wed),
textAlign: 'center',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
sum_Thur: {
displayText : $datapoint.sum_Thur,
textColor: '',
backgroundColor: cellColor($datapoint.sum_Thur),
textAlign: 'center',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
sum_Fri: {
displayText : $datapoint.sum_Fri,
textColor: '',
backgroundColor: cellColor($datapoint.sum_Fri),
textAlign: 'center',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
sum_Sat: {
displayText : $datapoint.sum_Sat,
textColor: '',
backgroundColor: cellColor($datapoint.sum_Sat),
textAlign: 'center',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
sum_Sun: {
displayText : $datapoint.sum_Sun,
textColor: '',
backgroundColor: cellColor($datapoint.sum_Sun),
textAlign: 'center',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
}
}
}
Advanced formatting evaluates per row, so there's not a good way of pulling in values from other rows.
If the data came in from the Data Expression, you could find the absolute min/max values and insert them as per-row attributes for the sake of calculating a cell color. But I don't think that will be dynamic in a way the responds to a filter. The only widgets that allow for interactive reference values are indicators, I believe.
Lauren, did you ever figure this out? I am trying something similar. Works great with defined integers. I also would like it to be dynamic and tried this.
It is a little off and I can't seem to dial it in.
I have not figured this out, if you get your to work successfully please let me know! @jcarlson any suggestions?