0.3.5 • Published 4 years ago

somehow v0.3.5

Weekly downloads
69
License
MIT
Repository
github
Last release
4 years ago

somehow creates SVG, using your data, that you can throw-into your webpage.

let somehow = require('somehow')

let world = somehow({
  height: 300,
  aspect: 'golden'
})

let line = world.line()
line.set(`
june 5 2019, 10
july 7 2019, 15
july 7 2020, 18
aug 8 2021, 50
`)

world.fit()

document.body.innerHTML = world.build()

image

the idea is that you think (mostly) about the actual data, and not the layout.

#1 - .fit()

this scales, and fits the data for all given shapes, automatically. You don't have to manage d3Scale range & domain.

#2 - .build()

running .build() returns html-strings by default, but the library uses Jason Miller's htm library so can call .bind(React.createElement) and return React Components.

The joke is that D3 is easy, as long as you're an expert.

This library is built for personal use, and is essentially a wrapper for d3-path, d3-shape, and spacetime.

more to come!

Current API:

- line(obj)
- dot(obj)
- text(obj)
- area(obj)
- midArea(obj)
- rect(obj)
- bar(obj)
- annotation(obj)
- image(obj)
- arrow(obj)
- snake(obj)
- shape(obj)

- bind(fn)
- xAxis
- yAxis
- fit(x, y)
- fitX(x)
- fitY(y)
- build()
- getShape(id)
- redraw()
- clip(bool)
- title(str)

Axis

- color(c)
- remove()
- show()
- format(str)
- ticks(arr)
- prefix(str)
- suffix(str)
- clip(bool)
- label()

Shape

- set(str)
- at(x, y)
- from(x, y)
- to(x, y)
- color(c)
- opacity(n)
- title(str)
- straight()
- soft()
- onMount(fn)
- click(fn)
- hover(fn)
- clip(bool)

Area

- line(n)

Rect

- color()
- width(n)
- height(n)
- rounded(n)
- border(n)

Line

- dotted()
- width()

Text

- before(x, y)
- after(x, y)
- center(x, y)
- left()
- right()
- middle()
- color(c)
- dy(num)
- dx(num)
- dodge(x, y)
- font(num)
- extent()
- text(str)

Dot

- radius(num)

Annotation

- on(x, y)
- title(str)
- nudge(x, y)

MidArea

- zero(y)

Bar

- width()
- zero()
- at(x, y)

Image

- src(txt)
- caption(str)
- size(w, h)
- width(w)
- height(h)

Arrow

- from(x,y)
- length(num)
- width(num)

Now

- top()
- bottom()
- label(str)

Title

- top()
- bottom()
- right()
- left()

MIT

0.3.5

4 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.0

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

6 years ago