• Stars
    star
    213
  • Rank 184,704 (Top 4 %)
  • Language
    JavaScript
  • License
    ISC License
  • Created about 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SVG patterns for Data Visualization.

svg-patterns

Create SVG patterns programmatically to visualize data, to help color-blind people and because it looks nice.

npm version build status ISC-licensed minimum Node.js version support me via GitHub Sponsors chat with me on Twitter

a simple pattern

This library is inspired by Textures.js but tries to do a few things differently:

  • svg-patterns does not limit you in which frontend stack you use. It just returns virtual-dom nodes.
  • Because Textures.js includes D3, it weighs 216k + 8k. svg-patterns weighs 19k.

Installing

npm install svg-patterns

Usage

svg-patterns exposes several styles, which you can customize by passing an object. The following list shows all styles, including their default options. You can fiddle with them on the website.

Getting Started

If you load a style via require('svg-patterns/p/style'), the bundle will be smaller. But you can also load it via require('svg-patterns').style.

const lines = require('svg-patterns/p/lines')
const stringify = require('virtual-dom-stringify')

const pattern = lines({
	stroke: 'darkorange',
	background: '#343434',
	orientations: [45]
})

process.stdout.write(`
	<svg xmlns="http://www.w3.org/2000/svg">
		<defs>${stringify(pattern)}</defs>
		<rect width="200" height="200" style="fill: ${pattern.url()}"/>
	</svg>
`)

a simple pattern

caps style

