MCPcopy
hub / github.com/plotly/plotly.js / makePadFn

Function makePadFn

src/plots/cartesian/autorange.js:211–246  ·  view source on GitHub ↗
(fullLayout, ax, max)

Source from the content-addressed store, hash-verified

209 * optional extrapad as 5% of the total axis length
210 */
211function makePadFn(fullLayout, ax, max) {
212 // 5% padding for points that specify extrapad: true
213 var extrappad = 0.05 * ax._length;
214
215 var anchorAxis = ax._anchorAxis || {};
216
217 if(
218 (ax.ticklabelposition || '').indexOf('inside') !== -1 ||
219 (anchorAxis.ticklabelposition || '').indexOf('inside') !== -1
220 ) {
221 var axReverse = ax.isReversed();
222 if(!axReverse) {
223 var rng = Lib.simpleMap(ax.range, ax.r2l);
224 axReverse = rng[1] < rng[0];
225 }
226 if(axReverse) max = !max;
227 }
228
229 var zero = 0;
230 if(!isLinked(fullLayout, ax._id)) {
231 zero = padInsideLabelsOnAnchorAxis(fullLayout, ax, max);
232 }
233 extrappad = Math.max(zero, extrappad);
234
235 // domain-constrained axes: base extrappad on the unconstrained
236 // domain so it's consistent as the domain changes
237 if((ax.constrain === 'domain') && ax._inputDomain) {
238 extrappad *= (ax._inputDomain[1] - ax._inputDomain[0]) /
239 (ax.domain[1] - ax.domain[0]);
240 }
241
242 return function getPad(pt) {
243 if(pt.nopad) return 0;
244 return pt.pad + (pt.extrapad ? extrappad : zero);
245 };
246}
247
248var TEXTPAD = 3;
249

Callers 1

getAutoRangeFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…