Skip to content

Better polar setConvert + a few misc polar touch ups #2895

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

Merged
merged 18 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/plots/polar/polar.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,11 +993,13 @@ proto.updateRadialDrag = function(fullLayout, polarLayout) {
var moduleCalcDataVisible = Lib.filterVisible(moduleCalcData);
var _module = moduleCalcData[0][0].trace._module;
var polarLayoutNow = gd._fullLayout[_this.id];
var isGL = Registry.traceIs(k, 'gl');

if(isGL && _this._scene) _this._scene.clear();
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to not have _this._scene at this point if there's a gl trace?

BTW this would be clearer with traceType instead of k.

I don't see a problem at the moment because there's only one gl type that can be here, but for future reference seems like if we ever add another we'll have to make sure only the first one clears the scene.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for tip. Improvements in -> b81885d


if(_this._scene) _this._scene.clear();
_module.plot(gd, _this, moduleCalcDataVisible, polarLayoutNow);

if(!Registry.traceIs(k, 'gl')) {
if(!isGL) {
for(var i = 0; i < moduleCalcDataVisible.length; i++) {
_module.style(gd, moduleCalcDataVisible[i]);
}
Expand Down
11 changes: 10 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,13 @@ describe('Test polar interactions:', function() {
patch: function(fig) {
fig.data.forEach(function(trace) { trace.mode = 'markers+lines'; });
}
}, {
desc: 'gl and non-gl on same subplot case',
patch: function(fig) {
fig.data.forEach(function(trace, i) {
trace.type = (i % 2) ? 'scatterpolar' : 'scatterpolargl';
});
}
}];

specs.forEach(function(s) {
Expand All @@ -1136,7 +1143,9 @@ describe('Test polar interactions:', function() {
fig.layout.margin = {l: 50, t: 50, b: 50, r: 50};

if(s.patch) s.patch(fig);
nTraces = fig.data.length;
nTraces = fig.data.reduce(function(acc, trace) {
return (trace.type === 'scatterpolargl') ? ++acc : acc;
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, OK. I always find prefix ++ confusing, and perhaps because it encourages stuff like that reduce also often comes out confusing to me. I realize it's better perf this way, but that's irrelevant to a test.
fig.data.filter(function(trace) { return trace.type === 'scatterpolargl'; }).length?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right, filter is better: b4700ca

}, 0);

Plotly.newPlot(gd, fig).then(function() {
scene = gd._fullLayout.polar._subplot._scene;
Expand Down