You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2018/01/07 00:50:07 UTC

[incubator-superset] branch master updated: Fix chart rendering error in time series table (#4156)

This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new b9af019  Fix chart rendering error in time series table (#4156)
b9af019 is described below

commit b9af01956795b3a684c1f54311c955c700c5c8cb
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Sat Jan 6 16:49:59 2018 -0800

    Fix chart rendering error in time series table (#4156)
---
 superset/assets/visualizations/time_table.jsx | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/superset/assets/visualizations/time_table.jsx b/superset/assets/visualizations/time_table.jsx
index 0347c41..8111cbb 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',

-- 
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <co...@superset.apache.org>'].