Replies: 2 comments 1 reply
|
The simple answer is… no. I also note that the transform you're applying disregards the facets, is that on purpose? |
1 reply
|
I've settled on a simple caching approach, but I might be overlooking something: I am now passing the data twice (to retrieve a datum at a certain index) to both an inner caching ( const RangeA = Plot.ruleY(data, {
...cachedTransform({
data, // How to access the parent data inside the cached transform?
cache,
x: "x",
y: 0,
fx: (d) => fx(d.key),
fy: (d) => fy(d.key),
dy: 5,
insetLeft: 10,
insetRight: 10,
stroke: "red",
strokeWidth: 1,
shapeRendering: "crispEdges"
})
});
// Second ruler re-uses the cached results
const RangeB = Plot.ruleY(data, {
...cachedTransform({
data,
cache,
x: "x",
y: 0,
fx: (d) => fx(d.key),
fy: (d) => fy(d.key),
dy: 10,
strokeWidth: 1,
stroke: "black",
marker: "circle"
})
}); |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Say we have an expensive selection/mapping/transformation that needs to be re-used between marks (example notebook):
This will calculate the transform twice, once per mark. Now we could simply apply the filtering/mapping beforehand on the data array or provide a custom render function with some caching logic, but I would like to see if there is a more idiomatic way to re-use Plot's built-in transforms when the underlying data remains the same.
All reactions