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

Function makeColorBarData

src/components/colorbar/draw.js:67–168  ·  view source on GitHub ↗
(gd)

Source from the content-addressed store, hash-verified

65}
66
67function makeColorBarData(gd) {
68 var fullLayout = gd._fullLayout;
69 var calcdata = gd.calcdata;
70 var out = [];
71
72 // single out item
73 var opts;
74 // colorbar attr parent container
75 var cont;
76 // trace attr container
77 var trace;
78 // colorbar options
79 var cbOpt;
80
81 function initOpts(opts) {
82 return extendFlat(opts, {
83 // fillcolor can be a d3 scale, domain is z values, range is colors
84 // or leave it out for no fill,
85 // or set to a string constant for single-color fill
86 _fillcolor: null,
87 // line.color has the same options as fillcolor
88 _line: {color: null, width: null, dash: null},
89 // levels of lines to draw.
90 // note that this DOES NOT determine the extent of the bar
91 // that's given by the domain of fillcolor
92 // (or line.color if no fillcolor domain)
93 _levels: {start: null, end: null, size: null},
94 // separate fill levels (for example, heatmap coloring of a
95 // contour map) if this is omitted, fillcolors will be
96 // evaluated halfway between levels
97 _filllevels: null,
98 // for continuous colorscales: fill with a gradient instead of explicit levels
99 // value should be the colorscale [[0, c0], [v1, c1], ..., [1, cEnd]]
100 _fillgradient: null,
101 // when using a gradient, we need the data range specified separately
102 _zrange: null
103 });
104 }
105
106 function calcOpts() {
107 if(typeof cbOpt.calc === 'function') {
108 cbOpt.calc(gd, trace, opts);
109 } else {
110 opts._fillgradient = cont.reversescale ?
111 flipScale(cont.colorscale) :
112 cont.colorscale;
113 opts._zrange = [cont[cbOpt.min], cont[cbOpt.max]];
114 }
115 }
116
117 for(var i = 0; i < calcdata.length; i++) {
118 var cd = calcdata[i];
119 trace = cd[0].trace;
120 if(!trace._module) continue;
121 var moduleOpts = trace._module.colorbar;
122
123 if(trace.visible === true && moduleOpts) {
124 var allowsMultiplotCbs = Array.isArray(moduleOpts);

Callers 1

drawFunction · 0.85

Calls 2

initOptsFunction · 0.85
calcOptsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…