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

Chart - sum Y column values rather than displaying last Y value #4587

Open
akc2267 opened this issue Jan 24, 2020 · 7 comments
Open

Chart - sum Y column values rather than displaying last Y value #4587

akc2267 opened this issue Jan 24, 2020 · 7 comments

Comments

@akc2267
Copy link

akc2267 commented Jan 24, 2020

Issue Summary

Chrome Mac OS. When creating Pie charts, I noticed that the fractional representation is accurate; however, the hover displays the last Y value rather than summing up all Y values for the given X value. This causes hover values that make absolutely no sense.

Steps to Reproduce

  1. Create a query that results in a table with 1 numerical value Y column (like population) and 2+ possible X columns (like City & State).
  2. Create a pie chart visualization with the larger X column (State) and the Y column (population).
  3. Notice that while the pie chart properly displays the fractional representation of the X values, it only displays the last row of the respective Y column for that X value. Instead, this should displayed the summed up value. (State should show the summed population of all of its cities, rather than the population of the last city in the table)

Technical details:

  • Redash Version: 7.0.0+b18042 (4a978ba)
  • Browser/OS: Chrome/MacOS
  • How did you install Redash: The company that employs me is running redash in a self-managed datacenter
@kravets-levko
Copy link
Collaborator

Hi @akc2267! There is a related discussion on our forum where we explain why the things work in this way and what you can use as a workaround: https://discuss.redash.io/t/wrong-label-view/5237

@akc2267
Copy link
Author

akc2267 commented Jan 24, 2020

Thank you for the quick response! Unfortunately that solution does not work for my use case. My dashboards are getting aggravatingly slow, as I have to create separate queries for each pie chart. My specific use case is dividing out costs across my Company's various orgs. These are represented in 6 layers (tier 1-6 for example). So in order to have accurate pie charts for all orgs, I need 6 queries to group by the 6 individual tiers. I would much rather have just 1 query that groups by all 6 tiers and displays the most granular dollar amount attributable to the lowest org. I could then attach 6 pie charts to this single query, with each pie chart using a different org tier as the X value and dollars as the Y value. This would massively reduce the time it takes to load my dashboard, especially considering I have filters to single out any specific tier or org.

@akc2267
Copy link
Author

akc2267 commented Jan 27, 2020

@kravets-levko, If I made a merge request to fix this, would it be reviewed?

I'm trying to reason with the current format and I just don't see how it could be considered an intended default behavior. Pie chart labels should match their fractional allocations always.

@kravets-levko
Copy link
Collaborator

Most likely we'll fix this one day, but no any estimates for now. If you want to submit a fix - you're welcome 🙂

@akc2267
Copy link
Author

akc2267 commented Jan 27, 2020

Just a note that this bug affects all chart data labels, not just pie charts

@akc2267
Copy link
Author

akc2267 commented Feb 21, 2020

@kravets-levko, I've found the error in the code:

prepareSeries(series, options, additionalOptions)
-the mapreduce functions result in only the last row (y) for each (x) actually being used.
-this exists in both preparePieData.js and prepeareDefaultData.js

I think the best way to fix this while keeping the general code structure intact is by creating a Dictionary, aggregating y values for each x. I am attempting to do this now.

But, I have a general question: why did y'all decide to create your own labels versus using Plotly's built in labels? Surely this is degrading your performance as both plotly and redash are calculating these values (and plotly currently does it incorrectly)
EDIT: it seems that plotly provides the percentage values. Maybe it doesn't provide the aggregated y values?

@akc2267
Copy link
Author

akc2267 commented Feb 21, 2020

Screen Shot 2020-02-21 at 10 10 18 AM

Note that the percentage values between the pie chart and the hover label are wildly different. Also note that the population value in the hover label only shows the population for one city in all of california

@akc2267 akc2267 changed the title Pie Chart - sum Y column values rather than displaying last Y value Chart - sum Y column values rather than displaying last Y value Feb 21, 2020
akc2267 pushed a commit to akc2267/redash that referenced this issue Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants