Growing each line of a multi_line plot using streaming data

I have a figure.multi_line plot in which the number of lines is constant, but each time new streaming data comes in, I want to append a new point to each of the lines. For instance:

# initial state, no data
cds.data = {
    'x': [
      [],
      [],
      []
    ],
    'y': [
      [],
      [],
      []
    ]
}
# after incorporating two points for each line
cds.data = {
    'x': [
      [1,2],
      [3,5],
      [5,3]
    ],
    'y': [
      [2,7],
      [7,4],
      [4,5]
    ]
}

This is a form of appending that cannot be achieved directly by using cds.stream(...), which would instead append to the outer lists cds.data['x'] and cds.data['y'].

So, I manipulated the cds.data field directly, I can confirm that the cds.data structure is as expected, but I don’t see anything showing up in the plot.

Is there some best practice for doing this kind of thing?

Thanks in advance!

I am afraid there is not currently any API for this specialized kind of streaming involving sub-lists, so the only option will be to re-assign all the data, with the new points appended to each sub-list. I’d encourage you to open a GitHub Issue to make a feature request for this kind of stream (please include as much motivating use-case detail as possible).

Regarding

So, I manipulated the cds.data field directly, I can confirm that the cds.data structure is as expected, but I don’t see anything showing up in the plot.

We need to see what exact steps you actually attempted (i.e. a complete Minimal Reproducible Example) to be able to advise.

1 Like

Sure, thanks for the suggestion. I’ll whip up a minimal reproducible example and open an issue with it.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.