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

Function doubleClick

src/plots/cartesian/dragbox.js:764–848  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

762 }
763
764 function doubleClick() {
765 if(gd._transitioningWithDuration) return;
766
767 var doubleClickConfig = gd._context.doubleClick;
768
769 var axList = [];
770 if(xActive) axList = axList.concat(xaxes);
771 if(yActive) axList = axList.concat(yaxes);
772 if(matches.xaxes) axList = axList.concat(matches.xaxes);
773 if(matches.yaxes) axList = axList.concat(matches.yaxes);
774
775 var attrs = {};
776 var ax, i;
777
778 // For reset+autosize mode:
779 // If *any* of the main axes is not at its initial range
780 // (or autoranged, if we have no initial range, to match the logic in
781 // doubleClickConfig === 'reset' below), we reset.
782 // If they are *all* at their initial ranges, then we autosize.
783 if(doubleClickConfig === 'reset+autosize') {
784 doubleClickConfig = 'autosize';
785
786 for(i = 0; i < axList.length; i++) {
787 ax = axList[i];
788 var r0 = ax._rangeInitial0;
789 var r1 = ax._rangeInitial1;
790 var hasRangeInitial =
791 r0 !== undefined ||
792 r1 !== undefined;
793
794 if((hasRangeInitial && (
795 (r0 !== undefined && r0 !== ax.range[0]) ||
796 (r1 !== undefined && r1 !== ax.range[1])
797 )) ||
798 (!hasRangeInitial && ax.autorange !== true)
799 ) {
800 doubleClickConfig = 'reset';
801 break;
802 }
803 }
804 }
805
806 if(doubleClickConfig === 'autosize') {
807 // don't set the linked axes here, so relayout marks them as shrinkable
808 // and we autosize just to the requested axis/axes
809 for(i = 0; i < axList.length; i++) {
810 ax = axList[i];
811 if(!ax.fixedrange) attrs[ax._name + '.autorange'] = true;
812 }
813 } else if(doubleClickConfig === 'reset') {
814 // when we're resetting, reset all linked axes too, so we get back
815 // to the fully-auto-with-constraints situation
816 if(xActive || links.isSubplotConstrained) axList = axList.concat(links.xaxes);
817 if(yActive && !links.isSubplotConstrained) axList = axList.concat(links.yaxes);
818
819 if(links.isSubplotConstrained) {
820 if(!xActive) axList = axList.concat(xaxes);
821 else if(!yActive) axList = axList.concat(yaxes);

Callers 1

clickFnFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…