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

[Timeseries Bar Chart V2] Bars disappear when changing the contribution mode to "Total" #19507

Closed
3 tasks done
ValentinC-BR opened this issue Apr 4, 2022 · 6 comments
Closed
3 tasks done
Labels
#bug Bug report

Comments

@ValentinC-BR
Copy link

I try to use the new version of the chart, to progressively migrate from legacy to echarts.

However, the timeseries bar chart v2 can't be used for 100% stacked bar chart : Some bars are not displayed when changing the contribution mode to "Ttoal".

How to reproduce the bug

  1. Create a timeseries bar chart (v2)
  2. Select "Contribution mode : Total"
  3. Run
  4. See error

Expected results

The number of bars is the same, and all bar have a constant height : 100%

Actual results

Some bar are missing

Screenshots

Without 100% stacking :

image

When choosing "Contribution mode : Total"

image

Environment

Browser type and version: Google Chrome Version 99.0.4844.51 (Oficial build) (x86_64)
Superset version: 1.4.1
Python version: 3.8.12
Node.js version: doesn’t apply, I run on Kubernetes, using gunicorn as server
Source : AWS Athena
Any feature flags active: ALERT_REPORTS, ENABLE_TEMPLATE_PROCESSING, DASHBOARD_NATIVE_FILTERS

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • (not relevant) I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

I'm also wondering why Superset has to calculate everything again, as soon as I change the contribution mode (once per contribution mode) ... Is the query sent to Athena different ?

@ValentinC-BR ValentinC-BR added the #bug Bug report label Apr 4, 2022
@smarmot
Copy link

smarmot commented Apr 23, 2022

Have the same issue.
I figured out this is because the data has null values before turning on Total in Contribution mode.

Before:
Screenshot 2022-04-23 at 15 24 28

After:
Screenshot 2022-04-23 at 15 28 18

@YiouZuo
Copy link

YiouZuo commented Aug 11, 2022

I have a similar issue -- Timeseries Bar Chart V2 malfunctions when there is NULL in the results, though in my case, not directly from the data.
I'm counting each group's occurrence each month. However, some accounts may not appear in all months, creating NULL in the query results. The original data doesn't have NULL.

Sample data :
Date, Group, Occurrence
2020-01-01, a, 2
2020-01-01, a, 3
2020-02-01, a, 5
...
2020-06-01, a, 5
2020-06-01, b, 1
2020-06-01, b, 2
2020-06-01, b, 1
...
2020-06-01, c, 4
2020-06-01, c, 1
...
2021-12-01, a, 5
2021-12-01, c, 5
...

Screenshots show the query results: for group b, when it had no occurrence from 2021-11 to 2022-3, it's NULL, and the corresponding stacked bars on the chart are not correctly displayed (missing group c for 3 out of 5 months).
Screen Shot 2022-08-10 at 10 15 08 PM

The test data I created (repeat 5 times for the full set):
test_null_timeseries_v2.csv

@YiouZuo
Copy link

YiouZuo commented Aug 11, 2022

The Timeseries Area Chart has a similar issue:
Screen Shot 2022-08-10 at 11 20 28 PM

@YiouZuo
Copy link

YiouZuo commented Aug 17, 2022

I figured out a workaround, we can write our own SQL script and fill the nulls in SQL LAB and then save it as a dataset. Below is my script.

with dates as (
select distinct DATE_TRUNC('DAY', date) as my_date
from public.test_null_timeseries_v2
),
accounts as (
select DISTINCT account_name
from public.test_null_timeseries_v2
),
full_list AS (
select my_date, account_name
from dates
cross join accounts
),
test AS (
SELECT DATE_TRUNC('DAY', date) AS my_date,
      account_name AS account_name,
      sum(value) AS sum_value
FROM public.test_null_timeseries_v2
group by my_date, account_name)
select f.my_date, f.account_name,
CASE 
  when t.sum_value is null then 0
  else t.sum_value
  end as sum_value_filled
from full_list as f 
left join test as t 
on f.my_date = t.my_date and f.account_name = t.account_name
order by f.my_date, f.account_name

@Shazad-khan
Copy link

This issue has been fixed in the recent release please recheck and close the issue

@michael-s-molina
Copy link
Member

Thank you @Shazad-khan for checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report
Projects
None yet
Development

No branches or pull requests

5 participants