# Accessibility MatPlotLibNet v0.8.8 adds first-class accessibility support across four areas: SVG semantic structure, keyboard navigation, color-blind safe palette, and high-contrast theme. --- ## SVG Semantics Every SVG produced by MatPlotLibNet carries: | Attribute / Element | Value | Purpose | |---|---|---| | `role="img"` | on `` | Marks the SVG as an image for assistive tech | | `` | alt text → figure title → empty | Screen-reader label | | `` | `Figure.Description` (optional) | Longer description | | `aria-labelledby="chart-title"` | on `` | Links to `` | | `aria-describedby="chart-desc"` | on `` when description set | Links to `` | | `aria-label="Chart legend"` | on legend group | Identifies legend section | | `aria-label="Color bar"` | on color bar group | Identifies color bar | | `aria-label="{series label}"` | on labeled series group | Names each data series | ### Setting Alt Text ```csharp Plt.Create() .WithAltText("Monthly revenue Q1 2025") .WithDescription("Line chart showing revenue growth from Jan to Mar 2025, peaking at $3.2M in March.") .Plot(months, revenue) .Save("revenue.svg"); ``` `WithAltText` maps to the SVG `` element. If omitted, `WithTitle` is used as the fallback. `WithDescription` maps to `<desc>` and is optional. --- ## Keyboard Navigation All five interactive SVG features are keyboard-accessible: ### Legend Toggle - Each legend entry receives `role="button"`, `tabindex="0"`, and `aria-pressed="false"` - Press **Enter** or **Space** to toggle series visibility - `aria-pressed` updates to reflect current state ### Series Highlight - Each series group receives `tabindex="0"` - **Focus** highlights the series (dims siblings); **Blur** restores all ### Zoom / Pan - The SVG receives `tabindex="0"` and `aria-roledescription="interactive chart"` - **`+`** or **`=`**: zoom in - **`-`**: zoom out - **Arrow keys** (←→↑↓): pan - **`Home`**: reset to original view ### Selection - **Escape**: cancel an active shift-drag selection rectangle ### Tooltips - Tooltip div carries `role="tooltip"` and `aria-live="polite"` - **Focus** on a `<title>`-parent element triggers the tooltip; **Blur** hides it --- ## Color-Blind Safe Palette `Theme.ColorBlindSafe` uses the [Okabe-Ito](https://jfly.uni-koeln.de/color/) 8-color palette, which is distinguishable under all three common forms of color vision deficiency. ```csharp Plt.Create() .WithTheme(Theme.ColorBlindSafe) .Plot(x, y, s => s.Label = "Revenue") .Plot(x, y2, s => s.Label = "Cost") .Save("colorblind.svg"); ``` The palette is also available as a colormap: ```csharp // Named "okabe_ito" / "okabe_ito_r" in the registry var map = ColorMaps.Get("okabe_ito"); ``` Colors (in cycle order): | # | Hex | Name | |---|---|---| | 1 | `#E69F00` | Orange | | 2 | `#56B4E9` | Sky blue | | 3 | `#009E73` | Bluish green | | 4 | `#F0E442` | Yellow | | 5 | `#0072B2` | Blue | | 6 | `#D55E00` | Vermillion | | 7 | `#CC79A7` | Reddish purple | | 8 | `#000000` | Black | --- ## High-Contrast Theme `Theme.HighContrast` targets WCAG AAA (7:1 contrast ratio). Pure white background and pure black text yield a 21:1 contrast ratio. The default font is bold at 13pt; the grid is 1.5px dark. ```csharp Plt.Create() .WithTheme(Theme.HighContrast) .Plot(x, y) .Save("high-contrast.svg"); ``` --- ## Serialization `Figure.AltText` and `Figure.Description` are included in the JSON round-trip: ```csharp var figure = Plt.Create() .WithAltText("Sales chart") .WithDescription("Monthly sales data for 2025") .Plot(x, y) .Build(); string json = ChartServices.Serializer.ToJson(figure); // includes altText / description Figure restored = ChartServices.Serializer.FromJson(json); // restores both properties ```