
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
@smarthr/patternomaly
Advanced tools
Easily generate patterns for use in data graphics.
Color-blindness, that's why.
This library came about as part of an issue in Chart.js.
pnpm install patternomaly
背景: セキュリティ要件によりpnpmの、minimumReleaseAge設定のためNodeバージョンを最新に更新しています。しかし、canvasパッケージ(テスト用)は何らかの事情によりpnpm installでは内部パッケージのビルドができないため、canvasのみ npm install を使用しています:
# メインの依存関係をpnpmでインストール
pnpm install
# canvasパッケージのみnpmで個別インストール(一時的な回避策)
cd node_modules/canvas
npm install
# テスト実行
pnpm test
Generate a single canvas pattern
pattern.draw('square', '#1f77b4');
Generate an array of canvas patterns
pattern.generate([
'#1f77b4',
'#ff7f0e',
'#2ca02c',
'#d62728'
]);
There are currently 21 pattern variants available. When using the generate method (above) patterns will be 'randomly' assigned.
It is however possible to provide specific patterns using the draw method.
datasets: [{
data: [
300, 50, 100, 210, 140
],
backgroundColor: [
pattern.draw('square', '#1f77b4'),
pattern.draw('circle', '#ff7f0e'),
pattern.draw('diamond', '#2ca02c'),
pattern.draw('zigzag-horizontal', '#17becf'),
pattern.draw('triangle', 'rgb(255, 99, 132, 0.4)') // with opacity
]
}]
Thanks to obedm503 for generating the example pattern image.
⚠️ 開発前の注意: canvasパッケージを個別にインストールしてください(上記のセキュリティ注意事項を参照)。
To run the examples locally:
pnpm run serve
This will:
http://localhost:3000Available examples:
chart-types.html - Chart.js integration examplesoptional.html - Pattern toggle functionalitypatterns.html - All available patterns displaycompare.html - Pattern vs color comparisonscaling.html - Pattern scaling examplessingle.html - Single pattern demoIn order to provide an alternative view for visually impaired viewers it's a good idea to provide a patterned alternative.
See the pattern option example page for a simple implementation of a pattern toggle switch for Chart.js.
A typings file is included in this package. Just insert import {draw, generate} from 'patternomaly' in the header of your .ts file.
Still you have to add the javascript file to your build e.g. in the scripts array in angular.cli.json e.g. "scripts": ["node_modules/patternomaly/dist/patternomaly.js"].
FAQs
Easily generate patterns for use in data graphics
The npm package @smarthr/patternomaly receives a total of 619 weekly downloads. As such, @smarthr/patternomaly popularity was classified as not popular.
We found that @smarthr/patternomaly demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 25 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.