Can't change number of points displayed in a scattergl plot #204
Description
If I run the app below and change the number of points plotted from the default value, any reduction from the initial value of 10 results in an empty trace being drawn (but with invisible points that can be hovered over), and any increase results in the first 10 points being plotted and the rest being plotted invisibly. 10 is used as a default example, I can change init_n_points
to any number and it still shows the same behaviour relative to that number.
With init_n_points=10
, when first opening page:
Changing the number of points to 9 and then clicking the button (hovering over an invisible point):
Changing to 200 (hovering over an invisible point):
The issue disappears if I remove the marker symbol (making me think it's related to #203) or if you change the type to Scatter
instead of Scattergl
.
As an aside, I initially thought that this was caused by #181 as I was seeing that error in conjunction with this effect (I see I forgot to mention that when I reported it). But when I look in the console for this app (which is a much simplier example based on the more complicated app that was showing the RangeError
s) I don't see that error, although when reducing the number of points from the initial value I see [.Offscreen-For-WebGL-00000000063E4360]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 0
import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html
from plotly import graph_objs
import random
app = dash.Dash()
init_n_points = 10
app.layout = html.Div(children=[
dcc.Input(id='input-number', inputmode='numeric', value=init_n_points),
html.Button(children='click', id='button'),
dcc.Graph(
id='example-graph',
)
])
@app.callback(
Output('example-graph', 'figure'),
[Input('button', 'n_clicks')],
[State('input-number', 'value')]
)
def f(n_clicks, n_points):
n_points = int(n_points)
tr = graph_objs.Scattergl(
x=[random.random() for _ in range(n_points)],
y=[random.random() for _ in range(n_points)],
mode='markers',
marker={'symbol': 'x'},
)
fig = {'data': [tr], 'layout': {}}
return fig
if __name__ == '__main__':
app.run_server(debug=True)