feat: apex chart restyle — shadcn aesthetic, 3 new chart types, sleek tooltips#26
Merged
Conversation
Introduced three new chart components to the ShellUI framework: DonutChart, RadarChart, and RadialChart. Each component utilizes ApexCharts for rendering and supports customizable data binding through parameters for data items, names, and value functions. This enhances the data visualization capabilities within the application.
Added `ShowToolbar` and `ShowLegend` parameters to the Chart component for improved customization of ApexCharts. Updated PieChart component by removing custom tooltip logic to streamline functionality. These changes enhance the flexibility and usability of chart components within the ShellUI framework.
Introduced DonutChart, RadarChart, and RadialChart components to the ChartsDemo, expanding the data visualization capabilities. Enhanced the Chart component with new parameters, ShowToolbar and ShowLegend, for improved customization. Updated the PieChart component by removing custom tooltip logic to streamline functionality. These changes enhance the flexibility and usability of chart components within the ShellUI framework.
Updated the ChartVariants class to include new tooltip styles and parameters for better customization. Removed outdated custom tooltip entries from the safelist and added new shellui-chart tooltip classes to align with the shadcn/ui aesthetic. Enhanced the ApexCharts configuration for improved visual consistency and usability across chart components.
…ents Updated ChartStylesTemplate and ChartVariantsTemplate to align with the shadcn/ui aesthetic, introducing new tooltip styles and improving chart configuration. Removed outdated tooltip logic from PieChartTemplate to streamline functionality. These changes enhance the visual consistency and usability of chart components within the ShellUI framework.
Replaced outdated tooltip class names in ChartStylesTests with new shellui-chart classes to align with recent styling updates. This change ensures that the tests accurately reflect the current implementation of chart tooltips, enhancing maintainability and clarity.
…eriment Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Reworks every chart's chrome to match the shadcn/ui aesthetic and ships three new chart types the roadmap called for.
The chrome rewrite
ChartVariants.GetOptionsused to hand ApexCharts a config that looked stock — visible axis borders, ticks, a busy toolbar, bottom legend with square markers, default palette hex colors, and a tooltip that never actually rendered for some chart types (see bugs below).The new default config:
<Chart ShowToolbar="true">--border@ 60%BorderRadiusApplication = End)Curve.SmoothAnimateGraduallyChartTheme.Default/Colorful/Monochromeselector.shellui-chart-tooltip— title bar + rows, tabular-nums values, compact~200pxmax-width, rounded-square markersNew chart types
RadarChart<TItem>DonutChart<TItem>RadialChart<TItem>All three follow the same shape as the existing chart family — inherit
Chart<TItem>, takeItems/KeySelector/Value/Name/XValue/YValue. Live + demo copies + CLI templates (data-picker-style split) all in sync.New
Chart.razorparametersShowToolbar(defaultfalse) — opt in to ApexCharts' download/zoom/pan/reset toolbar. Off by default = shadcn aesthetic.ShowLegend(defaulttrue) — quick way to hide the legend on single-series charts where it's redundant.Compact shadcn-style tooltip
Custom tooltip renderer generates
.shellui-chart-tooltipmarkup instead of relying on the ApexCharts default:max-width: 220px, no forcedmin-width— tight around content"February"), then rows of[10px square marker] [label] [value]font-variant-numeric: tabular-numson values so digits align cleanlyHandles both cartesian charts (bar/line/area/multi-series/radar) with a title + multiple series rows and circular charts (pie/donut/radialBar/polarArea) with a single label-value row. Chart-type detection uses a defensive fallback (
chart.typename → shape of the series array) so it doesn't rely on ApexCharts reportingchart.typeconsistently across chart variants.Bugs found and fixed along the way
1. Pie chart tooltip was silently clobbered on every render.
PieChart.razorhad anOnParametersSetoverride that replacedChartOptions.Tooltipwith a hardcoded config on every parameter change. Nothing anyone changed inChartVariantshad ever affected pie charts — the override wiped it out each render. Removed the tooltip override inPieChart.razor(live + demo + CLI template); kept just theChart.Type = Pieassignment which is the legit part.2. Tooltip title showed numeric indices instead of category strings.
w.globals.labels[dataPointIndex]was returning"2","3","4"instead of"Feb","Mar","Apr". ApexCharts stashes category strings incategoryLabelsorw.config.xaxis.categories, andlabelssometimes falls back to auto-numbering. Custom function now tries all three sources in order — real string wins.3. Tooltip drifted to the next column when hovering near boundaries.
Tooltip.FollowCursor = truepositioned the tooltip relative to the mouse pointer, which slid it to the neighbor column as the mouse approached the boundary. Flipped tofalse— tooltip anchors to the data point being reported.4. Pie chart's built-in slice labels overlapped the tooltip.
PlotOptionsPie.DataLabels.MinAngleToShowLabel = 360disables the native slice callout labels (theirlabel:valuetext was what was appearing inside the pie chart as raw white text).What we tried and rolled back
var(--chart-N)in the color array. SVG resolves CSS vars infill/strokeattributes just fine, but ApexCharts also draws to canvas contexts (some legend and marker paths) that don't resolvevar(), so parts of the chart went uncolored. Bigger issue: the theme's--chart-3/4/5were pure grayscale, so even wherevar()did resolve, the palette was 3 grays + 1 blue + 1 yellow — washed out.Fill.Type = GradientwithOpacityFrom: 0.4, OpacityTo: 0.05made every bar and pie slice fade toward transparent — visible outlines but no fill. Reverted toFill.Type = Solid, Opacity = 0.85.Both are documented as future paths — theme-following would need runtime JS interop to compute var values, and per-chart-type gradient overrides would go on
AreaChart.razorspecifically.Files
src/ShellUI.Components/Components/RadarChart.razor(new)src/ShellUI.Components/Components/DonutChart.razor(new)src/ShellUI.Components/Components/RadialChart.razor(new)src/ShellUI.Components/Variants/ChartVariants.csshowLegendparamsrc/ShellUI.Components/Components/Chart.razorShowToolbar+ShowLegendparameterssrc/ShellUI.Components/Components/PieChart.razorOnParametersSettooltip overridesrc/ShellUI.Components/wwwroot/shellui-theme.csssrc/ShellUI.Templates/Templates/ChartVariantsTemplate.cssrc/ShellUI.Templates/Templates/ChartStylesTemplate.cs.shellui-chart-tooltipsrc/ShellUI.Templates/Templates/PieChartTemplate.csNET10/BlazorInteractiveServer/Components/UI/{DonutChart,RadarChart,RadialChart}.razor(new)NET10/BlazorInteractiveServer/Components/UI/{Chart,PieChart}.razorNET10/BlazorInteractiveServer/Components/UI/Variants/ChartVariants.csNET10/BlazorInteractiveServer/Components/Demo/ChartsDemo.razorNET10/BlazorInteractiveServer/wwwroot/input.cssNET10/BlazorInteractiveServer/wwwroot/app.csssrc/ShellUI.Components/wwwroot/shellui-classes.txt+build/*.targetsShellUI.Tests/ChartStylesTests.cs.shellui-chart-tooltip*class namesTest plan
dotnet test— 80/80 green (safelist drift check auto-updated, chart-styles test updated for new class names)"Feb","Mar","Apr"), tabular-numeric values, square markers<Chart ShowToolbar="true">— zoom/pan/download appears; default renders clean<Chart ShowLegend="false">— legend hides on single-series chartsFollow-ups (not blocking)
--chart-Nvalues, or a build-time CSS-var → hex resolver. Real feature-flag path if we later ship a "chart config" API à la shadcn'sChartConfig.OnParametersSetwhile Bar/Pie stay solid. Small follow-up.feat/chart-compositionbranch that layers<ChartContainer>+<ChartConfig>+<ChartTooltip>primitives on top of ApexCharts for the compositional shadcn API pattern.