-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is temporary fix until plotly/react-plotly.js#2 has been released
- Loading branch information
1 parent
a07914d
commit ca5e2dd
Showing
2 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,51 @@ | ||
/* | ||
* DELETE THIS FILE. EVERYTHING NEEDS TO FIND A HOME. | ||
*/ | ||
import {list} from 'plotly.js/src/plots/cartesian/axis_ids'; | ||
import {list, getFromId} from 'plotly.js/src/plots/cartesian/axis_ids'; | ||
import nestedProperty from 'plotly.js/src/lib/nested_property'; | ||
|
||
export function noShame(opts) { | ||
if (opts.plotly && !opts.plotly.Axes) { | ||
opts.plotly.Axes = { | ||
list, | ||
}; | ||
opts.plotly.Axes = {list}; | ||
} | ||
} | ||
|
||
// Temporary fix for: | ||
// https://github.com/plotly/react-plotly.js-editor/issues/103 | ||
// We should be able to remove this once the plotly.react method has | ||
// been integrated into react-plotly.js and released: | ||
// https://github.com/plotly/react-plotly.js/issues/2 | ||
export const maybeClearAxisTypes = (graphDiv, traceIndexes, update) => { | ||
if (!Array.isArray(graphDiv._fullData)) { | ||
return; | ||
} | ||
let hasSrc = false; | ||
for (const key in update) { | ||
if (key.substr(key.length - 3) === 'src') { | ||
hasSrc = true; | ||
} | ||
} | ||
if (hasSrc) { | ||
clearAxisTypes(graphDiv, traceIndexes); | ||
} | ||
}; | ||
|
||
var axLetters = ['x', 'y', 'z']; | ||
function clearAxisTypes(gd, traces) { | ||
for (var i = 0; i < traces.length; i++) { | ||
var trace = gd._fullData[i]; | ||
for (var j = 0; j < 3; j++) { | ||
const type = axLetters[j]; | ||
const ax = getFromId(gd, trace[type + 'axis'] || type); | ||
|
||
// Do not clear log type. | ||
// Log types is never an auto result so must have been intentional. | ||
// We are also skipping clearing 3D which could cause bugs with 3D. | ||
if (ax && ax.type !== 'log') { | ||
const axAttr = ax._name; | ||
const typeAttr = axAttr + '.type'; | ||
nestedProperty(gd.layout, typeAttr).set(null); | ||
} | ||
} | ||
} | ||
} |