-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clarify documentation for the ariaLabel channel #797
Comments
|
Ah, thank you. I'm not sure I understand the difference between a May I suggest adding "The fill, fillOpacity, stroke, strokeWidth, strokeOpacity, and opacity options can be specified as either channels or constants." |
Yes we must find a way to clarify the documentation. Currently it says
|
Part of the confusion is that options like But other options can only be channels (like Speaking for myself, it would help if there is a single table of options, with columns along these lines:
|
This would also be covered by a warning that detects when the majority (or all) of a mark’s instances were filtered because the channel values were undefined. #593 #755
Ambiguity is an inherit risk when trying to make a concise API. 🙂 We’re only able to support string constants for fill because there is a formal way to disambiguate constant values (e.g., valid CSS colors) from column names. There isn’t such a formalism for ariaLabel because it is for human consumption, i.e., it is any text. So we use the most generic interpretation, which is a column name. In other words, fill is the exception here, not ariaLabel, because we know that fill is a color. These exceptions are specifically called out in the README:
(I originally objected to having string shorthand for column names since I anticipated this sort of ambiguity and We could try to introduce a heuristic for detecting column names, but that’s also fraught because there is no strong convention. For example I considered trying to inspect the associated data, but Plot wants to be flexible in how data is represented (e.g. for columnar data) so that’s not an option. Another challenge with ariaLabel is whether you intend the label to apply to each mark instance (i.e. each svg:rect element), or to all the mark’s instances (i.e. the parent svg:g element, as the ariaDescription does). Presumably you intended later, but we envisioned ariaLabel for making the data associated with the visual representation (i.e. the meaning of the mark) accessible to screen readers which necessitates it being a channel (a per-instance property). We could instead interpret ariaLabel: string as a constant property (applying to all instances), but then this option would behave differently from all other options, which probably isn’t desirable. |
The title, href, and ariaLabel can’t be specified as constants. They can only be specified as channels. That’s why they are not listed in this sentence. Edit: I added a new sentence explaining this. Thanks for the suggestion! |
Mark options are named properties of the object you pass as the second argument to the mark constructor, such as the fill in This is described in the README here:
|
I saw that after I RTFM more carefully. Have you considered using the labels "static" vs "dynamic"? In other contexts, I would consider a If I understand correctly, OTOH, since
Instead of that, what about looking at the datum to see if there is a column named "whatever", and treating it as a string if not? |
Would you agree that the named properties which are passed as the second argument are shared by all of the mark's generated shapes (regardless of whether the option is specified as a constant or as a channel)? If so, I suggest slightly altering the README text to:
|
It will typically look the same, but the semantics, the code path, and the generated DOM are different between these two specifications. In the Whereas with In the channel case, a fill channel is present in mark.channels, mark.fill is undefined, and the fill attribute is populated on each svg:circle element in applyChannelStyles: Line 161 in 3037a2a
Whereas in the constant case, no fill channel is present in mark.channels, but there is a mark.fill, and the fill attribute is populated on the parent svg:g element in applyIndirectStyles: Line 254 in 3037a2a
You can see this reflected in the generated SVG.
That is what I was referring to here:
The point being, if we want to support data being things like Apache Arrow tables, or other columnar representations, you can’t look at the datum associated with a particular instance because it might not exist (i.e., an object representing the row is never instantiated). We could try to support column inspection, but it would need to handle all the variety of ways data can be specified, and I would like to avoid opening that particular box. Also, I think it’s nice that you can look at a Plot specification and say that
Yeah, I think that’s an improvement, although I’m not 100% sure about the word “derived”… and also you can have channels that have the same value for every instance (the |
Ah, ok. Maybe that was a bad example. Maybe I didn't compare DOMs. I understand that the code path and efficiency would probably be different just due to the complexities in accepting a function as input and calling a function for each datum. I think I understand the semantic difference, at least what is implied by specifying a computation or formula. To my naive eye I'd consider them functionally equivalent because I'd expect them both to result in all marks using the hard-coded constant There are probably nuances of data science / data visualization that I'm missing.
There are probably better words. Maybe "resulting values"? I was thinking of it in terms of "base values" (the input data) and "derived values" (values that are computed from the base data, or the values that result from the mapping that is performed). |
Yes, these are identical because the former is promoted to the latter here: Line 16 in 2cb0639
|
Since the README says "All marks support the following optional channels:", I'm assuming that
ariaLabel
is supposed to work forrect
marks.However, IME adding
ariaLabel
causes the marks to not render at all. There aren't even<rect>
elements in the source anymore that I can see.I've added an explicit
z
channel as recommended in the README.ariaDescription
works as expected.There are no errors in the dev console.
Is this a bug, or am I doing something incorrectly?
To repeat
rect
plot and confirm that the marks plot as expected.ariaLabel
as an option. The marks disappear.Example: https://observablehq.com/@kentr/rect-mark-observable-plot
The text was updated successfully, but these errors were encountered: