Select nested data keys from a dataset for plots #1050
Answered
by
mbostock
captain-yoshi
asked this question in
Q&A
-
Is there a way to select a child or nested children like the example below ? Or do I have to modify my dataset to only have only one level. Plot.plot({
marks: [
Plot.boxY(data, {x: "query.request", y: "metrics.time"})
]
}) |
Beta Was this translation helpful? Give feedback.
Answered by
mbostock
Sep 15, 2022
Replies: 1 comment 1 reply
-
Yes, you can use a function accessor: Plot.plot({
marks: [
Plot.boxY(data.flatMap(d => d.metrics.time.map(t => ({request: d.query.request, time: t}))), {x: "request", y: "time"})
]
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
captain-yoshi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, you can use a function accessor:
{x: d => d.query.request, y: d => d.metrics.time}
. Though I think in your case you may need to flatten your data, as thed.metrics.time
is an array of samples and Plot.boxY will expect a single number. That might look like this…