villebro commented on a change in pull request #13122:
URL: https://github.com/apache/superset/pull/13122#discussion_r576151671
##########
File path: superset-frontend/src/visualizations/TimeTable/TimeTable.jsx
##########
@@ -209,10 +209,20 @@ const TimeTable = ({
.reduce((a, b) => a + b);
} else if (column.colType === 'avg') {
// Average over the last {timeLag}
- v =
- reversedEntries
- .map((k, i) => (i < column.timeLag ? k[valueField] : 0))
- .reduce((a, b) => a + b) / column.timeLag;
+ v = null;
+ if (reversedEntries.length > 0) {
+ const stats = reversedEntries.slice(undefined,
column.timeLag).reduce(
+ function ({ count, sum }, entry) {
+ return entry[valueField] != null
Review comment:
Just to be sure, let's also check for `undefined` here
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]