MCPcopy Create free account
hub / github.com/plotly/plotly.js / createShapeObj

Function createShapeObj

src/components/shapes/draw_newshape/newshapes.js:123–270  ·  view source on GitHub ↗
(outlines, dragOptions, dragmode)

Source from the content-addressed store, hash-verified

121}
122
123function createShapeObj(outlines, dragOptions, dragmode) {
124 var e = outlines[0][0]; // pick first outline
125 var gd = dragOptions.gd;
126
127 var d = e.getAttribute('d');
128 var newStyle = gd._fullLayout.newshape;
129 var plotinfo = dragOptions.plotinfo;
130 var isActiveShape = dragOptions.isActiveShape;
131
132 var xaxis = plotinfo.xaxis;
133 var yaxis = plotinfo.yaxis;
134 var xPaper = !!plotinfo.domain || !plotinfo.xaxis;
135 var yPaper = !!plotinfo.domain || !plotinfo.yaxis;
136
137 var isOpenMode = openMode(dragmode);
138 var polygons = readPaths(d, gd, plotinfo, isActiveShape);
139
140 var newShape = {
141 editable: true,
142
143 visible: newStyle.visible,
144 name: newStyle.name,
145 showlegend: newStyle.showlegend,
146 legend: newStyle.legend,
147 legendwidth: newStyle.legendwidth,
148 legendgroup: newStyle.legendgroup,
149 legendgrouptitle: {
150 text: newStyle.legendgrouptitle.text,
151 font: newStyle.legendgrouptitle.font
152 },
153 legendrank: newStyle.legendrank,
154
155 label: newStyle.label,
156
157 xref: xPaper ? 'paper' : xaxis._id,
158 yref: yPaper ? 'paper' : yaxis._id,
159
160 layer: newStyle.layer,
161 opacity: newStyle.opacity,
162 line: {
163 color: newStyle.line.color,
164 width: newStyle.line.width,
165 dash: newStyle.line.dash
166 }
167 };
168
169 if(!isOpenMode) {
170 newShape.fillcolor = newStyle.fillcolor;
171 newShape.fillrule = newStyle.fillrule;
172 }
173
174 var cell;
175 // line, rect and circle can be in one cell
176 // only define cell if there is single cell
177 if(polygons.length === 1) cell = polygons[0];
178
179 if(
180 cell &&

Callers 2

newShapesFunction · 0.85

Calls 2

r2pFunction · 0.85
p2rFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…