Conversation
mbostock
left a comment
There was a problem hiding this comment.
Hmm, what is the motivation for this PR? Why is it useful to set data attributes in this context? Is it more than “advanced” uses? Is this desirable enough to merit a first-class feature, rather than say a render transform to set attributes?
And how often is it that you want to set a whole set of data attributes, derived from an object, rather than being more specific about what attributes you choose? It feels unlike Plot to have a channel whose values are objects, and allow different attributes if the objects are not homogeneous. And likewise there’s the complexity of dealing with primitive values (and the arbitrariness of data-value, and pulling out the channel label, etc.).
I’m wondering about a more precise design where you can set individual data attributes, say like so for data-name:
Plot.dot(athletes, {x: "weight", y: "height", dataset: {name: "name"}})Or like so, which I think I prefer:
Plot.dot(athletes, {x: "weight", y: "height", "data-name": "name"})The latter would require extracting the data-* options out of the mark options, but that seems doable. But in any case, I’d like to hear the rationale to justify adding such a feature.
|
I wanted to allow a trace back to the original data points, that is not expressed visually but allows machine inspection. This would be useful, for example, to implement custom interactions (say, to click on a geo feature and select all the values from that feature); it's the primary use case I had in mind. I agree with your comments though (both about motivation and implementation). |
|
Would D3’s approach of setting |
|
Setting An advantage of |
|
Querying with CSS is also available via the className and ariaLabel options. 👍 |
Uh oh!
There was an error while loading. Please reload this page.