GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing plotly.com — Function reference in JavaScript Common parameters
Plotly.newPlotDraws a new plot in an<div> element, overwriting any existing plot. To update an existing plot in a <div>, it is much more efficient to use Plotly.react than to overwrite it.
After plotting, the data or layout can always be retrieved from the <div> element in which the plot was drawn:
Plotly.reactPlotly.react has the same signature as Plotly.newPlot above, and can be used in its place to create a plot, but when called again on the same <div> will update it far more efficiently than Plotly.newPlot, which would destroy and recreate the plot. Plotly.react is as fast as Plotly.restyle/Plotly.relayout documented below.
Important Note: In order to use this method to plot new items in arrays under data such as x or marker.color etc, these items must either have been added immutably (i.e. the identity of the parent array must have changed) or the value of layout.datarevision must have changed.
Plotly.restyleThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.An efficient means of changing attributes in the data array in an existing plot. When restyling, you may choose to have the specified changes affect as many traces as desired. The update is given as a single object and the traces that are affected are given as a list of traces indices. Note, leaving the trace indices unspecified assumes that you want to restyle all the traces.
See the Pen Plotly.restyle by plotly (@plotly) on CodePen. The above examples have applied values across single or multiple traces. However, you can also specify arrays of values to apply to traces in turn.
See the Pen Plotly.restyle Traces in Turn by plotly (@plotly) on CodePen. In restyle, arrays are assumed to be used in conjunction with the trace indices provided. Therefore, to apply an array as a value, you need to wrap it in an additional array. For example:
See the Pen Plotly.restyle Arrays by plotly (@plotly) on CodePen. The term attribute strings is used above to mean flattened (e.g., {marker: {color: 'red'}} vs. {'marker.color': red}). When you pass an attribute string to restyle inside the update object, it’s assumed to mean update only this attribute. Therefore, if you wish to replace and entire sub-object, you may simply specify one less level of nesting.
See the Pen Plotly.restyle Attribute strings by plotly (@plotly) on CodePen. Finally, you may wish to selectively reset or ignore certain properties when restyling. This may be useful when specifying multiple properties for multiple traces so that you can carefully target what is and is not affected. In general `null` resets a property to the default while `undefined` applies no change to the current state.
See the Pen null vs. undefined in Plotly.restyle by plotly (@plotly) on CodePen. Plotly.relayoutThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.An efficient means of updating the layout object of an existing plot. The call signature and arguments for relayout are similar (but simpler) to restyle. Because there are no indices to deal with, arrays need not be wrapped. Also, no argument specifying applicable trace indices is passed in.
See the Pen Plotly.relayout by plotly (@plotly) on CodePen. Plotly.updateThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.An efficient means of updating both the data array and layout object in an existing plot, basically a combination of Plotly.restyle and Plotly.relayout.
See the Pen Plotly.update by plotly (@plotly) on CodePen. Plotly.validatePlotly.validate allows users to validate their input data array and layout object. This can be done on the data array and layout object passed into Plotly.newPlot or on an updated graphDiv with Plotly.validate(graphDiv.data, graphDiv.layout).
Plotly.makeTemplatePlotly.makeTemplate copies the style information from a figure. It does this by returning a template object which can be passed to the layout.template attribute of another figure.
Plotly.validateTemplatePlotly.validateTemplate allows users to Test for consistency between the given figure and a template,
either already included in the figure or given separately. Note that not every issue identified here is necessarily
a problem, it depends on what you're using the template for.
Plotly.addTracesThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.This allows you to add new traces to an existing graphDiv at any location in its data array. Every graphDiv object has a data component which is an array of JSON blobs that each describe one trace. The full list of trace types can be found in the Full Reference.
See the Pen Plotly.addtraces by plotly (@plotly) on CodePen. Plotly.deleteTracesThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.This allows you to remove traces from an existing graphDiv by specifying the indices of the traces to be removed.
See the Pen Plotly.deleteTraces by plotly (@plotly) on CodePen. Plotly.moveTracesThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.This allows you to reorder traces in an existing graphDiv. This will change the ordering of the layering and the legend.
All traces defined in graphDiv are ordered in an array. They are drawn one by one from first to last. Each time a new layer or trace is drawn to the canvas the new trace is drawn directly over the current canvas, replacing the colors of the traces and background. This algorithm to image stacking/drawing is known as the Painter's Algorithm. As its name implies the Painter's Algorithm is typically the manner in which a painter paints a landscape, starting from objects with the most perspective depth and progressively moving forward and layering over the background objects.
See the Pen Plotly.moveTraces by plotly (@plotly) on CodePen. Plotly.extendTracesThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.This allows you to add data to traces in an existing graphDiv.
See the Pen Plotly.extendTraces by plotly (@plotly) on CodePen. Plotly.prependTracesThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.This allows you to prepend data to an existing trace graphDiv.
Plotly.addFramesThis function has comparable performance toPlotly.react and is faster than redrawing the whole plot with Plotly.newPlot.This allows you to add animation frames to a graphDiv. The group or name attribute of a frame can
be used by Plotly.animate in place of a frame object (or array of
frame objects).
See example here.
Plotly.animateAdd dynamic behaviour to plotly graphs withPlotly.animate.
See the Pen Plotly.animate by plotly (@plotly) on CodePen. Plotly.purgeUsingpurge will clear the div, and remove any Plotly plots that have been placed in it.
See the Pen Plotly.purge by plotly (@plotly) on CodePen. Plotly.toImagetoImage will generate a promise to an image of the plot in data URL format.
format takes one of png, jpeg, webp, svg, or full-json. The default is png.
full-json returns the figure as JSON instead of a rendered image. The JSON holds the data, layout, frames, and config, with every default value filled in.
Set imageDataOnly to true to get the raw JSON string rather than a data:application/json URL.
See the Pen Plotly.toImage by plotly (@plotly) on CodePen. Plotly.downloadImagedownloadImage will trigger a request to download the image of a Plotly plot.
format takes the same values as Plotly.toImage.
See the Pen Plotly.toImage by plotly (@plotly) on CodePen. Using eventsPlots emit events prefixed withplotly_ when clicked or hovered over, and event handlers can be bound to events using the on method that is exposed by the plot div object. For more information and examples of how to use Plotly events see: https://plotly.com/javascript/plotlyjs-events/.
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |