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

Ternary w/o ticks fixes #2993

Merged
merged 4 commits into from Sep 11, 2018

Conversation

Projects
None yet
2 participants
@etpinard
Copy link
Member

commented Sep 10, 2018

Fixes #2897

I initially wanted to fix this issue by implementing editType: 'ticks' in ternary axes (and polar axes which use Axis.doTicks in a similar way), but that turned out to be a little too messy for a bug-fix PR. I'm even starting to second-guess editType: 'ticks' all together.

So, ternary axis tick and tick labels updates as now as bad as for polar subplots - where they make use of a "state" fields (one for each axis) on the ternary subplot objects. Oh well, at least we now have a few tests locking the behavior down.

cc @alexcjohnson @antoinerg


exports.supplyLayoutDefaults = require('./layout/defaults');
exports.supplyLayoutDefaults = require('./layout_defaults');

This comment has been minimized.

Copy link
@alexcjohnson

alexcjohnson Sep 11, 2018

Contributor

Good call flattening this structure 👍

@@ -430,6 +457,11 @@ proto.drawAxes = function(doTitles) {
}
};

function strTickLayout(axLayout) {
return axLayout.ticks + String(axLayout.ticklen) + String(axLayout.showticklabels);

This comment has been minimized.

Copy link
@alexcjohnson

alexcjohnson Sep 11, 2018

Contributor

There are other inherited attributes that have editType: 'ticks' in cartesian... how did you know which ones need to be included here?

This comment has been minimized.

Copy link
@etpinard

etpinard Sep 11, 2018

Author Member

Axes.doTicks is able to re-style existing nodes (e.g. relayout calls involving tickfont) e.g. see this test:

it('should be able to relayout axis tickfont attributes', function(done) {
var gd = createGraphDiv();
var fig = Lib.extendDeep({}, require('@mocks/ternary_simple.json'));
function _assert(family, color, size) {
var tick = d3.select('g.aaxis > g.ytick > text').node();
expect(tick.style['font-family']).toBe(family, 'font family');
expect(parseFloat(tick.style['font-size'])).toBe(size, 'font size');
expect(tick.style.fill).toBe(color, 'font color');
}
Plotly.plot(gd, fig).then(function() {
_assert('"Open Sans", verdana, arial, sans-serif', 'rgb(204, 204, 204)', 12);
return Plotly.relayout(gd, 'ternary.aaxis.tickfont.size', 5);
})
.then(function() {
_assert('"Open Sans", verdana, arial, sans-serif', 'rgb(204, 204, 204)', 5);
return Plotly.relayout(gd, 'ternary.aaxis.tickfont', {
family: 'Roboto',
color: 'red',
size: 20
});
})
.then(function() {
_assert('Roboto', 'rgb(255, 0, 0)', 20);
})
.catch(failTest)
.then(done);
});

but it can't handle hide/show. Cartesian axes rely on this block:

plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove();
plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove();
if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove();
if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove();
fullLayout._infolayer.select('.g-' + xa._id + 'title').remove();
fullLayout._infolayer.select('.g-' + ya._id + 'title').remove();

which isn't compatible with non-cartesian subplots.

'.aaxis > .ytick > text',
'ternary.aaxis.showticklabels',
[true, false], [4, 0]
);

This comment has been minimized.

Copy link
@alexcjohnson

alexcjohnson Sep 11, 2018

Contributor

Minor style comment: you can put the extra function wrapping inside the definition of toggle, so that the individual calls are just .then(toggle(...))

Regardless toggle is a very nice simplification!

This comment has been minimized.

Copy link
@etpinard

etpinard Sep 11, 2018

Author Member

Good call. Done in -> 68e0628

@alexcjohnson

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2018

Nice fix. 💃

@etpinard etpinard merged commit 1fceea8 into master Sep 11, 2018

6 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: test-image Your tests passed on CircleCI!
Details
ci/circleci: test-image2 Your tests passed on CircleCI!
Details
ci/circleci: test-jasmine Your tests passed on CircleCI!
Details
ci/circleci: test-jasmine2 Your tests passed on CircleCI!
Details
ci/circleci: test-syntax Your tests passed on CircleCI!
Details

@etpinard etpinard deleted the ternary-noticks branch Sep 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.