* restyle: update trace attributes of an existing plot * * Can be called two ways. * * Signature 1: * @param {String | HTMLDivElement} gd * the id or DOM element of the graph container div * @param {String} astr * attribute string (like `'marker.symbol'`) to update * @param {*} val * va
(gd, astr, val, _traces)
| 1238 | * style files that want to specify cyclical default values). |
| 1239 | */ |
| 1240 | function restyle(gd, astr, val, _traces) { |
| 1241 | gd = Lib.getGraphDiv(gd); |
| 1242 | helpers.clearPromiseQueue(gd); |
| 1243 | |
| 1244 | var aobj = {}; |
| 1245 | if (typeof astr === 'string') aobj[astr] = val; |
| 1246 | else if (Lib.isPlainObject(astr)) { |
| 1247 | // the 3-arg form |
| 1248 | aobj = Lib.extendFlat({}, astr); |
| 1249 | if (_traces === undefined) _traces = val; |
| 1250 | } else { |
| 1251 | Lib.warn('Restyle fail.', astr, val, _traces); |
| 1252 | return Promise.reject(); |
| 1253 | } |
| 1254 | |
| 1255 | if (Object.keys(aobj).length) gd.changed = true; |
| 1256 | |
| 1257 | var traces = helpers.coerceTraceIndices(gd, _traces); |
| 1258 | |
| 1259 | var specs = _restyle(gd, aobj, traces); |
| 1260 | var flags = specs.flags; |
| 1261 | |
| 1262 | // clear calcdata and/or axis types if required so they get regenerated |
| 1263 | if (flags.calc) gd.calcdata = undefined; |
| 1264 | if (flags.clearAxisTypes) helpers.clearAxisTypes(gd, traces, {}); |
| 1265 | |
| 1266 | // fill in redraw sequence |
| 1267 | var seq = []; |
| 1268 | |
| 1269 | if (flags.fullReplot) { |
| 1270 | seq.push(exports._doPlot); |
| 1271 | } else { |
| 1272 | seq.push(Plots.previousPromises); |
| 1273 | |
| 1274 | // maybe only call Plots.supplyDataDefaults in the splom case, |
| 1275 | // to skip over long and slow axes defaults |
| 1276 | Plots.supplyDefaults(gd); |
| 1277 | |
| 1278 | if (flags.markerSize) { |
| 1279 | Plots.doCalcdata(gd); |
| 1280 | addAxRangeSequence(seq); |
| 1281 | |
| 1282 | // TODO |
| 1283 | // if all axes have autorange:false, then |
| 1284 | // proceed to subroutines.doTraceStyle(), |
| 1285 | // otherwise we must go through addAxRangeSequence, |
| 1286 | // which in general must redraws 'all' axes |
| 1287 | } |
| 1288 | |
| 1289 | if (flags.style) seq.push(subroutines.doTraceStyle); |
| 1290 | if (flags.colorbars) seq.push(subroutines.doColorBars); |
| 1291 | |
| 1292 | seq.push(emitAfterPlot); |
| 1293 | } |
| 1294 | |
| 1295 | seq.push(Plots.rehover, Plots.redrag, Plots.reselect); |
| 1296 | |
| 1297 | Queue.add(gd, restyle, [gd, specs.undoit, specs.traces], restyle, [gd, specs.redoit, specs.traces]); |
nothing calls this directly
no test coverage detected
searching dependent graphs…