Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chart rendering error in time series table #4156

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions superset/assets/visualizations/time_table.jsx
Expand Up @@ -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') {
Expand Down Expand Up @@ -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',
Expand Down