feat: Ability to draw contours?
Is ability to draw contours will be available anytime in the near future?
No but feel free to take a stab at it.
@flekschas I am open to spending some of my free time to add support for this, however I would appreciate some guidance/ideas on how to achieve this considering your context of the codebase you have. There is multiple means in which this support can be added.
When you are talking about contour I suppose you are talking about to add a simple black thin contour to any point, as you see in this bokeh scatter plot
With your component is just a little complicated to distinguish the points because not exist any contour arount the points
as you see. Add this contour would be a good feature in my opinion:
@masalinas I think you're talking about a different feature: point borders. Contours are something different. But @insertmike also didn't provide much context on what he would like to accomplish so I may be wrong here. @insertmike can you clarify when you have the chance?
E.g:
In your example, you can make the points easier to perceive by reducing the point size and/or opacity.
@insertmike If you're thinking of contour lines as in the example above, here's a rough list of things that you'd have to work on. But basically, I would approach this feature similar to the line connection feature in regl-scatterplot. I.e., it should be optional, and have minimal impact on the library performance.
Rough work items that come to mind:
- Determine an algorithm for efficiently computing the contour lines.
- Turn the algorithm into a worker similar to the spline-curve (see https://github.com/flekschas/regl-scatterplot/blob/master/src/spline-curve-worker.js and https://github.com/flekschas/regl-scatterplot/blob/master/src/spline-curve.js)
- Create a line render called
contoursininit()similar topointConnections - Add a function called
setContours()that calls the worker to compute the contour lines. (similar tosetPointConnections()) - Add a setting and option called
showContourstoregl-scatterplot(similar toshowPointConnections) - Add logic to the
publicDraw()function for drawing contour - Add logic to the render function around line
3530for drawing the contour lines by calledcontours.draw(). Keep in mind that during transitions, the contour lines should not be redrawn as lines cannot be interpolated at the moment. See howpointConnectionsis handled in that function. - Add cleanup logic to the
destroy()function - Add an example to
./example. The example should be simple but allow us to easily test the performance with different number of points. - Add tests
Being able to render contour lines would be a fantastic feature. But implementing it is a bit involved. If you want to take a stab at it, please feel free to set up a branch and PR where we can communicate about implementation details. Feel free to ask questions often. It's always best to get answers first before jumping into the implementation phase :)
@flekschas I tried to reduce the opacity like this, but as you see
You have to zoom in a lot to really start to perceive the contours. Can't you change that color outline from black to something that stands out?
@masalinas I'm not really sure what the issue is. Maybe you can open a new issue outline the issue in more detail. The issue at hand is not about point borders but about contour lines.