Open echo66 opened 9 years ago
Hey @echo66 ,
Sorry for the late reply,
I don't really see what could the use case for that feature, I mean from an application point of view.
As presented, it looks like a very particular need we could handle quite easily without the need of modifying the library.
Something like this (which is just a matter of creating a new array, each datum
would be passed by reference with no duplication) would work quite well in my opinion:
const visibleData = data.filter((datum) => { /* ... */ });
layer.data = visibleData;
layer.render();
layer.update();
It could also be done without the need to modify the layer, but just by overriding your shape to handle a given data attribute with some visibility: hidden
style.
Could explain your application use case ? Thanks
Greetings!
It would be nice to control the visibility of the shapes with a filter function. For example, the updateShapes method could accept an optional argument, the filter function.
Use case: You have a list of segments, each one can be a silent or non-silent segment. Instead of cloning the list and associating the clone with the Layer.data field, you could use the same list and a filter function.
I changed the Layer class in order to support this feature. I added an additional argument in render, update and updateShapes methods, filterFn.
In the render function, I have the following change:
In the update function:
In the updateShapes function: