-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Ternary w/o ticks fixes #2993
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
Changes from 1 commit
b495131
05f58ce
937f5cf
68e0628
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -382,6 +382,76 @@ describe('ternary plots', function() { | |
.then(done); | ||
}); | ||
|
||
it('should be able to hide/show ticks and tick labels', function(done) { | ||
var gd = createGraphDiv(); | ||
var fig = Lib.extendDeep({}, require('@mocks/ternary_simple.json')); | ||
|
||
function assertCnt(selector, expected, msg) { | ||
var sel = d3.select(gd).selectAll(selector); | ||
expect(sel.size()).toBe(expected, msg); | ||
} | ||
|
||
function toggle(selector, astr, vals, exps) { | ||
return Plotly.relayout(gd, astr, vals[0]).then(function() { | ||
assertCnt(selector, exps[0], astr + ' ' + vals[0]); | ||
return Plotly.relayout(gd, astr, vals[1]); | ||
}) | ||
.then(function() { | ||
assertCnt(selector, exps[1], astr + ' ' + vals[1]); | ||
return Plotly.relayout(gd, astr, vals[0]); | ||
}) | ||
.then(function() { | ||
assertCnt(selector, exps[0], astr + ' ' + vals[0]); | ||
}); | ||
} | ||
|
||
Plotly.plot(gd, fig) | ||
.then(function() { | ||
return toggle( | ||
'.aaxis > .ytick > text', | ||
'ternary.aaxis.showticklabels', | ||
[true, false], [4, 0] | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor style comment: you can put the extra function wrapping inside the definition of Regardless There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call. Done in -> 68e0628 |
||
}) | ||
.then(function() { | ||
return toggle( | ||
'.baxis > .xtick > text', | ||
'ternary.baxis.showticklabels', | ||
[true, false], [5, 0] | ||
); | ||
}) | ||
.then(function() { | ||
return toggle( | ||
'.caxis > .ytick > text', | ||
'ternary.caxis.showticklabels', | ||
[true, false], [4, 0] | ||
); | ||
}) | ||
.then(function() { | ||
return toggle( | ||
'.aaxis > path.ytick', | ||
'ternary.aaxis.ticks', | ||
['outside', ''], [4, 0] | ||
); | ||
}) | ||
.then(function() { | ||
return toggle( | ||
'.baxis > path.xtick', | ||
'ternary.baxis.ticks', | ||
['outside', ''], [5, 0] | ||
); | ||
}) | ||
.then(function() { | ||
return toggle( | ||
'.caxis > path.ytick', | ||
'ternary.caxis.ticks', | ||
['outside', ''], [4, 0] | ||
); | ||
}) | ||
.catch(failTest) | ||
.then(done); | ||
}); | ||
|
||
it('should render a-axis and c-axis with negative offsets', function(done) { | ||
var gd = createGraphDiv(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other inherited attributes that have
editType: 'ticks'
in cartesian... how did you know which ones need to be included here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Axes.doTicks
is able to re-style existing nodes (e.g. relayout calls involvingtickfont
) e.g. see this test:plotly.js/test/jasmine/tests/ternary_test.js
Lines 352 to 383 in 2a667d0
but it can't handle hide/show. Cartesian axes rely on this block:
plotly.js/src/plots/cartesian/axes.js
Lines 1550 to 1555 in 2a667d0
which isn't compatible with non-cartesian subplots.