Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c009426

Browse files
committed
detect polar with hasPolar
1 parent 5c96c36 commit c009426

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/plot_api/plot_api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Plotly.plot = function(gd, data, layout, config) {
121121
Plots.supplyDefaults(gd);
122122

123123
// Polar plots
124-
if(data && data[0] && data[0].r) return plotPolar(gd, data, layout);
124+
if(gd._fullLayout._hasPolar) return plotPolar(gd, data, layout);
125125

126126
// so we don't try to re-call Plotly.plot from inside
127127
// legend and colorbar, if margins changed

src/plots/plots.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ plots.getSubplotData = function getSubplotData(data, type, subplotId) {
258258
// the text is at first, so it needs to draw it,
259259
// then wait a little, then draw it again
260260
plots.redrawText = function(gd) {
261+
262+
// do not work for polar plots
263+
if(gd._fullLayout._hasPolar) return;
264+
261265
return new Promise(function(resolve) {
262266
setTimeout(function() {
263267
Plotly.Annotations.drawAll(gd);
@@ -472,7 +476,7 @@ plots.supplyDefaults = function(gd) {
472476
newFullData.push(fullTrace);
473477

474478
// detect polar
475-
if('r' in fullTrace) newFullLayout._hasPolar = true;
479+
if('r' in newData[i]) newFullLayout._hasPolar = true;
476480

477481
_module = fullTrace._module;
478482
if(!_module) continue;
@@ -482,6 +486,8 @@ plots.supplyDefaults = function(gd) {
482486
Lib.fillUnique(basePlotModules, fullTrace._module.basePlotModule);
483487
}
484488

489+
console.log(newFullLayout._hasPolar)
490+
485491
// attach helper method
486492
oldFullLayout._has = hasPlotType.bind(oldFullLayout);
487493
newFullLayout._has = hasPlotType.bind(newFullLayout);

src/snapshot/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function getDelay(fullLayout) {
1515
}
1616

1717
function getRedrawFunc(gd) {
18+
19+
// do not work for polar plots
20+
if(gd._fullLayout._hasPolar) return;
21+
1822
return function() {
1923
(gd.calcdata || []).forEach(function(d) {
2024
if(d[0] && d[0].t && d[0].t.cb) d[0].t.cb();

0 commit comments

Comments
 (0)