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

Function convert

src/traces/streamtube/convert.js:80–186  ·  view source on GitHub ↗
(scene, trace)

Source from the content-addressed store, hash-verified

78}
79
80function convert(scene, trace) {
81 var sceneLayout = scene.fullSceneLayout;
82 var dataScale = scene.dataScale;
83 var len = trace._len;
84 var tubeOpts = {};
85
86 function toDataCoords(arr, axisName) {
87 var ax = sceneLayout[axisName];
88 var scale = dataScale[axisName2scaleIndex[axisName]];
89 return Lib.simpleMap(arr, function(v) { return ax.d2l(v) * scale; });
90 }
91
92 tubeOpts.vectors = zip3(
93 toDataCoords(trace._u, 'xaxis'),
94 toDataCoords(trace._v, 'yaxis'),
95 toDataCoords(trace._w, 'zaxis'),
96 len
97 );
98
99 // Over-specified mesh case, this would error in tube2mesh
100 if(!len) {
101 return {
102 positions: [],
103 cells: []
104 };
105 }
106
107 var meshx = toDataCoords(trace._Xs, 'xaxis');
108 var meshy = toDataCoords(trace._Ys, 'yaxis');
109 var meshz = toDataCoords(trace._Zs, 'zaxis');
110
111 tubeOpts.meshgrid = [meshx, meshy, meshz];
112 tubeOpts.gridFill = trace._gridFill;
113
114 var slen = trace._slen;
115 if(slen) {
116 tubeOpts.startingPositions = zip3(
117 toDataCoords(trace._startsX, 'xaxis'),
118 toDataCoords(trace._startsY, 'yaxis'),
119 toDataCoords(trace._startsZ, 'zaxis')
120 );
121 } else {
122 // Default starting positions:
123 //
124 // if len>2, cut xz plane at min-y,
125 // takes all x/y/z pts on that plane except those on the edges
126 // to generate "well-defined" tubes,
127 //
128 // if len=2, take position halfway between two the pts,
129 //
130 // if len=1, take that pt
131 var sy0 = meshy[0];
132 var sx = getDfltStartingPositions(meshx);
133 var sz = getDfltStartingPositions(meshz);
134 var startingPositions = new Array(sx.length * sz.length);
135 var m = 0;
136
137 for(var i = 0; i < sx.length; i++) {

Callers 4

convert.jsFile · 0.70
createStreamtubeTraceFunction · 0.70
plot.jsFile · 0.50
plot.jsFile · 0.50

Calls 5

getDfltStartingPositionsFunction · 0.85
parseColorScaleFunction · 0.85
getBoundPadsFunction · 0.85
extractOptsFunction · 0.85
toDataCoordsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…