diff --git a/lib/index-strict.js b/lib/index-strict.js index cac9738bff8..8e332c3b56d 100644 --- a/lib/index-strict.js +++ b/lib/index-strict.js @@ -52,6 +52,7 @@ Plotly.register([ require('../src/traces/scatterpolargl/strict'), require('./barpolar'), require('./scattersmith'), + require('./scatterquiver'), // components require('./calendars'), diff --git a/lib/index.js b/lib/index.js index d4cb5bdcc87..d234cfca3ea 100644 --- a/lib/index.js +++ b/lib/index.js @@ -52,6 +52,7 @@ Plotly.register([ require('./scatterpolargl'), require('./barpolar'), require('./scattersmith'), + require('./scatterquiver'), // components require('./calendars'), diff --git a/lib/scatterquiver.js b/lib/scatterquiver.js new file mode 100644 index 00000000000..f3d08677cc2 --- /dev/null +++ b/lib/scatterquiver.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../src/traces/scatterquiver'); diff --git a/src/traces/scatterquiver/attributes.js b/src/traces/scatterquiver/attributes.js new file mode 100644 index 00000000000..6a72329cee5 --- /dev/null +++ b/src/traces/scatterquiver/attributes.js @@ -0,0 +1,207 @@ +'use strict'; + +var baseAttrs = require('../../plots/attributes'); +var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs; +var fontAttrs = require('../../plots/font_attributes'); +var dash = require('../../components/drawing/attributes').dash; + +var extendFlat = require('../../lib/extend').extendFlat; + +var attrs = { + x: { + valType: 'data_array', + editType: 'calc+clearAxisTypes', + anim: true, + description: 'Sets the x coordinates of the arrow locations.' + }, + y: { + valType: 'data_array', + editType: 'calc+clearAxisTypes', + anim: true, + description: 'Sets the y coordinates of the arrow locations.' + }, + 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.' + }, + scale: { + valType: 'number', + dflt: 0.1, + min: 0, + max: 1, + editType: 'calc', + description: 'Scales size of the arrows (ideally to avoid overlap). Default = 0.1' + }, + arrow_scale: { + valType: 'number', + dflt: 0.3, + min: 0, + max: 1, + editType: 'calc', + description: 'Value multiplied to length of barb to get length of arrowhead. Default = 0.3' + }, + angle: { + valType: 'number', + dflt: Math.PI / 9, + min: 0, + max: Math.PI / 2, + editType: 'calc', + description: 'Angle of arrowhead in radians. Default = π/9' + }, + scaleratio: { + valType: 'number', + min: 0, + editType: 'calc', + description: 'The ratio between the scale of the y-axis and the scale of the x-axis (scale_y / scale_x). Default = null, the scale ratio is not fixed.' + }, + hoverdistance: { + valType: 'number', + min: -1, + dflt: 20, + editType: 'calc', + description: 'Maximum distance (in pixels) to look for nearby arrows on hover.' + }, + + // Line styling for arrows + line: { + color: { + valType: 'color', + dflt: '#000', + editType: 'style', + description: 'Sets the color of the arrow lines.' + }, + width: { + valType: 'number', + min: 0, + dflt: 1, + editType: 'style', + description: 'Sets the width (in px) of the arrow lines.' + }, + dash: dash, + shape: { + valType: 'enumerated', + values: ['linear', 'spline', 'hv', 'vh', 'hvh', 'vhv'], + dflt: 'linear', + editType: 'plot', + description: 'Determines the line shape.' + }, + smoothing: { + valType: 'number', + min: 0, + max: 1.3, + dflt: 1, + editType: 'plot', + description: 'Has an effect only if `shape` is set to *spline*. Sets the amount of smoothing.' + }, + simplify: { + valType: 'boolean', + dflt: true, + editType: 'plot', + description: 'Simplifies lines by removing nearly-overlapping points.' + }, + editType: 'style' + }, + + // Text and labels + text: { + valType: 'data_array', + editType: 'calc', + anim: true, + description: 'Sets text elements associated with each (x,y) pair.' + }, + textposition: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle left', 'middle center', 'middle right', + 'bottom left', 'bottom center', 'bottom right' + ], + dflt: 'middle center', + editType: 'calc', + description: 'Sets the positions of the `text` elements with respects to the (x,y) coordinates.' + }, + // Text font + textfont: fontAttrs({ + editType: 'calc', + colorEditType: 'style', + arrayOk: true, + description: 'Sets the text font.' + }), + + // Selection and styling + selected: { + line: { + color: { + valType: 'color', + editType: 'style', + description: 'Sets the line color of selected points.' + }, + width: { + valType: 'number', + min: 0, + editType: 'style', + description: 'Sets the line width of selected points.' + }, + 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: { + line: { + color: { + valType: 'color', + editType: 'style', + description: 'Sets the line color of unselected points.' + }, + width: { + valType: 'number', + min: 0, + editType: 'style', + description: 'Sets the line width of unselected points.' + }, + 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' + } +}; + +// Extend with base attributes (includes hoverinfo, etc.) +extendFlat(attrs, baseAttrs); + +// Add hoverinfo with proper flags for quiver +// We need to create a new object to avoid mutating the shared base attributes +attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, { + flags: ['x', 'y', 'u', 'v', 'text', 'name'], + dflt: 'all' +}); + +// Add hovertemplate +attrs.hovertemplate = extendFlat({}, hovertemplateAttrs({}, { + keys: ['x', 'y', 'u', 'v', 'text', 'name'] +})); + +module.exports = attrs; \ No newline at end of file diff --git a/src/traces/scatterquiver/calc.js b/src/traces/scatterquiver/calc.js new file mode 100644 index 00000000000..28e11e95116 --- /dev/null +++ b/src/traces/scatterquiver/calc.js @@ -0,0 +1,47 @@ +'use strict'; + +var Lib = require('../../lib'); +var Axes = require('../../plots/cartesian/axes'); +var isNumeric = require('fast-isnumeric'); +var BADNUM = require('../../constants/numerical').BADNUM; +var scatterCalc = require('../scatter/calc'); + +/** + * Main calculation function for scatterquiver 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 + var xa = trace._xA = Axes.getFromId(gd, trace.xaxis || 'x', 'x'); + var ya = trace._yA = Axes.getFromId(gd, trace.yaxis || 'y', 'y'); + + var xVals = xa.makeCalcdata(trace, 'x'); + var yVals = ya.makeCalcdata(trace, 'y'); + + // u/v are read in plot using the original trace arrays via cdi.i + + var len = Math.min(xVals.length, yVals.length); + trace._length = len; + var cd = new Array(len); + + for(var i = 0; i < len; i++) { + var cdi = cd[i] = { i: i }; + var xValid = isNumeric(xVals[i]); + var yValid = isNumeric(yVals[i]); + + if(xValid && yValid) { + cdi.x = xVals[i]; + cdi.y = yVals[i]; + } else { + cdi.x = BADNUM; + cdi.y = BADNUM; + } + + // No additional props; keep minimal to avoid collisions with generic fields (e.g. `v`) + } + + // Ensure axes are expanded and categories registered like scatter traces do + scatterCalc.calcAxisExpansion(gd, trace, xa, ya, xVals, yVals); + + return cd; +}; \ No newline at end of file diff --git a/src/traces/scatterquiver/defaults.js b/src/traces/scatterquiver/defaults.js new file mode 100644 index 00000000000..1992c520baf --- /dev/null +++ b/src/traces/scatterquiver/defaults.js @@ -0,0 +1,76 @@ +'use strict'; + +var Lib = require('../../lib'); +var attributes = require('./attributes'); + +module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) { + // Selection styling - use coerce to set proper defaults + function coerce(attr, dflt) { + return Lib.coerce(traceIn, traceOut, attributes, attr, dflt); + } + + // Coerce x and y data arrays (this ensures proper data structure for category ordering) + var x = coerce('x'); + var y = coerce('y'); + var u = coerce('u'); + var v = coerce('v'); + + // Simple validation - check if we have the required arrays + if(!x || !Array.isArray(x) || x.length === 0 || + !y || !Array.isArray(y) || y.length === 0) { + traceOut.visible = false; + return; + } + + // If u/v are missing, default to zeros so the trace participates in calc/category logic + var len = Math.min(x.length, y.length); + if(!Array.isArray(u) || u.length === 0) { + traceOut.u = new Array(len); + for(var i = 0; i < len; i++) traceOut.u[i] = 0; + } + if(!Array.isArray(v) || v.length === 0) { + traceOut.v = new Array(len); + for(var j = 0; j < len; j++) traceOut.v[j] = 0; + } + + // Set basic properties + traceOut.type = 'scatterquiver'; + + // Set default values using coerce + coerce('scale', 0.1); + coerce('arrow_scale', 0.3); + coerce('angle', Math.PI / 9); + coerce('scaleratio'); + coerce('hoverdistance', 20); + + // Line styling + traceOut.line = { + color: traceIn.line && traceIn.line.color ? traceIn.line.color : defaultColor, + width: traceIn.line && traceIn.line.width ? traceIn.line.width : 1, + dash: traceIn.line && traceIn.line.dash ? traceIn.line.dash : 'solid', + shape: traceIn.line && traceIn.line.shape ? traceIn.line.shape : 'linear', + smoothing: traceIn.line && traceIn.line.smoothing ? traceIn.line.smoothing : 1, + simplify: traceIn.line && traceIn.line.simplify !== undefined ? traceIn.line.simplify : true + }; + + // Hover and interaction - let the plots module handle hoverinfo defaults + // traceOut.hoverinfo will be set by Lib.coerceHoverinfo in plots.js + traceOut.hovertemplate = traceIn.hovertemplate; + + // Text + traceOut.text = traceIn.text; + traceOut.textposition = traceIn.textposition || 'middle center'; + + // Use Lib.coerceFont to set textfont properly + Lib.coerceFont(coerce, 'textfont', layout.font); + + coerce('selected.line.color'); + coerce('selected.line.width'); + coerce('selected.textfont.color'); + coerce('unselected.line.color'); + coerce('unselected.line.width'); + coerce('unselected.textfont.color'); + + // Set the data length + traceOut._length = len; +}; \ No newline at end of file diff --git a/src/traces/scatterquiver/event_data.js b/src/traces/scatterquiver/event_data.js new file mode 100644 index 00000000000..faecde95abb --- /dev/null +++ b/src/traces/scatterquiver/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[pointNumber]; + out.v = trace.v[pointNumber]; + out.pointNumber = pointNumber; + out.trace = trace; +}; diff --git a/src/traces/scatterquiver/hover.js b/src/traces/scatterquiver/hover.js new file mode 100644 index 00000000000..d786ea3afc3 --- /dev/null +++ b/src/traces/scatterquiver/hover.js @@ -0,0 +1,75 @@ +'use strict'; + +var Lib = require('../../lib'); +var Fx = require('../../components/fx'); +var Registry = require('../../registry'); + +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); + + // Find the closest arrow base point to the hover point + var minDistance = Infinity; + var closestPoint = null; + var closestIndex = -1; + + // Each cd[i] is a calcdata point object with x/y + for(var i = 0; i < cd.length; i++) { + var cdi = cd[i]; + if(cdi.x === undefined || cdi.y === undefined) continue; + + var px = xa.c2p(cdi.x); + var py = ya.c2p(cdi.y); + + var distance = Math.sqrt((xpx - px) * (xpx - px) + (ypx - py) * (ypx - py)); + + if(distance < minDistance) { + minDistance = distance; + closestPoint = cdi; + closestIndex = i; + } + } + + var maxHoverDist = pointData.distance === Infinity ? Infinity : (trace.hoverdistance || 20); + if(!closestPoint || minDistance > maxHoverDist) return; + + // Create hover point data with proper label values and spikeline support + var hoverPoint = { + x: closestPoint.x, + y: closestPoint.y, + u: trace.u ? trace.u[closestIndex] : undefined, + v: trace.v ? trace.v[closestIndex] : undefined, + text: Array.isArray(trace.text) ? trace.text[closestIndex] : trace.text, + name: trace.name || '', + trace: trace, + index: closestIndex, + // Label values for formatting + xLabelVal: closestPoint.x, + yLabelVal: closestPoint.y, + uLabelVal: trace.u ? trace.u[closestIndex] : undefined, + vLabelVal: trace.v ? trace.v[closestIndex] : undefined, + // Spikeline support + xa: pointData.xa, + ya: pointData.ya, + x0: closestPoint.x, + x1: closestPoint.x, + y0: closestPoint.y, + y1: closestPoint.y, + distance: minDistance, + spikeDistance: minDistance, + curveNumber: trace.index, + color: trace.line ? trace.line.color : 'blue' + }; + + // Set hover text + var hovertext = trace.hovertext || trace.text; + if(hovertext && hovertext[closestIndex]) { + hoverPoint.hovertext = hovertext[closestIndex]; + } + + return [hoverPoint]; +}; \ No newline at end of file diff --git a/src/traces/scatterquiver/index.js b/src/traces/scatterquiver/index.js new file mode 100644 index 00000000000..b476090cc53 --- /dev/null +++ b/src/traces/scatterquiver/index.js @@ -0,0 +1,31 @@ +'use strict'; + +module.exports = { + moduleType: 'trace', + name: 'scatterquiver', + basePlotModule: require('../../plots/cartesian'), + categories: [ + 'cartesian', 'svg', 'showLegend', 'scatter-like', 'zoomScale' + ], + + attributes: require('./attributes'), + supplyDefaults: require('./defaults'), + calc: require('./calc'), + plot: require('./plot'), + style: require('./style'), + styleOnSelect: require('../scatter/style').styleOnSelect, + hoverPoints: require('./hover'), + eventData: require('./event_data'), + selectPoints: require('./select_points'), + animatable: true, + + meta: { + description: [ + 'The scatterquiver 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/scatterquiver/plot.js b/src/traces/scatterquiver/plot.js new file mode 100644 index 00000000000..87e2d754926 --- /dev/null +++ b/src/traces/scatterquiver/plot.js @@ -0,0 +1,148 @@ +'use strict'; + +var d3 = require('@plotly/d3'); + +var Registry = require('../../registry'); +var Lib = require('../../lib'); +var Drawing = require('../../components/drawing'); + +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 scatterquiver 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; + var fullLayout = gd._fullLayout; + + // 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(); + + // Update line segments + lineSegments.each(function(cdi) { + var path = d3.select(this); + + // Skip invalid points + if(cdi.x === undefined || cdi.y === undefined) { + path.attr('d', null); + return; + } + + // Compute arrow in data space + var scale = trace.scale || 1; + var scaleRatio = trace.scaleratio || 1; + var arrowScale = trace.arrow_scale || 0.2; + var angle = trace.angle || Math.PI / 12; // small default + + var u = (trace.u && trace.u[cdi.i]) || 0; + var v = (trace.v && trace.v[cdi.i]) || 0; + + var dx = u * scale * scaleRatio; + var dy = v * scale; + var barbLen = Math.sqrt((dx * dx) / scaleRatio + dy * dy); + var arrowLen = barbLen * arrowScale; + var barbAng = Math.atan2(dy, dx / scaleRatio); + + var ang1 = barbAng + angle; + var ang2 = barbAng - angle; + + var x0 = cdi.x; + var y0 = cdi.y; + var x1 = x0 + dx; + var y1 = y0 + dy; + + var xh1 = x1 - arrowLen * Math.cos(ang1) * scaleRatio; + var yh1 = y1 - arrowLen * Math.sin(ang1); + var xh2 = x1 - arrowLen * Math.cos(ang2) * scaleRatio; + var yh2 = y1 - arrowLen * Math.sin(ang2); + + // Convert to pixels + var p0x = xa.c2p(x0); + var p0y = ya.c2p(y0); + var p1x = xa.c2p(x1); + var p1y = ya.c2p(y1); + var ph1x = xa.c2p(xh1); + var ph1y = ya.c2p(yh1); + var ph2x = xa.c2p(xh2); + var ph2y = ya.c2p(yh2); + + var pathData = 'M' + p0x + ',' + p0y + 'L' + p1x + ',' + p1y + 'L' + ph1x + ',' + ph1y + 'L' + p1x + ',' + p1y + 'L' + ph2x + ',' + ph2y; + path.attr('d', pathData); + }); + + // Apply styling using Plotly's standard styling system + Drawing.lineGroupStyle(lineSegments, trace.line && trace.line.width, trace.line && trace.line.color, trace.line && trace.line.dash); + + // Handle transitions + if(transitionOpts && transitionOpts.duration > 0) { + var transition = d3.transition() + .duration(transitionOpts.duration) + .ease(transitionOpts.easing); + + lineSegments.transition(transition) + .style('opacity', 1); + } +} \ No newline at end of file diff --git a/src/traces/scatterquiver/select_points.js b/src/traces/scatterquiver/select_points.js new file mode 100644 index 00000000000..e169b1b9517 --- /dev/null +++ b/src/traces/scatterquiver/select_points.js @@ -0,0 +1,39 @@ +'use strict'; + +module.exports = function selectPoints(searchInfo, selectionTester) { + var cd = searchInfo.cd; + var xa = searchInfo.xaxis; + var ya = searchInfo.yaxis; + var selection = []; + var trace = cd[0].trace; + var i; + var segment; + var x; + var y; + + if(selectionTester === false) { // clear selection + for(i = 0; i < cd.length; i++) { + cd[i].selected = 0; + } + } else { + for(i = 0; i < cd.length; i++) { + segment = cd[i]; + // Use the start point of the arrow for selection testing + x = xa.c2p(segment[0].x); + y = ya.c2p(segment[0].y); + + if((segment[0].i !== null) && selectionTester.contains([x, y], false, i, searchInfo)) { + selection.push({ + pointNumber: segment[0].i, + x: xa.c2d(segment[0].x), + y: ya.c2d(segment[0].y) + }); + segment.selected = 1; + } else { + segment.selected = 0; + } + } + } + + return selection; +}; diff --git a/src/traces/scatterquiver/style.js b/src/traces/scatterquiver/style.js new file mode 100644 index 00000000000..deb72e21718 --- /dev/null +++ b/src/traces/scatterquiver/style.js @@ -0,0 +1,16 @@ +'use strict'; + +var d3 = require('@plotly/d3'); + +var Drawing = require('../../components/drawing'); +var Lib = require('../../lib'); + +module.exports = function style(gd, calcTrace) { + if(!calcTrace || !calcTrace.length || !calcTrace[0]) return; + + var trace = calcTrace[0].trace; + var s = d3.select(gd).selectAll('g.trace' + trace.uid); + + s.selectAll('path.js-line') + .call(Drawing.lineGroupStyle, trace.line || {}); +}; diff --git a/test/plot-schema.json b/test/plot-schema.json index fa9a2fff787..6f607a1157f 100644 --- a/test/plot-schema.json +++ b/test/plot-schema.json @@ -79123,6 +79123,864 @@ }, "type": "scatterpolargl" }, + "scatterquiver": { + "animatable": true, + "attributes": { + "angle": { + "description": "Angle of arrowhead in radians. Default = π/9", + "dflt": 0.3490658503988659, + "editType": "calc", + "max": 1.5707963267948966, + "min": 0, + "valType": "number" + }, + "arrow_scale": { + "description": "Value multiplied to length of barb to get length of arrowhead. Default = 0.3", + "dflt": 0.3, + "editType": "calc", + "max": 1, + "min": 0, + "valType": "number" + }, + "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" + }, + "customdatasrc": { + "description": "Sets the source reference on Chart Studio Cloud for `customdata`.", + "editType": "none", + "valType": "string" + }, + "hoverdistance": { + "description": "Maximum distance (in pixels) to look for nearby arrows on hover.", + "dflt": 20, + "editType": "calc", + "min": -1, + "valType": "number" + }, + "hoverinfo": { + "arrayOk": true, + "description": "Determines which trace information appear 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" + }, + "hoverinfosrc": { + "description": "Sets the source reference on Chart Studio Cloud for `hoverinfo`.", + "editType": "none", + "valType": "string" + }, + "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" + ] + }, + "alignsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `align`.", + "editType": "none", + "valType": "string" + }, + "bgcolor": { + "arrayOk": true, + "description": "Sets the background color of the hover labels for this trace", + "editType": "none", + "valType": "color" + }, + "bgcolorsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `bgcolor`.", + "editType": "none", + "valType": "string" + }, + "bordercolor": { + "arrayOk": true, + "description": "Sets the border color of the hover labels for this trace.", + "editType": "none", + "valType": "color" + }, + "bordercolorsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `bordercolor`.", + "editType": "none", + "valType": "string" + }, + "editType": "none", + "font": { + "color": { + "arrayOk": true, + "editType": "none", + "valType": "color" + }, + "colorsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `color`.", + "editType": "none", + "valType": "string" + }, + "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" + }, + "familysrc": { + "description": "Sets the source reference on Chart Studio Cloud for `family`.", + "editType": "none", + "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" + }, + "linepositionsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `lineposition`.", + "editType": "none", + "valType": "string" + }, + "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" + }, + "shadowsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `shadow`.", + "editType": "none", + "valType": "string" + }, + "size": { + "arrayOk": true, + "editType": "none", + "min": 1, + "valType": "number" + }, + "sizesrc": { + "description": "Sets the source reference on Chart Studio Cloud for `size`.", + "editType": "none", + "valType": "string" + }, + "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" + ] + }, + "stylesrc": { + "description": "Sets the source reference on Chart Studio Cloud for `style`.", + "editType": "none", + "valType": "string" + }, + "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" + ] + }, + "textcasesrc": { + "description": "Sets the source reference on Chart Studio Cloud for `textcase`.", + "editType": "none", + "valType": "string" + }, + "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" + ] + }, + "variantsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `variant`.", + "editType": "none", + "valType": "string" + }, + "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" + }, + "weightsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `weight`.", + "editType": "none", + "valType": "string" + } + }, + "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" + }, + "namelengthsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `namelength`.", + "editType": "none", + "valType": "string" + }, + "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. 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, every 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" + }, + "hovertemplatesrc": { + "description": "Sets the source reference on Chart Studio Cloud for `hovertemplate`.", + "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" + }, + "idssrc": { + "description": "Sets the source reference on Chart Studio Cloud for `ids`.", + "editType": "none", + "valType": "string" + }, + "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" + }, + "line": { + "color": { + "description": "Sets the color of the arrow lines.", + "dflt": "#000", + "editType": "style", + "valType": "color" + }, + "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", + "shape": { + "description": "Determines the line shape.", + "dflt": "linear", + "editType": "plot", + "valType": "enumerated", + "values": [ + "linear", + "spline", + "hv", + "vh", + "hvh", + "vhv" + ] + }, + "simplify": { + "description": "Simplifies lines by removing nearly-overlapping points.", + "dflt": true, + "editType": "plot", + "valType": "boolean" + }, + "smoothing": { + "description": "Has an effect only if `shape` is set to *spline*. Sets the amount of smoothing.", + "dflt": 1, + "editType": "plot", + "max": 1.3, + "min": 0, + "valType": "number" + }, + "width": { + "description": "Sets the width (in px) of the arrow lines.", + "dflt": 1, + "editType": "style", + "min": 0, + "valType": "number" + } + }, + "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" + }, + "metasrc": { + "description": "Sets the source reference on Chart Studio Cloud for `meta`.", + "editType": "none", + "valType": "string" + }, + "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" + }, + "scale": { + "description": "Scales size of the arrows (ideally to avoid overlap). Default = 0.1", + "dflt": 0.1, + "editType": "calc", + "max": 1, + "min": 0, + "valType": "number" + }, + "scaleratio": { + "description": "The ratio between the scale of the y-axis and the scale of the x-axis (scale_y / scale_x). Default = null, the scale ratio is not fixed.", + "editType": "calc", + "min": 0, + "valType": "number" + }, + "selected": { + "editType": "style", + "line": { + "color": { + "description": "Sets the line color of selected points.", + "editType": "style", + "valType": "color" + }, + "editType": "style", + "role": "object", + "width": { + "description": "Sets the line width of selected points.", + "editType": "style", + "min": 0, + "valType": "number" + } + }, + "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" + }, + "stream": { + "editType": "calc", + "maxpoints": { + "description": "Sets the maximum number of points to keep on the plots from an incoming stream. If `maxpoints` is set to *50*, only the newest 50 points will be displayed on the plot.", + "dflt": 500, + "editType": "calc", + "max": 10000, + "min": 0, + "valType": "number" + }, + "role": "object", + "token": { + "description": "The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.", + "editType": "calc", + "noBlank": true, + "strict": true, + "valType": "string" + } + }, + "text": { + "anim": true, + "description": "Sets text elements associated with each (x,y) pair.", + "editType": "calc", + "valType": "data_array" + }, + "textfont": { + "color": { + "arrayOk": true, + "editType": "style", + "valType": "color" + }, + "colorsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `color`.", + "editType": "none", + "valType": "string" + }, + "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" + }, + "familysrc": { + "description": "Sets the source reference on Chart Studio Cloud for `family`.", + "editType": "none", + "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" + }, + "linepositionsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `lineposition`.", + "editType": "none", + "valType": "string" + }, + "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" + }, + "shadowsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `shadow`.", + "editType": "none", + "valType": "string" + }, + "size": { + "arrayOk": true, + "editType": "calc", + "min": 1, + "valType": "number" + }, + "sizesrc": { + "description": "Sets the source reference on Chart Studio Cloud for `size`.", + "editType": "none", + "valType": "string" + }, + "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" + ] + }, + "stylesrc": { + "description": "Sets the source reference on Chart Studio Cloud for `style`.", + "editType": "none", + "valType": "string" + }, + "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" + ] + }, + "textcasesrc": { + "description": "Sets the source reference on Chart Studio Cloud for `textcase`.", + "editType": "none", + "valType": "string" + }, + "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" + ] + }, + "variantsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `variant`.", + "editType": "none", + "valType": "string" + }, + "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" + }, + "weightsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `weight`.", + "editType": "none", + "valType": "string" + } + }, + "textposition": { + "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" + ] + }, + "textsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `text`.", + "editType": "none", + "valType": "string" + }, + "type": "scatterquiver", + "u": { + "anim": true, + "description": "Sets the x components of the arrow vectors.", + "editType": "calc", + "valType": "data_array" + }, + "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", + "line": { + "color": { + "description": "Sets the line color of unselected points.", + "editType": "style", + "valType": "color" + }, + "editType": "style", + "role": "object", + "width": { + "description": "Sets the line width of unselected points.", + "editType": "style", + "min": 0, + "valType": "number" + } + }, + "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" + } + }, + "usrc": { + "description": "Sets the source reference on Chart Studio Cloud for `u`.", + "editType": "none", + "valType": "string" + }, + "v": { + "anim": true, + "description": "Sets the y components of the arrow vectors.", + "editType": "calc", + "valType": "data_array" + }, + "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" + ] + }, + "vsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `v`.", + "editType": "none", + "valType": "string" + }, + "x": { + "anim": true, + "description": "Sets the x coordinates of the arrow locations.", + "editType": "calc+clearAxisTypes", + "valType": "data_array" + }, + "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" + }, + "xsrc": { + "description": "Sets the source reference on Chart Studio Cloud for `x`.", + "editType": "none", + "valType": "string" + }, + "y": { + "anim": true, + "description": "Sets the y coordinates of the arrow locations.", + "editType": "calc+clearAxisTypes", + "valType": "data_array" + }, + "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" + }, + "ysrc": { + "description": "Sets the source reference on Chart Studio Cloud for `y`.", + "editType": "none", + "valType": "string" + } + }, + "categories": [ + "cartesian", + "svg", + "showLegend", + "scatter-like", + "zoomScale" + ], + "meta": { + "description": "The scatterquiver 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": "scatterquiver" + }, "scattersmith": { "animatable": false, "attributes": {