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 rendering regression from the introduction of bignumber #6937

Merged
merged 1 commit into from
Feb 26, 2019

Conversation

xtinec
Copy link
Contributor

@xtinec xtinec commented Feb 24, 2019

In superset-ui 0.8.0, we used bignumber.js to transform numbers in chartProps' payload from plain 64-bit floats to BigNumber instances. This causes a number of charts to render incorrectly when comparison functions in the rendering algorithms operate on BigNumber objects instead of floats. This PR uses the preTransformProps step in SuperChart to transform BigNumber instances back to floats so charts can render properly.

cc @soboko

In superset-ui 0.8.0, we used bignumber.js to transform numbers in chartProps' payload from plain 64-bit floats to BigNumber instances. This causes a number of charts to render incorrectly when comparison functions in the rendering algorithms operate on BigNumber objects instead of floats. This PR uses the preTransformProps step in SuperChart to transform BigNumber instances back to floats so charts can render properly.
@xtinec xtinec added !deprecated-label:bug Deprecated label - Use #bug instead review v0.31 labels Feb 24, 2019
@codecov-io
Copy link

codecov-io commented Feb 24, 2019

Codecov Report

Merging #6937 into master will increase coverage by <.01%.
The diff coverage is 72.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6937      +/-   ##
==========================================
+ Coverage   63.98%   63.99%   +<.01%     
==========================================
  Files         422      423       +1     
  Lines       20537    20555      +18     
  Branches     2230     2235       +5     
==========================================
+ Hits        13141    13154      +13     
- Misses       7264     7269       +5     
  Partials      132      132
Impacted Files Coverage Δ
superset/assets/src/chart/ChartRenderer.jsx 7.24% <0%> (-0.57%) ⬇️
superset/assets/src/chart/transformBigNumber.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e112659...b6fb56a. Read the comment docs.

Copy link
Contributor

@kristw kristw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// floats instead of BigNumber instances in their props to properly render.
import BigNumber from 'bignumber.js';

export default function transform(payload) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transformBigNumber? there's a lint rule for this we should enable.

payload[key] = transform(payload[key]);
}
}
} else if (payload.constructor === Array) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Array.isArray is preferred

@xtinec xtinec merged commit 73cdb37 into apache:master Feb 26, 2019
xtinec added a commit that referenced this pull request Feb 26, 2019
In superset-ui 0.8.0, we used bignumber.js to transform numbers in chartProps' payload from plain 64-bit floats to BigNumber instances. This causes a number of charts to render incorrectly when comparison functions in the rendering algorithms operate on BigNumber objects instead of floats. This PR uses the preTransformProps step in SuperChart to transform BigNumber instances back to floats so charts can render properly.

(cherry picked from commit 73cdb37)
@mistercrunch
Copy link
Member

I'm a bit concerned about recursing through all payloads looking for BigNumber. This probably adds significant client-side loads where large payloads are present.

How do BigNumber come to life first, any way handle it there?

xtinec added a commit to lyft/incubator-superset that referenced this pull request Apr 3, 2019
Revert "Fix rendering regression from the introduction of bignumber (apache#6937)"
xtinec added a commit that referenced this pull request Apr 3, 2019
…bignumber.js change to SQL editor in an opt-in fashion (#7210)

* revert: bignumber patch to prevent rendering regression in charts

* Revert "Fix rendering regression from the introduction of bignumber (#6937)"

* fix: consume the bignumber.js reversion -- apply the bignumber conversion in `actions/sqlLab.js` where it is needed (aka opt into bignumber.js).

* Revert "Fix deck.gl form data (#6953)" b/c formData now returns snake_cased properties for deck vizzes.
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels !deprecated-label:bug Deprecated label - Use #bug instead v0.31 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants