Add BarChart and AreaChart components to fidesui#7699
Merged
Conversation
Adds BarChart component, XAxisTick renderer, and time-series utility functions (pickInterval, formatTimestamp, deriveInterval, tooltipLabelFormatter) to support upcoming access control dashboard visualizations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds the summary tab for the access control feature (behind feature flag): - Time-series violations chart, violation rate donut, data consumers table - Paginated findings table with policy violation aggregates - RTK Query endpoints for summary data - Mock data and MSW handlers for local development Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Guard formatTimestamp/tooltipLabelFormatter against invalid dates - Add defensive defaults to XAxisTick props and document deriveInterval contract - Use useChartAnimation in BarChart (consistent with Sparkline, DonutChart, etc.) - Memoize useTooltipContentStyle to avoid unnecessary re-renders - Fix lint: merge duplicate react imports, sort imports Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Categorical labels were rendered by Recharts' default tick (browser sans-serif) while time-series labels went through ChartText (Bazier Mono). Now both paths use ChartText so the font is always consistent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This comment was marked as outdated.
This comment was marked as outdated.
- Fix tickFormatter being silently ignored when intervalMs is set by unifying both tick paths into a single ChartText-based renderer - Rename i → index in story generator - Replace div with Flex in story decorator Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review — BarChart + chart utilities
Overall this is clean, well-structured work. The component design is consistent with the existing chart patterns (animation hook, container-size observer, Ant Design token integration), and the new utility functions are focused and testable. A few things worth addressing before merge:
Suggestions
formatTimestampuses inconsistent 12h/24h formats — axis labels use 24h (HH:mm) but tooltip (verbose) uses 12h (h:mm a) for the same intervals. Pick one convention.onIntervalChangein effect deps — if callers pass an inline function, the effect re-fires on every parent render. Callers should wrap it inuseCallback, or the hook should internalize it via a ref. Same pattern in bothBarChartandAreaChart.pickIntervalHours72h cap is unexplained —Math.min(idealHours, 72)should either be a named constant or have a comment explaining why 72h is the ceiling.sizeprop inBarChartdoesn't affect rendered bar width —barWidthis used as a density hint forpickIntervalHoursbut never passed to<Bar barSize>. Clarify in a comment if this is intentional.LABEL_WIDTHchange (90 → 110) is a silent behavior change for all existing consumers ofChartText(e.g. DonutChart center label). Worth calling out explicitly.BarChart.stories.tsxonly exportsDefaultbut the PR description references 6 stories. Either add the missing stories or update the description.
Nice to have
- The exported public surface in
index.tsincludes several internal helpers (calcTickInterval,deriveInterval,pickIntervalHours,useContainerSize). Worth reviewing whether these need to be public API. - No unit tests for the new pure utility functions.
formatTimestamp,deriveInterval,calcTickInterval, andpickIntervalHourseach have meaningful edge cases (invalid dates, empty data, zero container width) that are straightforward to cover with@jest/globalsor Vitest.
- Stabilize onIntervalChange via ref in BarChart and AreaChart - Add barSize prop to Bar element for consistent visual width - Restore original width in ChartText to avoid visual regression - Use consistent 24h time format in formatTimestamp - Extract MAX_INTERVAL_HOURS constant - Remove internal helpers from public API exports Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gilluminate
approved these changes
Mar 24, 2026
Contributor
gilluminate
left a comment
There was a problem hiding this comment.
One tiny nit-pick but looks good!
| return gap > 0 ? gap : HOUR_MS; | ||
| }; | ||
|
|
||
| const MAX_INTERVAL_HOURS = 72; |
Contributor
There was a problem hiding this comment.
probably belongs in chart-constants.ts
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Ticket: N/A — part of PBAC work
Description Of Changes
Add generic, reusable chart components and time-series utilities to fidesui in preparation for the access control dashboard. These components are domain-agnostic and can be used by any feature requiring bar charts, area charts, or time-series visualizations.
New components:
BarChart— responsive bar chart with Ant Design theme integration, configurable bar size (sm/md/lg), and smartonIntervalChangecallback for responsive data bucketingAreaChart— multi-series area chart with gradient fills, grid lines, and the same responsive interval API as BarChartXAxisTick— custom X-axis tick renderer with smart timestamp formatting based on data intervalUtilities added to
chart-utils.ts:formatTimestamp(timestamp, intervalMs, verbose?)— formats ISO timestamps for tick labels or tooltips using date-fns, with invalid-date fallbackderiveInterval(data)— auto-detects interval between consecutive data pointspickIntervalHours(rangeMs, containerWidth, minPointWidth)— computes ideal bucket size (in hours) that fits the data range into the containercalcTickInterval(pointCount, containerWidth, labelWidth)— calculates tick skip count to prevent label overlapuseChartAnimation(duration)— disables recharts animation after initial render to prevent re-triggering on interactionuseContainerSize(ref)— returns{ width, height }from a ResizeObserver (refactored from existing hook)Other changes:
DonutChartupdated to use the refactoreduseContainerSizereturn shapeChartTextminor cleanupchart-constants.tswithBarSizetype,BAR_SIZE_TOKENmapping,LABEL_WIDTH,MIN_PX_PER_POINTstory-utils.tswith a seeded PRNG for deterministic Storybook dataCode Changes
clients/fidesui/src/components/charts/AreaChart.tsx— New reusable area chart componentclients/fidesui/src/components/charts/AreaChart.stories.tsx— Storybook stories (single and multi-series)clients/fidesui/src/components/charts/BarChart.tsx— New reusable bar chart componentclients/fidesui/src/components/charts/BarChart.stories.tsx— Storybook stories with resizable container democlients/fidesui/src/components/charts/XAxisTick.tsx— Custom X-axis tick rendererclients/fidesui/src/components/charts/chart-utils.ts— Time-series utilities and hooksclients/fidesui/src/components/charts/chart-constants.ts— Shared constants and typesclients/fidesui/src/components/charts/story-utils.ts— Seeded PRNG for storiesclients/fidesui/src/index.ts— Export new components and utilitiesSteps to Confirm
cd clients/fidesui && npm run storybookPre-Merge Checklist
CHANGELOG.mdupdated