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

Implement axis.layer with 'above traces' and 'below traces' values #1871

Merged
merged 7 commits into from
Jul 13, 2017

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Jul 11, 2017

to be merged in #1861 with (hopefully) all the requirements for #1385

This PR adds an axis attribute layer with two possible values: 'above traces' (the default and current behavior) and 'below traces' which allows together with cliponaxis: false to draw markers and text nodes above axis lines and tick labels. See cliponaxis_false mock in e44aa4d for an example.

We chose to make layer have a hard 'above traces' default value corresponding to the behavior on master. This might be revisited in v2.

This PR also fixes a bug in the cliponaxis: false implementation in 7b62b73 and lints a few things.


In a private convo with @alexcjohnson , we opted to not include special auto-range logic for cliponaxis: false traces. This issue will be dealt with by having a few more axis options in a later PR. I'll open up a ticket about this tomorrow. DONE in #1876

Unless someone ⛔ me, I'll won't add a workaround patch for the cartesian line clip path problems on pan (see #1861 (comment)) nor will I fix the IE / Edge issues from #1861 (comment). In trying to fix these, I broke some animation tests; I think it would be wise to wait until Ricky is back to working full-time before making another attempt. I'll document this things in new separate issues tomorrow. FIXED in e234827

etpinard added 4 commits July 11, 2017 17:22
- which is more meaningul
- other misc lint
- has 2 possible values: 'above traces' and 'below traces' for now,
  but opens the door for other values down the road.
- show off `(x|y)axis.layer`
- lock down behavior for `cliponaxis: true` traces
  on hasClipOnAxisFalse subplot
- add annotations for more descriptive mock
@alexcjohnson
Copy link
Collaborator

I won't add a workaround patch for the cartesian line clip path problems on pan (see #1861 (comment)) nor will I fix the IE / Edge issues from #1861 (comment).

That's fine, I'll make an issue for the IE/Edge one since it's not new. For the chrome issue since it IS new, can you investigate a little (perhaps reduce it to a static SVG bug in codepen?) and then either make an internal issue or report it to chromium?

})
.catch(failTest)
.then(done);
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Beautiful. This test is exactly the question I was about to ask when looking at the code.

'Sets the layer on which this axis is displayed.',
'If *above traces*, this axis is displayed above all the subplot\'s traces',
'If *below traces*, this axis is displayed below all the subplot\'s traces,',
'but above the grid lines.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Per #1861 (comment) - can you mention scatter.cliponaxis here (and vice versa)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call 📚

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 6f494c6

etpinard added 2 commits July 12, 2017 16:40
- which replaces all `require('d3')` with `require('./strict-d3')`
- so that strict-d3.js can more easily be used across all our tools
- activate when bundling plotly.js in jasmine tests,
  `npm run watch` and `npm run cibuild`
- 🔪 <script> injecting old IIFE
- require('fast-isnumeric') in strict-d3.js
- instead of on <clipPath> element itself
- see https://codepen.io/etpinard/pen/eRbxrp for more info
  on the problem
- lock down this rule by adding condition in strict-d3.js
* Transform `require('d3')` expressions to `require(/path/to/strict-d3.js)`
*/

module.exports = transformTools.makeRequireTransform('requireTransform',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcjohnson I hope you don't mind this commit too much. This made incorporating strict-d3.js in our jasmine tests a lot easier - which is very useful e.g. to 🔒 down e234827

Companion plotly-mock-viewer PR: rreusser/plotly-mock-viewer#15

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, looks great!

function checkAttrVal(sel, key) {
// setting the transform attribute on a <clipPath> does not
// work in Chrome, IE and Edge
if(sel.node().nodeName === 'clipPath' && key === 'transform') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need for additional jasmine tests cases, this here made many animation and interaction test fail.

@@ -743,7 +743,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
var plotDx = xa2._offset - clipDx / xScaleFactor2,
plotDy = ya2._offset - clipDy / yScaleFactor2;

fullLayout._defs.selectAll('#' + subplot.clipId)
fullLayout._defs.select('#' + subplot.clipId + '> rect')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See https://codepen.io/etpinard/pen/eRbxrp?editors=1010 for more info on this topic.

var pathIn = args[0];
var pathOut;

if(pathIn === 'd3' && opts.file !== pathToStrictD3Module) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I gather this is so that strict-d3 itself can still get the original d3?

Copy link
Contributor Author

@etpinard etpinard Jul 12, 2017

Choose a reason for hiding this comment

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

Bingo. 🎲

@alexcjohnson
Copy link
Collaborator

💃

@etpinard etpinard merged commit bbb31f4 into cliponaxis-false-take2 Jul 13, 2017
@etpinard etpinard deleted the axis-layer-above-below branch July 13, 2017 00:58
@etpinard etpinard mentioned this pull request Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants