graceguo-supercat closed pull request #4156: Fix chart rendering error in time
series table
URL: https://github.com/apache/incubator-superset/pull/4156
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/assets/visualizations/time_table.jsx
b/superset/assets/visualizations/time_table.jsx
index 0347c4148f..8111cbbf4e 100644
--- a/superset/assets/visualizations/time_table.jsx
+++ b/superset/assets/visualizations/time_table.jsx
@@ -137,9 +137,16 @@ function viz(slice, payload) {
} else {
const recent = reversedData[0][metric];
let v;
+ let errorMsg;
if (column.colType === 'time') {
// Time lag ratio
- v = reversedData[parseInt(column.timeLag, 10)][metric];
+ const timeLag = parseInt(column.timeLag, 10);
+ const totalLag = Object.keys(reversedData).length;
+ if (timeLag > totalLag) {
+ errorMsg = `The time lag set at ${timeLag} exceeds the length of
data at ${reversedData.length}. No data available.`;
+ } else {
+ v = reversedData[timeLag][metric];
+ }
if (column.comparisonType === 'diff') {
v = recent - v;
} else if (column.comparisonType === 'perc') {
@@ -175,11 +182,11 @@ function viz(slice, payload) {
}
row[column.key] = {
data: v,
- display: (
- <div style={{ color }}>
+ display: errorMsg ?
+ (<div>{errorMsg}</div>) :
+ (<div style={{ color }}>
<FormattedNumber num={v} format={column.d3format} />
- </div>
- ),
+ </div>),
style: color && {
boxShadow: `inset 0px -2.5px 0px 0px ${color}`,
borderRight: '2px solid #fff',
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services