danchitnis / webgl-plot

A high-Performance real-time 2D plotting library based on native WebGL
https://danchitnis.github.io/webgl-plot-examples/vanilla/
MIT License
576 stars 33 forks source link

gaps #54

Closed vinnitu closed 4 years ago

vinnitu commented 4 years ago

Hi

I need to show gaps on the graph.

Now I use dygraphs for this, but have a high CPU usage (that is why I want webgl)

Here is an example of how to define unknown serie values (null) and missing values (NaN) http://dygraphs.com/gallery/#g/independent-series

My own implementation uses set of gl.LINES instead of gl.LINE_STRIP

I convert serie data like this [1, 2, 3, null, 5, 6, NaN, 7, 8] -> [(1, 2), (2, 3), (3, 5), (5, 6), (7, 8)]

What do you think about it?

danchitnis commented 4 years ago

I understand your point about having a gap in the plotting to show null data. I have encountered these before in real-time instrumentation. One easy way is to have multiple lines. Notice that you want to minimize the size of the array which you send to the GPU. Let me think about. I will come back to you on this.

danchitnis commented 4 years ago

In theory, Webgl-plot (and indeed Webgl) accepts a Float32 array, and then converts it to a line. You cannot have a null value in the array. All of the members of the array are parts of the memory, and there is always a value in the memory! Whenever you have a null value in your datapoint then is it probably due to poor handling of the incoming data. This will be responsibility of the end-user to clean-up their data.

Having said that in cases when a data point is wrong (only the user knows that), there can be an indication, for example a red line, or a red box, indicating these data ranges are wrong. No matter what method you choose, there will be a reduction in the performance especially on large data sets.