const defaults = {
	size: 9, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: .9,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

circles style

const defaults = {
	size: 15, // size of the pattern
	radius: 3,
	complement: true,
	fill: '#545454', // any SVG-compatible color
	strokeWidth: 0,
	stroke: 'none', // any SVG-compatible color
	background: null // any SVG-compatible color
}

crosses style

const defaults = {
	size: 10, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: .8,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

hexagons style

const defaults = {
	size: 10, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: 1,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

lines style

const defaults = {
	size: 8, // size of the pattern
	strokeWidth: .7,
	stroke: '#343434', // any SVG-compatible color
	background: null, // any SVG-compatible color
	orientations: [45] // can be any combination of 0, 45, -45, 90
}

nylon style

const defaults = {
	size: 15, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: 1,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

rhombic style

const defaults = {
	size: 12, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: .9,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

rhombic3d style

const defaults = {
	size: 14, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: .6,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

squares style

const defaults = {
	size: 10, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: .9,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

waves style

const defaults = {
	size: 8, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: .8,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

woven style

const defaults = {
	size: 9, // size of the pattern
	fill: 'none', // any SVG-compatible color
	strokeWidth: 1,
	stroke: '#343434', // any SVG-compatible color
	background: null // any SVG-compatible color
}

See also

Contributing

If you have a question or need support using svg-patterns, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, use the issues page.

More Repositories

1

tcp-over-websockets

Tunnel TCP through WebSockets.
JavaScript
681
star
2

vbb-rest

An HTTP API for Berlin & Brandenburg public transport.
JavaScript
118
star
3

svg-radar-chart

Generate SVG radar charts.
JavaScript
76
star
4

vbb-cli

A CLI for Berlin & Brandenburg public transport.
JavaScript
72
star
5

bvg-rest

An HTTP API for Berlin & Brandenburg public transport.
JavaScript
65
star
6

vbb-modules

List of JavaScript modules for Berlin & Brandenburg public transport.
59
star
7

db-rest

A clean REST API wrapping around the Deutsche Bahn API.
JavaScript
54
star
8

gemini

Gemini protocol server & client.
JavaScript
43
star
9

wifi-on-ice-portal-client

Query information from the WifiOnICE portal in German ICE trains.
JavaScript
42
star
10

flightradar24-client

Fetch aircraft data from Flightradar24.
JavaScript
41
star
11

asciicast-to-svg

Render frames of Asciicasts as SVGs.
JavaScript
38
star
12

self-decrypting-html-page

Generate a standalone HTML page that decrypts data.
JavaScript
33
star
13

html-vault

Store a secret securely in a standalone HTML file.
JavaScript
32
star
14

email-providers

A list of common eMail providers.
JavaScript
30
star
15

cli-autocomplete

A command line prompt with autocompletion.
JavaScript
27
star
16

time-tracking

โฑ Minimalistic command line time tracking.
JavaScript
27
star
17

geojson-to-svg-cli

Command line tool to convert GeoJSON to SVG.
JavaScript
26
star
18

build-wikipedia-feed

Build a hyperdb of Wikipedia articles.
JavaScript
24
star
19

play-on-apple-tv

A command line tool to play any audio/video on an Apple TV.
JavaScript
24
star
20

db-stations

A list of Deutsche Bahn stations.
JavaScript
22
star
21

location

Get your current location from the OS.
JavaScript
21
star
22

parse-human-relative-time

Parse human relative time strings like "next Tuesday 3pm".
JavaScript
21
star
23

flickr-photo-url

Download Flickr photos without API key.
JavaScript
20
star
24

query-overpass

Query the OpenStreetMap Overpass API.
JavaScript
20
star
25

generate-db-shop-urls

Given a journey, generate a URL for a matching Deutsche Bahn ticket.
HTML
19
star
26

websocket-pool

A pool of WebSocket connections. Supports reconnecting.
JavaScript
17
star
27

date-prompt

A CLI date picker prompt.
JavaScript
17
star
28

sepa-payment-qr-code

Generate a QR code to initiate a SEPA bank transfer.
JavaScript
17
star
29

bvg-topological-map

BVG transport map as a nice SVG.
JavaScript
17
star
30

node-spotlight

Search macOS using Spotlight.
JavaScript
16
star
31

js-playgrounds

A command line JavaScript editor analyzing your code.
JavaScript
16
star
32

ics-service

Create a calendar feed that people can subscribe to.
JavaScript
16
star
33

svg-world-map

Show a location on a world map.
JavaScript
16
star
34

transform-coordinates

Transform coordinates from one coordinate system to another.
JavaScript
16
star
35

vbb-telegram

A Telegram bot for Berlin & Brandenburg public transport.
JavaScript
15
star
36

epsg-index

A machine-readable index of all EPSG coordinate systems.
JavaScript
15
star
37

inspect-code

Run code and get the value of every expression.
JavaScript
15
star
38

nbayes

A Naive Bayes classifier written in JavaScript.
JavaScript
15
star
39

svg-partial-circle

Compute the SVG path of a partial circle.
JavaScript
15
star
40

osx-setup

Jumpstart OS X.
Shell
14
star
41

url-decode-encode-cli

Command line utility for URL decoding & encoding.
JavaScript
14
star
42

tiny-cli-editor

A nano-like command line editor.
JavaScript
13
star
43

prompt-skeleton

A consistent behavior for CLI prompts.
JavaScript
13
star
44

db-prices-cli

Check prices for a DB route.
JavaScript
12
star
45

eco-counter-client

Fetch data about bicycle counters from the Eco Counter API.
JavaScript
12
star
46

print-gtfs-rt-cli

Read a GTFS Realtime feed from stdin, print human-readable or as JSON.
JavaScript
12
star
47

combine-tiles

Combine map tiles into a single large image.
JavaScript
12
star
48

casket

casket is an easy-to-use web file storage.
JavaScript
12
star
49

dict-cc-cli

Offline dict.cc lookup in the command line.
JavaScript
12
star
50

synchronous-autocomplete

Fast, simple autocompletion.
JavaScript
11
star
51

parse-gml-polygon

Convert a GML Polygon into GeoJSON.
JavaScript
11
star
52

hafas-gtfs-rt-feed

Format HAFAS data as GTFS Realtime.
JavaScript
10
star
53

berlin-wall-shape

The Berlin Wall (Berliner Mauer) as GeoJSON.
JavaScript
10
star
54

scroll-animation

Animate elements based on the scroll position.
JavaScript
10
star
55

friendly-audio-streaming-protocol

A simple and open protocol for streaming audio in local networks.
10
star
56

gulp-scale-images

Gulp plugin to resize each image into multiple smaller variants.
JavaScript
10
star
57

finn

[deprecated] โ€“ย finn is a Siri-like personal assistant running on node.js.
CoffeeScript
9
star
58

berlin-gtfs-rt-server

Expose Berlin & Brandenburg transit data as a GTFS-RT feed.
JavaScript
9
star
59

vbb-stations

A list of VBB stations.
JavaScript
9
star
60

vbb-stations-with-wifi

All VBB stations with free wifi.
JavaScript
9
star
61

hifo

Stores & sorts only the highest values.
JavaScript
9
star
62

vbb-map-routing

Use VBB interactively, using a map.
JavaScript
9
star
63

youtube-metadata-cli

Get metadata on YouTube videos.
JavaScript
9
star
64

sbahn-berlin-tweets

Fetch & parse @SBahnBerlin tweets on the operating status of S-Bahn Berlin.
JavaScript
9
star
65

listen-to-youtube-cli

Stream YouTube audio and listen to it.
JavaScript
9
star
66

multiselect-prompt

A prompt to select zero or more items.
JavaScript
8
star
67

os-x-contacts

Query all macOS Address Book contacts.
JavaScript
8
star
68

hvv-rest

An HTTP API for Hamburg public transport.
JavaScript
8
star
69

local-network-chat

A chat for the local network, powered by IP multicast.
JavaScript
8
star
70

vbb-journey-ui

UI component for displaying a journey like in Google Maps.
JavaScript
8
star
71

generate-vbb-graph

Generate a JSON graph from Berlin & Brandenburg public transport.
JavaScript
8
star
72

pev2-cli

Run the PostgreSQL Explain Visualizer 2 (pev2) from the command line.
JavaScript
8
star
73

db-stations-autocomplete

Search for stations of DB (data from DB station API).
JavaScript
8
star
74

node-awdl

Send data via Apple Wireless Direct Link (AWDL) using JavaScript.
JavaScript
7
star
75

generate-vbb-transit-map

Generate an SVG transit map for Berlin public transport.
JavaScript
7
star
76

sms-cli

Read & write SMS from the command line.
JavaScript
7
star
77

redis-stream

Redis 5 Streams as readable & writable Node streams. Plus a CLI.
JavaScript
7
star
78

coup-letmein

Open the door at co.up Berlin.
JavaScript
7
star
79

cli-on-key

Read command line key presses from process.stdin. Based on TooTallNate/keypress.
JavaScript
7
star
80

url-parser-cli

Parse a URL, get one or all components pretty-printed or as JSON.
JavaScript
7
star
81

authenticated-pipe

Make sure you receive data from the right person.
JavaScript
7
star
82

parse-jsonp

Get the payload of a JSONP response.
JavaScript
7
star
83

hafas-linked-connections-server

[work in progress] โ€“ย Create a Linked Connections endpoint from a HAFAS client.
JavaScript
6
star
84

hafas-rest-api-client

An API client for hafas-rest-api endpoints.
JavaScript
6
star
85

cli-minesweeper

Play Minesweeper in the command line!
JavaScript
6
star
86

vbb-station-photos

Photos of every subway station in Berlin.
JavaScript
6
star
87

cli-styles

A consistent look & feel for CLI prompts.
JavaScript
6
star
88

db-cli

A CLI for Deutsche Bahn.
JavaScript
6
star
89

node-sockopt

getsockopt & setsockopt for Node.js sockets.
JavaScript
6
star
90

digital-im-regio-portal-client

Query information from the Digital im Regio portal in German Regio trains.
JavaScript
6
star
91

avion

Share files without NSA.
JavaScript
6
star
92

select-prompt

A prompt to select zero or more items.
JavaScript
6
star
93

berlin-postal-code-areas

The shapes of all ZIP code areas in Berlin as GeoJSON.
JavaScript
6
star
94

hafas-generate-gtfs

[work in progress] โ€“ Generate GTFS dumps from HAFAS endpoints.
JavaScript
6
star
95

range-prompt

A prompt to select a value in a range.
JavaScript
5
star
96

hafas-monitor-trips

Using a HAFAS endpoint, watch all trips in a bounding box.
JavaScript
5
star
97

transit-map-generator

[work in progress] โ€“ Generate and optimize transit maps interactively.
JavaScript
5
star
98

leveldb-editor

[unfinished] โ€“ย Edit a LevelDB from the command line.
JavaScript
5
star
99

vbb-static

[deprecated] โ€“ A JavaScript API for the Berlin & Brandenburg public transport service (VBB) GTFS data.
CoffeeScript
5
star
100

german-postal-codes

A list of all postal (ZIP) codes in Germany.
JavaScript
5
star