diff --git a/draftlogs/7710_add.md b/draftlogs/7710_add.md new file mode 100644 index 00000000000..5a98635a261 --- /dev/null +++ b/draftlogs/7710_add.md @@ -0,0 +1 @@ +- Add `quiver` trace type to visualize vector fields using arrows [[#7710](https://github.com/plotly/plotly.js/pull/7710)], with thanks to @degzhaus for the contribution! diff --git a/lib/index-strict.js b/lib/index-strict.js index 434bd33eba1..976695f8443 100644 --- a/lib/index-strict.js +++ b/lib/index-strict.js @@ -49,6 +49,7 @@ Plotly.register([ require('../src/traces/scatterpolargl/strict'), require('./barpolar'), require('./scattersmith'), + require('./quiver'), // components require('./calendars'), diff --git a/lib/index.js b/lib/index.js index f176a0183fd..f61d8ab484d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -49,6 +49,7 @@ Plotly.register([ require('./scatterpolargl'), require('./barpolar'), require('./scattersmith'), + require('./quiver'), // components require('./calendars'), diff --git a/lib/quiver.js b/lib/quiver.js new file mode 100644 index 00000000000..12179a54900 --- /dev/null +++ b/lib/quiver.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../src/traces/quiver'); diff --git a/src/components/legend/style.js b/src/components/legend/style.js index 07c13461e90..a149a535f84 100644 --- a/src/components/legend/style.js +++ b/src/components/legend/style.js @@ -684,7 +684,7 @@ function getGradientDirection(reversescale, isRadial) { function getStyleGuide(d) { var trace = d[0].trace; var contours = trace.contours; - var showLine = subTypes.hasLines(trace); + var showLine = subTypes.hasLines(trace) || (trace.visible && trace.type === 'quiver'); var showMarker = subTypes.hasMarkers(trace); var showFill = trace.visible && trace.fill && trace.fill !== 'none'; diff --git a/src/components/modebar/manage.js b/src/components/modebar/manage.js index 716fa9054c5..c5e2bd230af 100644 --- a/src/components/modebar/manage.js +++ b/src/components/modebar/manage.js @@ -284,7 +284,7 @@ function isSelectable(fullData) { if(!trace._module || !trace._module.selectPoints) continue; - if(Registry.traceIs(trace, 'scatter-like')) { + if(Registry.traceIs(trace, 'scatter-like') && trace.type !== 'quiver') { if(scatterSubTypes.hasMarkers(trace) || scatterSubTypes.hasText(trace)) { selectable = true; } diff --git a/src/traces/quiver/attributes.js b/src/traces/quiver/attributes.js new file mode 100644 index 00000000000..27d9e269935 --- /dev/null +++ b/src/traces/quiver/attributes.js @@ -0,0 +1,190 @@ +'use strict'; + +var baseAttrs = require('../../plots/attributes'); +var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs; +var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat; +var extendFlat = require('../../lib/extend').extendFlat; +var colorScaleAttrs = require('../../components/colorscale/attributes'); +var dash = require('../../components/drawing/attributes').dash; +var annotationAttrs = require('../../components/annotations/attributes'); +var scatterAttrs = require('../scatter/attributes'); + +var attrs = { + x: { + valType: 'data_array', + editType: 'calc+clearAxisTypes', + anim: true, + description: 'Sets the x coordinates of the arrow locations.' + }, + x0: scatterAttrs.x0, + dx: scatterAttrs.dx, + y: { + valType: 'data_array', + editType: 'calc+clearAxisTypes', + anim: true, + description: 'Sets the y coordinates of the arrow locations.' + }, + y0: scatterAttrs.y0, + dy: scatterAttrs.dy, + u: { + valType: 'data_array', + editType: 'calc', + anim: true, + description: 'Sets the x components of the arrow vectors.' + }, + v: { + valType: 'data_array', + editType: 'calc', + anim: true, + description: 'Sets the y components of the arrow vectors.' + }, + anglemode: { + valType: 'enumerated', + values: ['paper', 'data'], + dflt: 'axis', + editType: 'calc', + description: [ + 'Sets the mode used to determine the angle of the arrow vectors.', + 'If *paper*, u/v are interpreted in pixel coordinates and the rendered vector angle', + 'does not change regardless of the axes scales.', + 'If *data*, u/v are interpreted in data coordinates and the rendered vector angle', + 'may change, e.g. if zooming in along a single axis' + ].join(' ') + }, + sizemode: { + valType: 'enumerated', + values: ['scaled', 'raw'], + editType: 'calc', + dflt: 'scaled', + description: [ + 'Determines whether arrows are drawn according to their raw lengths,', + 'or scaled based on the maximum vector length and point density. Note: When `anglemode` is *data*', + 'arrows are alwyas scaled and `sizemode` *raw* is ignored.', + ].join(' ') + }, + sizeref: { + valType: 'number', + min: 0, + editType: 'calc', + dflt: 1, + description: [ + 'Adjusts the arrow size scaling. The arrow length is determined by the vector norm multiplied by `sizeref`,', + 'optionally normalized when `sizemode` is *scaled* (`sizeref` is applied after scaling).' + ].join(' ') + }, + anchor: { + valType: 'enumerated', + values: ['tip', 'tail', 'center'], + dflt: 'tail', + editType: 'calc', + description: [ + 'Sets the arrows\' anchor with respect to their (x,y) positions.', + 'Use *tail* to place (x,y) at the base, *tip* to place (x,y) at the head,', + 'or *center* to center the arrow on (x,y).' + ].join(' ') + }, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + uhoverformat: axisHoverFormat('u', 'noDate'), + vhoverformat: axisHoverFormat('v', 'noDate'), + + hoverinfo: extendFlat({}, baseAttrs.hoverinfo, { + flags: ['x', 'y', 'u', 'v', 'text', 'name'], + dflt: 'all' + }), + hovertemplate: hovertemplateAttrs({}, { + keys: ['x', 'y', 'u', 'v', 'text', 'name'] + }), + + // Text and labels (shared with scatter) + text: scatterAttrs.text, + textposition: scatterAttrs.textposition, + textfont: scatterAttrs.textfont, + + // Marker: color, colorscale, arrowhead sizing, and line styling for arrows + marker: extendFlat( + { + arrowsize: extendFlat({}, annotationAttrs.arrowsize, { + editType: 'calc', + description: [ + 'Sets the size of the arrow head relative to `marker.line.width`.', + 'A value of 1 (default) gives a head about 3x as wide as the line.' + ].join(' ') + }), + line: { + width: { + valType: 'number', + min: 0, + dflt: 2, + editType: 'style', + description: 'Sets the width (in px) of the arrow lines.' + }, + dash: dash, + editType: 'style' + }, + editType: 'calc' + }, + colorScaleAttrs('marker', { + showScaleDflt: true, + editTypeOverride: 'calc' + }) + ), + selected: { + marker: { + color: { + valType: 'color', + editType: 'style', + description: 'Sets the marker color of selected points.' + }, + line: { + width: { + valType: 'number', + min: 0, + editType: 'style', + description: 'Sets the line width of selected points.' + }, + editType: 'style' + }, + editType: 'style' + }, + textfont: { + color: { + valType: 'color', + editType: 'style', + description: 'Sets the text font color of selected points, applied only when a selection exists.' + }, + editType: 'style' + }, + editType: 'style' + }, + unselected: { + marker: { + color: { + valType: 'color', + editType: 'style', + description: 'Sets the marker color of unselected points, applied only when a selection exists.' + }, + line: { + width: { + valType: 'number', + min: 0, + editType: 'style', + description: 'Sets the line width of unselected points, applied only when a selection exists.' + }, + editType: 'style' + }, + editType: 'style' + }, + textfont: { + color: { + valType: 'color', + editType: 'style', + description: 'Sets the text font color of unselected points, applied only when a selection exists.' + }, + editType: 'style' + }, + editType: 'style' + } +}; + +module.exports = attrs; diff --git a/src/traces/quiver/calc.js b/src/traces/quiver/calc.js new file mode 100644 index 00000000000..2b7e6b7253a --- /dev/null +++ b/src/traces/quiver/calc.js @@ -0,0 +1,218 @@ +'use strict'; + +var Lib = require('../../lib'); +var Axes = require('../../plots/cartesian/axes'); +var isNumeric = require('fast-isnumeric'); +var BADNUM = require('../../constants/numerical').BADNUM; +var colorscaleCalc = require('../../components/colorscale/calc'); +var calcSelection = require('../scatter/calc_selection'); + +/** + * Main calculation function for quiver trace + * Creates calcdata with arrow path data for each vector + */ +module.exports = function calc(gd, trace) { + // Map x/y through axes so category/date values become numeric calcdata + const xa = trace._xA = Axes.getFromId(gd, trace.xaxis || 'x', 'x'); + const ya = trace._yA = Axes.getFromId(gd, trace.yaxis || 'y', 'y'); + + const xVals = xa.makeCalcdata(trace, 'x'); + const yVals = ya.makeCalcdata(trace, 'y'); + + const len = Math.min(xVals.length, yVals.length); + trace._length = len; + const cd = new Array(len); + + var normMin = Infinity; + var normMax = -Infinity; + var cMin = Infinity; + var cMax = -Infinity; + const markerColor = trace.marker.color; + const hasMarkerColorArray = Lib.isArrayOrTypedArray(markerColor); + + const uArr = trace.u || []; + const vArr = trace.v || []; + + const anglemode = trace.anglemode; + const sizemode = trace.sizemode; + const anchor = trace.anchor; + const isTip = anchor === 'tip'; + const isCenter = anchor === 'center'; + + // Keep track of: + // - minimum and maximum x and y (for density calculation) + // - number of valid (x, y) pairs (for density calculation) + // - minimum and maximum u and v (for setting axis ranges) + var xMin = Infinity; + var xMax = -Infinity; + var yMin = Infinity; + var yMax = -Infinity; + var uMin = Infinity; + var uMax = -Infinity; + var vMin = Infinity; + var vMax = -Infinity; + var nValid = 0; + + // First pass: build calcdata, and keep track of the maximum and minimum vector norm in the trace, + // to be used for sizemode 'scaled' (max norm only) and for magnitude-based colorscale range + for(var i = 0; i < len; i++) { + var cdi = cd[i] = { i: i }; + var xValid = isNumeric(xVals[i]); + var yValid = isNumeric(yVals[i]); + + // Sanitize u/v: If either u or v is non-numeric (bad strings, Infinity, + // NaN, null, undefined) for a single point, set both to zero. + // Cast numeric strings to numbers. + // Store in calcdata so that the sanitized values can be reused. + // Use underscore-prefixed keys because 'v' is already used by box/violin + // (meaning "value") and setting it here has unintended side effects. + var ui, vi; + if(isNumeric(uArr[i]) && isNumeric(vArr[i])) { + ui = cdi._u = +uArr[i]; + vi = cdi._v = +vArr[i]; + } else { + ui = cdi._u = 0; + vi = cdi._v = 0; + } + + if(xValid && yValid) { + nValid++; + cdi.x = xVals[i]; + cdi.y = yVals[i]; + + if (xVals[i] < xMin) xMin = xVals[i]; + if (xVals[i] > xMax) xMax = xVals[i]; + if (yVals[i] < yMin) yMin = yVals[i]; + if (yVals[i] > yMax) yMax = yVals[i]; + if (ui < uMin) uMin = ui; + if (ui > uMax) uMax = ui; + if (vi < vMin) vMin = vi; + if (vi > vMax) vMax = vi; + + var norm = Math.sqrt(ui * ui + vi * vi); + if(norm > normMax) normMax = norm; + if(norm < normMin) normMin = norm; + + if(hasMarkerColorArray) { + var ci = markerColor[i]; + if(isNumeric(ci)) { + if(ci < cMin) cMin = ci; + if(ci > cMax) cMax = ci; + } + } + } else { + cdi.x = BADNUM; + cdi.y = BADNUM; + } + } + + // Store maxNorm for use by plot step + trace._maxNorm = normMax; + + if (sizemode === 'scaled' || anglemode === 'paper') { + // Ignore sizemode 'raw' if anglemode is set to 'paper': always scale + + // Compute point density of the entire trace: Area of bounding box + // divided by number of points. This is used to scale arrows in + // 'scaled' sizemode. + // TODO: How to handle the case where there is just one point in a trace, + // or all points have the same x or y value? This will give a boxArea of 0. + // For now I'm going to just normalize to a vector of unit length (1) in that case, + // but that's not a great solution + const boxArea = (xMax - xMin) * (yMax - yMin); + const pointDensity = boxArea / len; + // Now, compute the scale factor for scaled size mode + // The scale factor should be such that + // _maxNorm * _scaleFactor = Math.sqrt(_pointDensity) + // Therefore: _scaleFactor = Math.sqrt(_pointDensity) / _maxNorm + if (pointDensity === 0) { + trace._scaleFactor = 1 / trace._maxNorm + } else { + trace._scaleFactor = Math.sqrt(pointDensity) / trace._maxNorm; + } + // Note: If anglemode === 'paper', this scale factor must be + // multiplied by Math.sqrt(xa._m * ya._m), but we can't do that quite yet + // since the axis scales are not fully determined. Do it in plot step instead. + } else { // sizemode === 'raw' + // For raw sizemode, scale factor is always 1 + trace._scaleFactor = 1; + } + + // Multiply scale factor by sizeref + trace._scaleFactor *= trace.sizeref; + + // Now we need to compute the arrow geometry for axis autorange + const xTipPositions = new Array(len); + const yTipPositions = new Array(len); + const xTailPositions = new Array(len); + const yTailPositions = new Array(len); + var arrowLenX, arrowLenY; + // Compute the x- and y-positions of the tip of each arrow, + // assuming anglemode === 'data' (i.e. u/v are in data coordinates) + for(var i = 0; i < len; i++) { + var cdi = cd[i]; + arrowLenX = cdi._u * trace._scaleFactor; + arrowLenY = cdi._v * trace._scaleFactor; + if (isTip) { + xTipPositions[i] = cdi.x; + yTipPositions[i] = cdi.y; + xTailPositions[i] = cdi.x - arrowLenX; + yTailPositions[i] = cdi.y - arrowLenY; + } else if (isCenter) { + xTipPositions[i] = cdi.x + arrowLenX / 2; + yTipPositions[i] = cdi.y + arrowLenY / 2; + xTailPositions[i] = cdi.x - arrowLenX / 2; + yTailPositions[i] = cdi.y - arrowLenY / 2; + } else { // tail + xTipPositions[i] = cdi.x + arrowLenX; + yTipPositions[i] = cdi.y + arrowLenY; + xTailPositions[i] = cdi.x; + yTailPositions[i] = cdi.y; + } + } + + if (anglemode === 'data') { + // If anglemode is 'data', we can use the arrow tip positions directly to expand the axes ranges + trace._extremes[xa._id] = Axes.findExtremes(xa, xTipPositions.concat(xTailPositions), {padded: true}); + trace._extremes[ya._id] = Axes.findExtremes(ya, yTipPositions.concat(yTailPositions), {padded: true}); + } else { // anglemode === 'paper' + // TODO: For now, just do the same thing as for anglemode === 'data', but this is not correct. + // We actually need more sophisticated logic here, since this will give a bad result + // if the data aspect ratio is very different from the plot aspect ratio. + trace._extremes[xa._id] = Axes.findExtremes(xa, xTipPositions.concat(xTailPositions), {padded: true}); + trace._extremes[ya._id] = Axes.findExtremes(ya, yTipPositions.concat(yTailPositions), {padded: true}); + } + + xa._minDtick = 0; + ya._minDtick = 0; + + // Merge text arrays into calcdata for Drawing.textPointStyle + Lib.mergeArray(trace.text, cd, 'tx'); + Lib.mergeArray(trace.textposition, cd, 'tp'); + if(trace.textfont) { + Lib.mergeArrayCastPositive(trace.textfont.size, cd, 'ts'); + Lib.mergeArray(trace.textfont.color, cd, 'tc'); + Lib.mergeArray(trace.textfont.family, cd, 'tf'); + Lib.mergeArray(trace.textfont.weight, cd, 'tw'); + Lib.mergeArray(trace.textfont.style, cd, 'ty'); + Lib.mergeArray(trace.textfont.variant, cd, 'tv'); + } + + // Colorscale cmin/cmax computation: prefer provided marker.color, else magnitude + if(trace._hasColorscale) { + var vals = hasMarkerColorArray ? [cMin, cMax] : [normMin, normMax]; + // Guard against all-invalid input (no finite values found), which would + // otherwise leave the seeds at +/-Infinity and feed them into the + // colorscale calc. Fall back to a neutral [0, 1] range. + if(!isFinite(vals[0]) || !isFinite(vals[1])) vals = [0, 1]; + colorscaleCalc(gd, trace, { + vals: vals, + containerStr: 'marker', + cLetter: 'c' + }); + } + + calcSelection(cd, trace); + + return cd; +}; diff --git a/src/traces/quiver/cross_trace_calc.js b/src/traces/quiver/cross_trace_calc.js new file mode 100644 index 00000000000..404144556f3 --- /dev/null +++ b/src/traces/quiver/cross_trace_calc.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function crossTraceCalc(gd, plotinfo) { + // TODO: Does anything need to happen here? +}; diff --git a/src/traces/quiver/defaults.js b/src/traces/quiver/defaults.js new file mode 100644 index 00000000000..43ba6973803 --- /dev/null +++ b/src/traces/quiver/defaults.js @@ -0,0 +1,87 @@ +'use strict'; + +var Lib = require('../../lib'); +var attributes = require('./attributes'); +var handleXYDefaults = require('../scatter/xy_defaults'); +var hasColorscale = require('../../components/colorscale/helpers').hasColorscale; +var colorscaleDefaults = require('../../components/colorscale/defaults'); + +module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) { + function coerce(attr, dflt) { + return Lib.coerce(traceIn, traceOut, attributes, attr, dflt); + } + + var len = handleXYDefaults(traceIn, traceOut, layout, coerce); + if(!len) { + traceOut.visible = false; + return; + } + + var u = coerce('u'); + var v = coerce('v'); + + // If u/v are missing, default to zeros so the trace participates in calc/category logic + if(!Lib.isArrayOrTypedArray(u) || u.length === 0) { + traceOut.u = new Array(len); + for(var i = 0; i < len; i++) traceOut.u[i] = 0; + } + if(!Lib.isArrayOrTypedArray(v) || v.length === 0) { + traceOut.v = new Array(len); + for(var j = 0; j < len; j++) traceOut.v[j] = 0; + } + + coerce('anglemode'); + + // Sizing API inspired by cone, but not identical + coerce('sizemode'); + coerce('sizeref'); + coerce('anchor'); + + // Arrow styling + coerce('marker.arrowsize'); + + // Line styling under marker.line + coerce('marker.line.width'); + coerce('marker.line.dash'); + + // Text + coerce('text'); + coerce('textposition'); + Lib.coerceFont(coerce, 'textfont', layout.font); + + // Hover + coerce('hovertemplate'); + coerce('xhoverformat'); + coerce('yhoverformat'); + coerce('uhoverformat'); + coerce('vhoverformat'); + + // Colorscale defaults (adds colorscale, showscale, colorbar, etc.) + // Ensure traceOut.marker exists before colorscaleDefaults, which captures + // a reference to it via npMaybe at the start of its execution. + if(!traceOut.marker) traceOut.marker = {}; + coerce('marker.color', defaultColor); + var withColorscale = hasColorscale(traceIn, 'marker') || (traceIn.marker || {}).coloraxis; + traceOut._hasColorscale = !!withColorscale; + if(withColorscale) { + colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: 'marker.', cLetter: 'c' }); + } + + // Provide trace.line for compat with shared code (legend, getTraceColor) + var markerLine = traceOut.marker.line || {}; + var mc = traceOut.marker.color; + traceOut.line = { + width: markerLine.width, + color: Lib.isArrayOrTypedArray(mc) ? defaultColor : mc, + dash: markerLine.dash + }; + + // Selection styling + coerce('selected.marker.color'); + coerce('selected.marker.line.width'); + coerce('selected.textfont.color'); + coerce('unselected.marker.color'); + coerce('unselected.marker.line.width'); + coerce('unselected.textfont.color'); + +}; diff --git a/src/traces/quiver/event_data.js b/src/traces/quiver/event_data.js new file mode 100644 index 00000000000..bd8507a676c --- /dev/null +++ b/src/traces/quiver/event_data.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function eventData(out, pt, trace, cd, pointNumber) { + out.x = pt.x; + out.y = pt.y; + out.u = trace.u ? trace.u[pointNumber] : undefined; + out.v = trace.v ? trace.v[pointNumber] : undefined; + + return out; +}; diff --git a/src/traces/quiver/format_labels.js b/src/traces/quiver/format_labels.js new file mode 100644 index 00000000000..6ed314702ef --- /dev/null +++ b/src/traces/quiver/format_labels.js @@ -0,0 +1,30 @@ +'use strict'; + +var Axes = require('../../plots/cartesian/axes'); +var Lib = require('../../lib'); + +module.exports = function formatLabels(cdi, trace, fullLayout) { + var labels = {}; + + var mockGd = {_fullLayout: fullLayout}; + var xa = Axes.getFromTrace(mockGd, trace, 'x'); + var ya = Axes.getFromTrace(mockGd, trace, 'y'); + + var x = cdi.x; + var y = cdi.y; + + labels.xLabel = Axes.tickText(xa, xa.c2l(x), true).text; + labels.yLabel = Axes.tickText(ya, ya.c2l(y), true).text; + + var u = trace.u ? trace.u[cdi.i] : 0; + var v = trace.v ? trace.v[cdi.i] : 0; + + // Format u and v using hoverformat if provided + var uhoverformat = trace.uhoverformat; + var vhoverformat = trace.vhoverformat; + + labels.uLabel = uhoverformat ? Lib.numberFormat(uhoverformat)(u) : String(u); + labels.vLabel = vhoverformat ? Lib.numberFormat(vhoverformat)(v) : String(v); + + return labels; +}; diff --git a/src/traces/quiver/hover.js b/src/traces/quiver/hover.js new file mode 100644 index 00000000000..416cb8d27c9 --- /dev/null +++ b/src/traces/quiver/hover.js @@ -0,0 +1,87 @@ +'use strict'; + +var Lib = require('../../lib'); +var Fx = require('../../components/fx'); +var getTraceColor = require('../scatter/get_trace_color'); + +// Returns the shortest pixel distance from point (px,py) +// to segment (ax,ay)-(bx,by) +function distToSegment(px, py, ax, ay, bx, by) { + const dx = bx - ax; + const dy = by - ay; + const len2 = dx * dx + dy * dy; // Length of segment (ax,ay)-(bx,by), squared + if(!len2) { + // Zero-length segment, so fall back to point-to-point distance + return Math.sqrt((px - ax) * (px - ax) + (py - ay) * (py - ay)); + } + // Compute position of point on segment which is closest to (px,py) -> call it (cx, cy) + var t = ((px - ax) * dx + (py - ay) * dy) / len2; + t = Math.max(0, Math.min(1, t)); + const cx = ax + t * dx; + const cy = ay + t * dy; + // Compute distance from (px,py) to (cx,cy) + return Math.sqrt((px - cx) * (px - cx) + (py - cy) * (py - cy)); +} + +module.exports = function hoverPoints(pointData, xval, yval, hovermode) { + var cd = pointData.cd; + var trace = cd[0].trace; + var xa = pointData.xa; + var ya = pointData.ya; + var xpx = xa.c2p(xval); + var ypx = ya.c2p(yval); + + // Check distance from the whole arrow body (base -> tip) + // rather than only the (x,y) data position of the arrow + var distfn = function(di) { + if(di._px0 === undefined) return Infinity; + return distToSegment(xpx, ypx, di._px0, di._py0, di._px1, di._py1); + }; + + Fx.getClosest(cd, distfn, pointData); + + // skip if we didn't find a close point + if(pointData.index === false) return; + + // the closest data point + var di = cd[pointData.index]; + var xc = xa.c2p(di.x, true); + var yc = ya.c2p(di.y, true); + + // Compute distance from cursor to the base point (x,y) of the arrow + var distToPoint = Math.sqrt((xpx - xc) * (xpx - xc) + (ypx - yc) * (ypx - yc)); + + // now we're done using the whole `calcdata` array, replace the + // index with the original index + pointData.index = di.i; + + var u = trace.u ? trace.u[di.i] : 0; + var v = trace.v ? trace.v[di.i] : 0; + + // Build extraText to show u and v values + var extraText = 'u: ' + u + ', v: ' + v; + + Lib.extendFlat(pointData, { + color: getTraceColor(trace, di), + + x0: xc - 3, + x1: xc + 3, + xLabelVal: di.x, + + y0: yc - 3, + y1: yc + 3, + yLabelVal: di.y, + + uLabelVal: u, + vLabelVal: v, + + extraText: extraText, + + spikeDistance: distToPoint, + hovertemplate: trace.hovertemplate + }); + + Lib.fillText(di, trace, pointData); + + return [pointData]; +}; diff --git a/src/traces/quiver/index.js b/src/traces/quiver/index.js new file mode 100644 index 00000000000..b4183ebac0e --- /dev/null +++ b/src/traces/quiver/index.js @@ -0,0 +1,34 @@ +'use strict'; + +module.exports = { + moduleType: 'trace', + name: 'quiver', + basePlotModule: require('../../plots/cartesian'), + categories: [ + 'cartesian', 'svg', 'showLegend', 'scatter-like', 'zoomScale' + ], + + attributes: require('./attributes'), + supplyDefaults: require('./defaults'), + calc: require('./calc'), + crossTraceCalc: require('./cross_trace_calc'), + plot: require('./plot'), + style: require('./style').style, + styleOnSelect: require('./style').styleOnSelect, + hoverPoints: require('./hover'), + formatLabels: require('./format_labels'), + eventData: require('./event_data'), + selectPoints: require('../scatter/select'), + colorbar: require('../scatter/marker_colorbar'), + animatable: true, + + meta: { + description: [ + 'The quiver trace type visualizes vector fields using arrows.', + 'Specify a vector field using 4 1D arrays:', + '2 position arrays `x`, `y` and 2 vector component arrays `u`, `v`.', + 'The arrows are drawn exactly at the positions given by `x` and `y`.', + 'Arrow length and direction are determined by `u` and `v` components.' + ].join(' ') + } +}; diff --git a/src/traces/quiver/plot.js b/src/traces/quiver/plot.js new file mode 100644 index 00000000000..55ff64b43b6 --- /dev/null +++ b/src/traces/quiver/plot.js @@ -0,0 +1,235 @@ +'use strict'; + +var d3 = require('@plotly/d3'); + +var Lib = require('../../lib'); +var Drawing = require('../../components/drawing'); +var colorscaleStroke = require('./style').colorscaleStroke; + +// Fixed arrowhead wedge angle (radians). Arrow direction is fully +// determined by u,v (see angPx below); this constant only controls the +// relative angle of the point of the arrowhead +const HEAD_ANGLE = Math.PI / 12; + +// Length (px) of each arrowhead arm per unit of marker.line.width at +// arrowsize = 1. With the head's half-angle of PI/12, this yields an opening +// roughly 3x the line width, matching the `marker.arrowsize` spec +const HEAD_LEN_PER_WIDTH = 5.8; + +// Minimum line width value used when calculating arrowhead size, to ensure +// arrowhead is visible at narrow line widths. This minimum is ignored when +// `arrowsize` is set manually +const MIN_LINE_WIDTH_FOR_ARROWSIZE = 1.5; + +// Max arrowhead length as a fraction of the body length, so the head stays +// slightly shorter than the body for very short arrows +const MAX_HEAD_FRAC = 0.7; + +module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transitionOpts, makeOnCompleteCallback) { + var join, onComplete; + + // If transition config is provided, then it is only a partial replot and traces not + // updated are removed. + var isFullReplot = !transitionOpts; + var hasTransition = !!transitionOpts && transitionOpts.duration > 0; + + join = scatterLayer.selectAll('g.trace') + .data(cdscatter, function(d) { return d[0].trace.uid; }); + + // Append new traces: + join.enter().append('g') + .attr('class', function(d) { + return 'trace quiver trace' + d[0].trace.uid; + }) + .style('stroke-miterlimit', 2); + join.order(); + + if(hasTransition) { + if(makeOnCompleteCallback) { + onComplete = makeOnCompleteCallback(); + } + + var transition = d3.transition() + .duration(transitionOpts.duration) + .ease(transitionOpts.easing) + .each('end', function() { + onComplete && onComplete(); + }) + .each('interrupt', function() { + onComplete && onComplete(); + }); + + transition.each(function() { + scatterLayer.selectAll('g.trace').each(function(d, i) { + plotOne(gd, i, plotinfo, d, cdscatter, this, transitionOpts); + }); + }); + } else { + join.each(function(d, i) { + plotOne(gd, i, plotinfo, d, cdscatter, this, transitionOpts); + }); + } + + if(isFullReplot) { + join.exit().remove(); + } +}; + +function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transitionOpts) { + var trace = cdscatter[0].trace; + var xa = plotinfo.xaxis; + var ya = plotinfo.yaxis; + + cdscatter[0][plotinfo.isRangePlot ? 'nodeRangePlot3' : 'node3'] = d3.select(element); + + // Create line group for arrows + var lines = d3.select(element).selectAll('g.lines') + .data([cdscatter]); + + lines.enter().append('g') + .classed('lines', true); + + Drawing.setClipUrl(lines, plotinfo.layerClipId, gd); + + // Create one path per data point (arrow) + var lineSegments = lines.selectAll('path.js-line') + .data(cdscatter); + + lineSegments.enter().append('path') + .classed('js-line', true) + .style('vector-effect', 'non-scaling-stroke'); + + lineSegments.exit().remove(); + + // Use maxNorm precomputed in calc + const maxNorm = trace._maxNorm || 0; + const anglemode = trace.anglemode; + const sizemode = trace.sizemode; + const sizeref = trace.sizeref; + const anchor = trace.anchor; + + // Adjust scale factor if anglemode is 'paper' + const scaleFactor = (anglemode === 'paper') ? trace._scaleFactor * Math.sqrt(Math.abs(xa._m * ya._m)) : trace._scaleFactor; + const markerArrowsize = trace.marker.arrowsize; + + // Update line segments + lineSegments.each(function(cdi) { + const path = d3.select(this); + + // Skip invalid points + if(cdi.x === undefined || cdi.y === undefined) { + path.attr('d', null); + return; + } + + // Compute pixel location of vector tip, *relative to* vector base (before scaling). + // If anglemode is 'paper', then u/v are interpreted in pixel coordinates, so we can use them directly. + // If anglemode is 'data', then u/v are interpreted in data coordinates, so we need to convert them to pixel coordinates. + // TODO: This probably doesn't work for log axes, but let's ignore log axes for now + // since I'm not sure they make sense for quiver plots anyway + const pu = ((anglemode === 'paper') ? cdi._u * Math.sign(xa._m) : d3.round(xa._m * cdi._u)) * scaleFactor; + const pv = ((anglemode === 'paper') ? cdi._v * Math.sign(ya._m) : d3.round(ya._m * cdi._v)) * scaleFactor; + + // Compute arrow in data space + // Check whether arrowsize was set explicitly in the input trace + const hasExplicitArrowsize = (trace._input.marker || {}).arrowsize !== undefined; + + var px0, px1, py0, py1; + if(anchor === 'tip') { + px0 = xa.c2p(cdi.x) - pu; + py0 = ya.c2p(cdi.y) - pv; + px1 = xa.c2p(cdi.x); + py1 = ya.c2p(cdi.y); + } else if(anchor === 'center') { + px0 = xa.c2p(cdi.x) - pu / 2; + py0 = ya.c2p(cdi.y) - pv / 2; + px1 = xa.c2p(cdi.x) + pu / 2; + py1 = ya.c2p(cdi.y) + pv / 2; + } else { // tail + px0 = xa.c2p(cdi.x); + py0 = ya.c2p(cdi.y); + px1 = xa.c2p(cdi.x) + pu; + py1 = ya.c2p(cdi.y) + pv; + } + + // Store the arrow body endpoints in calcData so that + // hovertext can be shown based on distance to the whole arrow segment, + // not just the base point (x,y) + cdi._px0 = px0; + cdi._py0 = py0; + cdi._px1 = px1; + cdi._py1 = py1; + + // Arrowhead is sized in pixels (relative to the line width) + // so it remains the same regardless of zoom, rather than scaling with the data space + // Set max head size so the head stays slightly shorter than the arrow body + // (e.g. for very short arrows when zoomed out). No head for zero-length arrows. + var lineWidthForArrowsize = trace.marker.line.width; + // If arrowsize is not set explicitly, increase line width for arrowsize calculations + // to a minimum value, in order to avoid very small arrowheads + if(!hasExplicitArrowsize) lineWidthForArrowsize = Math.max(lineWidthForArrowsize, MIN_LINE_WIDTH_FOR_ARROWSIZE); + + const bodyLenPx = Math.sqrt((px1 - px0) * (px1 - px0) + (py1 - py0) * (py1 - py0)); + const maxHeadPx = MAX_HEAD_FRAC * bodyLenPx; + const headLenPx = Math.min(HEAD_LEN_PER_WIDTH * markerArrowsize * lineWidthForArrowsize, maxHeadPx); + const angPx = Math.atan2(py1 - py0, px1 - px0); + + const ph1x = px1 - headLenPx * Math.cos(angPx - HEAD_ANGLE); + const ph1y = py1 - headLenPx * Math.sin(angPx - HEAD_ANGLE); + const ph2x = px1 - headLenPx * Math.cos(angPx + HEAD_ANGLE); + const ph2y = py1 - headLenPx * Math.sin(angPx + HEAD_ANGLE); + + const pathData = 'M' + px0 + ',' + py0 + 'L' + px1 + ',' + py1 + 'L' + ph1x + ',' + ph1y + 'L' + px1 + ',' + py1 + 'L' + ph2x + ',' + ph2y; + path.attr('d', pathData); + }); + + // Apply styling using Plotly's standard styling system + var marker = trace.marker || {}; + var markerLine = marker.line || {}; + var lineColor = Lib.isArrayOrTypedArray(marker.color) ? undefined : marker.color; + Drawing.lineGroupStyle(lineSegments, markerLine.width, lineColor, markerLine.dash); + + // If colorscale present, color arrows by marker.color or magnitude |(u,v)|. + // Shared with style.js so the static render and restyle stay in sync. + if(trace._hasColorscale) colorscaleStroke(lineSegments, trace); + + // Render text labels at data points + var textGroup = d3.select(element).selectAll('g.text') + .data([cdscatter]); + + textGroup.enter().append('g').classed('text', true); + + Drawing.setClipUrl(textGroup, plotinfo.layerClipId, gd); + + var textJoin = textGroup.selectAll('g.textpoint') + .data(cdscatter); + + textJoin.enter().append('g').classed('textpoint', true).append('text'); + textJoin.exit().remove(); + + textJoin.each(function(d) { + var g = d3.select(this); + var hasNode = Drawing.translatePoint(d, g.select('text'), xa, ya); + if(!hasNode) g.remove(); + }); + + textJoin.selectAll('text') + .call(Drawing.textPointStyle, trace, gd) + .each(function(d) { + var x = xa.c2p(d.x); + var y = ya.c2p(d.y); + d3.select(this).selectAll('tspan.line').each(function() { + d3.select(this).attr({x: x, y: y}); + }); + }); + + // Handle transitions + if(transitionOpts && transitionOpts.duration > 0) { + var transition = d3.transition() + .duration(transitionOpts.duration) + .ease(transitionOpts.easing); + + lineSegments.transition(transition) + .style('opacity', 1); + } +} diff --git a/src/traces/quiver/style.js b/src/traces/quiver/style.js new file mode 100644 index 00000000000..05e9843f097 --- /dev/null +++ b/src/traces/quiver/style.js @@ -0,0 +1,95 @@ +'use strict'; + +var d3 = require('@plotly/d3'); +var Lib = require('../../lib'); + +var Drawing = require('../../components/drawing'); +var Colorscale = require('../../components/colorscale'); +var DESELECTDIM = require('../../constants/interactions').DESELECTDIM; + +// Stroke each arrow path according to the trace colorscale, using marker.color +// when it is an array of scalar values, otherwise falling back to the vector +// magnitude |(u, v)|. `paths` may be a multi-path selection or a single path. +function colorscaleStroke(paths, trace) { + var marker = trace.marker || {}; + var colorFunc = Colorscale.makeColorScaleFuncFromTrace(marker); + + paths.style('stroke', function(cdi) { + var markerColor = marker.color; + var value; + if(Lib.isArrayOrTypedArray(markerColor) && markerColor.length > cdi.i && isFinite(markerColor[cdi.i])) { + value = markerColor[cdi.i]; + } else { + var uVal = (trace.u && trace.u[cdi.i]) || 0; + var vVal = (trace.v && trace.v[cdi.i]) || 0; + value = Math.sqrt(uVal * uVal + vVal * vVal); + } + return colorFunc(value); + }); +} + +function style(gd) { + var s = d3.select(gd).selectAll('g.trace.quiver'); + s.each(function(d) { + styleArrows(gd, d, d3.select(this)); + }); +} + +function styleOnSelect(gd, cd, sel) { + styleArrows(gd, cd, sel); +} + +function styleArrows(gd, cd, sel) { + var trace = cd[0].trace; + var marker = trace.marker || {}; + var markerLine = marker.line || {}; + var lineColor = Lib.isArrayOrTypedArray(marker.color) ? undefined : marker.color; + var hasColorscale = trace._hasColorscale; + + if(!sel) return; + + if(trace.selectedpoints) { + var selectedMarker = (trace.selected || {}).marker || {}; + var unselectedMarker = (trace.unselected || {}).marker || {}; + var selectedMarkerLine = selectedMarker.line || {}; + var unselectedMarkerLine = unselectedMarker.line || {}; + + sel.selectAll('path.js-line').each(function(d) { + var path = d3.select(this); + var dim = !d.selected; + + var explicitColor = dim ? unselectedMarker.color : selectedMarker.color; + var lineWidth = dim ? + (unselectedMarkerLine.width !== undefined ? unselectedMarkerLine.width : markerLine.width) : + (selectedMarkerLine.width !== undefined ? selectedMarkerLine.width : markerLine.width); + + if(explicitColor) { + Drawing.lineGroupStyle(path, lineWidth, explicitColor, markerLine.dash); + path.style('stroke-opacity', 1); + } else { + // Fall back to the arrow's own color (scalar marker.color, a + // marker.color array, or the colorscale). When marker.color is an + // array, lineColor is undefined and we cannot bake opacity into a + // color, so we keep each arrow's color and dim unselected arrows + // via stroke-opacity instead. + Drawing.lineGroupStyle(path, lineWidth, lineColor, markerLine.dash); + if(hasColorscale) colorscaleStroke(path, trace); + path.style('stroke-opacity', dim ? DESELECTDIM : 1); + } + }); + + Drawing.selectedTextStyle(sel.selectAll('text'), trace); + } else { + var paths = sel.selectAll('path.js-line'); + paths.call(Drawing.lineGroupStyle, markerLine.width, lineColor, markerLine.dash); + if(hasColorscale) colorscaleStroke(paths, trace); + paths.style('stroke-opacity', 1); + Drawing.textPointStyle(sel.selectAll('text'), trace, gd); + } +} + +module.exports = { + style: style, + styleOnSelect: styleOnSelect, + colorscaleStroke: colorscaleStroke +}; diff --git a/src/traces/scatter/select.js b/src/traces/scatter/select.js index 01f757a779e..c4c4c3479cc 100644 --- a/src/traces/scatter/select.js +++ b/src/traces/scatter/select.js @@ -13,7 +13,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { var x; var y; - var hasOnlyLines = (!subtypes.hasMarkers(trace) && !subtypes.hasText(trace)); + var hasOnlyLines = trace.mode && !subtypes.hasMarkers(trace) && !subtypes.hasText(trace); if(hasOnlyLines) return []; if(selectionTester === false) { // clear selection diff --git a/src/types/generated/schema.d.ts b/src/types/generated/schema.d.ts index 92fdc3e79d7..604bce4b194 100644 --- a/src/types/generated/schema.d.ts +++ b/src/types/generated/schema.d.ts @@ -23,7 +23,7 @@ export type PatternShape = '' | '/' | '\\' | 'x' | '-' | '|' | '+' | '.'; export type TransitionEasing = 'linear' | 'quad' | 'cubic' | 'sin' | 'exp' | 'circle' | 'elastic' | 'back' | 'bounce' | 'linear-in' | 'quad-in' | 'cubic-in' | 'sin-in' | 'exp-in' | 'circle-in' | 'elastic-in' | 'back-in' | 'bounce-in' | 'linear-out' | 'quad-out' | 'cubic-out' | 'sin-out' | 'exp-out' | 'circle-out' | 'elastic-out' | 'back-out' | 'bounce-out' | 'linear-in-out' | 'quad-in-out' | 'cubic-in-out' | 'sin-in-out' | 'exp-in-out' | 'circle-in-out' | 'elastic-in-out' | 'back-in-out' | 'bounce-in-out'; -export type TraceType = 'bar' | 'barpolar' | 'box' | 'candlestick' | 'carpet' | 'choropleth' | 'choroplethmap' | 'cone' | 'contour' | 'contourcarpet' | 'densitymap' | 'funnel' | 'funnelarea' | 'heatmap' | 'histogram' | 'histogram2d' | 'histogram2dcontour' | 'icicle' | 'image' | 'indicator' | 'isosurface' | 'mesh3d' | 'ohlc' | 'parcats' | 'parcoords' | 'pie' | 'sankey' | 'scatter' | 'scatter3d' | 'scattercarpet' | 'scattergeo' | 'scattergl' | 'scattermap' | 'scatterpolar' | 'scatterpolargl' | 'scattersmith' | 'scatterternary' | 'splom' | 'streamtube' | 'sunburst' | 'surface' | 'table' | 'treemap' | 'violin' | 'volume' | 'waterfall'; +export type TraceType = 'bar' | 'barpolar' | 'box' | 'candlestick' | 'carpet' | 'choropleth' | 'choroplethmap' | 'cone' | 'contour' | 'contourcarpet' | 'densitymap' | 'funnel' | 'funnelarea' | 'heatmap' | 'histogram' | 'histogram2d' | 'histogram2dcontour' | 'icicle' | 'image' | 'indicator' | 'isosurface' | 'mesh3d' | 'ohlc' | 'parcats' | 'parcoords' | 'pie' | 'quiver' | 'sankey' | 'scatter' | 'scatter3d' | 'scattercarpet' | 'scattergeo' | 'scattergl' | 'scattermap' | 'scatterpolar' | 'scatterpolargl' | 'scattersmith' | 'scatterternary' | 'splom' | 'streamtube' | 'sunburst' | 'surface' | 'table' | 'treemap' | 'violin' | 'volume' | 'waterfall'; /** @deprecated Renamed to TraceType. */ export type PlotType = TraceType; @@ -1627,14 +1627,7 @@ export interface CandlestickData { * Minimum: 0 */ legendwidth?: number; - line?: { - /** - * Sets the width (in px) of line bounding the box(es). Note that this style setting can also be set per direction via `increasing.line.width` and `decreasing.line.width`. - * @default 2 - * Minimum: 0 - */ - width?: number; - }; + line?: _internal.ErrorY; /** Sets the low values. */ low?: Datum[] | Datum[][] | TypedArray; /** Assigns extra meta information associated with this trace that can be used in various text attributes. Attributes such as trace `name`, graph, axis and colorbar `title.text`, annotation `text` `rangeselector`, `updatemenues` and `sliders` `label` text all support `meta`. To access the trace `meta` values in an attribute in the same trace, simply use `%{meta[i]}` where `i` is the index or key of the `meta` item in question. To access trace `meta` in layout attributes, use `%{data[n[.meta[i]}` where `i` is the index or key of the `meta` and `n` is the trace index. */ @@ -6685,6 +6678,221 @@ export interface PieData { visible?: true | false | 'legendonly'; } +export interface QuiverData { + /** + * Sets the arrows' anchor with respect to their (x,y) positions. Use *tail* to place (x,y) at the base, *tip* to place (x,y) at the head, or *center* to center the arrow on (x,y). + * @default 'tail' + */ + anchor?: 'tip' | 'tail' | 'center'; + /** + * Sets the mode used to determine the angle of the arrow vectors. If *paper*, u/v are interpreted in pixel coordinates and the rendered vector angle does not change regardless of the axes scales. If *data*, u/v are interpreted in data coordinates and the rendered vector angle may change, e.g. if zooming in along a single axis + * @default 'axis' + */ + anglemode?: 'paper' | 'data'; + /** Assigns extra data each datum. This may be useful when listening to hover, click and selection events. Note that, *scatter* traces also appends customdata items in the markers DOM elements */ + customdata?: Datum[] | Datum[][] | TypedArray; + /** + * Sets the x coordinate step. See `x0` for more info. + * @default 1 + */ + dx?: number; + /** + * Sets the y coordinate step. See `y0` for more info. + * @default 1 + */ + dy?: number; + /** + * Determines what trace information appears on hover. If `none` or `skip` are set, no information is displayed upon hovering. But, if `none` is set, click and hover events are still fired. + * @default 'all' + */ + hoverinfo?: 'x' | 'y' | 'u' | 'v' | 'text' | 'name' | 'all' | 'none' | 'skip' | (string & {}) | ('x' | 'y' | 'u' | 'v' | 'text' | 'name' | 'all' | 'none' | 'skip' | (string & {}))[]; + hoverlabel?: HoverLabel; + /** Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example "y: %{y}" as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, *xother* will be added to those with different x positions from the first point. An underscore before or after *(x|y)other* will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. Variables that can't be found will be replaced with the specifier. For example, a template of "data: %{x}, %{y}" will result in a value of "data: 1, %{y}" if x is 1 and y is missing. Variables with an undefined value will be replaced with the fallback value. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, all attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. Finally, the template string has access to variables `x`, `y`, `u`, `v`, `text` and `name`. Anything contained in tag `` is displayed in the secondary box, for example `%{fullData.name}`. To hide the secondary box completely, use an empty tag ``. */ + hovertemplate?: string | string[]; + /** Assigns id labels to each datum. These ids for object constancy of data points during animation. Should be an array of strings, not numbers or any other type. */ + ids?: Datum[] | Datum[][] | TypedArray; + /** + * Sets the reference to a legend to show this trace in. References to these legends are *legend*, *legend2*, *legend3*, etc. Settings for these legends are set in the layout, under `layout.legend`, `layout.legend2`, etc. + * @default 'legend' + */ + legend?: string; + /** Sets the legend group for this trace. Traces and shapes part of the same legend group hide/show at the same time when toggling legend items. */ + legendgroup?: string; + legendgrouptitle?: LegendGroupTitle; + /** + * Sets the legend rank for this trace. Items and groups with smaller ranks are presented on top/left side while with *reversed* `legend.traceorder` they are on bottom/right side. The default legendrank is 1000, so that you can use ranks less than 1000 to place certain items before all unranked items, and ranks greater than 1000 to go after all unranked items. When having unranked or equal rank items shapes would be displayed after traces i.e. according to their order in data and layout. + * @default 1000 + */ + legendrank?: number; + /** + * Sets the width (in px or fraction) of the legend for this trace. + * Minimum: 0 + */ + legendwidth?: number; + marker?: { + /** + * Sets the size of the arrow head relative to `marker.line.width`. A value of 1 (default) gives a head about 3x as wide as the line. + * @default 1 + * Minimum: 0.3 + */ + arrowsize?: number; + /** + * Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. Has an effect only if in `marker.color` is set to a numerical array. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed. + * @default true + */ + autocolorscale?: boolean; + /** + * Determines whether or not the color domain is computed with respect to the input data (here in `marker.color`) or the bounds set in `marker.cmin` and `marker.cmax` Has an effect only if in `marker.color` is set to a numerical array. Defaults to `false` when `marker.cmin` and `marker.cmax` are set by the user. + * @default true + */ + cauto?: boolean; + /** + * Sets the upper bound of the color domain. Has an effect only if in `marker.color` is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmin` must be set as well. + * Setting this also sets: cauto = false + */ + cmax?: number; + /** Sets the mid-point of the color domain by scaling `marker.cmin` and/or `marker.cmax` to be equidistant to this point. Has an effect only if in `marker.color` is set to a numerical array. Value should have the same units as in `marker.color`. Has no effect when `marker.cauto` is `false`. */ + cmid?: number; + /** + * Sets the lower bound of the color domain. Has an effect only if in `marker.color` is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmax` must be set as well. + * Setting this also sets: cauto = false + */ + cmin?: number; + /** Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `marker.cmin` and `marker.cmax` if set. */ + color?: Color | Color[]; + /** Sets a reference to a shared color axis. References to these shared color axes are *coloraxis*, *coloraxis2*, *coloraxis3*, etc. Settings for these shared color axes are set in the layout, under `layout.coloraxis`, `layout.coloraxis2`, etc. Note that multiple color scales can be linked to the same color axis. */ + coloraxis?: string; + colorbar?: ColorBar; + /** + * Sets the colorscale. Has an effect only if in `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsla, hwb, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Blackbody,Bluered,Blues,Cividis,Earth,Electric,Greens,Greys,Hot,Jet,Picnic,Portland,Rainbow,RdBu,Reds,Viridis,YlGnBu,YlOrRd. + * Setting this also sets: autocolorscale = false + */ + colorscale?: ColorScale; + line?: { + /** + * Sets the dash style of lines. Set to a dash type string (*solid*, *dot*, *dash*, *longdash*, *dashdot*, or *longdashdot*) or a dash length list in px (eg *5px,10px,2px,2px*). + * @default 'solid' + */ + dash?: Dash; + /** + * Sets the width (in px) of the arrow lines. + * @default 2 + * Minimum: 0 + */ + width?: number; + }; + /** + * Reverses the color mapping if true. Has an effect only if in `marker.color` is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color. + * @default false + */ + reversescale?: boolean; + /** + * Determines whether or not a colorbar is displayed for this trace. Has an effect only if in `marker.color` is set to a numerical array. + * @default true + */ + showscale?: boolean; + }; + /** Assigns extra meta information associated with this trace that can be used in various text attributes. Attributes such as trace `name`, graph, axis and colorbar `title.text`, annotation `text` `rangeselector`, `updatemenues` and `sliders` `label` text all support `meta`. To access the trace `meta` values in an attribute in the same trace, simply use `%{meta[i]}` where `i` is the index or key of the `meta` item in question. To access trace `meta` in layout attributes, use `%{data[n[.meta[i]}` where `i` is the index or key of the `meta` and `n` is the trace index. */ + meta?: any; + /** Sets the trace name. The trace name appears as the legend item and on hover. */ + name?: string; + /** + * Sets the opacity of the trace. + * @default 1 + * Range: [0, 1] + */ + opacity?: number; + selected?: { + marker?: { + /** Sets the marker color of selected points. */ + color?: Color; + line?: _internal.ErrorY; + }; + textfont?: Font; + }; + /** Array containing integer indices of selected points. Has an effect only for traces that support selections. Note that an empty array means an empty selection where the `unselected` are turned on for all points, whereas, any other non-array values means no selection all where the `selected` and `unselected` styles have no effect. */ + selectedpoints?: any; + /** + * Determines whether or not an item corresponding to this trace is shown in the legend. + * @default true + */ + showlegend?: boolean; + /** + * Determines whether arrows are drawn according to their raw lengths, or scaled based on the maximum vector length and point density. Note: When `anglemode` is *data* arrows are alwyas scaled and `sizemode` *raw* is ignored. + * @default 'scaled' + */ + sizemode?: 'scaled' | 'raw'; + /** + * Adjusts the arrow size scaling. The arrow length is determined by the vector norm multiplied by `sizeref`, optionally normalized when `sizemode` is *scaled* (`sizeref` is applied after scaling). + * @default 1 + * Minimum: 0 + */ + sizeref?: number; + /** Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace `hoverinfo` contains a *text* flag and *hovertext* is not set, these elements will be seen in the hover labels. */ + text?: string | string[]; + /** Sets the text font. */ + textfont?: FontArray; + /** + * Sets the positions of the `text` elements with respects to the (x,y) coordinates. + * @default 'middle center' + */ + textposition?: 'top left' | 'top center' | 'top right' | 'middle left' | 'middle center' | 'middle right' | 'bottom left' | 'bottom center' | 'bottom right' | ('top left' | 'top center' | 'top right' | 'middle left' | 'middle center' | 'middle right' | 'bottom left' | 'bottom center' | 'bottom right')[]; + type?: 'quiver'; + /** Sets the x components of the arrow vectors. */ + u?: Datum[] | Datum[][] | TypedArray; + /** Sets the hover text formatting rule for `u` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format.By default the values are formatted using generic number format. */ + uhoverformat?: string; + /** Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions. */ + uid?: string; + /** Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves. */ + uirevision?: any; + unselected?: { + marker?: { + /** Sets the marker color of unselected points, applied only when a selection exists. */ + color?: Color; + line?: _internal.ErrorY; + }; + textfont?: Font; + }; + /** Sets the y components of the arrow vectors. */ + v?: Datum[] | Datum[][] | TypedArray; + /** Sets the hover text formatting rule for `v` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format.By default the values are formatted using generic number format. */ + vhoverformat?: string; + /** + * Determines whether or not this trace is visible. If *legendonly*, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible). + * @default true + */ + visible?: true | false | 'legendonly'; + /** Sets the x coordinates of the arrow locations. */ + x?: Datum[] | Datum[][] | TypedArray; + /** + * Alternate to `x`. Builds a linear space of x coordinates. Use with `dx` where `x0` is the starting coordinate and `dx` the step. + * @default 0 + */ + x0?: any; + /** + * Sets a reference between this trace's x coordinates and a 2D cartesian x axis. If *x* (the default value), the x coordinates refer to `layout.xaxis`. If *x2*, the x coordinates refer to `layout.xaxis2`, and so on. + * @default 'x' + */ + xaxis?: string; + /** Sets the hover text formatting rule for `x` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: *%h* for half of the year as a decimal number as well as *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*By default the values are formatted using `xaxis.hoverformat`. */ + xhoverformat?: string; + /** Sets the y coordinates of the arrow locations. */ + y?: Datum[] | Datum[][] | TypedArray; + /** + * Alternate to `y`. Builds a linear space of y coordinates. Use with `dy` where `y0` is the starting coordinate and `dy` the step. + * @default 0 + */ + y0?: any; + /** + * Sets a reference between this trace's y coordinates and a 2D cartesian y axis. If *y* (the default value), the y coordinates refer to `layout.yaxis`. If *y2*, the y coordinates refer to `layout.yaxis2`, and so on. + * @default 'y' + */ + yaxis?: string; + /** Sets the hover text formatting rule for `y` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: *%h* for half of the year as a decimal number as well as *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*By default the values are formatted using `yaxis.hoverformat`. */ + yhoverformat?: string; +} + export interface SankeyData { /** * If value is `snap` (the default), the node arrangement is assisted by automatic snapping of elements to preserve space between nodes specified via `nodepad`. If value is `perpendicular`, the nodes can only move along a line perpendicular to the flow. If value is `freeform`, the nodes can freely move on the plane. If value is `fixed`, the nodes are stationary. @@ -11592,6 +11800,7 @@ export type Data = | Partial | Partial | Partial + | Partial | Partial | Partial | Partial diff --git a/test/image/baselines/quiver_anchor.png b/test/image/baselines/quiver_anchor.png new file mode 100644 index 00000000000..1f420e7aae9 Binary files /dev/null and b/test/image/baselines/quiver_anchor.png differ diff --git a/test/image/baselines/quiver_arrow-styling.png b/test/image/baselines/quiver_arrow-styling.png new file mode 100644 index 00000000000..593963ab00d Binary files /dev/null and b/test/image/baselines/quiver_arrow-styling.png differ diff --git a/test/image/baselines/quiver_categorical.png b/test/image/baselines/quiver_categorical.png new file mode 100644 index 00000000000..64f147b649a Binary files /dev/null and b/test/image/baselines/quiver_categorical.png differ diff --git a/test/image/baselines/quiver_colorscale.png b/test/image/baselines/quiver_colorscale.png new file mode 100644 index 00000000000..2f5eb078070 Binary files /dev/null and b/test/image/baselines/quiver_colorscale.png differ diff --git a/test/image/baselines/quiver_custom-colorscale.png b/test/image/baselines/quiver_custom-colorscale.png new file mode 100644 index 00000000000..30e7c9ff261 Binary files /dev/null and b/test/image/baselines/quiver_custom-colorscale.png differ diff --git a/test/image/baselines/quiver_multi-trace.png b/test/image/baselines/quiver_multi-trace.png new file mode 100644 index 00000000000..72f3e96334e Binary files /dev/null and b/test/image/baselines/quiver_multi-trace.png differ diff --git a/test/image/baselines/quiver_sizemode.png b/test/image/baselines/quiver_sizemode.png new file mode 100644 index 00000000000..35a1160b3cd Binary files /dev/null and b/test/image/baselines/quiver_sizemode.png differ diff --git a/test/image/baselines/quiver_wind.png b/test/image/baselines/quiver_wind.png new file mode 100644 index 00000000000..5897a8e32ab Binary files /dev/null and b/test/image/baselines/quiver_wind.png differ diff --git a/test/image/mocks/quiver_anchor.json b/test/image/mocks/quiver_anchor.json new file mode 100644 index 00000000000..ff1eb3bd12b --- /dev/null +++ b/test/image/mocks/quiver_anchor.json @@ -0,0 +1,81 @@ +{ + "data": [ + { + "type": "quiver", + "name": "tail anchor", + "x": [0, 1, 2, 0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1, 2, 2, 2], + "u": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "v": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "sizemode": "scaled", + "anchor": "tail", + "marker": { + "color": "#4466ee", + "line": {"width": 2} + }, + "xaxis": "x", + "yaxis": "y" + }, + { + "type": "quiver", + "name": "tip anchor", + "x": [0, 1, 2, 0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1, 2, 2, 2], + "u": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "v": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "sizemode": "scaled", + "anchor": "tip", + "marker": { + "color": "#ee3344", + "line": {"width": 2} + }, + "xaxis": "x2", + "yaxis": "y2" + }, + { + "type": "quiver", + "name": "center anchor", + "x": [0, 1, 2, 0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1, 2, 2, 2], + "u": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "v": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "sizemode": "scaled", + "anchor": "center", + "marker": { + "color": "#8811cc", + "line": {"width": 2} + }, + "xaxis": "x3", + "yaxis": "y3" + } + ], + "layout": { + "width": 700, + "height": 400, + "showlegend": false, + "title": {"text": "Quiver anchors"}, + "xaxis": { + "domain": [0, 0.3], + "title": {"text": "tail anchor"} + }, + "yaxis": { + "domain": [0, 1] + }, + "xaxis2": { + "domain": [0.35, 0.65], + "title": {"text": "tip anchor"} + }, + "yaxis2": { + "domain": [0, 1], + "anchor": "x2" + }, + "xaxis3": { + "domain": [0.7, 1], + "title": {"text": "center anchor"} + }, + "yaxis3": { + "domain": [0, 1], + "anchor": "x3" + } + } +} diff --git a/test/image/mocks/quiver_arrow-styling.json b/test/image/mocks/quiver_arrow-styling.json new file mode 100644 index 00000000000..1c32bcb3f50 --- /dev/null +++ b/test/image/mocks/quiver_arrow-styling.json @@ -0,0 +1,138 @@ +{ + "data": [ + { + "type": "quiver", + "x": [1], + "y": [1], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#fe218b", + "arrowsize": 1, + "line": {"width": 1} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + }, + { + "type": "quiver", + "x": [2], + "y": [1], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#fe218b", + "arrowsize": 2, + "line": {"width": 1} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + }, + { + "type": "quiver", + "x": [3], + "y": [1], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#fe218b", + "arrowsize": 3, + "line": {"width": 1} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + }, + { + "type": "quiver", + "x": [1], + "y": [2], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#e0af00", + "arrowsize": 1, + "line": {"width": 2} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + }, + { + "type": "quiver", + "x": [2], + "y": [2], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#e0af00", + "arrowsize": 2, + "line": {"width": 2} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + }, + { + "type": "quiver", + "x": [3], + "y": [2], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#e0af00", + "arrowsize": 3, + "line": {"width": 2} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + }, + { + "type": "quiver", + "x": [1], + "y": [3], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#21b0fe", + "arrowsize": 1, + "line": {"width": 3} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + }, + { + "type": "quiver", + "x": [2], + "y": [3], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#21b0fe", + "arrowsize": 2, + "line": {"width": 3} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + }, + { + "type": "quiver", + "x": [3], + "y": [3], + "u": [1], + "v": [1], + "anchor": "tail", + "marker": { + "color": "#21b0fe", + "arrowsize": 3, + "line": {"width": 3} + }, + "hovertemplate": "line.width=%{y}
arrowsize=%{x}" + } + ], + "layout": { + "width": 600, + "height": 600, + "showlegend": false, + "xaxis": {"title": {"text": "arrowsize"}}, + "yaxis": {"title": {"text": "line.width"}}, + "title": {"text": "Quiver arrow styling
(marker.line.width and marker.arrowsize)"} + } +} diff --git a/test/image/mocks/quiver_categorical.json b/test/image/mocks/quiver_categorical.json new file mode 100644 index 00000000000..f5b9b629c7a --- /dev/null +++ b/test/image/mocks/quiver_categorical.json @@ -0,0 +1,24 @@ +{ + "data": [ + { + "type": "quiver", + "x": ["A", "B", "C", "A", "B", "C", "A", "B", "C"], + "y": ["X", "X", "X", "Y", "Y", "Y", "Z", "Z", "Z"], + "u": [1, 0, -1, 1, 0, -1, 1, 0, -1], + "v": [1, 1, 1, 0, 0, 0, -1, -1, -1], + "text": ["A", "B", "C", "D", "E", "F", "G", "H", "I"], + "textposition": "top center", + "textfont": { "size": 12 }, + "sizemode": "scaled", + "anchor": "tail", + "marker": { + "line": {"width": 2} + } + } + ], + "layout": { + "title": {"text": "Quiver with Categorical Axes"}, + "width": 500, + "height": 500 + } +} diff --git a/test/image/mocks/quiver_colorscale.json b/test/image/mocks/quiver_colorscale.json new file mode 100644 index 00000000000..bfa3e432279 --- /dev/null +++ b/test/image/mocks/quiver_colorscale.json @@ -0,0 +1,29 @@ +{ + "data": [ + { + "type": "quiver", + "x": [0, 1, 2, 0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1, 2, 2, 2], + "u": [1, 2, 3, 1, 2, 3, 1, 2, 3], + "v": [1, 1, 1, 2, 2, 2, 3, 3, 3], + "sizemode": "scaled", + "anchor": "tail", + "anglemode": "paper", + "marker": { + "showscale": true, + "colorbar": { + "title": {"text": "Magnitude"} + }, + "line": {"width": 2} + } + } + ], + "layout": { + "width": 600, + "height": 500, + "title": { + "text": "Quiver with Colorscale", + "subtitle": {"text": "When using a colorscale, vector magnitude is used for color,
unless marker.color is an array of values"} + } + } +} diff --git a/test/image/mocks/quiver_custom-colorscale.json b/test/image/mocks/quiver_custom-colorscale.json new file mode 100644 index 00000000000..30f407331da --- /dev/null +++ b/test/image/mocks/quiver_custom-colorscale.json @@ -0,0 +1,32 @@ +{ + "data": [ + { + "type": "quiver", + "x": [0, 1, 2, 0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1, 2, 2, 2], + "u": [0.5, 1.5, 2.5, 0.5, 1.5, 2.5, 0.5, 1.5, 2.5], + "v": [0.5, 0.5, 0.5, 1.5, 1.5, 1.5, 2.5, 2.5, 2.5], + "marker": { + "color": [9, 7, 5, 8, 3, 6, 1, 4, 2], + "colorscale": [ + [0, "rgb(0,0,255)"], + [0.5, "rgb(0,255,0)"], + [1, "rgb(255,0,0)"] + ], + "showscale": true, + "colorbar": { + "title": {"text": "Custom Field"}, + "x": 1.02 + }, + "line": {"width": 2} + }, + "sizemode": "scaled", + "anchor": "tail" + } + ], + "layout": { + "title": {"text": "Quiver with Custom Scalar Field"}, + "width": 600, + "height": 500 + } +} diff --git a/test/image/mocks/quiver_multi-trace.json b/test/image/mocks/quiver_multi-trace.json new file mode 100644 index 00000000000..08fb36bf386 --- /dev/null +++ b/test/image/mocks/quiver_multi-trace.json @@ -0,0 +1,38 @@ +{ + "data": [ + { + "type": "quiver", + "name": "Field A", + "x": [0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1], + "u": [1, 1.5, 2, 1, 1.5, 2], + "v": [0.5, 1, 0.5, 1, 1.5, 1], + "sizemode": "scaled", + "anchor": "tail", + "marker": { + "color": "red", + "line": {"width": 2} + } + }, + { + "type": "quiver", + "name": "Field B", + "x": [3, 4, 5, 3, 4, 5], + "y": [0, 0, 0, 1, 1, 1], + "u": [-1, -1.5, -2, -1, -1.5, -2], + "v": [1, 0.5, 1, 0.5, 1, 0.5], + "sizemode": "scaled", + "anchor": "tail", + "marker": { + "color": "blue", + "line": {"width": 2} + } + } + ], + "layout": { + "title": {"text": "Multiple Quiver Traces"}, + "width": 700, + "height": 500, + "showlegend": true + } +} diff --git a/test/image/mocks/quiver_sizemode.json b/test/image/mocks/quiver_sizemode.json new file mode 100644 index 00000000000..f328399af18 --- /dev/null +++ b/test/image/mocks/quiver_sizemode.json @@ -0,0 +1,82 @@ +{ + "data": [ + { + "type": "quiver", + "name": "scaled", + "x": [0, 1, 2, 0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1, 2, 2, 2], + "u": [1, 2, 3, 1, 2, 3, 1, 2, 3], + "v": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "sizemode": "scaled", + "anchor": "tail", + "marker": { + "color": "red", + "line": {"width": 2} + }, + "xaxis": "x", + "yaxis": "y" + }, + { + "type": "quiver", + "name": "raw (sizeref=1.2)", + "x": [0, 1, 2, 0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1, 2, 2, 2], + "u": [1, 2, 3, 1, 2, 3, 1, 2, 3], + "v": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "sizemode": "raw", + "sizeref": 1.2, + "anchor": "tail", + "marker": { + "color": "blue", + "line": {"width": 2} + }, + "xaxis": "x2", + "yaxis": "y2" + }, + { + "type": "quiver", + "name": "raw (sizeref=0.6)", + "x": [0, 1, 2, 0, 1, 2, 0, 1, 2], + "y": [0, 0, 0, 1, 1, 1, 2, 2, 2], + "u": [1, 2, 3, 1, 2, 3, 1, 2, 3], + "v": [1, 1, 1, 1, 1, 1, 1, 1, 1], + "sizemode": "raw", + "sizeref": 0.6, + "anchor": "tail", + "marker": { + "color": "green", + "line": {"width": 2} + }, + "xaxis": "x3", + "yaxis": "y3" + } + ], + "layout": { + "width": 800, + "height": 400, + "showlegend": true, + "xaxis": { + "domain": [0, 0.3], + "title": {"text": "scaled"} + }, + "yaxis": { + "domain": [0, 1] + }, + "xaxis2": { + "domain": [0.35, 0.65], + "title": {"text": "raw (sizeref=1.2)"} + }, + "yaxis2": { + "domain": [0, 1], + "anchor": "x2" + }, + "xaxis3": { + "domain": [0.7, 1], + "title": {"text": "raw (sizeref=0.6)"} + }, + "yaxis3": { + "domain": [0, 1], + "anchor": "x3" + } + } +} diff --git a/test/image/mocks/quiver_wind.json b/test/image/mocks/quiver_wind.json new file mode 100644 index 00000000000..71bb062a139 --- /dev/null +++ b/test/image/mocks/quiver_wind.json @@ -0,0 +1,50 @@ +{ + "data": [ + { + "type": "quiver", + "name": "Wind field", + "x": [0, 0.5, 1, 1.5, 2, 2.5, 3, + 0, 0.5, 1, 1.5, 2, 2.5, 3, + 0, 0.5, 1, 1.5, 2, 2.5, 3, + 0, 0.5, 1, 1.5, 2, 2.5, 3, + 0, 0.5, 1, 1.5, 2, 2.5, 3], + "y": [0, 0, 0, 0, 0, 0, 0, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 1, 1, 1, 1, 1, 1, 1, + 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, + 2, 2, 2, 2, 2, 2, 2], + "u": [1, 1.5, 2, 2.5, 3, 2.5, 2, + 0.8, 1.2, 1.8, 2.2, 2.8, 2.2, 1.8, + 0.5, 1, 1.5, 2, 2.5, 2, 1.5, + 0.3, 0.8, 1.2, 1.8, 2.2, 1.8, 1.2, + 0.1, 0.5, 1, 1.5, 2, 1.5, 1], + "v": [0.2, 0.3, 0.5, 0.8, 1, 0.8, 0.5, + 0.5, 0.8, 1, 1.2, 1.5, 1.2, 1, + 0.8, 1.2, 1.5, 1.8, 2, 1.8, 1.5, + 0.5, 0.8, 1.2, 1.5, 1.8, 1.5, 1.2, + 0.2, 0.5, 0.8, 1.2, 1.5, 1.2, 0.8], + "sizemode": "scaled", + "anchor": "center", + "marker": { + "colorscale": "Jet", + "showscale": true, + "colorbar": { + "title": {"text": "Speed"}, + "x": 1.02 + }, + "line": {"width": 1.5} + } + } + ], + "layout": { + "title": {"text": "Vector Wind Field Visualization"}, + "width": 700, + "height": 600, + "xaxis": { + "title": {"text": "X"} + }, + "yaxis": { + "title": {"text": "Y"} + } + } +} diff --git a/test/jasmine/assets/mock_lists.js b/test/jasmine/assets/mock_lists.js index bf93191c0c3..6981ed9cc59 100644 --- a/test/jasmine/assets/mock_lists.js +++ b/test/jasmine/assets/mock_lists.js @@ -28,6 +28,7 @@ var svgMockList = [ ['layout-colorway', require('../../image/mocks/layout-colorway.json')], ['multicategory', require('../../image/mocks/multicategory.json')], ['polar_categories', require('../../image/mocks/polar_categories.json')], + ['quiver_categorical', require('../../image/mocks/quiver_categorical.json')], ['polar_direction', require('../../image/mocks/polar_direction.json')], ['polar_wind-rose', require('../../image/mocks/polar_wind-rose.json')], ['range_selector_style', require('../../image/mocks/range_selector_style.json')], diff --git a/test/jasmine/tests/lib_test.js b/test/jasmine/tests/lib_test.js index 42d01940201..6f59958da97 100644 --- a/test/jasmine/tests/lib_test.js +++ b/test/jasmine/tests/lib_test.js @@ -2784,8 +2784,9 @@ describe('Test lib.js:', function () { for (var i = 0; i < 15; i++) { Lib.hovertemplateString({ fallback: '', template: '%{idontexist}' }); } - // Expect 11 since the suppression warning also calls Lib.warn - expect(Lib.warn.calls.count()).toBe(11); + // Depending on prior tests, the suppression warning may already be reached once. + expect(Lib.warn.calls.count()).toBeGreaterThanOrEqual(10); + expect(Lib.warn.calls.count()).toBeLessThanOrEqual(11); }); // This test must come after the warning count since it will affect the count diff --git a/test/jasmine/tests/quiver_test.js b/test/jasmine/tests/quiver_test.js new file mode 100644 index 00000000000..7acffc73e12 --- /dev/null +++ b/test/jasmine/tests/quiver_test.js @@ -0,0 +1,341 @@ +var Plotly = require('../../../lib/index'); + +var supplyAllDefaults = require('../assets/supply_defaults'); +var createGraphDiv = require('../assets/create_graph_div'); +var destroyGraphDiv = require('../assets/destroy_graph_div'); + +var delay = require('../assets/delay'); +var mouseEvent = require('../assets/mouse_event'); + +var customAssertions = require('../assets/custom_assertions'); +var assertHoverLabelContent = customAssertions.assertHoverLabelContent; + +describe('Test quiver defaults', function() { + var gd; + + function makeGD() { + return { + data: [{ + type: 'quiver', + x: [1, 2], + y: [1, 2], + u: [1, 2], + v: [1, 2] + }], + layout: {} + }; + } + + it('should not set `visible: false` for traces with x,y arrays', function() { + gd = makeGD(); + supplyAllDefaults(gd); + expect(gd._fullData[0].visible).toBe(true); + }); + + it('should set `visible: false` for traces missing both x and y arrays', function() { + gd = makeGD(); + delete gd.data[0].x; + delete gd.data[0].y; + + supplyAllDefaults(gd); + expect(gd._fullData[0].visible).toBe(false); + }); + + it('should generate the missing axis from x0/dx or y0/dy (like scatter)', function() { + // missing x: generated from x0/dx (defaults 0 and 1) + gd = makeGD(); + delete gd.data[0].x; + supplyAllDefaults(gd); + expect(gd._fullData[0].visible).toBe(true, 'missing x'); + expect(gd._fullData[0].x0).toBe(0); + expect(gd._fullData[0].dx).toBe(1); + expect(gd._fullData[0]._length).toBe(2); + + // missing y: generated from y0/dy (defaults 0 and 1) + gd = makeGD(); + delete gd.data[0].y; + supplyAllDefaults(gd); + expect(gd._fullData[0].visible).toBe(true, 'missing y'); + expect(gd._fullData[0].y0).toBe(0); + expect(gd._fullData[0].dy).toBe(1); + expect(gd._fullData[0]._length).toBe(2); + }); + + it('should default u,v to zeros when missing', function() { + gd = { + data: [{ + type: 'quiver', + x: [1, 2, 3], + y: [1, 2, 3] + }], + layout: {} + }; + + supplyAllDefaults(gd); + expect(gd._fullData[0].visible).toBe(true); + expect(gd._fullData[0].u).toEqual([0, 0, 0]); + expect(gd._fullData[0].v).toEqual([0, 0, 0]); + }); + + it('should default u,v to zeros when empty', function() { + gd = { + data: [{ + type: 'quiver', + x: [1, 2, 3], + y: [1, 2, 3], + u: [], + v: [] + }], + layout: {} + }; + + supplyAllDefaults(gd); + expect(gd._fullData[0].visible).toBe(true); + expect(gd._fullData[0].u).toEqual([0, 0, 0]); + expect(gd._fullData[0].v).toEqual([0, 0, 0]); + }); + + it('should set sizemode and sizeref defaults correctly', function() { + gd = makeGD(); + supplyAllDefaults(gd); + expect(gd._fullData[0].sizemode).toBe('scaled'); + expect(gd._fullData[0].sizeref).toBe(1); + }); + + it('should set anchor default to tail', function() { + gd = makeGD(); + supplyAllDefaults(gd); + expect(gd._fullData[0].anchor).toBe('tail'); + }); +}); + +describe('Test quiver calc', function() { + var gd; + + beforeEach(function() { + gd = createGraphDiv(); + }); + + afterEach(function() { + Plotly.purge(gd); + destroyGraphDiv(); + }); + + it('should calculate data correctly for simple vectors', function(done) { + Plotly.newPlot(gd, [{ + type: 'quiver', + x: [0, 1, 2], + y: [0, 1, 2], + u: [1, 0, -1], + v: [0, 1, 0] + }]).then(function() { + var calcData = gd.calcdata[0]; + expect(calcData.length).toBe(3); + expect(calcData[0].x).toBe(0); + expect(calcData[0].y).toBe(0); + expect(calcData[1].x).toBe(1); + expect(calcData[1].y).toBe(1); + expect(calcData[2].x).toBe(2); + expect(calcData[2].y).toBe(2); + }) + .then(done, done.fail); + }); + + it('should generate x from x0/dx and y from y0/dy with the expected values', function(done) { + // missing x -> x generated from x0/dx defaults (0, 1) + Plotly.newPlot(gd, [{ + type: 'quiver', + y: [10, 20, 30], + u: [1, 1, 1], + v: [1, 1, 1] + }]).then(function() { + var cd = gd.calcdata[0]; + expect(cd.map(function(c) { return c.x; })).toEqual([0, 1, 2]); + expect(cd.map(function(c) { return c.y; })).toEqual([10, 20, 30]); + + // missing y -> y generated from y0/dy defaults (0, 1) + return Plotly.newPlot(gd, [{ + type: 'quiver', + x: [10, 20, 30], + u: [1, 1, 1], + v: [1, 1, 1] + }]); + }).then(function() { + var cd = gd.calcdata[0]; + expect(cd.map(function(c) { return c.x; })).toEqual([10, 20, 30]); + expect(cd.map(function(c) { return c.y; })).toEqual([0, 1, 2]); + }) + .then(done, done.fail); + }); +}); + +describe('Test quiver interactions', function() { + var gd; + + beforeEach(function() { + gd = createGraphDiv(); + }); + + afterEach(function() { + Plotly.purge(gd); + destroyGraphDiv(); + }); + + it('should add/clear svg objects correctly', function(done) { + Plotly.newPlot(gd, [{ + type: 'quiver', + x: [1, 2], + y: [1, 2], + u: [1, 0], + v: [0, 1] + }, { + type: 'quiver', + x: [3, 4], + y: [3, 4], + u: [1, 1], + v: [1, 1] + }]).then(function() { + var quiverLayers = gd._fullLayout._plots.xy.plot.selectAll('.trace.quiver'); + expect(quiverLayers.size()).toBe(2); + + return Plotly.deleteTraces(gd, [0]); + }) + .then(function() { + var quiverLayers = gd._fullLayout._plots.xy.plot.selectAll('.trace.quiver'); + expect(quiverLayers.size()).toBe(1); + + return Plotly.deleteTraces(gd, [0]); + }) + .then(function() { + var quiverLayers = gd._fullLayout._plots.xy.plot.selectAll('.trace.quiver'); + expect(quiverLayers.size()).toBe(0); + }) + .then(done, done.fail); + }); + + it('should restyle arrow properties', function(done) { + Plotly.newPlot(gd, [{ + type: 'quiver', + x: [1, 2], + y: [1, 2], + u: [1, 0], + v: [0, 1], + sizeref: 0.5 + }]).then(function() { + expect(gd._fullData[0].sizeref).toBe(0.5); + return Plotly.restyle(gd, 'sizeref', 1.5); + }) + .then(function() { + expect(gd._fullData[0].sizeref).toBe(1.5); + return Plotly.restyle(gd, 'anchor', 'tip'); + }) + .then(function() { + expect(gd._fullData[0].anchor).toBe('tip'); + }) + .then(done, done.fail); + }); + + it('should display hover labels', function(done) { + var fig = { + data: [{ + type: 'quiver', + x: [1, 2, 3], + y: [1, 2, 3], + u: [1, 0, -1], + v: [0, 1, 0] + }], + layout: { + margin: {l: 0, t: 0, r: 0, b: 0}, + width: 400, + height: 400 + } + }; + + Plotly.newPlot(gd, fig) + .then(function() { + mouseEvent('mousemove', 200, 200); + }) + .then(delay(20)) + .then(function() { + assertHoverLabelContent({ + nums: '(2, 2)\nu: 0, v: 1' + }); + }) + .then(done, done.fail); + }); + + it('should render multiple quiver traces', function(done) { + Plotly.newPlot(gd, [{ + type: 'quiver', + name: 'trace A', + x: [1, 2], + y: [1, 2], + u: [1, 0], + v: [0, 1], + marker: {color: 'red'} + }, { + type: 'quiver', + name: 'trace B', + x: [3, 4], + y: [3, 4], + u: [-1, 0], + v: [0, -1], + marker: {color: 'blue'} + }], { + margin: {l: 0, t: 0, r: 0, b: 0}, + width: 400, + height: 400 + }) + .then(function() { + var quiverLayers = gd._fullLayout._plots.xy.plot.selectAll('.trace.quiver'); + expect(quiverLayers.size()).toBe(2); + }) + .then(done, done.fail); + }); + + it('should handle sizemode changes', function(done) { + Plotly.newPlot(gd, [{ + type: 'quiver', + x: [0, 1, 2], + y: [0, 1, 2], + u: [1, 2, 3], + v: [1, 2, 3], + sizemode: 'scaled', + sizeref: 0.5 + }]).then(function() { + expect(gd._fullData[0].sizemode).toBe('scaled'); + return Plotly.restyle(gd, 'sizemode', 'raw'); + }) + .then(function() { + expect(gd._fullData[0].sizemode).toBe('raw'); + return Plotly.restyle(gd, 'sizemode', 'scaled'); + }) + .then(function() { + expect(gd._fullData[0].sizemode).toBe('scaled'); + }) + .then(done, done.fail); + }); + + it('should handle anchor changes', function(done) { + Plotly.newPlot(gd, [{ + type: 'quiver', + x: [1, 2], + y: [1, 2], + u: [1, 1], + v: [1, 1], + anchor: 'tail' + }]).then(function() { + expect(gd._fullData[0].anchor).toBe('tail'); + return Plotly.restyle(gd, 'anchor', 'tip'); + }) + .then(function() { + expect(gd._fullData[0].anchor).toBe('tip'); + return Plotly.restyle(gd, 'anchor', 'center'); + }) + .then(function() { + expect(gd._fullData[0].anchor).toBe('center'); + }) + .then(done, done.fail); + }); +}); + diff --git a/test/plot-schema.json b/test/plot-schema.json index f4286815758..804924e7874 100644 --- a/test/plot-schema.json +++ b/test/plot-schema.json @@ -49845,6 +49845,1395 @@ }, "type": "pie" }, + "quiver": { + "animatable": true, + "attributes": { + "anchor": { + "description": "Sets the arrows' anchor with respect to their (x,y) positions. Use *tail* to place (x,y) at the base, *tip* to place (x,y) at the head, or *center* to center the arrow on (x,y).", + "dflt": "tail", + "editType": "calc", + "valType": "enumerated", + "values": [ + "tip", + "tail", + "center" + ] + }, + "anglemode": { + "description": "Sets the mode used to determine the angle of the arrow vectors. If *paper*, u/v are interpreted in pixel coordinates and the rendered vector angle does not change regardless of the axes scales. If *data*, u/v are interpreted in data coordinates and the rendered vector angle may change, e.g. if zooming in along a single axis", + "dflt": "axis", + "editType": "calc", + "valType": "enumerated", + "values": [ + "paper", + "data" + ] + }, + "customdata": { + "description": "Assigns extra data each datum. This may be useful when listening to hover, click and selection events. Note that, *scatter* traces also appends customdata items in the markers DOM elements", + "editType": "calc", + "valType": "data_array" + }, + "dx": { + "anim": true, + "description": "Sets the x coordinate step. See `x0` for more info.", + "dflt": 1, + "editType": "calc", + "valType": "number" + }, + "dy": { + "anim": true, + "description": "Sets the y coordinate step. See `y0` for more info.", + "dflt": 1, + "editType": "calc", + "valType": "number" + }, + "hoverinfo": { + "arrayOk": true, + "description": "Determines what trace information appears on hover. If `none` or `skip` are set, no information is displayed upon hovering. But, if `none` is set, click and hover events are still fired.", + "dflt": "all", + "editType": "none", + "extras": [ + "all", + "none", + "skip" + ], + "flags": [ + "x", + "y", + "u", + "v", + "text", + "name" + ], + "valType": "flaglist" + }, + "hoverlabel": { + "align": { + "arrayOk": true, + "description": "Sets the horizontal alignment of the text content within hover label box. Has an effect only if the hover label text spans more two or more lines", + "dflt": "auto", + "editType": "none", + "valType": "enumerated", + "values": [ + "left", + "right", + "auto" + ] + }, + "bgcolor": { + "arrayOk": true, + "description": "Sets the background color of the hover labels for this trace", + "editType": "none", + "valType": "color" + }, + "bordercolor": { + "arrayOk": true, + "description": "Sets the border color of the hover labels for this trace.", + "editType": "none", + "valType": "color" + }, + "editType": "none", + "font": { + "color": { + "arrayOk": true, + "editType": "none", + "valType": "color" + }, + "description": "Sets the font used in hover labels.", + "editType": "none", + "family": { + "arrayOk": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.", + "editType": "none", + "noBlank": true, + "strict": true, + "valType": "string" + }, + "lineposition": { + "arrayOk": true, + "description": "Sets the kind of decoration line(s) with text, such as an *under*, *over* or *through* as well as combinations e.g. *under+over*, etc.", + "dflt": "none", + "editType": "none", + "extras": [ + "none" + ], + "flags": [ + "under", + "over", + "through" + ], + "valType": "flaglist" + }, + "role": "object", + "shadow": { + "arrayOk": true, + "description": "Sets the shape and color of the shadow behind text. *auto* places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.", + "dflt": "none", + "editType": "none", + "valType": "string" + }, + "size": { + "arrayOk": true, + "editType": "none", + "min": 1, + "valType": "number" + }, + "style": { + "arrayOk": true, + "description": "Sets whether a font should be styled with a normal or italic face from its family.", + "dflt": "normal", + "editType": "none", + "valType": "enumerated", + "values": [ + "normal", + "italic" + ] + }, + "textcase": { + "arrayOk": true, + "description": "Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.", + "dflt": "normal", + "editType": "none", + "valType": "enumerated", + "values": [ + "normal", + "word caps", + "upper", + "lower" + ] + }, + "variant": { + "arrayOk": true, + "description": "Sets the variant of the font.", + "dflt": "normal", + "editType": "none", + "valType": "enumerated", + "values": [ + "normal", + "small-caps", + "all-small-caps", + "all-petite-caps", + "petite-caps", + "unicase" + ] + }, + "weight": { + "arrayOk": true, + "description": "Sets the weight (or boldness) of the font.", + "dflt": "normal", + "editType": "none", + "extras": [ + "normal", + "bold" + ], + "max": 1000, + "min": 1, + "valType": "integer" + } + }, + "namelength": { + "arrayOk": true, + "description": "Sets the default length (in number of characters) of the trace name in the hover labels for all traces. -1 shows the whole name regardless of length. 0-3 shows the first 0-3 characters, and an integer >3 will show the whole name if it is less than that many characters, but if it is longer, will truncate to `namelength - 3` characters and add an ellipsis.", + "dflt": 15, + "editType": "none", + "min": -1, + "valType": "integer" + }, + "role": "object", + "showarrow": { + "description": "Sets whether or not to show the hover label arrow/triangle pointing to the data point.", + "dflt": true, + "editType": "none", + "valType": "boolean" + } + }, + "hovertemplate": { + "arrayOk": true, + "description": "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\" as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, *xother* will be added to those with different x positions from the first point. An underscore before or after *(x|y)other* will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:$.2f}\". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example \"Day: %{2019-01-01|%A}\". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. Variables that can't be found will be replaced with the specifier. For example, a template of \"data: %{x}, %{y}\" will result in a value of \"data: 1, %{y}\" if x is 1 and y is missing. Variables with an undefined value will be replaced with the fallback value. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, all attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. Finally, the template string has access to variables `x`, `y`, `u`, `v`, `text` and `name`. Anything contained in tag `` is displayed in the secondary box, for example `%{fullData.name}`. To hide the secondary box completely, use an empty tag ``.", + "dflt": "", + "editType": "none", + "valType": "string" + }, + "ids": { + "anim": true, + "description": "Assigns id labels to each datum. These ids for object constancy of data points during animation. Should be an array of strings, not numbers or any other type.", + "editType": "calc", + "valType": "data_array" + }, + "legend": { + "description": "Sets the reference to a legend to show this trace in. References to these legends are *legend*, *legend2*, *legend3*, etc. Settings for these legends are set in the layout, under `layout.legend`, `layout.legend2`, etc.", + "dflt": "legend", + "editType": "style", + "valType": "subplotid" + }, + "legendgroup": { + "description": "Sets the legend group for this trace. Traces and shapes part of the same legend group hide/show at the same time when toggling legend items.", + "dflt": "", + "editType": "style", + "valType": "string" + }, + "legendgrouptitle": { + "editType": "style", + "font": { + "color": { + "editType": "style", + "valType": "color" + }, + "description": "Sets this legend group's title font.", + "editType": "style", + "family": { + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.", + "editType": "style", + "noBlank": true, + "strict": true, + "valType": "string" + }, + "lineposition": { + "description": "Sets the kind of decoration line(s) with text, such as an *under*, *over* or *through* as well as combinations e.g. *under+over*, etc.", + "dflt": "none", + "editType": "style", + "extras": [ + "none" + ], + "flags": [ + "under", + "over", + "through" + ], + "valType": "flaglist" + }, + "role": "object", + "shadow": { + "description": "Sets the shape and color of the shadow behind text. *auto* places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.", + "dflt": "none", + "editType": "style", + "valType": "string" + }, + "size": { + "editType": "style", + "min": 1, + "valType": "number" + }, + "style": { + "description": "Sets whether a font should be styled with a normal or italic face from its family.", + "dflt": "normal", + "editType": "style", + "valType": "enumerated", + "values": [ + "normal", + "italic" + ] + }, + "textcase": { + "description": "Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.", + "dflt": "normal", + "editType": "style", + "valType": "enumerated", + "values": [ + "normal", + "word caps", + "upper", + "lower" + ] + }, + "variant": { + "description": "Sets the variant of the font.", + "dflt": "normal", + "editType": "style", + "valType": "enumerated", + "values": [ + "normal", + "small-caps", + "all-small-caps", + "all-petite-caps", + "petite-caps", + "unicase" + ] + }, + "weight": { + "description": "Sets the weight (or boldness) of the font.", + "dflt": "normal", + "editType": "style", + "extras": [ + "normal", + "bold" + ], + "max": 1000, + "min": 1, + "valType": "integer" + } + }, + "role": "object", + "text": { + "description": "Sets the title of the legend group.", + "dflt": "", + "editType": "style", + "valType": "string" + } + }, + "legendrank": { + "description": "Sets the legend rank for this trace. Items and groups with smaller ranks are presented on top/left side while with *reversed* `legend.traceorder` they are on bottom/right side. The default legendrank is 1000, so that you can use ranks less than 1000 to place certain items before all unranked items, and ranks greater than 1000 to go after all unranked items. When having unranked or equal rank items shapes would be displayed after traces i.e. according to their order in data and layout.", + "dflt": 1000, + "editType": "style", + "valType": "number" + }, + "legendwidth": { + "description": "Sets the width (in px or fraction) of the legend for this trace.", + "editType": "style", + "min": 0, + "valType": "number" + }, + "marker": { + "arrowsize": { + "description": "Sets the size of the arrow head relative to `marker.line.width`. A value of 1 (default) gives a head about 3x as wide as the line.", + "dflt": 1, + "editType": "calc", + "min": 0.3, + "valType": "number" + }, + "autocolorscale": { + "description": "Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. Has an effect only if in `marker.color` is set to a numerical array. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", + "dflt": true, + "editType": "calc", + "impliedEdits": {}, + "valType": "boolean" + }, + "cauto": { + "description": "Determines whether or not the color domain is computed with respect to the input data (here in `marker.color`) or the bounds set in `marker.cmin` and `marker.cmax` Has an effect only if in `marker.color` is set to a numerical array. Defaults to `false` when `marker.cmin` and `marker.cmax` are set by the user.", + "dflt": true, + "editType": "calc", + "impliedEdits": {}, + "valType": "boolean" + }, + "cmax": { + "description": "Sets the upper bound of the color domain. Has an effect only if in `marker.color` is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmin` must be set as well.", + "dflt": null, + "editType": "calc", + "impliedEdits": { + "cauto": false + }, + "valType": "number" + }, + "cmid": { + "description": "Sets the mid-point of the color domain by scaling `marker.cmin` and/or `marker.cmax` to be equidistant to this point. Has an effect only if in `marker.color` is set to a numerical array. Value should have the same units as in `marker.color`. Has no effect when `marker.cauto` is `false`.", + "dflt": null, + "editType": "calc", + "impliedEdits": {}, + "valType": "number" + }, + "cmin": { + "description": "Sets the lower bound of the color domain. Has an effect only if in `marker.color` is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmax` must be set as well.", + "dflt": null, + "editType": "calc", + "impliedEdits": { + "cauto": false + }, + "valType": "number" + }, + "color": { + "arrayOk": true, + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `marker.cmin` and `marker.cmax` if set.", + "editType": "calc", + "valType": "color" + }, + "coloraxis": { + "description": "Sets a reference to a shared color axis. References to these shared color axes are *coloraxis*, *coloraxis2*, *coloraxis3*, etc. Settings for these shared color axes are set in the layout, under `layout.coloraxis`, `layout.coloraxis2`, etc. Note that multiple color scales can be linked to the same color axis.", + "dflt": null, + "editType": "calc", + "regex": "/^coloraxis([2-9]|[1-9][0-9]+)?$/", + "valType": "subplotid" + }, + "colorbar": { + "bgcolor": { + "description": "Sets the color of padded area.", + "dflt": "rgba(0,0,0,0)", + "editType": "colorbars", + "valType": "color" + }, + "bordercolor": { + "description": "Sets the axis line color.", + "dflt": "#444", + "editType": "colorbars", + "valType": "color" + }, + "borderwidth": { + "description": "Sets the width (in px) or the border enclosing this color bar.", + "dflt": 0, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "dtick": { + "description": "Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to *log* and *date* axes. If the axis `type` is *log*, then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. *log* has several special values; *L*, where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = *L0.5* will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use *D1* (all digits) or *D2* (only 2 and 5). `tick0` is ignored for *D1* and *D2*. If the axis `type` is *date*, then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. *date* also has special values *M* gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to *2000-01-15* and `dtick` to *M3*. To set ticks every 4 years, set `dtick` to *M48*", + "editType": "colorbars", + "impliedEdits": { + "tickmode": "linear" + }, + "valType": "any" + }, + "editType": "colorbars", + "exponentformat": { + "description": "Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If *none*, it appears as 1,000,000,000. If *e*, 1e+9. If *E*, 1E+9. If *power*, 1x10^9 (with 9 in a super script). If *SI*, 1G. If *B*, 1B. *SI* uses prefixes from \"femto\" f (10^-15) to \"tera\" T (10^12). *SI extended* covers instead the full SI range from \"quecto\" q (10^-30) to \"quetta\" Q (10^30). If *SI* or *SI extended* is used and the exponent is beyond the above ranges, the formatting rule will automatically be switched to the power notation.", + "dflt": "B", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "none", + "e", + "E", + "power", + "SI", + "B", + "SI extended" + ] + }, + "labelalias": { + "description": "Replacement text for specific tick or hover labels. For example using {US: 'USA', CA: 'Canada'} changes US to USA and CA to Canada. The labels we would have shown must match the keys exactly, after adding any tickprefix or ticksuffix. For negative numbers the minus sign symbol used (U+2212) is wider than the regular ascii dash. That means you need to use −1 instead of -1. labelalias can be used with any axis type, and both keys (if needed) and values (if desired) can include html-like tags or MathJax.", + "dflt": false, + "editType": "colorbars", + "valType": "any" + }, + "len": { + "description": "Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends.", + "dflt": 1, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "lenmode": { + "description": "Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot *fraction* or in *pixels. Use `len` to set the value.", + "dflt": "fraction", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "fraction", + "pixels" + ] + }, + "minexponent": { + "description": "Hide SI prefix for 10^n if |n| is below this number. This only has an effect when `tickformat` is *SI* or *B*.", + "dflt": 3, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "nticks": { + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", + "dflt": 0, + "editType": "colorbars", + "min": 0, + "valType": "integer" + }, + "orientation": { + "description": "Sets the orientation of the colorbar.", + "dflt": "v", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "h", + "v" + ] + }, + "outlinecolor": { + "description": "Sets the axis line color.", + "dflt": "#444", + "editType": "colorbars", + "valType": "color" + }, + "outlinewidth": { + "description": "Sets the width (in px) of the axis line.", + "dflt": 1, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "role": "object", + "separatethousands": { + "description": "If \"true\", even 4-digit integers are separated", + "dflt": false, + "editType": "colorbars", + "valType": "boolean" + }, + "showexponent": { + "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear.", + "dflt": "all", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "all", + "first", + "last", + "none" + ] + }, + "showticklabels": { + "description": "Determines whether or not the tick labels are drawn.", + "dflt": true, + "editType": "colorbars", + "valType": "boolean" + }, + "showtickprefix": { + "description": "If *all*, all tick labels are displayed with a prefix. If *first*, only the first tick is displayed with a prefix. If *last*, only the last tick is displayed with a suffix. If *none*, tick prefixes are hidden.", + "dflt": "all", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "all", + "first", + "last", + "none" + ] + }, + "showticksuffix": { + "description": "Same as `showtickprefix` but for tick suffixes.", + "dflt": "all", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "all", + "first", + "last", + "none" + ] + }, + "thickness": { + "description": "Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels.", + "dflt": 30, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "thicknessmode": { + "description": "Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot *fraction* or in *pixels*. Use `thickness` to set the value.", + "dflt": "pixels", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "fraction", + "pixels" + ] + }, + "tick0": { + "description": "Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is *log*, then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2) except when `dtick`=*L* (see `dtick` for more info). If the axis `type` is *date*, it should be a date string, like date data. If the axis `type` is *category*, it should be a number, using the scale where each category is assigned a serial number from zero in the order it appears.", + "editType": "colorbars", + "impliedEdits": { + "tickmode": "linear" + }, + "valType": "any" + }, + "tickangle": { + "description": "Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically.", + "dflt": "auto", + "editType": "colorbars", + "valType": "angle" + }, + "tickcolor": { + "description": "Sets the tick color.", + "dflt": "#444", + "editType": "colorbars", + "valType": "color" + }, + "tickfont": { + "color": { + "editType": "colorbars", + "valType": "color" + }, + "description": "Sets the color bar's tick label font", + "editType": "colorbars", + "family": { + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.", + "editType": "colorbars", + "noBlank": true, + "strict": true, + "valType": "string" + }, + "lineposition": { + "description": "Sets the kind of decoration line(s) with text, such as an *under*, *over* or *through* as well as combinations e.g. *under+over*, etc.", + "dflt": "none", + "editType": "colorbars", + "extras": [ + "none" + ], + "flags": [ + "under", + "over", + "through" + ], + "valType": "flaglist" + }, + "role": "object", + "shadow": { + "description": "Sets the shape and color of the shadow behind text. *auto* places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.", + "dflt": "none", + "editType": "colorbars", + "valType": "string" + }, + "size": { + "editType": "colorbars", + "min": 1, + "valType": "number" + }, + "style": { + "description": "Sets whether a font should be styled with a normal or italic face from its family.", + "dflt": "normal", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "normal", + "italic" + ] + }, + "textcase": { + "description": "Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.", + "dflt": "normal", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "normal", + "word caps", + "upper", + "lower" + ] + }, + "variant": { + "description": "Sets the variant of the font.", + "dflt": "normal", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "normal", + "small-caps", + "all-small-caps", + "all-petite-caps", + "petite-caps", + "unicase" + ] + }, + "weight": { + "description": "Sets the weight (or boldness) of the font.", + "dflt": "normal", + "editType": "colorbars", + "extras": [ + "normal", + "bold" + ], + "max": 1000, + "min": 1, + "valType": "integer" + } + }, + "tickformat": { + "description": "Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: *%h* for half of the year as a decimal number as well as *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*", + "dflt": "", + "editType": "colorbars", + "valType": "string" + }, + "tickformatstops": { + "items": { + "tickformatstop": { + "dtickrange": { + "description": "range [*min*, *max*], where *min*, *max* - dtick values which describe some zoom level, it is possible to omit *min* or *max* value by passing *null*", + "editType": "colorbars", + "items": [ + { + "editType": "colorbars", + "valType": "any" + }, + { + "editType": "colorbars", + "valType": "any" + } + ], + "valType": "info_array" + }, + "editType": "colorbars", + "enabled": { + "description": "Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`.", + "dflt": true, + "editType": "colorbars", + "valType": "boolean" + }, + "name": { + "description": "When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template.", + "editType": "colorbars", + "valType": "string" + }, + "role": "object", + "templateitemname": { + "description": "Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`.", + "editType": "colorbars", + "valType": "string" + }, + "value": { + "description": "string - dtickformat for described zoom level, the same as *tickformat*", + "dflt": "", + "editType": "colorbars", + "valType": "string" + } + } + }, + "role": "object" + }, + "ticklabeloverflow": { + "description": "Determines how we handle tick labels that would overflow either the graph div or the domain of the axis. The default value for inside tick labels is *hide past domain*. In other cases the default is *hide past div*.", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "allow", + "hide past div", + "hide past domain" + ] + }, + "ticklabelposition": { + "description": "Determines where tick labels are drawn relative to the ticks. Left and right options are used when `orientation` is *h*, top and bottom when `orientation` is *v*.", + "dflt": "outside", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "outside", + "inside", + "outside top", + "inside top", + "outside left", + "inside left", + "outside right", + "inside right", + "outside bottom", + "inside bottom" + ] + }, + "ticklabelstep": { + "description": "Sets the spacing between tick labels as compared to the spacing between ticks. A value of 1 (default) means each tick gets a label. A value of 2 means shows every 2nd label. A larger value n means only every nth tick is labeled. `tick0` determines which labels are shown. Not implemented for axes with `type` *log* or *multicategory*, or when `tickmode` is *array*.", + "dflt": 1, + "editType": "colorbars", + "min": 1, + "valType": "integer" + }, + "ticklen": { + "description": "Sets the tick length (in px).", + "dflt": 5, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "tickmode": { + "description": "Sets the tick mode for this axis. If *auto*, the number of ticks is set via `nticks`. If *linear*, the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` (*linear* is the default value if `tick0` and `dtick` are provided). If *array*, the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. (*array* is the default value if `tickvals` is provided).", + "editType": "colorbars", + "impliedEdits": {}, + "valType": "enumerated", + "values": [ + "auto", + "linear", + "array" + ] + }, + "tickprefix": { + "description": "Sets a tick label prefix.", + "dflt": "", + "editType": "colorbars", + "valType": "string" + }, + "ticks": { + "description": "Determines whether ticks are drawn or not. If **, this axis' ticks are not drawn. If *outside* (*inside*), this axis' are drawn outside (inside) the axis lines.", + "dflt": "", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "outside", + "inside", + "" + ] + }, + "ticksuffix": { + "description": "Sets a tick label suffix.", + "dflt": "", + "editType": "colorbars", + "valType": "string" + }, + "ticktext": { + "description": "Sets the text displayed at the ticks position via `tickvals`. Only has an effect if `tickmode` is set to *array*. Used with `tickvals`.", + "editType": "colorbars", + "valType": "data_array" + }, + "tickvals": { + "description": "Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to *array*. Used with `ticktext`.", + "editType": "colorbars", + "valType": "data_array" + }, + "tickwidth": { + "description": "Sets the tick width (in px).", + "dflt": 1, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "title": { + "editType": "colorbars", + "font": { + "color": { + "editType": "colorbars", + "valType": "color" + }, + "description": "Sets this color bar's title font.", + "editType": "colorbars", + "family": { + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.", + "editType": "colorbars", + "noBlank": true, + "strict": true, + "valType": "string" + }, + "lineposition": { + "description": "Sets the kind of decoration line(s) with text, such as an *under*, *over* or *through* as well as combinations e.g. *under+over*, etc.", + "dflt": "none", + "editType": "colorbars", + "extras": [ + "none" + ], + "flags": [ + "under", + "over", + "through" + ], + "valType": "flaglist" + }, + "role": "object", + "shadow": { + "description": "Sets the shape and color of the shadow behind text. *auto* places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.", + "dflt": "none", + "editType": "colorbars", + "valType": "string" + }, + "size": { + "editType": "colorbars", + "min": 1, + "valType": "number" + }, + "style": { + "description": "Sets whether a font should be styled with a normal or italic face from its family.", + "dflt": "normal", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "normal", + "italic" + ] + }, + "textcase": { + "description": "Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.", + "dflt": "normal", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "normal", + "word caps", + "upper", + "lower" + ] + }, + "variant": { + "description": "Sets the variant of the font.", + "dflt": "normal", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "normal", + "small-caps", + "all-small-caps", + "all-petite-caps", + "petite-caps", + "unicase" + ] + }, + "weight": { + "description": "Sets the weight (or boldness) of the font.", + "dflt": "normal", + "editType": "colorbars", + "extras": [ + "normal", + "bold" + ], + "max": 1000, + "min": 1, + "valType": "integer" + } + }, + "role": "object", + "side": { + "description": "Determines the location of color bar's title with respect to the color bar. Defaults to *top* when `orientation` is *v* and defaults to *right* when `orientation` is *h*.", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ] + }, + "text": { + "description": "Sets the title of the color bar.", + "editType": "colorbars", + "valType": "string" + } + }, + "x": { + "description": "Sets the x position with respect to `xref` of the color bar (in plot fraction). When `xref` is *paper*, defaults to 1.02 when `orientation` is *v* and 0.5 when `orientation` is *h*. When `xref` is *container*, defaults to *1* when `orientation` is *v* and 0.5 when `orientation` is *h*. Must be between *0* and *1* if `xref` is *container* and between *-2* and *3* if `xref` is *paper*.", + "editType": "colorbars", + "valType": "number" + }, + "xanchor": { + "description": "Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the *left*, *center* or *right* of the color bar. Defaults to *left* when `orientation` is *v* and *center* when `orientation` is *h*.", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "left", + "center", + "right" + ] + }, + "xpad": { + "description": "Sets the amount of padding (in px) along the x direction.", + "dflt": 10, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "xref": { + "description": "Sets the container `x` refers to. *container* spans the entire `width` of the plot. *paper* refers to the width of the plotting area only.", + "dflt": "paper", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "container", + "paper" + ] + }, + "y": { + "description": "Sets the y position with respect to `yref` of the color bar (in plot fraction). When `yref` is *paper*, defaults to 0.5 when `orientation` is *v* and 1.02 when `orientation` is *h*. When `yref` is *container*, defaults to 0.5 when `orientation` is *v* and 1 when `orientation` is *h*. Must be between *0* and *1* if `yref` is *container* and between *-2* and *3* if `yref` is *paper*.", + "editType": "colorbars", + "valType": "number" + }, + "yanchor": { + "description": "Sets this color bar's vertical position anchor This anchor binds the `y` position to the *top*, *middle* or *bottom* of the color bar. Defaults to *middle* when `orientation` is *v* and *bottom* when `orientation` is *h*.", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "top", + "middle", + "bottom" + ] + }, + "ypad": { + "description": "Sets the amount of padding (in px) along the y direction.", + "dflt": 10, + "editType": "colorbars", + "min": 0, + "valType": "number" + }, + "yref": { + "description": "Sets the container `y` refers to. *container* spans the entire `height` of the plot. *paper* refers to the height of the plotting area only.", + "dflt": "paper", + "editType": "colorbars", + "valType": "enumerated", + "values": [ + "container", + "paper" + ] + } + }, + "colorscale": { + "description": "Sets the colorscale. Has an effect only if in `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsla, hwb, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Blackbody,Bluered,Blues,Cividis,Earth,Electric,Greens,Greys,Hot,Jet,Picnic,Portland,Rainbow,RdBu,Reds,Viridis,YlGnBu,YlOrRd.", + "dflt": null, + "editType": "calc", + "impliedEdits": { + "autocolorscale": false + }, + "valType": "colorscale" + }, + "editType": "calc", + "line": { + "dash": { + "description": "Sets the dash style of lines. Set to a dash type string (*solid*, *dot*, *dash*, *longdash*, *dashdot*, or *longdashdot*) or a dash length list in px (eg *5px,10px,2px,2px*).", + "dflt": "solid", + "editType": "style", + "valType": "string", + "values": [ + "solid", + "dot", + "dash", + "longdash", + "dashdot", + "longdashdot" + ] + }, + "editType": "style", + "role": "object", + "width": { + "description": "Sets the width (in px) of the arrow lines.", + "dflt": 2, + "editType": "style", + "min": 0, + "valType": "number" + } + }, + "reversescale": { + "description": "Reverses the color mapping if true. Has an effect only if in `marker.color` is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color.", + "dflt": false, + "editType": "plot", + "valType": "boolean" + }, + "role": "object", + "showscale": { + "description": "Determines whether or not a colorbar is displayed for this trace. Has an effect only if in `marker.color` is set to a numerical array.", + "dflt": true, + "editType": "calc", + "valType": "boolean" + } + }, + "meta": { + "arrayOk": true, + "description": "Assigns extra meta information associated with this trace that can be used in various text attributes. Attributes such as trace `name`, graph, axis and colorbar `title.text`, annotation `text` `rangeselector`, `updatemenues` and `sliders` `label` text all support `meta`. To access the trace `meta` values in an attribute in the same trace, simply use `%{meta[i]}` where `i` is the index or key of the `meta` item in question. To access trace `meta` in layout attributes, use `%{data[n[.meta[i]}` where `i` is the index or key of the `meta` and `n` is the trace index.", + "editType": "plot", + "valType": "any" + }, + "name": { + "description": "Sets the trace name. The trace name appears as the legend item and on hover.", + "editType": "style", + "valType": "string" + }, + "opacity": { + "description": "Sets the opacity of the trace.", + "dflt": 1, + "editType": "style", + "max": 1, + "min": 0, + "valType": "number" + }, + "selected": { + "editType": "style", + "marker": { + "color": { + "description": "Sets the marker color of selected points.", + "editType": "style", + "valType": "color" + }, + "editType": "style", + "line": { + "editType": "style", + "role": "object", + "width": { + "description": "Sets the line width of selected points.", + "editType": "style", + "min": 0, + "valType": "number" + } + }, + "role": "object" + }, + "role": "object", + "textfont": { + "color": { + "description": "Sets the text font color of selected points, applied only when a selection exists.", + "editType": "style", + "valType": "color" + }, + "editType": "style", + "role": "object" + } + }, + "selectedpoints": { + "description": "Array containing integer indices of selected points. Has an effect only for traces that support selections. Note that an empty array means an empty selection where the `unselected` are turned on for all points, whereas, any other non-array values means no selection all where the `selected` and `unselected` styles have no effect.", + "editType": "calc", + "valType": "any" + }, + "showlegend": { + "description": "Determines whether or not an item corresponding to this trace is shown in the legend.", + "dflt": true, + "editType": "style", + "valType": "boolean" + }, + "sizemode": { + "description": "Determines whether arrows are drawn according to their raw lengths, or scaled based on the maximum vector length and point density. Note: When `anglemode` is *data* arrows are alwyas scaled and `sizemode` *raw* is ignored.", + "dflt": "scaled", + "editType": "calc", + "valType": "enumerated", + "values": [ + "scaled", + "raw" + ] + }, + "sizeref": { + "description": "Adjusts the arrow size scaling. The arrow length is determined by the vector norm multiplied by `sizeref`, optionally normalized when `sizemode` is *scaled* (`sizeref` is applied after scaling).", + "dflt": 1, + "editType": "calc", + "min": 0, + "valType": "number" + }, + "text": { + "arrayOk": true, + "description": "Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace `hoverinfo` contains a *text* flag and *hovertext* is not set, these elements will be seen in the hover labels.", + "dflt": "", + "editType": "calc", + "valType": "string" + }, + "textfont": { + "color": { + "arrayOk": true, + "editType": "style", + "valType": "color" + }, + "description": "Sets the text font.", + "editType": "calc", + "family": { + "arrayOk": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.", + "editType": "calc", + "noBlank": true, + "strict": true, + "valType": "string" + }, + "lineposition": { + "arrayOk": true, + "description": "Sets the kind of decoration line(s) with text, such as an *under*, *over* or *through* as well as combinations e.g. *under+over*, etc.", + "dflt": "none", + "editType": "calc", + "extras": [ + "none" + ], + "flags": [ + "under", + "over", + "through" + ], + "valType": "flaglist" + }, + "role": "object", + "shadow": { + "arrayOk": true, + "description": "Sets the shape and color of the shadow behind text. *auto* places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.", + "dflt": "none", + "editType": "calc", + "valType": "string" + }, + "size": { + "arrayOk": true, + "editType": "calc", + "min": 1, + "valType": "number" + }, + "style": { + "arrayOk": true, + "description": "Sets whether a font should be styled with a normal or italic face from its family.", + "dflt": "normal", + "editType": "calc", + "valType": "enumerated", + "values": [ + "normal", + "italic" + ] + }, + "textcase": { + "arrayOk": true, + "description": "Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.", + "dflt": "normal", + "editType": "calc", + "valType": "enumerated", + "values": [ + "normal", + "word caps", + "upper", + "lower" + ] + }, + "variant": { + "arrayOk": true, + "description": "Sets the variant of the font.", + "dflt": "normal", + "editType": "calc", + "valType": "enumerated", + "values": [ + "normal", + "small-caps", + "all-small-caps", + "all-petite-caps", + "petite-caps", + "unicase" + ] + }, + "weight": { + "arrayOk": true, + "description": "Sets the weight (or boldness) of the font.", + "dflt": "normal", + "editType": "calc", + "extras": [ + "normal", + "bold" + ], + "max": 1000, + "min": 1, + "valType": "integer" + } + }, + "textposition": { + "arrayOk": true, + "description": "Sets the positions of the `text` elements with respects to the (x,y) coordinates.", + "dflt": "middle center", + "editType": "calc", + "valType": "enumerated", + "values": [ + "top left", + "top center", + "top right", + "middle left", + "middle center", + "middle right", + "bottom left", + "bottom center", + "bottom right" + ] + }, + "type": "quiver", + "u": { + "anim": true, + "description": "Sets the x components of the arrow vectors.", + "editType": "calc", + "valType": "data_array" + }, + "uhoverformat": { + "description": "Sets the hover text formatting rule for `u` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format.By default the values are formatted using generic number format.", + "dflt": "", + "editType": "none", + "valType": "string" + }, + "uid": { + "anim": true, + "description": "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.", + "editType": "plot", + "valType": "string" + }, + "uirevision": { + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves.", + "editType": "none", + "valType": "any" + }, + "unselected": { + "editType": "style", + "marker": { + "color": { + "description": "Sets the marker color of unselected points, applied only when a selection exists.", + "editType": "style", + "valType": "color" + }, + "editType": "style", + "line": { + "editType": "style", + "role": "object", + "width": { + "description": "Sets the line width of unselected points, applied only when a selection exists.", + "editType": "style", + "min": 0, + "valType": "number" + } + }, + "role": "object" + }, + "role": "object", + "textfont": { + "color": { + "description": "Sets the text font color of unselected points, applied only when a selection exists.", + "editType": "style", + "valType": "color" + }, + "editType": "style", + "role": "object" + } + }, + "v": { + "anim": true, + "description": "Sets the y components of the arrow vectors.", + "editType": "calc", + "valType": "data_array" + }, + "vhoverformat": { + "description": "Sets the hover text formatting rule for `v` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format.By default the values are formatted using generic number format.", + "dflt": "", + "editType": "none", + "valType": "string" + }, + "visible": { + "description": "Determines whether or not this trace is visible. If *legendonly*, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).", + "dflt": true, + "editType": "calc", + "valType": "enumerated", + "values": [ + true, + false, + "legendonly" + ] + }, + "x": { + "anim": true, + "description": "Sets the x coordinates of the arrow locations.", + "editType": "calc+clearAxisTypes", + "valType": "data_array" + }, + "x0": { + "anim": true, + "description": "Alternate to `x`. Builds a linear space of x coordinates. Use with `dx` where `x0` is the starting coordinate and `dx` the step.", + "dflt": 0, + "editType": "calc+clearAxisTypes", + "valType": "any" + }, + "xaxis": { + "description": "Sets a reference between this trace's x coordinates and a 2D cartesian x axis. If *x* (the default value), the x coordinates refer to `layout.xaxis`. If *x2*, the x coordinates refer to `layout.xaxis2`, and so on.", + "dflt": "x", + "editType": "calc+clearAxisTypes", + "valType": "subplotid" + }, + "xhoverformat": { + "description": "Sets the hover text formatting rule for `x` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: *%h* for half of the year as a decimal number as well as *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*By default the values are formatted using `xaxis.hoverformat`.", + "dflt": "", + "editType": "none", + "valType": "string" + }, + "y": { + "anim": true, + "description": "Sets the y coordinates of the arrow locations.", + "editType": "calc+clearAxisTypes", + "valType": "data_array" + }, + "y0": { + "anim": true, + "description": "Alternate to `y`. Builds a linear space of y coordinates. Use with `dy` where `y0` is the starting coordinate and `dy` the step.", + "dflt": 0, + "editType": "calc+clearAxisTypes", + "valType": "any" + }, + "yaxis": { + "description": "Sets a reference between this trace's y coordinates and a 2D cartesian y axis. If *y* (the default value), the y coordinates refer to `layout.yaxis`. If *y2*, the y coordinates refer to `layout.yaxis2`, and so on.", + "dflt": "y", + "editType": "calc+clearAxisTypes", + "valType": "subplotid" + }, + "yhoverformat": { + "description": "Sets the hover text formatting rule for `y` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: *%h* for half of the year as a decimal number as well as *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*By default the values are formatted using `yaxis.hoverformat`.", + "dflt": "", + "editType": "none", + "valType": "string" + } + }, + "categories": [ + "cartesian", + "svg", + "showLegend", + "scatter-like", + "zoomScale" + ], + "meta": { + "description": "The quiver trace type visualizes vector fields using arrows. Specify a vector field using 4 1D arrays: 2 position arrays `x`, `y` and 2 vector component arrays `u`, `v`. The arrows are drawn exactly at the positions given by `x` and `y`. Arrow length and direction are determined by `u` and `v` components." + }, + "type": "quiver" + }, "sankey": { "animatable": false, "attributes": {