You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initializing plots with empty traces (traces are defined and styled but have no data yet) throws an error when using scattergl for the traces' type.
This behavior is not consistent with how Plotly acts when using scatter, which allows the user to do this.
An error also results when using Plotly.addTraces with scattergl trace that has no data present, which is also inconsistent with how Plotly behaves when the trace is of type scatter.
It seems to be due to an assumption that the traces always have some data in plotly.js/src/components/errorbars/index.js`, but I do not understand enough of the code base to create a pull request, hence this issue.
Details
In some situations I find it helpful to initialize traces with empty arrays for their data prior to adding values through Plotly.extendTraces().
For example, before data starts arriving, we might wish to style the traces, or ensure that the traces are in some particular order.
This behavior appears to be supported in the SVG case (at least for type: scatter), but results in an error when using GL version.
The following works, allowing one to define the traces without adding data, and later extend them see CodePen demo
vardata=[{y: [],type: 'scattergl'}];varlayout={title: 'Graph Title'};// This throws an error (Plotly 1.21.3)Plotly.newPlot(graphDiv,data,layout);
From the console, we get:
Uncaught TypeError: Cannot set property 'trace' of undefined
at Object.errorBars.calcFromTrace (eval at <anonymous> (bundle.js:3613), <anonymous>:96224:27)
at LineWithMarkers.proto.updateFancy (eval at <anonymous> (bundle.js:3613), <anonymous>:147929:31)
at LineWithMarkers.proto.update (eval at <anonymous> (bundle.js:3613), <anonymous>:147793:14)
at Object.createLineWithMarkers [as plot] (eval at <anonymous> (bundle.js:3613), <anonymous>:148148:10)
at Scene2D.proto.updateTraces (eval at <anonymous> (bundle.js:3613), <anonymous>:124457:42)
at Scene2D.proto.plot (eval at <anonymous> (bundle.js:3613), <anonymous>:124336:10)
at Object.plotGl2d [as plot] (eval at <anonymous> (bundle.js:3613), <anonymous>:123933:15)
at drawData (eval at <anonymous> (bundle.js:3613), <anonymous>:109268:32)
at Object.lib.syncOrAsync (eval at <anonymous> (bundle.js:3613), <anonymous>:106093:15)
at Object.Plotly.plot (eval at <anonymous> (bundle.js:3613), <anonymous>:109312:9)
It would appear that the issue originates in the assumption that the initial traces will always contain some data, in plotly.js/src/components/errorbars/index.js:
...Which is in turn called because Plotly determines that these traces are fancy (I apologize but I could not find reference to what qualifies a trace as fancy in the documentation and was unable to assess what was going on without delving deeply into the code).
Requested Fix
It would be nice if I could still initialize empty traces when using the GL charts.
The text was updated successfully, but these errors were encountered:
Summary
scattergl
for the traces' type.scatter
, which allows the user to do this.Plotly.addTraces
withscattergl
trace that has no data present, which is also inconsistent with how Plotly behaves when the trace is of typescatter
.Details
In some situations I find it helpful to initialize traces with empty arrays for their data prior to adding values through
Plotly.extendTraces()
.For example, before data starts arriving, we might wish to style the traces, or ensure that the traces are in some particular order.
This behavior appears to be supported in the SVG case (at least for
type: scatter
), but results in an error when using GL version.The following works, allowing one to define the traces without adding data, and later extend them see CodePen demo
If we use
type: 'scattergl'
instead, it throws an errorFrom the console, we get:
For verification that it works when initial data is supplied, see this CodePen demo
It would appear that the issue originates in the assumption that the initial traces will always contain some data, in
plotly.js/src/components/errorbars/index.js
:...Which is in turn called because Plotly determines that these traces are fancy (I apologize but I could not find reference to what qualifies a trace as fancy in the documentation and was unable to assess what was going on without delving deeply into the code).
Requested Fix
It would be nice if I could still initialize empty traces when using the GL charts.
The text was updated successfully, but these errors were encountered: