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

[nvd3] refactor, thinner margins #6282

Merged
merged 1 commit into from Nov 10, 2018

Conversation

mistercrunch
Copy link
Member

There was an unneeded margin on the pie chart + cleaned up the margin-related code a bit.

screen shot 2018-11-05 at 11 29 54 pm

screen shot 2018-11-05 at 11 27 33 pm

@codecov-io
Copy link

codecov-io commented Nov 6, 2018

Codecov Report

Merging #6282 into master will increase coverage by 0.1%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #6282     +/-   ##
=========================================
+ Coverage   76.91%   77.01%   +0.1%     
=========================================
  Files          64       64             
  Lines        9508     9508             
=========================================
+ Hits         7313     7323     +10     
+ Misses       2195     2185     -10
Impacted Files Coverage Δ
superset/connectors/sqla/models.py 80.56% <0%> (+0.74%) ⬆️
superset/db_engine_specs.py 55.03% <0%> (+0.87%) ⬆️

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 c653ab1...bef9525. 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.

LGTM, couple small comments :)

const maxXAxisLabelHeight = getMaxLabelSize(svg, 'nv-x');
margins.left = maxYAxisLabelWidth + marginPad;

if (yAxisLabel && yAxisLabel !== '') {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit -- the second condition will never be reached because '' is falsy

Copy link
Member Author

Choose a reason for hiding this comment

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

I copied this blindly from line 595 but happy to improve it.

// Hack to adjust margins to accommodate long axis tick labels.
// - has to be done only after the chart has been rendered once
// - measure the width or height of the labels
// ---- (x axis labels are rotated 45 degrees so we use height),
// - adjust margins based on these measures and render again
const margins = chart.margin();
margins.bottom = 28;
if (chart.xAxis) {
margins.bottom = 28;
Copy link
Contributor

Choose a reason for hiding this comment

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

just to understand -- we are modifying the reference to the chart margin object directly? should we instead copy it and call chart.margin(newMargin)? if it works I guess that's fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. I understand how non-functional that is and didn't to go too deep in the refactor. I mostly just grouped all margin-related code in one section and made sure that logically would produce the same results. Hopefully we can get rid of this whole module and nvd3 fairly soon!

@mistercrunch
Copy link
Member Author

Hey since I got the approval and wanted to minimize the changes as much as possible, I'll just merge this as-is.

@mistercrunch mistercrunch merged commit 841d5e6 into apache:master Nov 10, 2018
@williaster
Copy link
Contributor

sg 👍

bipinsoniguavus pushed a commit to ThalesGroup/incubator-superset that referenced this pull request Dec 26, 2018
@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 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.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants