Build Design Systems With Penpot Components
Penpot's new component system for building scalable design systems, emphasizing designer-developer collaboration.

medium bookmark / Raindrop.io |
Color is pretty good for separating things. That’s what your basic pie chart is, isn’t it? You tell the slices apart by color. With enough color contrast, you might be OK, but you might be even better off (particularly where accessibility is concerned) using patterns, or a combination.
Enhancing Charts With SVG Patterns:
When one of the slices is filled with something more than color, it’s easier to figure out [who the Independents are]:
Filling a pie slice with a pattern is not a common charting library feature (yet), but if your library of choice is SVG-based, you are free to implement SVG patterns.
As in, literally a <pattern />
in SVG!
Here’s a simple one for horizontal lines:
<pattern
id="horzLines"
width="8"
height="4"
patternUnits="userSpaceOnUse">
<line
x1="0"
y1="0"
x2="8"
y2="0"
style="stroke:#999;stroke-width:1.5"
/>
</pattern>
Now any SVG element can use that pattern as a fill. Even strokes. Here’s an example of mixed usage of two simple patterns:
That’s nice for filling SVG elements, but what about HTML elements?
There are several ways to use Pattern Fills:
You can use the
patterns.css
file that contains all the current patterns. That will only work for non-SVG elements.You can use individual patterns, but copying them from the sample pages. CSS class definitions can be found here and SVG pattern defs can be found here
You can add your own patterns or modify mine! The conversion process from SVG document to pattern is very tedious. The purpose of the pattern fills toolchain is to simplify this process. You can clone the repo, run
npm install
andgrunt dev
to get a local server going. After that, any changes or additions to thesrc/patterns/**/*
files will be automatically picked up and will re-render the CSS file and the sample pages. If you make new patterns, send them over in a pull request!
Here’s me applying them to SVG elements (but could just as easily be applied to HTML elements):
The CSS usage is as base64 data URLs though, so once they are there they aren’t super duper manageable/changeable.
Here’s Irene with an old timey chart, using d3:
If your URL encode the SVG just right, you and plop it right into CSS and have it remain fairly managable.
Here’s one by John Schulz:
Ricardo Marimón has an example creating the pattern in d3. The pattern looks largely the same on the slices, but perhaps it’s a start to modify.
We rounded a bunch of them up recently!
AI-driven updates, curated by humans and hand-edited for the Prototypr community