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

Function drawOne

src/components/legend/draw.js:82–503  ·  view source on GitHub ↗
(gd, opts)

Source from the content-addressed store, hash-verified

80
81
82function drawOne(gd, opts) {
83 var legendObj = opts || {};
84
85 var fullLayout = gd._fullLayout;
86 var legendId = helpers.getId(legendObj);
87
88 var clipId, layer;
89
90 var inHover = legendObj._inHover;
91 if(inHover) {
92 layer = legendObj.layer;
93 clipId = 'hover';
94 } else {
95 layer = fullLayout._infolayer;
96 clipId = legendId;
97 }
98 if(!layer) return;
99 clipId += fullLayout._uid;
100
101 if(!gd._legendMouseDownTime) gd._legendMouseDownTime = 0;
102
103 var legendData;
104 if(!inHover) {
105 var calcdata = (gd.calcdata || []).slice();
106
107 var shapes = fullLayout.shapes;
108 for(var i = 0; i < shapes.length; i++) {
109 var shape = shapes[i];
110 if(!shape.showlegend) continue;
111
112 var shapeLegend = {
113 _isShape: true,
114 _fullInput: shape,
115 index: shape._index,
116 name: shape.name || shape.label.text || ('shape ' + shape._index),
117 legend: shape.legend,
118 legendgroup: shape.legendgroup,
119 legendgrouptitle: shape.legendgrouptitle,
120 legendrank: shape.legendrank,
121 legendwidth: shape.legendwidth,
122 showlegend: shape.showlegend,
123 visible: shape.visible,
124 opacity: shape.opacity,
125 mode: shape.type === 'line' ? 'lines' : 'markers',
126 line: shape.line,
127 marker: {
128 line: shape.line,
129 color: shape.fillcolor,
130 size: 12,
131 symbol:
132 shape.type === 'rect' ? 'square' :
133 shape.type === 'circle' ? 'circle' :
134 // case of path
135 'hexagon2'
136 },
137 };
138
139 calcdata.push([{ trace: shapeLegend }]);

Callers 3

draw.jsFile · 0.70
reactFunction · 0.50
manage_arrays.jsFile · 0.50

Calls 10

setupTitleToggleFunction · 0.85
computeLegendDimensionsFunction · 0.85
getXanchorFunction · 0.85
getYanchorFunction · 0.85
expandMarginFunction · 0.85
scrollHandlerFunction · 0.85
getScrollBarDragYFunction · 0.85
getNaturalDragYFunction · 0.85
clickOrDoubleClickFunction · 0.85
textLayoutFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…