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

Rendering bug with stacked data #487

Closed
wylieconlon opened this issue Dec 6, 2019 · 7 comments · Fixed by #488 or elastic/kibana#52619
Closed

Rendering bug with stacked data #487

wylieconlon opened this issue Dec 6, 2019 · 7 comments · Fixed by #488 or elastic/kibana#52619
Labels
released Issue released publicly

Comments

@wylieconlon
Copy link

wylieconlon commented Dec 6, 2019

I am testing out data formats that are used in Kibana, and found this example. For this sample SQL query there is incorrect rendering.

Sample query: SELECT geo.src, geo.dest, COUNT(*) as C GROUP BY geo.src, geo.dest ORDER BY COUNT(*) DESC LIMIT 50

This rendering shows all the data on the legend, but does not draw any bars.

Screenshot 2019-12-06 15 07 02

I've created a minimal test case here for you to see the data used: https://codesandbox.io/s/async-meadow-divin

See the full data set
const rows = [['IN', 'IN', '142'],
['IN', 'CN', '50'],
['CN', 'CN', '49'],
['CN', 'IN', '41'],
['CN', 'US', '24'],
['US', 'IN', '24'],
['IN', 'US', '22'],
['US', 'CN', '18'],
['CN', 'ID', '13'],
['ID', 'CN', '13'],
['US', 'US', '13'],
['CN', 'BR', '11'],
['JP', 'IN', '10'],
['BR', 'CN', '9'],
['BR', 'IN', '8'],
['IN', 'BD', '8'],
['IN', 'BR', '8'],
['IN', 'IR', '8'],
['IN', 'PK', '8'],
['IT', 'CN', '8'],
['CN', 'DE', '7'],
['KR', 'CN', '7'],
['MX', 'IN', '7'],
['NG', 'CN', '7'],
['US', 'ID', '7'],
['CN', 'BD', '6'],
['CN', 'MM', '6'],
['CN', 'MX', '6'],
['CN', 'NG', '6'],
['CN', 'RU', '6'],
['ES', 'IN', '6'],
['ID', 'IN', '6'],
['IN', 'ID', '6'],
['US', 'BR', '6'],
['US', 'TR', '6'],
['BD', 'CN', '5'],
['BD', 'IN', '5'],
['BR', 'US', '5'],
['CN', 'ES', '5'],
['CN', 'JP', '5'],
['EG', 'IN', '5'],
['ES', 'CN', '5'],
['ID', 'US', '5'],
['IN', 'EG', '5'],
['IN', 'JP', '5'],
['IN', 'MX', '5'],
['IN', 'NG', '5'],
['IN', 'PH', '5'],
['PK', 'CN', '5'],
['PK', 'IN', '5']];

There is also some connection to this Canvas issue: elastic/kibana#52419

@wylieconlon
Copy link
Author

I've compared our rendering to how Vega deals with the same dataset, for reference:

Screenshot 2019-12-06 15 48 43

Try it in the vega editor

@markov00
Copy link
Member

markov00 commented Dec 6, 2019

@wylieconlon the y axis is a linear scale but in the data table the y values are strings.
We don't automatically convert them to numbers because we assume a valid dataset configured by the user. If you remap the dataset converting the y value to a number it will correctly show the stacked bar chart:
Screenshot 2019-12-06 at 23 29 45

@wylieconlon
Copy link
Author

Okay yes, I see that now if I convert the values to numbers they are rendered correctly. What I don't understand is- if the linear scale can't handle strings, why does render at all?

@markov00
Copy link
Member

markov00 commented Dec 6, 2019

It's a d3 scale magic :D

@markov00
Copy link
Member

markov00 commented Dec 6, 2019

Or there is something else going on in our chart that wrongly interpret the numbers here. Let me check and I will be back

@markov00
Copy link
Member

markov00 commented Dec 6, 2019

Ok, so this has something to deal with the way we compute the stacked values.
Since we expect the y to be a number, to compute the y position of a stacked bar we sum the current value with the previous value. You can easily imagine what can happen if you "sum" two strings...
Screenshot 2019-12-06 at 23 50 20

markov00 added a commit to markov00/elastic-charts that referenced this issue Dec 9, 2019
The stacked bars are computed adding up the previous value with the current one. This works fine if
the passed values are numbers. If the number is codified as a string, the resulting stacked value is
a wrongly concatenated string of values. This commit cast every y value to a number, if NaN or null
it will use null.

fix elastic#487
markov00 added a commit that referenced this issue Dec 12, 2019
The stacked bars are computed adding up the previous value with the current one. This works fine if the passed values are numbers. If the number is codified as a string, the resulting stacked value is a wrongly concatenated string of values. This commit cast every y value to a number, if NaN or null it will use null

fix #487
markov00 pushed a commit that referenced this issue Dec 12, 2019
## [15.0.5](v15.0.4...v15.0.5) (2019-12-12)

### Bug Fixes

* render stacked bar with stringified values ([#488](#488)) ([811ee90](811ee90)), closes [#487](#487)
@markov00
Copy link
Member

🎉 This issue has been resolved in version 15.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Dec 12, 2019
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this issue Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Issue released publicly
Projects
None yet
2 participants