-
Notifications
You must be signed in to change notification settings - Fork 121
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
feat(a11y): allow user to add optional semantic meaning to goal/gauge charts #1218
Conversation
packages/charts/src/chart_types/goal_chart/renderer/canvas/connected_component.tsx
Outdated
Show resolved
Hide resolved
packages/charts/src/components/accessibility/goal_semantic_description.tsx
Outdated
Show resolved
Hide resolved
stories/goal/25_goal_semantic.tsx
Outdated
<Goal | ||
id="spec_1" | ||
subtype={subtype} | ||
base={0} | ||
target={260} | ||
actual={170} | ||
// doesn't mess with canvas_renderers.ts | ||
// @ts-ignore | ||
bands={bandsWithSemantics.flat().filter((val) => typeof val === 'number')} | ||
ticks={[0, 50, 100, 150, 200, 250, 300]} | ||
tickValueFormatter={({ value }: BandFillColorAccessorInput) => String(value)} | ||
bandFillColor={({ value }: BandFillColorAccessorInput) => semanticBandFillColor(value)} | ||
labelMajor="Revenue 2020 YTD " | ||
labelMinor="(thousand USD) " | ||
centralMajor="170" | ||
centralMinor="" | ||
config={{ angleStart: Math.PI, angleEnd: 0 }} | ||
semanticValues={bandsWithSemantics} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure where to leave this comment but I figured here is as good a place as any.
If a user is passing in semantic data, I don't think they should also have to send in the old bands
prop. Here it looks like you're able to deduce it programmatically so it'd be nice to do that for the consumer.
So I'm not sure if this would be best as a new prop like you have it, or whether to allow a different shape of data to be passed into bands
so that you can pass in either type of data (semantic or not) into one prop. (I would love to see it all in one prop but that's just a personal preference.)
jenkins test this |
As it's not a review comment, we can't set it to "resolve", so doing it via a reply (we looked at it together) |
stories/goal/25_goal_semantic.tsx
Outdated
const subtype = GoalSubtype.Goal; | ||
|
||
export const Example = () => { | ||
const bandsWithSemantics = ['freezing', 'chilly', 'brisk']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! Nit: the variable could be renamed to bandLabels
, and semanticBandFillColor
to bandFillColor
, though it's not significant enough for using electricity for a new test run, only worth doing if there's some other change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if instead of
<dt>200</dt><dd>freezing</dd>
<dt>250</dt><dd>chilly</dd>
<dt>300</dt><dd>brisk</dd>
it'd be better to use
<dt>0 - 200</dt><dd>freezing</dd>
<dt>200 - 250</dt><dd>chilly</dd>
<dt>250 - 300</dt><dd>brisk</dd>
as the bands/colors render as ranges. The "from" value is the previous band value, except for the lowest band value, where it's the lowest value in the ticks
array.
The visualization itself does not show band label texts, while the colors represent intervals, not single values. What do you think @rshen91 @markov00 @myasonik?
++ I like it! |
I also think this is fine! 0bfdec4 for changes - thanks! |
In an effort to provide value to visual and screen reader users alike, I wonder if it makes sense to expose the semantic meaning in a tooltip over the ranges as well? Color understanding isn't universal so having it explicitly defined for many users may be helpful. |
Actually I'm seeing that the bulletViewModel includes a lowestValue. Is this value good for this case? Thanks! |
Yes @rshen91 it's better than my suggestions, good call! |
I agree @myasonik with showing band info in a visual channel. It'd need some design, eg.
So,
the tooltip with tbe band names could be a separate PR. Pls. share if it has some negatives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
# [32.0.0](v31.1.0...v32.0.0) (2021-07-12) ### chore * **license:** elastic license 2.0 ([#1242](#1242)) ([67fa0a3](67fa0a3)), closes [#1213](#1213) ### Features * **a11y:** allow user to add optional semantic meaning to goal/gauge charts ([#1218](#1218)) ([87629e2](87629e2)), closes [#1161](#1161) ### BREAKING CHANGES * **license:** the library is released now under Elastic License 2.0 and SSPL
🎉 This PR is included in version 32.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 32.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [31.2.0](Metrika-Inc/metrika-charts@v31.1.0...v31.2.0) (2021-07-21) ### Bug Fixes * **heatmap:** correctly place x axis text in all cases ([1cf37d4](Metrika-Inc/metrika-charts@1cf37d4)) * **xychart:** when axis title is on top, it correctly lines up with axis labels vertically ([12839b5](Metrika-Inc/metrika-charts@12839b5)) ### Features * **a11y:** allow user to add optional semantic meaning to goal/gauge charts ([elastic#1218](https://github.com/Metrika-Inc/metrika-charts/issues/1218)) ([87629e2](Metrika-Inc/metrika-charts@87629e2)), closes [elastic#1161](https://github.com/Metrika-Inc/metrika-charts/issues/1161) * **heatmap:** added the ability to customize the position and rotation of the x axis labels ([8280b64](Metrika-Inc/metrika-charts@8280b64)) * **heatmap:** hard code x-axis labels sideways ([26ebe5e](Metrika-Inc/metrika-charts@26ebe5e)) * **xychart:** basic customization support for putting the axis title on top of the chart ([79865ba](Metrika-Inc/metrika-charts@79865ba)) * **xychart:** hard code left axis label to top of graph ([f10ff72](Metrika-Inc/metrika-charts@f10ff72)) * **xychart:** the title for the right axis can now also go on top ([b2087a1](Metrika-Inc/metrika-charts@b2087a1))
For reviewers, please review #1174 first!
Summary
The
bandLabels
prop is now added toGoal
charts. This is an optional prop.For example, users can pass band labels with semantic values associated with each band:
['chilly', 'brisk', 'warm']
.Details
The idea of creating a separate prop on the Goal component was to not interfere with the rendering logic that the
bands
prop handles.Issues
Closes #1161
Checklist
packages/charts/src/index.ts
(and stories only import from../src
except for test data & storybook)