How can I write a CustomJS function to add more circles to a circle glyph? I tried circle_data_source.data.x.push(...)
(and similarly for y
), but this didn’t work.
@aroberts If you update the CDS the way you show, then you need to apply an .change.emit()
to the CDS. However, I believe it is not recommended to update a CDS this way (with change.emit()
). Either one updates the whole .data at once or, as in your case, the recommended way of appending data to a CDS is the use of stream
.
CustomJS(
args = {'source': source},
code = '''
const data = {
'x' : [Math.random() * 10],
'y' : [Math.random() * 10],
}
source.stream(data);
// or - not recommended
//source.data.x.push(Math.random() * 10);
//source.data.y.push(Math.random() * 10);
//source.change.emit();
'''
)
1 Like
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.