<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/distinctive-patterns-for-categorical-data-in-swift-charts-sy0kw7qou" -->

---
title: Distinctive patterns for categorical data in Swift Charts
description: This post shows how to make Swift Charts categories distinguishable regardless of how color is perceived. It draws small 8-point tile images with diagonal...
canonical: https://daily.dev/posts/distinctive-patterns-for-categorical-data-in-swift-charts-sy0kw7qou
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Distinctive patterns for categorical data in Swift Charts | daily.dev
og:description: This post shows how to make Swift Charts categories distinguishable regardless of how color is perceived. It draws small 8-point tile images with diagonal...
og:url: https://daily.dev/posts/distinctive-patterns-for-categorical-data-in-swift-charts-sy0kw7qou
og:image: https://api.daily.dev/og/posts/SY0kw7QoU.png
og:image:alt: Distinctive patterns for categorical data in Swift Charts
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Distinctive patterns for categorical data in Swift Charts

**[Nil Coalescing](https://daily.dev/sources/nilcoalescing)** · 7 min read · 0 upvotes · 0 comments

## Summary

This post shows how to make Swift Charts categories distinguishable regardless of how color is perceived. It draws small 8-point tile images with diagonal stripes, dots, or a checkerboard using a GraphicsContext, then wraps them in ImagePaint as a custom ShapeStyle. A PatternFill type conforms to ShapeStyle and checks accessibilityDifferentiateWithoutColor in its resolve(in:) method, returning the pattern only when that accessibility setting is on and the plain color otherwise. This lets you write Color.indigo.checkerboard directly in chartForegroundStyleScale.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nilcoalescing.com/blog/DistinctivePatternsForCategoricalDataInSwiftCharts>

## Questions this post answers

### How do I make Swift Charts categories distinguishable without relying only on color?

Draw small repeating tile images (diagonal stripes, dots, or checkerboard) with a GraphicsContext inside Image(size:label:opaque:colorMode:renderer:), wrap the tile in ImagePaint, and pass it to chartForegroundStyleScale. Each color keeps its hue while gaining a distinct texture, so categories remain distinguishable even when colors look similar under color vision deficiencies.

_daily.dev surfaces practical SwiftUI accessibility techniques like this for developers building charts._

### How can I detect if accessibilityDifferentiateWithoutColor is enabled in a custom SwiftUI ShapeStyle?

Make the custom type conform to ShapeStyle and implement resolve(in environment: EnvironmentValues), checking environment.accessibilityDifferentiateWithoutColor. Return the plain base style when the setting is off and an alternate style, such as a pattern-filled ImagePaint, when it's on, letting the shape style itself react to the environment without changing call sites.

_Developers adapting SwiftUI views to accessibility settings can track patterns like this on daily.dev._

## Similar posts on daily.dev

- [Building an accessible calendar chart with Swift Charts](https://daily.dev/posts/building-an-accessible-calendar-chart-with-swift-charts-o2wzjpdld) · Nil Coalescing · 0 upvotes · 0 comments
- [Visualising data with a hexagonal heatmap in Swift Charts](https://daily.dev/posts/visualising-data-with-a-hexagonal-heatmap-in-swift-charts-qmmjuenky) · Nil Coalescing · 0 upvotes · 0 comments
- [The art of visual inspection: Spot the hidden story in your charts](https://daily.dev/posts/the-art-of-visual-inspection-spot-the-hidden-story-in-your-charts-sfqimseoq) · The New Stack · 1 upvotes · 0 comments
- [Building a sunburst diagram in Swift Charts](https://daily.dev/posts/building-a-sunburst-diagram-in-swift-charts-pa8wdkc6c) · Nil Coalescing · 0 upvotes · 0 comments

---

Tags: [#swift](https://daily.dev/tags/swift), [#accessibility](https://daily.dev/tags/accessibility), [#data-visualization](https://daily.dev/tags/data-visualization), [#swiftui](https://daily.dev/tags/swiftui)

[View this post on daily.dev](https://daily.dev/posts/distinctive-patterns-for-categorical-data-in-swift-charts-sy0kw7qou)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Distinctive patterns for categorical data in Swift Charts","url":"https://daily.dev/posts/distinctive-patterns-for-categorical-data-in-swift-charts-sy0kw7qou","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/distinctive-patterns-for-categorical-data-in-swift-charts-sy0kw7qou"},"datePublished":"2026-11-25T08:00:00.289Z","dateModified":"2026-11-25T08:00:25.872Z","description":"This post shows how to make Swift Charts categories distinguishable regardless of how color is perceived. It draws small 8-point tile images with diagonal...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c00ce229648d2a92972b3eb1d080020f?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c00ce229648d2a92972b3eb1d080020f?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Nil Coalescing","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Nil Coalescing","logo":"https://media.daily.dev/image/upload/s--rcEu6sag--/f_auto,q_auto/v1785654899/logos/nilcoalescing?_a=BAMAMicg0","url":"https://daily.dev/sources/nilcoalescing"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/distinctive-patterns-for-categorical-data-in-swift-charts-sy0kw7qou","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift,accessibility,data-visualization,swiftui","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nil Coalescing","item":"https://daily.dev/sources/nilcoalescing"},{"@type":"ListItem","position":3,"name":"Distinctive patterns for categorical data in Swift Charts"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/distinctive-patterns-for-categorical-data-in-swift-charts-sy0kw7qou#faq","mainEntity":[{"@type":"Question","name":"How do I make Swift Charts categories distinguishable without relying only on color?","acceptedAnswer":{"@type":"Answer","text":"Draw small repeating tile images (diagonal stripes, dots, or checkerboard) with a GraphicsContext inside Image(size:label:opaque:colorMode:renderer:), wrap the tile in ImagePaint, and pass it to chartForegroundStyleScale. Each color keeps its hue while gaining a distinct texture, so categories remain distinguishable even when colors look similar under color vision deficiencies. daily.dev surfaces practical SwiftUI accessibility techniques like this for developers building charts."}},{"@type":"Question","name":"How can I detect if accessibilityDifferentiateWithoutColor is enabled in a custom SwiftUI ShapeStyle?","acceptedAnswer":{"@type":"Answer","text":"Make the custom type conform to ShapeStyle and implement resolve(in environment: EnvironmentValues), checking environment.accessibilityDifferentiateWithoutColor. Return the plain base style when the setting is off and an alternate style, such as a pattern-filled ImagePaint, when it's on, letting the shape style itself react to the environment without changing call sites. Developers adapting SwiftUI views to accessibility settings can track patterns like this on daily.dev."}}]}
```

