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

Function computeTickMarks

src/plots/gl3d/layout/tick_marks.js:28–91  ·  view source on GitHub ↗
(scene)

Source from the content-addressed store, hash-verified

26}
27
28function computeTickMarks(scene) {
29 var axesOptions = scene.axesOptions;
30 var glRange = scene.glplot.axesPixels;
31 var sceneLayout = scene.fullSceneLayout;
32
33 var ticks = [[], [], []];
34
35 for(var i = 0; i < 3; ++i) {
36 var axes = sceneLayout[AXES_NAMES[i]];
37
38 axes._length = (glRange[i].hi - glRange[i].lo) *
39 glRange[i].pixelsPerDataUnit / scene.dataScale[i];
40
41 if(Math.abs(axes._length) === Infinity ||
42 isNaN(axes._length)) {
43 ticks[i] = [];
44 } else {
45 axes._input_range = axes.range.slice();
46 axes.range[0] = (glRange[i].lo) / scene.dataScale[i];
47 axes.range[1] = (glRange[i].hi) / scene.dataScale[i];
48 axes._m = 1.0 / (scene.dataScale[i] * glRange[i].pixelsPerDataUnit);
49
50 if(axes.range[0] === axes.range[1]) {
51 axes.range[0] -= 1;
52 axes.range[1] += 1;
53 }
54 // this is necessary to short-circuit the 'y' handling
55 // in tickmode part of calcTicks... Treating all axes as 'y' in this case
56 // running the tickmode here, then setting
57 // automode to linear to get around the 2D handling in calcTicks.
58 var tickModeCached = axes.tickmode;
59 if(axes.tickmode === 'auto') {
60 axes.tickmode = 'linear';
61 var nticks = axes.nticks || Lib.constrain((axes._length / 40), 4, 9);
62 Axes.autoTicks(axes, Math.abs(axes.range[1] - axes.range[0]) / nticks);
63 }
64 var dataTicks = Axes.calcTicks(axes, { msUTC: true });
65 for(var j = 0; j < dataTicks.length; ++j) {
66 dataTicks[j].x = dataTicks[j].x * scene.dataScale[i];
67
68 if(axes.type === 'date') {
69 dataTicks[j].text =
70 dataTicks[j].text.replace(/\<br\>/g, ' ');
71 }
72 }
73 ticks[i] = dataTicks;
74
75
76 axes.tickmode = tickModeCached;
77 }
78 }
79
80 axesOptions.ticks = ticks;
81
82 // Calculate tick lengths dynamically
83 for(var i = 0; i < 3; ++i) {
84 centerPoint[i] = 0.5 * (scene.glplot.bounds[0][i] + scene.glplot.bounds[1][i]);
85 for(var j = 0; j < 2; ++j) {

Callers 1

scene.jsFile · 0.85

Calls 1

contourLevelsFromTicksFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…