MCPcopy Index your code
hub / github.com/plotly/plotly.js / diffLayout

Function diffLayout

src/plot_api/plot_api.js:2808–2864  ·  view source on GitHub ↗
(gd, oldFullLayout, newFullLayout, immutable, transition)

Source from the content-addressed store, hash-verified

2806}
2807
2808function diffLayout(gd, oldFullLayout, newFullLayout, immutable, transition) {
2809 var flags = editTypes.layoutFlags();
2810 flags.arrays = {};
2811 flags.rangesAltered = {};
2812 flags.nChanges = 0;
2813 flags.nChangesAnim = 0;
2814
2815 function getLayoutValObject(parts) {
2816 return PlotSchema.getLayoutValObject(newFullLayout, parts);
2817 }
2818
2819 // Clear out any _inputDomain that's no longer valid
2820 for (var key in newFullLayout) {
2821 if (!key.startsWith('xaxis') && !key.startsWith('yaxis')) {
2822 continue;
2823 }
2824 if (!oldFullLayout[key]) {
2825 continue;
2826 }
2827 var newDomain = newFullLayout[key].domain;
2828 var oldDomain = oldFullLayout[key].domain;
2829 var oldInputDomain = oldFullLayout[key]._inputDomain;
2830 if (oldFullLayout[key]._inputDomain) {
2831 if (newDomain[0] === oldInputDomain[0] && newDomain[1] === oldInputDomain[1]) {
2832 // what you're asking for hasn't changed, so let plotly.js start with what it
2833 // concluded last time and iterate from there
2834 newFullLayout[key].domain = oldFullLayout[key].domain;
2835 } else if (newDomain[0] !== oldDomain[0] || newDomain[1] !== oldDomain[1]) {
2836 // what you're asking for HAS changed, so clear _inputDomain and let us start from scratch
2837 newFullLayout[key]._inputDomain = null;
2838 }
2839 // We skip the else case (newDomain !== oldInputDomain && newDomain === oldDomain)
2840 // because it's likely that if the newDomain and oldDomain are the same, the user
2841 // passed in the same layout object and we should keep the _inputDomain.
2842 }
2843 }
2844
2845 var diffOpts = {
2846 getValObject: getLayoutValObject,
2847 flags: flags,
2848 immutable: immutable,
2849 transition: transition,
2850 gd: gd
2851 };
2852
2853 getDiffFlags(oldFullLayout, newFullLayout, [], diffOpts);
2854
2855 if (flags.plot || flags.calc) {
2856 flags.layoutReplot = true;
2857 }
2858
2859 if (transition && flags.nChanges && flags.nChangesAnim) {
2860 flags.anim = flags.nChanges === flags.nChangesAnim ? 'all' : 'some';
2861 }
2862
2863 return flags;
2864}
2865

Callers 1

reactFunction · 0.85

Calls 1

getDiffFlagsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…