0.12.1 • Published 1 year ago

@svizzle/barchart v0.12.1

Weekly downloads
16
License
MIT
Repository
github
Last release
1 year ago

barchart

A package containing barchart components for Svelte:

  • BarchartV: vertical barchart

Props

defaultColor

The default bar color, if any.

If not provided bars will render in the default background-color of the page (most probably be black).

Type: string

Default: null

focusedKey

The focused bar key, if any.

Type: string

Default: undefined

focusedKeyColor

The focused bar color, if any.

Type: string

Default: rgba(0, 0, 0, 0.1)

hoverColor

The hovered bar color.

Type: string

Default: rgba(0, 0, 0, 0.05)

isInteractive

If true emits events when interacting with the bars, the payload being an object {id: key} (key being the key of the bar we interacted with):

Clicking on a bar dispatches a clicked event: dispatch('clicked', {id: key}).

Mouse-entering a bar dispatches a entered event: dispatch('entered', {id: key}).

Mouse-exiting a bar dispatches a entered event: dispatch('exited', {id: key}).

Type: boolean

Default: false

items

The bar items to be displayed.

Type: array

Default: undefined

Example:

[
  {key: 'foo', value: 2},
  {key: 'bar', value: 34}
]

keyToColor

By providing a object mapping bar key -> bar color, you can control the bars colour.

Notice that the default color for keys not in keyToColor is black.

Type: object

Default: undefined

Example:

{
  foo: 'yellow',
  bar: '#ff0000',
}

keyToLabel

By providing a object mapping bar key -> bar label, you can control how the bar are labeled.

Type: object

Default: undefined

Example:

{
  foo: 'Foo',
  bar: 'Bar',
}

keyToLabelFn

By providing a function mapping bar key -> bar label, you can control how the bar are labeled programmatically.

Type: function

Default: undefined

Example:

key => {
  ...

  return newKey;
}

title

If provided, show the component title.

Type: string

Default: undefined

shouldResetScroll

If true, updating the props will reset the scroll.

Type: boolean

Default: false

valueAccessor

The value accessor. By default we assume that items has the shape {key, value}.

Type: function

Default: getValue

0.12.1

1 year ago

0.11.0

1 year ago

0.10.1

1 year ago

0.12.0

1 year ago

0.10.0

2 years ago

0.9.0

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.8

3 years ago

0.6.7

3 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

5 years ago

0.1.0

5 years ago