mirror of https://github.com/apache/superset.git
Fix chart rendering error in time series table (#4156)
This commit is contained in:
parent
e7f8143c3b
commit
b9af019567
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue