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

Update BigNumber #5469

Merged
merged 1 commit into from
Aug 2, 2018
Merged

Update BigNumber #5469

merged 1 commit into from
Aug 2, 2018

Conversation

kristw
Copy link
Contributor

@kristw kristw commented Jul 23, 2018

Revise the big number design.

  • Implement BigNumberVis as react component, with simple adaptor for transforming superset data into it. The trendline is a data-ui component.
  • The visual ensures that the big numbers are aligned, with or without subheader.
  • The number sizes vary depends on available width and presence of the trendline.
  • Revise visutils to use svg for text size estimation because svg can support css class and also returns height while context.measureText() only returns width and does not support css class.

image

Reference: Refactored from PR 4313 by @williaster
cf2c0ff

@mistercrunch
Copy link
Member

Welcome on board @kristw! Please paste a screenshot. [optional] you may want to preserve the original commit to keep the attribution in place and make it possible to see the changes on top of the original PR. We'd have to be careful to Merge and not Squash and Merge to ensure it gets preserve on master. Oh and you may want to update your Github profile :)

@williaster
Copy link
Contributor

no worries about the history preservation, I closed #4313.

I think we'll still iterate on the styling of this to make sure there's an option to set color based on the compare ratio delta.

@codecov-io
Copy link

codecov-io commented Jul 27, 2018

Codecov Report

Merging #5469 into master will increase coverage by 0.02%.
The diff coverage is 20.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5469      +/-   ##
==========================================
+ Coverage   63.29%   63.31%   +0.02%     
==========================================
  Files         349      349              
  Lines       22194    22212      +18     
  Branches     2467     2473       +6     
==========================================
+ Hits        14047    14064      +17     
- Misses       8133     8134       +1     
  Partials       14       14
Impacted Files Coverage Δ
superset/assets/src/visualizations/BigNumber.jsx 0% <0%> (ø)
superset/assets/src/modules/visUtils.js 58.33% <58.33%> (-16.67%) ⬇️
superset/models/core.py 86.95% <0%> (-0.05%) ⬇️
superset/views/base.py 67.56% <0%> (ø) ⬆️
superset/assets/src/explore/controls.jsx 46.96% <0%> (ø) ⬆️
superset/views/core.py 74.19% <0%> (+0.01%) ⬆️
superset/assets/src/visualizations/nvd3_vis.js 8.99% <0%> (+0.03%) ⬆️
superset/security.py 73.09% <0%> (+0.19%) ⬆️
...rc/explore/components/controls/AnnotationLayer.jsx 23.35% <0%> (+0.69%) ⬆️

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 4bf69a7...c935050. Read the comment docs.

Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

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

This looks great to me overall, nice improvements! This will look so much better 😍

One question: it looks like BigNumber supports a className, what are your thoughts on varying the className based on the trend (+/-, or 0)? That way you could have custom css hooks to change color based on this.

Will get the react-15-compatible @data-ui/xy-chart version out ASAP.

};
}

const propTypes = {
Copy link
Contributor

Choose a reason for hiding this comment

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

future lint rules will require all PropTypes that aren't required to have defaults, could add those now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. will take care of that.

BigNumberVis.propTypes = propTypes;
BigNumberVis.defaultProps = defaultProps;

function adaptor(slice, payload) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️ the term adaptor for this + code style here

stroke-width: 1;
.big_number_header_line {
position: relative;
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to define font-family more than once or can you inherit from the container? or is this necessary for proper size-detection?

Copy link
Contributor Author

@kristw kristw Jul 27, 2018

Choose a reason for hiding this comment

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

Necessary for proper size detection. The getTextDimension function accept className and create svg text with that class.

  const fontSize = computeMaxFontSize({
      text,
      maxWidth: width,
      maxHeight,
      className: 'big_number_header_line',
    });

Otherwise the util function will have to create same nesting structure (with outer container have .big_number) or be able to accept parent DOM node (which does not exist yet).

I understand this looks annoyingly redundant, but don't have a good work around yet. Unless all body use same font family.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense 👍and I agree no obvious work around. We could possibly add a comment in the css that removing it would potentially break proper sizing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about this again and made the util function accept container DOM element, therefore got rid of the font family.

@kristw
Copy link
Contributor Author

kristw commented Jul 27, 2018

@williaster For clarification, will the positive/negative cssClass be for subheader? I think that should be doable. Will find a clean way to do it.

@williaster
Copy link
Contributor

yeah I think that'd make the most sense. could possibly add it for the trend line, but actually they could probably change that if they really wanted if the header had the class.

@@ -45,6 +45,7 @@
"dependencies": {
"@data-ui/event-flow": "^0.0.54",
"@data-ui/sparkline": "^0.0.54",
"@data-ui/xy-chart": "^0.0.60-alpha.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

0.0.60 is out now FYI

@kristw kristw force-pushed the kristw/big-number branch 2 times, most recently from 5c8bd19 to 98ab56a Compare August 2, 2018 05:35
support toggling trend line

experiment using svg to measure size instead of canvas

refactor BigNumber with chart sticked to the bottom

made header line stick to bottom and css adjustment

remove commented code

fix svg text size estimation

remove unused code and round dimensions

handle missing getbbox

remove vx/text from dependency

ensure svg deletion after measurement

add comment to css file.

Add `positive` and `negative` class based on diff.

Add default props.

rename variable

accept container as argument and remove redundant font family

refactor visutils for consistent api

update xy-chart

update xy-chart to alpha1.0

fix pointseries

remove points

update yarn.lock

[4c9c01d7] update xy-chart version

remove unused import
@kristw
Copy link
Contributor Author

kristw commented Aug 2, 2018

@williaster ready to merge

@williaster
Copy link
Contributor

solid 🙌 🚢

@williaster williaster merged commit 1b9e5d4 into apache:master Aug 2, 2018
@mistercrunch
Copy link
Member

happy

@kristw kristw deleted the kristw/big-number branch August 13, 2018 20:59
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
support toggling trend line

experiment using svg to measure size instead of canvas

refactor BigNumber with chart sticked to the bottom

made header line stick to bottom and css adjustment

remove commented code

fix svg text size estimation

remove unused code and round dimensions

handle missing getbbox

remove vx/text from dependency

ensure svg deletion after measurement

add comment to css file.

Add `positive` and `negative` class based on diff.

Add default props.

rename variable

accept container as argument and remove redundant font family

refactor visutils for consistent api

update xy-chart

update xy-chart to alpha1.0

fix pointseries

remove points

update yarn.lock

[4c9c01d7] update xy-chart version

remove unused import
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.28.0 labels Feb 27, 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 🚢 0.28.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants