Repository navigation
[Insights] Add summaries to the headline charts #107750
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2ab2cff
Add summaries to Insights headline charts
luacmartins a21f55e
Stop requesting headline summaries explicitly
luacmartins d79eac3
Clarify Insights headline skeleton sizing and loading
luacmartins 4efd372
Merge remote-tracking branch 'origin/main' into cmartins-insights-hea…
luacmartins 383ba34
Merge remote-tracking branch 'origin/main' into cmartins-insights-hea…
luacmartins a770bf2
Polish Insights headline comparisons
luacmartins b9a5a80
Simplify the Workflow efficiency legend
luacmartins 189ba02
Keep Insights headline totals type private
luacmartins 4e95d39
Polish Insights headline summaries and legend spacing
luacmartins f032659
Merge main into cmartins-insights-headline-summary
luacmartins 76c8f3d
Keep Insights headline summaries in sync with chart rows
luacmartins 2cc16cb
Merge main into cmartins-insights-headline-summary
luacmartins 3b5f77b
Align Insights headline comparison colors
luacmartins 8cec574
Merge origin/main into cmartins-insights-headline-summary
luacmartins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /** Keeps comparison swatches together so the period label only needs to appear once. */ | ||
| import type {ChartSeries} from '@components/Charts/types'; | ||
| import VictoryTheme from '@components/Charts/VictoryTheme'; | ||
| import Text from '@components/Text'; | ||
|
|
||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
|
|
||
| import {formatList} from '@libs/Localize'; | ||
|
|
||
| import {View} from 'react-native'; | ||
|
|
||
| type StackedBarChartLegendProps = { | ||
| /** Each stack's first series supplies its group label. Compared swatches follow the primary stage order. */ | ||
| stacks: ReadonlyArray<readonly ChartSeries[]>; | ||
| }; | ||
|
|
||
| function StackedBarChartLegend({stacks}: StackedBarChartLegendProps) { | ||
| const styles = useThemeStyles(); | ||
| const theme = useTheme(); | ||
| const StyleUtils = useStyleUtils(); | ||
|
|
||
| const renderSwatch = ({key, color}: ChartSeries) => ( | ||
| <View | ||
| key={key} | ||
| aria-hidden | ||
| style={[styles.pieChartLegendDot, styles.flexShrink0, StyleUtils.getBackgroundColorStyle(color ?? VictoryTheme.colors.default)]} | ||
| /> | ||
| ); | ||
|
|
||
| return ( | ||
| <View style={[styles.pieChartLegendContainer, styles.justifyContentStart, styles.mh0, styles.mt0, styles.mb3]}> | ||
| {stacks.flatMap((stack) => { | ||
| const firstSeries = stack.at(0); | ||
| if (!firstSeries?.stackLabel) { | ||
| return stack.map((series) => ( | ||
| <View | ||
| key={series.key} | ||
| style={[styles.flexRow, styles.alignItemsCenter, styles.gap2, styles.flexShrink1]} | ||
| > | ||
| {renderSwatch(series)} | ||
| <Text | ||
| variant="micro" | ||
| color={theme.icon} | ||
| style={styles.flexShrink1} | ||
| > | ||
| {series.label} | ||
| </Text> | ||
| </View> | ||
| )); | ||
| } | ||
|
|
||
| const {key, stackLabel} = firstSeries; | ||
| const stageLabels = stack.flatMap(({label}) => (label ? [label] : [])); | ||
| return [ | ||
| <View | ||
| key={key} | ||
| style={[styles.flexRow, styles.alignItemsCenter, styles.gap2, styles.flexShrink1]} | ||
| role="group" | ||
| accessible | ||
| accessibilityLabel={formatList([stackLabel, ...stageLabels])} | ||
| > | ||
| <View style={[styles.flexRow, styles.gap1]}>{stack.map(renderSwatch)}</View> | ||
| <Text | ||
| variant="micro" | ||
| color={theme.icon} | ||
| style={styles.flexShrink1} | ||
| aria-hidden | ||
| > | ||
| {stackLabel} | ||
| </Text> | ||
| </View>, | ||
| ]; | ||
| })} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default StackedBarChartLegend; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
❌ CONSISTENCY-18 (docs)
This line now prefers
comparison[CONST.SEARCH.CHART_METRIC.DURATION]over the locally computedgetStackedAverage(data, stages), but nothing explains why the backend-supplied duration should win. A future reader can't tell that this is the report-weighted range average (matching the headline summary) and that the bucket average is only a fallback for older cached responses. Add a short comment stating the reason, e.g.:Reviewed at: 76c8f3d | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.