Scott/chart styles#400
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces horizontal and vertical bar charts, refactors the line chart to be responsive, and updates card auto-height calculations to handle asynchronous SVG rendering via a MutationObserver. Feedback focuses on optimizing wheel event propagation to prevent layout thrashing, fixing visual misalignment bugs in custom chart cursors, simplifying the auto-height observer architecture to avoid performance issues, and removing hardcoded locales to support internationalization.
| thead { | ||
| position: sticky; | ||
| top: 0; | ||
| z-index: 1; |
There was a problem hiding this comment.
Let's use:
| z-index: 1; | |
| z-index: $z-index-above-content; |
| <m.div | ||
| key={activeTab.label} | ||
| role="tabpanel" | ||
| className={clsx(s.panel)} |
There was a problem hiding this comment.
| className={clsx(s.panel)} | |
| className={s.panel} |
| const BAR_COLOR = `rgb(${COLORS['card-surface-selected']})`; | ||
| const GRID_COLOR = `rgb(${COLORS['card-chart-grid']})`; | ||
| const AXIS_COLOR = `rgb(${COLORS['card-content-muted']})`; |
There was a problem hiding this comment.
I reckon all chart colours should probably just be directly tokenized for ease. I.e:
| const BAR_COLOR = `rgb(${COLORS['card-surface-selected']})`; | |
| const GRID_COLOR = `rgb(${COLORS['card-chart-grid']})`; | |
| const AXIS_COLOR = `rgb(${COLORS['card-content-muted']})`; | |
| const BAR_COLOR = `rgb(${COLORS['card-chart-bar']})`; | |
| const GRID_COLOR = `rgb(${COLORS['card-chart-grid']})`; | |
| const AXIS_COLOR = `rgb(${COLORS['card-chart-axis']})`; |
9dbc8ff to
f7150cd
Compare
nick-nlb
left a comment
There was a problem hiding this comment.
In doing the query relating to poverty in South East Asian countries, we encounter a two errors:
intercept-console-error.ts:48 Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
We see significant jitter on the chart cards when this error occurs (the error then ocurs repeatedly, indicating an infinite loop, as implied by the error.
Another console error occurs regardless of the query, as long as a chart appears:
forward-logs-shared.ts:95 The width(0) and height(0) of chart should be greater than 0,
please check the style of container, or the props width(100%) and height(undefined),
or add a minWidth(0) or minHeight(undefined) or use aspect(1.78) to control the
height and width.
| @@ -0,0 +1,27 @@ | |||
| import styles from './custom_tooltip.module.scss'; | |||
There was a problem hiding this comment.
We've been going with the principle of category-first naming: tooltip_custom (along with this component).
| background: rgb(var(--color-control-accent) / 12%); | ||
| } | ||
|
|
||
| &:hover:not([data-is-selected="true"]) { |
There was a problem hiding this comment.
The FRONTEND.md guide specifies no bare hovers (see the Section 8)
|
|
||
| const compactFormatter = new Intl.NumberFormat('en', { notation: 'compact' }); | ||
| const compactFormatter = new Intl.NumberFormat(undefined, { | ||
| notation: 'standard', |
There was a problem hiding this comment.
The notation specified here is standard, but the formatter itself is still called compactFormatter - we could rename the variable, but perhaps this is a sign that this variable name is overspecified.
Overview
Adds styled bar chart variants (vertical and horizontal) and line chart improvements to chart cards, replaces hardcoded chart dimensions with responsive containers, and fixes several layout issues around card resizing, table scrolling, and wheel event propagation.
Changes Made
DataChartBarVerticalandDataChartBarHorizontalcomponents using RechartsBarChartwith design token colors, tooltips, compact number formatting, and custom cursors/axis linesDataChartLineto useResponsiveContainerinstead of fixedwidth/heightprops; add tooltip, custom cursor, active dot styling, and full-width axis linebar-vertical,bar-horizontal, andlineeach render the correct chart componentMutationObserveralongside the existingResizeObserverthead, standard (non-compact) number formatting, and bottom marginoverflow-y: auto)