patternomaly

WebJar for patternomaly

Лицензия

Лицензия

MIT
Категории

Категории

Github Инструменты разработки Контроль версий
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

github-com-ashiguruma-patternomaly
Последняя версия

Последняя версия

1.3.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

patternomaly
WebJar for patternomaly
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/ashiguruma/patternomaly

Скачать github-com-ashiguruma-patternomaly

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/github-com-ashiguruma-patternomaly/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>github-com-ashiguruma-patternomaly</artifactId>
    <version>1.3.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-ashiguruma-patternomaly/
implementation 'org.webjars.npm:github-com-ashiguruma-patternomaly:1.3.2'
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-ashiguruma-patternomaly/
implementation ("org.webjars.npm:github-com-ashiguruma-patternomaly:1.3.2")
'org.webjars.npm:github-com-ashiguruma-patternomaly:jar:1.3.2'
<dependency org="org.webjars.npm" name="github-com-ashiguruma-patternomaly" rev="1.3.2">
  <artifact name="github-com-ashiguruma-patternomaly" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='github-com-ashiguruma-patternomaly', version='1.3.2')
)
libraryDependencies += "org.webjars.npm" % "github-com-ashiguruma-patternomaly" % "1.3.2"
[org.webjars.npm/github-com-ashiguruma-patternomaly "1.3.2"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

Patternomaly

Easily generate patterns for use in data graphics.

Pattern example

But why?

Color-blindness, that's why.

This library came about as part of an issue in Chart.js.

Usage

npm install patternomaly

Generate a single canvas pattern

pattern.draw('square', '#1f77b4');

Generate an array of canvas patterns

pattern.generate([
  '#1f77b4',
  '#ff7f0e',
  '#2ca02c',
  '#d62728'
]);

Available Patterns

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
  ]
}]

Pattern Keys

  • plus
  • cross
  • dash
  • cross-dash
  • dot
  • dot-dash
  • disc
  • ring
  • line
  • line-vertical
  • weave
  • zigzag
  • zigzag-vertical
  • diagonal
  • diagonal-right-left
  • square
  • box
  • triangle
  • triangle-inverted
  • diamond
  • diamond-box

Pattern example

Thanks to obedm503 for generating the example pattern image.

Providing a Pattern Alternative

In 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.

Typescript / Angular

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"].

Версии библиотеки

Версия
1.3.2
1.3.0